summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorSalud Lemus <saludlemus@google.com>2021-02-04 01:43:58 +0000
committerSalud Lemus <saludlemus@google.com>2021-02-23 20:14:32 +0000
commit60ea32bec762fc8406ce079cb27f0e910bf99d7b (patch)
tree3ca9485647f1c1e5e2f0823b44e8cb607c3a626b /core/java/android
parentcd4ec6acfb80bfd3d1e8b5d7b2e251dfaaa7de41 (diff)
Add API to set device owner type for a managed device
With this API, it will allow to customize Device Owner warning messages on a financed device. Bug: 173826319 Bug: 158157476 Bug: 180521289 Test: m -j64 Test: Used a test device that is registered via ZT Test: atest FrameworksServicesTests:com.android.server.devicepolicy.OwnersTest Test: atest FrameworksServicesTests:com.android.server.devicepolicy.DevicePolicyManagerTest Change-Id: I97a2e9c4626d3cd9d01b19ce1d233be5fbd7377a
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/admin/DevicePolicyManager.java77
-rw-r--r--core/java/android/app/admin/IDevicePolicyManager.aidl3
2 files changed, 80 insertions, 0 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 59e5144113c9..b7b3ec16d24f 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -2746,6 +2746,32 @@ public class DevicePolicyManager {
@Retention(RetentionPolicy.SOURCE)
public @interface PersonalAppsSuspensionReason {}
+ /**
+ * The default device owner type for a managed device.
+ *
+ * @hide
+ */
+ public static final int DEVICE_OWNER_TYPE_DEFAULT = 0;
+
+ /**
+ * The device owner type for a financed device.
+ *
+ * @hide
+ */
+ public static final int DEVICE_OWNER_TYPE_FINANCED = 1;
+
+ /**
+ * Different device owner types for a managed device.
+ *
+ * @hide
+ */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = { "DEVICE_OWNER_TYPE_" }, value = {
+ DEVICE_OWNER_TYPE_DEFAULT,
+ DEVICE_OWNER_TYPE_FINANCED
+ })
+ public @interface DeviceOwnerType {}
+
/** @hide */
@TestApi
public static final int OPERATION_LOCK_NOW = 1;
@@ -13460,6 +13486,57 @@ public class DevicePolicyManager {
}
/**
+ * Sets the device owner type for a managed device (e.g. financed device).
+ *
+ * @param admin The {@link DeviceAdminReceiver} that is the device owner.
+ * @param deviceOwnerType The device owner type is set to. Use
+ * {@link #DEVICE_OWNER_TYPE_DEFAULT} for the default device owner type. Use
+ * {@link #DEVICE_OWNER_TYPE_FINANCED} for the financed device owner type.
+ *
+ * @throws IllegalStateException When admin is not the device owner, or there is no device
+ * owner, or attempting to set the device owner type again for the same admin.
+ * @throws SecurityException If the caller does not have the permission
+ * {@link permission#MANAGE_PROFILE_AND_DEVICE_OWNERS}.
+ *
+ * @hide
+ */
+ public void setDeviceOwnerType(@NonNull ComponentName admin,
+ @DeviceOwnerType int deviceOwnerType) {
+ throwIfParentInstance("setDeviceOwnerType");
+ if (mService != null) {
+ try {
+ mService.setDeviceOwnerType(admin, deviceOwnerType);
+ } catch (RemoteException re) {
+ throw re.rethrowFromSystemServer();
+ }
+ }
+ }
+
+ /**
+ * Returns the device owner type for the admin used in
+ * {@link #setDeviceOwnerType(ComponentName, int)}. {@link #DEVICE_OWNER_TYPE_DEFAULT}
+ * would be returned when the device owner type is not set for the device owner admin.
+ *
+ * @param admin The {@link DeviceAdminReceiver} that is the device owner.
+ *
+ * @throws IllegalStateException When admin is not the device owner or there is no device owner.
+ *
+ * @hide
+ */
+ @DeviceOwnerType
+ public int getDeviceOwnerType(@NonNull ComponentName admin) {
+ throwIfParentInstance("getDeviceOwnerType");
+ if (mService != null) {
+ try {
+ return mService.getDeviceOwnerType(admin);
+ } catch (RemoteException re) {
+ throw re.rethrowFromSystemServer();
+ }
+ }
+ return DEVICE_OWNER_TYPE_DEFAULT;
+ }
+
+ /**
* Called by device owner or profile owner of an organization-owned managed profile to
* enable or disable USB data signaling for the device. When disabled, USB data connections
* (except from charging functions) are prohibited.
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index 8a87b16b760b..ac1592d2d2a1 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -503,6 +503,9 @@ interface IDevicePolicyManager {
UserHandle createAndProvisionManagedProfile(in ManagedProfileProvisioningParams provisioningParams, in String callerPackage);
void provisionFullyManagedDevice(in FullyManagedDeviceProvisioningParams provisioningParams, in String callerPackage);
+ void setDeviceOwnerType(in ComponentName admin, in int deviceOwnerType);
+ int getDeviceOwnerType(in ComponentName admin);
+
void resetDefaultCrossProfileIntentFilters(int userId);
boolean canAdminGrantSensorsPermissionsForUser(int userId);