summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorEran Messeri <eranm@google.com>2020-03-19 19:06:18 +0000
committerEran Messeri <eranm@google.com>2020-03-20 13:33:41 +0000
commit17429b5394e77acdd143c2142a14a97b5fbb2cde (patch)
treed948dd18202615f0bd40f60d3955f81989c68488 /core/java
parent6ef8f5e1abc2676b0ea01f19570544274082eb5a (diff)
Address API Review for setProfileOwnerCanAccessDeviceIds
Per API council's suggestion, make setProfileOwnerCanAccessDeviceIds throw only if the API level of the calling app is R and above, and call markProfileOwnerOnOrganizationOwnedDevice if called from apps targeting Q and below. This code path is extremely unlikely to ever trigger because this method was marked as SystemApi unintentionally, and could only be called during the provisioning flow. Test: Manual Bug: 150957726 Change-Id: I4215c7dce642c9e3ff00183f43867802507911ca
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/admin/DevicePolicyManager.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 32e815e5b170..fbcb8842828a 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -11492,7 +11492,11 @@ public class DevicePolicyManager {
/**
* Deprecated. Use {@code markProfileOwnerOnOrganizationOwnedDevice} instead.
- * Throws UnsupportedOperationException when called.
+ * When called by an app targeting SDK level {@link android.os.Build.VERSION_CODES#Q} or
+ * below, will behave the same as {@link #markProfileOwnerOnOrganizationOwnedDevice}.
+ *
+ * When called by an app targeting SDK level {@link android.os.Build.VERSION_CODES#R}
+ * or above, will throw an UnsupportedOperationException when called.
*
* @deprecated Use {@link #markProfileOwnerOnOrganizationOwnedDevice} instead.
*
@@ -11503,9 +11507,14 @@ public class DevicePolicyManager {
@RequiresPermission(value = android.Manifest.permission.GRANT_PROFILE_OWNER_DEVICE_IDS_ACCESS,
conditional = true)
public void setProfileOwnerCanAccessDeviceIds(@NonNull ComponentName who) {
- throw new UnsupportedOperationException(
- "This method is deprecated. use markProfileOwnerOnOrganizationOwnedDevice instead"
- + ".");
+ ApplicationInfo ai = mContext.getApplicationInfo();
+ if (ai.targetSdkVersion > Build.VERSION_CODES.Q) {
+ throw new UnsupportedOperationException(
+ "This method is deprecated. use markProfileOwnerOnOrganizationOwnedDevice"
+ + " instead.");
+ } else {
+ markProfileOwnerOnOrganizationOwnedDevice(who);
+ }
}
/**