diff --git a/docs/html/images/training/enterprise/app_restrictions_diagram.png b/docs/html/images/training/enterprise/app_restrictions_diagram.png new file mode 100644 index 0000000000000..5ab3f8db6484d Binary files /dev/null and b/docs/html/images/training/enterprise/app_restrictions_diagram.png differ diff --git a/docs/html/images/training/enterprise/app_restrictions_diagram_2x.png b/docs/html/images/training/enterprise/app_restrictions_diagram_2x.png new file mode 100644 index 0000000000000..13a2db1933965 Binary files /dev/null and b/docs/html/images/training/enterprise/app_restrictions_diagram_2x.png differ diff --git a/docs/html/training/enterprise/app-restrictions.jd b/docs/html/training/enterprise/app-restrictions.jd index dd2c2c015bce9..07b1de7b5c177 100644 --- a/docs/html/training/enterprise/app-restrictions.jd +++ b/docs/html/training/enterprise/app-restrictions.jd @@ -152,10 +152,10 @@ enterprise administrator to:

<restrictions xmlns:android="http://schemas.android.com/apk/res/android" > <restriction - android:key="downloadOnCellular" - android:title="App is allowed to download data via cellular" + android:key="download_on_cell" + android:title="@string/download_on_cell_title" android:restrictionType="bool" - android:description="If 'false', app can only download data via Wi-Fi" + android:description="@string/download_on_cell_description" android:defaultValue="true" /> </restrictions> @@ -166,6 +166,12 @@ enterprise administrator to:

documented in the reference for {@link android.content.RestrictionsManager}.

+

+ Note: bundle and + bundle_array restriction types are not supported by Google Play + for Work. +

+

You use each restriction's android:key attribute to read its value from a restrictions bundle. For this reason, each restriction must have @@ -211,7 +217,7 @@ enterprise administrator to:

  • When the app is notified of a restriction change, as described in - Listen for Device Configuration + Listen for App Configuration Changes
  • @@ -254,9 +260,30 @@ enterprise administrator to:

    the {@link android.content.Intent#ACTION_APPLICATION_RESTRICTIONS_CHANGED ACTION_APPLICATION_RESTRICTIONS_CHANGED} intent to find out if restrictions change while your app is active, as described in Listen for - Device Configuration Changes. + App Restriction Changes.

    +

    + When your app checks for restrictions using + {@link android.content.RestrictionsManager#getApplicationRestrictions + RestrictionsManager.getApplicationRestrictions()}, we recommend that you + check to see if the enterprise administrator has set the key-value pair + {@link android.os.UserManager#KEY_RESTRICTIONS_PENDING} to true. If so, you + should block the user from using the app, and prompt them to contact their + enterprise administrator. The app should then proceed as normal, registering + for the {@link android.content.Intent#ACTION_APPLICATION_RESTRICTIONS_CHANGED + ACTION_APPLICATION_RESTRICTIONS_CHANGED} broadcast. +

    + + + +

    + Figure 1. Checking whether restrictions are pending before + registering for the broadcast. +

    +

    Reading and applying restrictions

    @@ -266,11 +293,11 @@ enterprise administrator to:

    getApplicationRestrictions()} method returns a {@link android.os.Bundle} containing a key-value pair for each restriction that has been set. The values are all of type Boolean, int, - String, and String[]. Once you have the - restrictions {@link android.os.Bundle}, you can check the current - restrictions settings with the standard {@link android.os.Bundle} methods for - those data types, such as {@link android.os.Bundle#getBoolean getBoolean()} - or + String, String[], Bundle, and + Bundle[]. Once you have the restrictions {@link android.os.Bundle}, + you can check the current restrictions settings with the standard + {@link android.os.Bundle} methods for those data types, such as + {@link android.os.Bundle#getBoolean getBoolean()} or {@link android.os.Bundle#getString getString()}.

    @@ -284,10 +311,11 @@ enterprise administrator to:

    It is up to your app to take appropriate action based on the current - restrictions settings. For example, if your app has a restriction specifying - whether it can download data over a cellular connection, and you find that - the restriction is set to false, you would have to disable data - download except when the device has a Wi-Fi connection, as shown in the + restrictions settings. For example, if your app has a restriction schema + to specify whether it can download over a cellular connection (like the + example in Define App Restrictions), + and you find that the restriction is set to false, you would have to disable + data download except when the device has a Wi-Fi connection, as shown in the following example code:

    @@ -307,6 +335,13 @@ if (!appCanUseCellular) { // ...show appropriate notices to user } +

    + Note: The restrictions schema should be + backward and forward compatible, since Google Play for Work + gives the EMM only one version of the App Restrictions + Schema per app. +

    +

    Listen for App Restriction Changes

    @@ -354,8 +389,8 @@ registerReceiver(restrictionsReceiver, restrictionsFilter); Note: Ordinarily, your app does not need to be notified about restriction changes when it is paused. Instead, you should unregister your broadcast receiver when the app is paused. When the app resumes, you - first check for the current restrictions (as discussed in Check Device Restrictions), then register your - broadcast receiver to make sure you're notified about restriction changes + first check for the current restrictions (as discussed in + Check App Restrictions), then register + your broadcast receiver to make sure you're notified about restriction changes that happen while the app is active.

    diff --git a/docs/image_sources/training/enterprise/app_restrictions_diagram.txt b/docs/image_sources/training/enterprise/app_restrictions_diagram.txt new file mode 100644 index 0000000000000..19fbfc8aff629 --- /dev/null +++ b/docs/image_sources/training/enterprise/app_restrictions_diagram.txt @@ -0,0 +1,5 @@ +The source file for app_restrictions_diagram.png is a +Google Doc owned by Matt Werner, mattwerner@google.com. +You can access the diagram in this doc: + +https://docs.google.com/document/d/1qffQfciilSYHHJxpWCs-VEsANnbIt69Zz1qmQuGe0Wc/edit \ No newline at end of file