<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sebastian Kaspari on Medium]]></title>
        <description><![CDATA[Stories by Sebastian Kaspari on Medium]]></description>
        <link>https://medium.com/@s.kaspari?source=rss-24718b759d0d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*olVSAlnwa-IKna4v.jpg</url>
            <title>Stories by Sebastian Kaspari on Medium</title>
            <link>https://medium.com/@s.kaspari?source=rss-24718b759d0d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 09:20:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@s.kaspari/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Lessons learned: Adding support for runtime permissions to Firefox for Android]]></title>
            <link>https://medium.com/firefox-mobile-engineering/lessons-learned-adding-support-for-runtime-permissions-to-firefox-for-android-c30565288b81?source=rss-24718b759d0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c30565288b81</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Sebastian Kaspari]]></dc:creator>
            <pubDate>Thu, 14 Apr 2016 17:24:39 GMT</pubDate>
            <atom:updated>2016-04-14T17:27:14.372Z</atom:updated>
            <content:encoded><![CDATA[<p>Up until recently users granted permissions to apps when they installed or updated the apps. Beginning in Android 6.0 users now grant permissions to an app while the app is running — if supported by the app (<a href="http://developer.android.com/training/permissions/requesting.html">Android documentation)</a>.</p><p>Firefox for Android 46.0 (<a href="https://play.google.com/store/apps/details?id=org.mozilla.firefox_beta">Currently in the beta channel</a>) is the first version that supports runtime permissions. This article is not a guide on how to add runtime permissions to your app (There are other good ones: <a href="https://blog.stylingandroid.com/permissions-part-1/">Styling Android — Permissions</a> for example). Instead it is a collection of observations and lessons learned while adding support to Firefox for Android.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/311/1*yXb34Sh8Jrl_fnoyfhjj9g.png" /><figcaption>Firefox 46.0 (Beta) asking to access the device’s location.</figcaption></figure><h4>You can get a lot of permissions without asking the user now</h4><p>Android divides system permissions into two categories (protection level): normal and dangerous.</p><p>Normal permissions shouldn’t affect the user’s privacy and therefore are granted at install time. You still need to add the permissions to the manifest but you don’t need to prompt the user in order to use it. This also means that the user can’t revoke those permissions. An example for a normal permission is the NFC permission. On Android 6+ every app can have it (if listed in the manifest) and use it without any further interaction from the user needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2_cpWfyf8N1b2TiXbfU8vA.png" /><figcaption>List of permissions with protection level “normal” (Android 6.0 / API 23).</figcaption></figure><p>Dangerous permissions on the other hand might affect the user’s privacy and need to be accepted first.</p><h4>Updated protection levels</h4><p>With Android 6 the protection levels of several permissions have been updated.</p><p>Most noteworthy changes:</p><ul><li>The INTERNET permission now has protection level “normal” — every Android app targeting SDK 23 can access the internet.</li><li>READ_EXTERNAL_STORAGE is “dangerous” now. Apps will need to prompt for the permission at runtime.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pafsudEHhiNuhHaLsCifew.png" /><figcaption>Changes — Normal permissions (Red: Protection level changed or permission removed, Green: Level changed to “normal” or new permission)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RAhuEoIMMHRtsi0th5iPWA.png" /><figcaption>Changes — Dangerous permissions (Red: Protection level changed or permission removed, Green: Level changed to “dangerous”)</figcaption></figure><h4>Permission groups</h4><p>Android categorizes all dangerous permissions into 9 groups. When requesting a specific permission you are actually asking for all permissions in the group. For example when requesting the READ_CONTACTS permission then the system will show a generic prompt for the CONTACTS group. After accepting the permission and once you ask for another permission from this group, say GET_ACCOUNTS, the system will automatically grant you the permission without prompting the user. You will still have to request permissions from the group — especially because those groups can change in the future — but in the worst case the user won’t see more than 9 different prompts currently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y1b7ySJKsCc42STycwf83Q.png" /><figcaption>Permission groups of Android 6.0</figcaption></figure><h4>At runtime you can get more permissions but never less</h4><p>At runtime your app might already have some permissions and you can request additional permissions when needed. An app can’t dismiss a permission itself and the user has to go to Android’s settings first in order to revoke a permission. If permissions are revoked from an app then Android will kill the app. As a consequence your app can get more permissions but it can never have less while it is running.</p><p>This is great news for app developers: Usually it’s enough to guard the entry point to code requiring a permission and you do not need to wrap <em>every</em> code requiring a permission in a permission check.</p><p>For example if you are writing a background service that requires the <em>dangerous</em> READ_CONTACTS permission then it’s enough to check the permission at the start of the service and stop the service immediately if you do not have the permission. All other code in the service won’t need to perform the check because the permission can’t be revoked while it is running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7hCuVtiqC8OMJ0Rzl2hzWA.png" /><figcaption>Revoking permissions from Firefox</figcaption></figure><h4>Official API and libraries</h4><p>The official API for runtime permissions is a bit clunky. The reason for that is that it is heavily tied to the Activity class. This somehow makes sense: You prompt for a permission by showing a dialog and this is something you do with an Activity context. By now there are plenty of <a href="https://github.com/search?utf8=%E2%9C%93&amp;q=android+runtime+permissions">libraries for runtime permissions on GitHub</a>.</p><p>For Firefox we also wrapped Android’s API into something that is inspired by <a href="https://github.com/ReactiveX/RxJava">RxJava</a> and JavaScript’s <a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise:</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/17faf268103e759c24a1167e42aa0cc1/href">https://medium.com/media/17faf268103e759c24a1167e42aa0cc1/href</a></iframe><p>You can find the code <a href="https://dxr.mozilla.org/mozilla-central/source/mobile/android/base/java/org/mozilla/gecko/permissions">here</a>.</p><h4>Turning down permission requests</h4><p>Of course a user can turn down permission requests. Android provides a utility method, <a href="http://developer.android.com/reference/android/app/Activity.html#shouldShowRequestPermissionRationale(java.lang.String)">shouldShowRequestPermissionRationale()</a>, that returns true if the user has denied the request previously and you should show UI explaining why the app needs the permission.</p><p>A special case is the “Never ask again” checkbox that appears for subsequent requests. There’s no official API for checking whether the request has been denied permanently by the user. However you can guess it from the return values of shouldShowRequestPermissionRationale() <strong>after</strong> you have requested the permission:</p><p>A value of <em>false</em> <strong>after</strong> requesting a permission and the user denying it means that you do not have the permission <em>and</em> should <strong>not</strong> show a rationale the next time: The permission has been denied permanently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*IhLp97TolUFPSdjMGxGHqw.png" /><figcaption>[X] Never ask again</figcaption></figure><p>For permanently rejected permissions you will not be able to show the prompt to the user again. As a last resort you can only send your users to the system’s settings to manually edit the permissions of the application.</p><h4>UI testing with runtime permissions</h4><p>Testing the UI of your application with Robotium or Espresso on Android 6+ can be a challenge if you are using runtime permissions. The frameworks are not able to interact with the permission dialogs.</p><p>Instead you can either grant specific permissions via adb or install the APK with all permission granted automatically:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ddde84af5dac5434cc060bed239e1c6d/href">https://medium.com/media/ddde84af5dac5434cc060bed239e1c6d/href</a></iframe><p>After that the app will have all needed permissions and no prompts will be shown during test. To test the behavior of permissions not being granted you will have to mock your implementation of checking and requesting permissions to return values as if the user would have denied the request.</p><h4>Updating the application to a version with targetSdkVersion 23</h4><p>There’s good news for everyone with an application that doesn’t target SDK 23 yet. As soon as your users update to a new version targeting 23 the permissions that have already been granted at install time in the past will still be granted after the update. So if your app has the camera permission then after update you won’t need to prompt for the camera permission. Only new installations won’t have the permission until you ask for it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c30565288b81" width="1" height="1" alt=""><hr><p><a href="https://medium.com/firefox-mobile-engineering/lessons-learned-adding-support-for-runtime-permissions-to-firefox-for-android-c30565288b81">Lessons learned: Adding support for runtime permissions to Firefox for Android</a> was originally published in <a href="https://medium.com/firefox-mobile-engineering">Mozilla Mobile Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Support for restricted profiles in Firefox 42]]></title>
            <link>https://medium.com/firefox-mobile-engineering/support-for-restricted-profiles-in-firefox-42-b0d2adecce77?source=rss-24718b759d0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0d2adecce77</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[android-development]]></category>
            <dc:creator><![CDATA[Sebastian Kaspari]]></dc:creator>
            <pubDate>Thu, 17 Sep 2015 00:00:00 GMT</pubDate>
            <atom:updated>2016-03-16T11:06:13.124Z</atom:updated>
            <content:encoded><![CDATA[<p>One of our goals for <a href="https://www.mozilla.org/en-US/firefox/android/">Firefox for Android</a> 42.0 was to create a kid and parent-friendly web experience (Project <em>KinderFox / KidFox</em>): The browser should be easy to use for a kid and at the same time parents want to be in control and decide what the kid can do with it.<br> <br>There are a lot of things you can do to create a kid-friendly browsing experience. In this first version we focused on making the browser simpler by hiding complex or kid-unfriendly features and utilizing the parental controls of the Android system: <em>Restricted profiles</em>.</p><h3>What are restricted profiles?</h3><p>Restricted Profiles have been introduced in Android 4.3. The device administrator can create these profiles and restrict access to apps and features on the device. In addition to that restrictions inside an app can be configured if supported by the app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*5xlt-qvwAF_gD_2P.png" /><figcaption>Configuring which apps the restricted profile can access.</figcaption></figure><h3>Being in control</h3><p>Our final list of restrictable features for Firefox 42 contains 10 items:</p><ul><li><em>Disable add-on installation</em></li><li><em>Disable ‘Import from Android’ (Bookmark import)</em></li><li><em>Disable developer tools</em></li><li><em>Disable Home customization (</em><a href="https://hacks.mozilla.org/2014/07/building-firefox-hub-add-ons-for-firefox-for-android/"><em>Home panels</em></a><em>)</em></li><li><em>Disable Private Browsing</em></li><li><em>Disable Location Services (Contributing to </em><a href="https://location.services.mozilla.com/"><em>Mozilla’s Location Service</em></a><em>)</em></li><li><em>Disable Display settings</em></li><li><em>Disable ‘Clear browsing history’</em></li><li><em>Disable master password</em></li><li><em>Disable Guest Browsing</em></li></ul><p>Limiting access to features is a very personal decision. Not every parent wants to control every aspect of the browsing experience. That’s why we decided to make these restrictions configurable by the parent. By implementing a broadcast receiver that listens to <a href="https://developer.android.com/reference/android/content/Intent.html#ACTION_GET_RESTRICTION_ENTRIES">ACTION_GET_RESTRICTION_ENTRIES</a> actions it’s possible to send a list of restrictions to the system and so they will show up in the admin interface:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*OldZYwFCpdJ4afdn.png" /><figcaption>Configuring restrictions of an application.</figcaption></figure><p>Configuring restrictions of an application. Later the application can query the <a href="http://developer.android.com/reference/android/os/UserManager.html">UserManager</a> to ask which restrictions have been enabled or disabled.</p><h3>Technical details</h3><p><strong>User restrictions vs. application restrictions</strong><br>There are two kinds of restrictions. <a href="http://developer.android.com/reference/android/os/UserManager.html#getUserRestrictions%28%29">User restrictions</a> are imposed on the user by the system and <a href="http://developer.android.com/reference/android/os/UserManager.html#getApplicationRestrictions%28java.lang.String%29">application restrictions</a> are added by an application via the broadcast mechanism mentioned above. An application can query the <a href="http://developer.android.com/reference/android/os/UserManager.html">UserManager</a> only for its own and global user restrictions.<br> <br><strong>Detecting restricted profiles</strong><br>One of the first things you might want to do in your app is to detect if the current user is using a restricted or a normal profile. There’s no API method to do that and the video linked above suggests to query the user restrictions from the <a href="http://developer.android.com/reference/android/os/UserManager.html">UserManager</a> and if the returned bundle is not empty then you are in a restricted profile.<br> <br>This worked fine until we deployed the application to a phone running an Android M preview build. On this phone — that doesn’t even support restricted profiles — the <a href="http://developer.android.com/reference/android/os/UserManager.html">UserManager</a> always returned a restriction. Whoops, suddenly everyone with Android M on their phones had a very limited <a href="https://nightly.mozilla.org/">Firefox Nightly</a>. We then switched to iterating over the returned Bundles (for application and user restrictions) and only assuming we are in a restricted profile if at least one restriction in those bundles is enabled (<em>getBoolean()</em> returns true).<br> <br>In general it is a better approach to never detect whether you are in a restricted profile or not but instead always check whether a specific (application) restriction is enabled or not.<strong> </strong><br> <br><strong>A resource qualifier would be nice</strong><br>Hiding features and UI in restricted profiles will add a lot of <em>if</em> statements to the code base. It would have been nice to have a <a href="http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources">resource qualifier</a> for restricted profiles to load different layouts, drawables and other configurations. Besides that this would also solve the “detect restricted profile” problem quite elegant.<br> <br><strong>Strict mode: Disk read violation</strong><br>At runtime we noticed that we have been triggering a lot of disk read violations. Looking at <a href="http://androidxref.com/5.1.1_r6/xref/frameworks/base/services/core/java/com/android/server/pm/UserManagerService.java#readApplicationRestrictionsLocked">Android’s source code</a> it turns out that <a href="http://developer.android.com/reference/android/os/UserManager.html#getApplicationRestrictions%28java.lang.String%29">UserManager.getApplicationRestrictions()</a> reads and parses an XML file on every call. Without caching anything like <a href="http://developer.android.com/reference/android/content/SharedPreferences.html">SharedPreferences</a> do. We worked around that by implementing our own memory cache and refreshing the list of restrictions whenever the application is resumed. To update restrictions the user will always have to switch to the admin profile and therefore leave (and later resume) the application.<br> <br><strong>No Fun<br></strong>Android Marshmallow (6.0) introduced a new <em>Easter egg</em> system restriction: <a href="http://developer.android.com/reference/android/os/UserManager.html#DISALLOW_FUN">UserManager.DISALLOW_FUN</a> — <em>Specifies if the user is not allowed to have fun. In some cases, the device owner may wish to prevent the user from experiencing amusement or joy while using the device. The default value is false</em>.</p><h3>What’s next?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*RzB8U3a_n2KaXi7i.png" /><figcaption>Simplified browser UI with custom theme using a restricted profile (Firefox 42).</figcaption></figure><p>With the current set of restrictions parents can create a kid-friendly and simplified browsing experience. Of course there are a lot of more possible features around parental controls that come to mind like block lists and restricting Web APIs (Microphone, Webcam). Some of these ideas have already been filed (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1125710">Bug 1125710</a>) and in addition to that we just started planning features for the next version (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1205615">Bug 1205615</a>). More ideas are definitely welcome!</p><h3>Testing and feedback</h3><p>At the time of this writing support for restricted profiles is available in <a href="https://ftp.mozilla.org/pub/mozilla.org/mobile/nightly/latest-mozilla-aurora-android-api-11/">Aurora</a> (42.0) and <a href="https://nightly.mozilla.org/">Nightly</a> (43.0) builds of Firefox. Restricted Profiles serve a very specific use case and therefore do not get as much usage coverage like other browser features. If you do have a tablet and are interested in restricted profiles then help us testing it! :)</p><h3>Contributing</h3><p>Firefox for Android is open-source software and contributors are very welcome! You can find me on IRC (irc.mozilla.org) in #mobile (my nickname is “sebastian”), on <a href="https://twitter.com/Anti_Hype">Twitter</a> and <a href="http://plus.google.com/+SebastianKaspari">Google+</a>. <a href="https://wiki.mozilla.org/Mobile/Get_Involved">Get involved with Firefox for Android</a>.</p><h3>More resources about Project KidFox</h3><ul><li><a href="https://wiki.mozilla.org/Mobile/Projects/Kinderfox">Mozilla Wiki: Project KinderFox</a></li><li><a href="https://wiki.mozilla.org/Mobile/Projects/Kid_browsing">Mozilla Wiki: KidFox proposal</a></li><li><a href="https://wiki.mozilla.org/Mobile/Briefs/Kidfox">Mozilla wiki: KidFox brief</a></li><li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1125710">Generic meta bug</a></li><li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1125984">Bugzilla meta bug for v1</a></li><li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1205615">Bugzilla meta bug for v2</a></li></ul><p><em>Originally published at </em><a href="http://www.androidzeitgeist.com/2015/09/support-restricted-profiles-firefox.html"><em>www.androidzeitgeist.com</em></a><em> on September 17, 2015.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0d2adecce77" width="1" height="1" alt=""><hr><p><a href="https://medium.com/firefox-mobile-engineering/support-for-restricted-profiles-in-firefox-42-b0d2adecce77">Support for restricted profiles in Firefox 42</a> was originally published in <a href="https://medium.com/firefox-mobile-engineering">Mozilla Mobile Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>