Closed
Bug 1042715
Opened 10 years ago
Closed 10 years ago
Add support for Restricted Profiles
Categories
(Firefox for Android Graveyard :: Profile Handling, defect)
Tracking
(firefox33 wontfix, firefox34 fixed, relnote-firefox 34+)
RESOLVED
FIXED
Firefox 34
People
(Reporter: mfinkle, Assigned: mfinkle)
References
Details
Attachments
(2 files, 1 obsolete file)
297.15 KB,
image/png
|
Details | |
15.56 KB,
patch
|
rnewman
:
review+
lmandel
:
approval-mozilla-beta+
|
Details | Diff | Splinter Review |
Firefox should be aware that it's being run from a Restricted Profile on Android. We can then make other runtime changes to the application.
Restricted profiles:
https://developer.android.com/about/versions/android-4.3.html#RestrictedProfiles
Possible runtime changes:
* Implement nsIParentalControls which will control:
* Send the "Prefer: safe" header
* Block downloading files
* Block add-on installation
* Block webapp installation
* Block access to add-ons, downloads, apps about: pages
Updated•10 years ago
|
Component: General → Profile Handling
OS: Linux → Android
Hardware: x86_64 → All
Assignee | ||
Updated•10 years ago
|
Assignee | ||
Comment 1•10 years ago
|
||
We can also disable Sync using code like this:
@TargetApi(18)
public static boolean shouldDisableSync(Context context) {
if (Build.VERSION.SDK_INT >= 18) {
UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
Bundle restrictions = um.getUserRestrictions();
return restrictions.getBoolean(UserManager.DISALLOW_MODIFY_ACCOUNTS, false);
}
return false;
}
Assignee | ||
Comment 2•10 years ago
|
||
This patch lands the basics, like the OS X support already in the tree:
* Add JNI helpers for getting restriction info
* Add an Android impl of nsIParentalControlsService that uses the helpers
* Add a simple test to verify that nsIParentalControlsService is available and functional on Android
This is enough to send the "Prefer: safe" header, as verified in a restricted profile. The service and JNI helpers could be used to add more functional it in other places of the app too. I'll leave that for followup bugs.
Assignee: nobody → mark.finkle
Attachment #8461117 -
Flags: review?(rnewman)
Assignee | ||
Comment 3•10 years ago
|
||
Shows the header being sent
Assignee | ||
Comment 4•10 years ago
|
||
I forgot to mention. This patch requires VERSION.SDK_INT >= 18, so we'll need the builders updated. I think there is already a bug filed for that.
Updated•10 years ago
|
Comment 5•10 years ago
|
||
Comment on attachment 8461117 [details] [diff] [review]
restricted-profiles v0.1
Review of attachment 8461117 [details] [diff] [review]:
-----------------------------------------------------------------
This looks fine, with the exception of the API19 dependency; f+ waiting for that.
Automated tests for this are hard. I'm not convinced that it's worth the mocking effort to make it testable.
::: mobile/android/base/GeckoAppShell.java
@@ +2522,5 @@
> }
>
> + @WrapElementForJNI
> + public static boolean isUserRestricted() {
> + if (Build.VERSION.SDK_INT >= 18) {
Invert, early return.
@@ +2526,5 @@
> + if (Build.VERSION.SDK_INT >= 18) {
> + UserManager mgr = (UserManager)getContext().getSystemService(Context.USER_SERVICE);
> + Bundle restrictions = mgr.getUserRestrictions();
> +
> + return (restrictions.keySet().size() > 0);
I think you can just do
return !restrictions.isEmpty();
@@ +2534,5 @@
> +
> + @WrapElementForJNI
> + public static String getUserRestrictions() {
> + JSONObject json = new JSONObject();
> + if (Build.VERSION.SDK_INT >= 18) {
if (Build.VERSION.SDK_INT < 18) {
return "{}";
}
@@ +2541,5 @@
> +
> + Set<String> keys = restrictions.keySet();
> + for (String key : keys) {
> + try {
> + json.put(key, JSONObject.wrap(restrictions.get(key)));
JSONObject.wrap was added in API 19. You need to find another way.
You should also check for JSONObject.wrap() == JSONObject.NULL here, and avoid adding the mapping.
::: toolkit/components/parentalcontrols/nsParentalControlsServiceAndroid.cpp
@@ +42,5 @@
> +}
> +
> +NS_IMETHODIMP
> +nsParentalControlsService::Log(int16_t aEntryType,
> + bool blocked,
aBlocked?
@@ +51,5 @@
> +}
> +
> +NS_IMETHODIMP
> +nsParentalControlsService::RequestURIOverride(nsIURI *aTarget,
> + nsIInterfaceRequestor *aCocoadowContext,
aCocoadowContext!?
Attachment #8461117 -
Flags: review?(rnewman) → feedback+
Assignee | ||
Comment 6•10 years ago
|
||
(In reply to Richard Newman [:rnewman] from comment #5)
> Automated tests for this are hard. I'm not convinced that it's worth the
> mocking effort to make it testable.
I have an idea for that I can try tonight
> ::: mobile/android/base/GeckoAppShell.java
> > + public static boolean isUserRestricted() {
> > + if (Build.VERSION.SDK_INT >= 18) {
>
> Invert, early return.
Done
> > + return (restrictions.keySet().size() > 0);
>
> I think you can just do
>
> return !restrictions.isEmpty();
Done
> > + public static String getUserRestrictions() {
> > + JSONObject json = new JSONObject();
> > + if (Build.VERSION.SDK_INT >= 18) {
>
> if (Build.VERSION.SDK_INT < 18) {
> return "{}";
> }
Done
> > + json.put(key, JSONObject.wrap(restrictions.get(key)));
>
> JSONObject.wrap was added in API 19. You need to find another way.
>
> You should also check for JSONObject.wrap() == JSONObject.NULL here, and
> avoid adding the mapping.
I just went with a simple:
json.put(key, restrictions.get(key));
Which won't handle Collections or Maps, but the bundle should only hold simple types anyway. Worst case, we drop this method. It's just a helper for JS code to get the restrictions.
> ::: toolkit/components/parentalcontrols/nsParentalControlsServiceAndroid.cpp
> > +nsParentalControlsService::Log(int16_t aEntryType,
> > + bool blocked,
>
> aBlocked?
>
> > +nsParentalControlsService::RequestURIOverride(nsIURI *aTarget,
> > + nsIInterfaceRequestor *aCocoadowContext,
>
> aCocoadowContext!?
Comment 7•10 years ago
|
||
> aCocoadowContext!?
Hah.
aWindowContext
:%s,Win,Cocoa
Someone a long time ago failed to double-check a patch.
Might as well fix this while you're here, rather than cargo-culting it into the future.
Assignee | ||
Comment 8•10 years ago
|
||
* Updated based on comments
* I tried to add another test, using a Mock nsIParentalControlsService. It worked for any code getting an instance of the service after I injected the Mock, but the nsHttpHandler code is initialized very early and caches the enabled state before my Mock could take affect. Oh well.
Attachment #8461117 -
Attachment is obsolete: true
Attachment #8461275 -
Flags: review?(rnewman)
Updated•10 years ago
|
Attachment #8461275 -
Flags: review?(rnewman) → review+
Assignee | ||
Comment 9•10 years ago
|
||
Comment 10•10 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 34
Comment 11•10 years ago
|
||
Comment on attachment 8461275 [details] [diff] [review]
restricted-profiles v0.2
Approval Request Comment
[Feature/regressing bug #]:
New.
[User impact if declined]:
Don't get the feature.
[Describe test coverage new/current, TBPL]:
Adds a test.
[Risks and why]:
Finkle and I discussed uplifting this a week or so ago. If it's not giving us any trouble, let's get this into 33. It's partner-relevant.
[String/UUID change made/needed]:
None that I can see.
Attachment #8461275 -
Flags: approval-mozilla-beta?
Comment 12•10 years ago
|
||
Comment on attachment 8461275 [details] [diff] [review]
restricted-profiles v0.2
I spoke with Kar and there is a good reason to take this desktop parity feature in 33. Beta+
Kevin - This is a feature uplift. Is there an existing restricted profile test plan that you can use to test this feature in beta2? Can you also please request that your test do some exploratory testing of this feature this week so that we can try to flush out any issues earlier in beta?
Attachment #8461275 -
Flags: approval-mozilla-beta? → approval-mozilla-beta+
Flags: needinfo?(kbrosnan)
Comment 13•10 years ago
|
||
Release Note Request (optional, but appreciated)
[Why is this notable]: Adds support for Prefer:Safe HTTP header.
[Suggested wording]: Added support for Prefer:Safe HTTP header
[Links (documentation, blog post, etc)]:
relnote-firefox:
--- → ?
Comment 14•10 years ago
|
||
Needs rebasing for beta uplift.
status-firefox33:
--- → affected
status-firefox34:
--- → fixed
Flags: needinfo?(mark.finkle)
Keywords: branch-patch-needed
Assignee | ||
Comment 15•10 years ago
|
||
(In reply to Ryan VanderMeulen [:RyanVM UTC-4] from comment #14)
> Needs rebasing for beta uplift.
I rebased the patch and I'm making a test build.
Flags: needinfo?(mark.finkle)
Comment 16•10 years ago
|
||
Looks like Mark landed this on beta:
https://hg.mozilla.org/releases/mozilla-beta/rev/080344c7c80b
Keywords: branch-patch-needed
Comment 17•10 years ago
|
||
Assignee | ||
Comment 18•10 years ago
|
||
(In reply to Ryan VanderMeulen [:RyanVM UTC-4] from comment #17)
> Backed out for bustage.
> https://hg.mozilla.org/releases/mozilla-beta/rev/fcf16a67fed4
>
> https://tbpl.mozilla.org/php/getParsedLog.php?id=47629536&tree=Mozilla-Beta
Fx33 (Beta) is not using API version 20. It's using 17:
http://mxr.mozilla.org/mozilla-beta/source/mobile/android/config/mozconfigs/common#18
I don't feel like bumping the SDK version on Beta. Let's leave this in Fx34 (Aurora) to ride the trains.
Flags: needinfo?(mark.finkle)
Updated•10 years ago
|
Keywords: branch-patch-needed
Updated•10 years ago
|
Flags: needinfo?(kbrosnan)
Comment 19•10 years ago
|
||
(In reply to Mark Finkle (:mfinkle) from comment #18)
> (In reply to Ryan VanderMeulen [:RyanVM UTC-4] from comment #17)
> > Backed out for bustage.
> > https://hg.mozilla.org/releases/mozilla-beta/rev/fcf16a67fed4
> >
> > https://tbpl.mozilla.org/php/getParsedLog.php?id=47629536&tree=Mozilla-Beta
>
> Fx33 (Beta) is not using API version 20. It's using 17:
> http://mxr.mozilla.org/mozilla-beta/source/mobile/android/config/mozconfigs/
> common#18
>
> I don't feel like bumping the SDK version on Beta. Let's leave this in Fx34
> (Aurora) to ride the trains.
I appreciate you taking the safe approach here Mark.
cc Karen, who should know that this feature will not ship in 33.
Comment 20•10 years ago
|
||
Added to the release notes with "Added support for Prefer:Safe HTTP header" as wording.
Updated•4 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•