summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorCraig Lafayette <craiglafa@google.com>2015-04-02 13:14:39 -0400
committerCraig Lafayette <craiglafa@google.com>2015-04-13 09:14:33 -0400
commitdbe31a6616f2e8cb8436ea235149d076302fb793 (patch)
tree606dece49007ee258eb235b15a0467e3aba0fbbc /core/java
parent08f90af8030c9b61f53486a694d53abd24ea9293 (diff)
downloadframeworks_base-dbe31a6616f2e8cb8436ea235149d076302fb793.zip
frameworks_base-dbe31a6616f2e8cb8436ea235149d076302fb793.tar.gz
frameworks_base-dbe31a6616f2e8cb8436ea235149d076302fb793.tar.bz2
Send device initializer status.
- Create method in DevicePolicyManager to send device provisioning status to ManagedProvisioning. - Define status updates used by ManagedProvisioning. Bug: 20001077 Change-Id: Ia98fc765d1ebb2ba9680636ca15c2c870d160261
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/admin/DeviceInitializerStatus.java177
-rw-r--r--core/java/android/app/admin/DevicePolicyManager.java54
-rw-r--r--core/java/android/app/admin/IDevicePolicyManager.aidl2
3 files changed, 233 insertions, 0 deletions
diff --git a/core/java/android/app/admin/DeviceInitializerStatus.java b/core/java/android/app/admin/DeviceInitializerStatus.java
new file mode 100644
index 0000000..b58711c
--- /dev/null
+++ b/core/java/android/app/admin/DeviceInitializerStatus.java
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.app.admin;
+
+/**
+ * Defines constants designating device provisioning status used with {@link
+ * android.app.admin.DevicePolicyManager#sendDeviceInitializerStatus(int,String)}.
+ *
+ * This class contains flag constants that define special status codes:
+ * <ul>
+ * <li>{@link #FLAG_STATUS_ERROR} is used to define provisioning error status codes
+ * <li>{@link #FLAG_STATUS_CUSTOM} is used to define custom status codes
+ * <li>{@link #FLAG_STATUS_HIGH_PRIORITY} is used to define high priority status codes
+ * </ul>
+ *
+ * <p>Status codes used by ManagedProvisioning are also defined in this class. These status codes
+ * include provisioning errors and status codes.
+ * <ul>
+ * <li>{@link #STATUS_ERROR_CONNECT_WIFI}
+ * <li>{@link #STATUS_ERROR_RESET_PROTECTION_BLOCKING_PROVISIONING}
+ * <li>{@link #STATUS_ERROR_DOWNLOAD_PACKAGE}
+ * <li>{@link #STATUS_ERROR_INSTALL_PACKAGE}
+ * <li>{@link #STATUS_ERROR_SET_DEVICE_POLICY}
+ * <li>{@link #STATUS_ERROR_DELETE_APPS}
+ * <li>{@link #STATUS_ERROR_DOUBLE_BUMP}
+ * <li>{@link #STATUS_STATE_CONNECT_BLUETOOTH_PROXY}
+ * <li>{@link #STATUS_STATE_DISCONNECT_BLUETOOTH_PROXY}
+ * <li>{@link #STATUS_STATE_DEVICE_PROVISIONED}
+ * </ul>
+ */
+public class DeviceInitializerStatus {
+ /**
+ * A flag used to designate an error status.
+ *
+ * <p>This flag is used with {@code statusCode} values sent through
+ * {@link android.app.admin.DevicePolicyManager#sendDeviceInitializerStatus(int,String)}
+ * @see #isErrorStatus(int)
+ */
+ public static final int FLAG_STATUS_ERROR = 0x01000000;
+
+ /**
+ * A flag used to designate a custom status. Custom status codes will be defined by device
+ * initializer agents.
+ *
+ * <p>This flag is used with {@code statusCode} values sent through
+ * {@link android.app.admin.DevicePolicyManager#sendDeviceInitializerStatus(int,String)}
+ * @see #isCustomStatus(int)
+ */
+ public static final int FLAG_STATUS_CUSTOM = 0x02000000;
+
+ /**
+ * A bit flag used to designate a reserved status. Reserved status codes will not be defined
+ * in AOSP.
+ *
+ * <p>This flag is used with {@code statusCode} values sent through
+ * {@link android.app.admin.DevicePolicyManager#sendDeviceInitializerStatus(int,String)}
+ */
+ public static final int FLAG_STATUS_RESERVED = 0x04000000;
+
+ /**
+ * A flag used to indicate that a status message is high priority.
+ *
+ * <p>This flag is used with {@code statusCode} values sent through
+ * {@link android.app.admin.DevicePolicyManager#sendDeviceInitializerStatus(int,String)}
+ * @see #isHighPriority(int)
+ */
+ public static final int FLAG_STATUS_HIGH_PRIORITY = 0x08000000;
+
+ /**
+ * Device provisioning status code that indicates that a device is connecting to establish
+ * a Bluetooth network proxy.
+ */
+ public static final int STATUS_STATE_CONNECT_BLUETOOTH_PROXY = FLAG_STATUS_HIGH_PRIORITY | 8;
+
+ /**
+ * Device provisioning status code that indicates that a connected Bluetooth network proxy
+ * is being shut down.
+ */
+ public static final int STATUS_STATE_DISCONNECT_BLUETOOTH_PROXY = FLAG_STATUS_HIGH_PRIORITY | 9;
+
+ /**
+ * Device provisioning status code that indicates that a device has been successfully
+ * provisioned.
+ */
+ public static final int STATUS_STATE_DEVICE_PROVISIONED = FLAG_STATUS_HIGH_PRIORITY | 10;
+
+ /**
+ * Device provisioning error status code that indicates that a device could not connect to
+ * a Wi-Fi network.
+ */
+ public static final int STATUS_ERROR_CONNECT_WIFI = FLAG_STATUS_ERROR | 21;
+
+ /**
+ * Device provisioning error status indicating that factory reset protection is enabled on
+ * the provisioned device and cannot be disabled with the provided data.
+ */
+ public static final int STATUS_ERROR_RESET_PROTECTION_BLOCKING_PROVISIONING =
+ FLAG_STATUS_ERROR | 22;
+
+ /**
+ * Device provisioning error status indicating that device administrator and device initializer
+ * packages could not be downloaded and verified successfully.
+ */
+ public static final int STATUS_ERROR_DOWNLOAD_PACKAGE = FLAG_STATUS_ERROR | 23;
+
+ /**
+ * Device provisioning error status indicating that device owner and device initializer packages
+ * could not be installed.
+ */
+ public static final int STATUS_ERROR_INSTALL_PACKAGE = FLAG_STATUS_ERROR | 24;
+
+ /**
+ * Device provisioning error status indicating that the device owner or device initializer
+ * components could not be set.
+ */
+ public static final int STATUS_ERROR_SET_DEVICE_POLICY = FLAG_STATUS_ERROR | 25;
+
+ /**
+ * Device provisioning error status indicating that deleting non-required applications during
+ * provisioning failed.
+ */
+ public static final int STATUS_ERROR_DELETE_APPS = FLAG_STATUS_ERROR | 26;
+
+ /**
+ * Device provisioning error status code that indicates that a provisioning attempt has failed
+ * because the device has already been provisioned or that provisioning has already started.
+ */
+ public static final int STATUS_ERROR_DOUBLE_BUMP = FLAG_STATUS_ERROR | 30;
+
+ /**
+ * Determine if the specified status code represents an error status.
+ * @param statusCode status code to check
+ * @return {@code true} if the status code is an error status code
+ */
+ public static boolean isErrorStatus(int statusCode) {
+ return isFlagSet(statusCode, FLAG_STATUS_ERROR);
+ }
+
+ /**
+ * Determine if the specified status code is a custom status. Custom status codes are defined
+ * and sent by device initialization agents.
+ * @param statusCode status code to check
+ * @return {@code true} if the status code is a custom status code
+ */
+ public static boolean isCustomStatus(int statusCode) {
+ return isFlagSet(statusCode, FLAG_STATUS_CUSTOM);
+ }
+
+ /**
+ * Determine if the specified status code is a high priority status code.
+ * @param statusCode status code to check
+ * @return {@code true} if the status code is a high priority status code
+ */
+ public static boolean isHighPriority(int statusCode) {
+ return isFlagSet(statusCode, FLAG_STATUS_HIGH_PRIORITY);
+ }
+
+ private static boolean isFlagSet(int statusCode, int flag) {
+ return (statusCode & flag) != 0;
+ }
+
+ private DeviceInitializerStatus() {}
+}
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 68f4707..26b1b36 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -651,6 +651,45 @@ public class DevicePolicyManager {
= "android.app.action.SET_PROFILE_OWNER";
/**
+ * Protected broadcast action that will be sent to managed provisioning to notify it that a
+ * status update has been reported by the device initializer. The status update will be
+ * reported to the remote setup device over Bluetooth.
+ *
+ * <p>Broadcasts with this action must supply a
+ * {@linkplain DeviceInitializerStatus#isCustomStatus(int) custom} status code in the
+ * {@link EXTRA_DEVICE_INITIALIZER_STATUS_CODE} extra.
+ *
+ * <p>Broadcasts may optionally contain a description in the
+ * {@link EXTRA_DEVICE_INITIALIZER_STATUS_DESCRIPTION} extra.
+ * @hide
+ */
+ @SystemApi
+ public static final String ACTION_SEND_DEVICE_INITIALIZER_STATUS
+ = "android.app.action.SEND_DEVICE_INITIALIZER_STATUS";
+
+ /**
+ * An integer extra that contains the status code that defines a status update. This extra must
+ * sent as part of a broadcast with an action of {@code ACTION_SEND_DEVICE_INITIALIZER_STATUS}.
+ *
+ * <p>The status code sent with this extra must be a custom status code as defined by
+ * {@link DeviceInitializerStatus#isCustomStatus(int)}.
+ * @hide
+ */
+ @SystemApi
+ public static final String EXTRA_DEVICE_INITIALIZER_STATUS_CODE
+ = "android.app.extra.DEVICE_INITIALIZER_STATUS_CODE";
+
+ /**
+ * A {@code String} extra that contains an optional description accompanying a status update.
+ * This extra my be sent as part of a broadcast with an action of
+ * {@code ACTION_SEND_DEVICE_INITIALIZER_STATUS}.
+ * @hide
+ */
+ @SystemApi
+ public static final String EXTRA_DEVICE_INITIALIZER_STATUS_DESCRIPTION
+ = "android.app.extra.DEVICE_INITIALIZER_STATUS_DESCRIPTION";
+
+ /**
* @hide
* Name of the profile owner admin that controls the user.
*/
@@ -4012,4 +4051,19 @@ public class DevicePolicyManager {
Log.w(TAG, "Could not set the user icon ", re);
}
}
+
+ /**
+ * Called by device initializer to send a provisioning status update to the remote setup device.
+ *
+ * @param statusCode a custom status code value as defined by
+ * {@link DeviceInitializerStatus#isCustomStatus(int)}.
+ * @param description custom description of the status code sent
+ */
+ public void sendDeviceInitializerStatus(int statusCode, String description) {
+ try {
+ mService.sendDeviceInitializerStatus(statusCode, description);
+ } catch (RemoteException re) {
+ Log.w(TAG, "Could not send device initializer status", re);
+ }
+ }
}
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index c68311e..75b97a8 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -213,4 +213,6 @@ interface IDevicePolicyManager {
ComponentName getDeviceInitializerComponent();
void setUserIcon(in ComponentName admin, in Bitmap icon);
+
+ void sendDeviceInitializerStatus(int statusCode, String description);
}