From 1cc4ecc3e2c64ade5078581b039e1b068c6ed0ed Mon Sep 17 00:00:00 2001 From: Sander Alewijnse Date: Mon, 23 Jun 2014 19:56:52 +0100 Subject: [PATCH] Add public constants for Device Owner Provisioning. Change-Id: I46dca4e31ab256273eb810f57083f31541815735 --- api/current.txt | 14 ++ .../android/app/admin/DeviceAdminReceiver.java | 5 + .../android/app/admin/DevicePolicyManager.java | 196 ++++++++++++++++++++- 3 files changed, 208 insertions(+), 7 deletions(-) diff --git a/api/current.txt b/api/current.txt index fbbae6c8d031..ee335e310c51 100644 --- a/api/current.txt +++ b/api/current.txt @@ -5320,9 +5320,22 @@ package android.app.admin { field public static final java.lang.String EXTRA_ADD_EXPLANATION = "android.app.extra.ADD_EXPLANATION"; field public static final java.lang.String EXTRA_DEVICE_ADMIN = "android.app.extra.DEVICE_ADMIN"; field public static final java.lang.String EXTRA_PROVISIONING_DEFAULT_MANAGED_PROFILE_NAME = "android.app.extra.defaultManagedProfileName"; + field public static final java.lang.String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM = "android.app.extra.deviceAdminPackageChecksum"; + field public static final java.lang.String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION = "android.app.extra.deviceAdminPackageDownloadLocation"; field public static final java.lang.String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME = "android.app.extra.deviceAdminPackageName"; field public static final java.lang.String EXTRA_PROVISIONING_EMAIL_ADDRESS = "android.app.extra.ManagedProfileEmailAddress"; + field public static final java.lang.String EXTRA_PROVISIONING_LOCALE = "android.app.extra.locale"; + field public static final java.lang.String EXTRA_PROVISIONING_LOCAL_TIME = "android.app.extra.localTime"; + field public static final java.lang.String EXTRA_PROVISIONING_TIME_ZONE = "android.app.extra.timeZone"; field public static final java.lang.String EXTRA_PROVISIONING_TOKEN = "android.app.extra.token"; + field public static final java.lang.String EXTRA_PROVISIONING_WIFI_HIDDEN = "android.app.extra.wifiHidden"; + field public static final java.lang.String EXTRA_PROVISIONING_WIFI_PAC_URL = "android.app.extra.wifiPacUrl"; + field public static final java.lang.String EXTRA_PROVISIONING_WIFI_PASSWORD = "android.app.extra.wifiPassword"; + field public static final java.lang.String EXTRA_PROVISIONING_WIFI_PROXY_BYPASS = "android.app.extra.wifiProxyBypassHosts"; + field public static final java.lang.String EXTRA_PROVISIONING_WIFI_PROXY_HOST = "android.app.extra.wifiProxyHost"; + field public static final java.lang.String EXTRA_PROVISIONING_WIFI_PROXY_PORT = "android.app.extra.wifiProxyPort"; + field public static final java.lang.String EXTRA_PROVISIONING_WIFI_SECURITY_TYPE = "android.app.extra.wifiSecurityType"; + field public static final java.lang.String EXTRA_PROVISIONING_WIFI_SSID = "android.app.extra.wifiSsid"; field public static int FLAG_MANAGED_CAN_ACCESS_PARENT; field public static int FLAG_PARENT_CAN_ACCESS_MANAGED; field public static final int KEYGUARD_DISABLE_FEATURES_ALL = 2147483647; // 0x7fffffff @@ -5339,6 +5352,7 @@ package android.app.admin { field public static final int PASSWORD_QUALITY_NUMERIC = 131072; // 0x20000 field public static final int PASSWORD_QUALITY_SOMETHING = 65536; // 0x10000 field public static final int PASSWORD_QUALITY_UNSPECIFIED = 0; // 0x0 + field public static final java.lang.String PROVISIONING_NFC_MIME_TYPE = "application/com.android.managedprovisioning"; field public static final int RESET_PASSWORD_REQUIRE_ENTRY = 1; // 0x1 field public static final int WIPE_EXTERNAL_STORAGE = 1; // 0x1 } diff --git a/core/java/android/app/admin/DeviceAdminReceiver.java b/core/java/android/app/admin/DeviceAdminReceiver.java index ca4043677a70..1f168c3d6434 100644 --- a/core/java/android/app/admin/DeviceAdminReceiver.java +++ b/core/java/android/app/admin/DeviceAdminReceiver.java @@ -209,6 +209,11 @@ public class DeviceAdminReceiver extends BroadcastReceiver { * specified in the original intent or NFC bump that started the provisioning process * (@see DevicePolicyManager#ACTION_PROVISION_MANAGED_PROFILE). * + *

A device admin application which listens to this intent can find out if the device was + * provisioned for the device owner or profile owner case by calling respectively + * {@link android.app.admin.DevicePolicyManager#isDeviceOwnerApp} and + * {@link android.app.admin.DevicePolicyManager#isProfileOwnerApp}. + * *

Input: Nothing.

*

Output: Nothing

*/ diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index 4351f9d82c48..633080432ce8 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -115,11 +115,10 @@ public class DevicePolicyManager { * *

When managed provisioning has completed, an intent of the type * {@link DeviceAdminReceiver#ACTION_PROFILE_PROVISIONING_COMPLETE} is broadcasted to the - * managed profile. The intent is sent to the {@link DeviceAdminReceiver} specified in the - * {@link #EXTRA_DEVICE_ADMIN} exclusively. + * managed profile. * - * If provisioning fails, the managedProfile is removed so the device returns to its previous - * state. + *

If provisioning fails, the managedProfile is removed so the device returns to its + * previous state. * *

Input: Nothing.

*

Output: Nothing

@@ -140,9 +139,15 @@ public class DevicePolicyManager { = "android.app.action.ACTION_PROVISIONING_USER_HAS_CONSENTED"; /** - * A String extra holding the name of the package of the mobile device management application - * that starts the managed provisioning flow. This package will be set as the profile owner. - *

Use with {@link #ACTION_PROVISION_MANAGED_PROFILE}. + * A String extra holding the package name of the mobile device management application that + * will be set as the profile owner or device owner. + * + *

If an application starts provisioning directly via an intent with action + * {@link #ACTION_PROVISION_MANAGED_PROFILE} this package has to match the package name of the + * application that started provisioning. The package will be set as profile owner in that case. + * + *

This package is set as device owner when device owner provisioning is started by an Nfc + * message containing an Nfc record with MIME type {@link #PROVISIONING_NFC_MIME_TYPE}. */ public static final String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME = "android.app.extra.deviceAdminPackageName"; @@ -162,6 +167,7 @@ public class DevicePolicyManager { /** * A String extra holding the default name of the profile that is created during managed profile * provisioning. + * *

Use with {@link #ACTION_PROVISION_MANAGED_PROFILE} */ public static final String EXTRA_PROVISIONING_DEFAULT_MANAGED_PROFILE_NAME @@ -179,6 +185,182 @@ public class DevicePolicyManager { = "android.app.extra.ManagedProfileEmailAddress"; /** + * A String extra holding the time zone {@link android.app.AlarmManager} that the device + * will be set to. + * + *

Use in an Nfc record with {@link #PROVISIONING_NFC_MIME_TYPE} that starts device owner + * provisioning via an Nfc bump. + */ + public static final String EXTRA_PROVISIONING_TIME_ZONE + = "android.app.extra.timeZone"; + + /** + * A Long extra holding the local time {@link android.app.AlarmManager} that the device + * will be set to. + * + *

Use in an Nfc record with {@link #PROVISIONING_NFC_MIME_TYPE} that starts device owner + * provisioning via an Nfc bump. + */ + public static final String EXTRA_PROVISIONING_LOCAL_TIME + = "android.app.extra.localTime"; + + /** + * A String extra holding the {@link java.util.Locale} that the device will be set to. + * Format: xx_yy, where xx is the language code, and yy the country code. + * + *

Use in an Nfc record with {@link #PROVISIONING_NFC_MIME_TYPE} that starts device owner + * provisioning via an Nfc bump. + */ + public static final String EXTRA_PROVISIONING_LOCALE + = "android.app.extra.locale"; + + /** + * A String extra holding the ssid of the wifi network that should be used during nfc device + * owner provisioning for downloading the mobile device management application. + * + *

Use in an Nfc record with {@link #PROVISIONING_NFC_MIME_TYPE} that starts device owner + * provisioning via an Nfc bump. + */ + public static final String EXTRA_PROVISIONING_WIFI_SSID + = "android.app.extra.wifiSsid"; + + /** + * A boolean extra indicating whether the wifi network in {@link #EXTRA_PROVISIONING_WIFI_SSID} + * is hidden or not. + * + *

Use in an Nfc record with {@link #PROVISIONING_NFC_MIME_TYPE} that starts device owner + * provisioning via an Nfc bump. + */ + public static final String EXTRA_PROVISIONING_WIFI_HIDDEN + = "android.app.extra.wifiHidden"; + + /** + * A String extra indicating the security type of the wifi network in + * {@link #EXTRA_PROVISIONING_WIFI_SSID}. + * + *

Use in an Nfc record with {@link #PROVISIONING_NFC_MIME_TYPE} that starts device owner + * provisioning via an Nfc bump. + */ + public static final String EXTRA_PROVISIONING_WIFI_SECURITY_TYPE + = "android.app.extra.wifiSecurityType"; + + /** + * A String extra holding the password of the wifi network in + * {@link #EXTRA_PROVISIONING_WIFI_SSID}. + * + *

Use in an Nfc record with {@link #PROVISIONING_NFC_MIME_TYPE} that starts device owner + * provisioning via an Nfc bump. + */ + public static final String EXTRA_PROVISIONING_WIFI_PASSWORD + = "android.app.extra.wifiPassword"; + + /** + * A String extra holding the proxy host for the wifi network in + * {@link #EXTRA_PROVISIONING_WIFI_SSID}. + * + *

Use in an Nfc record with {@link #PROVISIONING_NFC_MIME_TYPE} that starts device owner + * provisioning via an Nfc bump. + */ + public static final String EXTRA_PROVISIONING_WIFI_PROXY_HOST + = "android.app.extra.wifiProxyHost"; + + /** + * An int extra holding the proxy port for the wifi network in + * {@link #EXTRA_PROVISIONING_WIFI_SSID}. + * + *

Use in an Nfc record with {@link #PROVISIONING_NFC_MIME_TYPE} that starts device owner + * provisioning via an Nfc bump. + */ + public static final String EXTRA_PROVISIONING_WIFI_PROXY_PORT + = "android.app.extra.wifiProxyPort"; + + /** + * A String extra holding the proxy bypass for the wifi network in + * {@link #EXTRA_PROVISIONING_WIFI_SSID}. + * + *

Use in an Nfc record with {@link #PROVISIONING_NFC_MIME_TYPE} that starts device owner + * provisioning via an Nfc bump. + */ + public static final String EXTRA_PROVISIONING_WIFI_PROXY_BYPASS + = "android.app.extra.wifiProxyBypassHosts"; + + /** + * A String extra holding the proxy auto-config (PAC) URL for the wifi network in + * {@link #EXTRA_PROVISIONING_WIFI_SSID}. + * + *

Use in an Nfc record with {@link #PROVISIONING_NFC_MIME_TYPE} that starts device owner + * provisioning via an Nfc bump. + */ + public static final String EXTRA_PROVISIONING_WIFI_PAC_URL + = "android.app.extra.wifiPacUrl"; + + /** + * A String extra holding a url that specifies the download location of the device admin + * package. When not provided it is assumed that the device admin package is already installed. + * + *

Use in an Nfc record with {@link #PROVISIONING_NFC_MIME_TYPE} that starts device owner + * provisioning via an Nfc bump. + */ + public static final String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION + = "android.app.extra.deviceAdminPackageDownloadLocation"; + + /** + * A String extra holding the SHA-1 checksum of the file at download location specified in + * {@link #EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION}. If this doesn't match + * the file at the download location an error will be shown to the user and the user will be + * asked to factory reset the device. + * + *

Use in an Nfc record with {@link #PROVISIONING_NFC_MIME_TYPE} that starts device owner + * provisioning via an Nfc bump. + */ + public static final String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM + = "android.app.extra.deviceAdminPackageChecksum"; + + /** + * This MIME type is used for starting the Device Owner provisioning. + * + *

During device owner provisioning a device admin app is set as the owner of the device. + * A device owner has full control over the device. The device owner can not be modified by the + * user and the only way of resetting the device is if the device owner app calls a factory + * reset. + * + *

A typical use case would be a device that is owned by a company, but used by either an + * employee or client. + * + *

The Nfc message should be send to an unprovisioned device. + * + *

The Nfc record must contain a serialized {@link java.util.Properties} object which + * contains the following properties: + *

+ * + *

When device owner provisioning has completed, an intent of the type + * {@link DeviceAdminReceiver#ACTION_PROFILE_PROVISIONING_COMPLETE} is broadcasted to the + * device owner. + * + *

+ * If provisioning fails, the device is factory reset. + * + *

Input: Nothing.

+ *

Output: Nothing

+ */ + public static final String PROVISIONING_NFC_MIME_TYPE + = "application/com.android.managedprovisioning"; + + /** * Activity action: ask the user to add a new device administrator to the system. * The desired policy is the ComponentName of the policy in the * {@link #EXTRA_DEVICE_ADMIN} extra field. This will invoke a UI to -- 2.11.0