summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorEran Messeri <eranm@google.com>2019-11-07 12:06:18 +0000
committerEran Messeri <eranm@google.com>2019-11-26 09:33:03 +0000
commitb8c46e08621600b93ce3ca12121ee47652256fcc (patch)
treed933610ab44395877c43e1fb63568cd6ff1ead2c /core/java
parent7d72e1ea9a88646c07aa3a2d6500107c10cd8183 (diff)
Wiping and relinquishing org-owned devices
Add the following functionality, on devices with a managed profile created during provisionining (and as such, considered organization-owned): * Let the Profile Owner relinquish a device by calling DevicePolicyManager.wipeData. The device then transitions to a fully-personal device. * Let the Profile Owner wipe the entire device by calling wipeData on the parent profile DevicePolicyManager instance. Bug: 138709470 Test: Manual with TestDPC. Test: atest CtsDevicePolicyManagerTestCases:com.android.cts.devicepolicy.OrgOwnedProfileOwnerTest Test: atest com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testDeviceIdAttestationForProfileOwner Change-Id: If3cc9741079592cb07bc1ef5ccca8fb2b57a52e9
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/admin/DevicePolicyManager.java27
-rw-r--r--core/java/android/app/admin/IDevicePolicyManager.aidl2
2 files changed, 21 insertions, 8 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 50adb7ca3297..9a5444cfcd57 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -88,7 +88,6 @@ import android.telephony.data.ApnSetting;
import android.util.ArraySet;
import android.util.Log;
-import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.BackgroundThread;
import com.android.internal.util.Preconditions;
@@ -4198,6 +4197,12 @@ public class DevicePolicyManager {
* The calling device admin must have requested {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA} to
* be able to call this method; if it has not, a security exception will be thrown.
*
+ * If the caller is a profile owner of an organization-owned managed profile, it may
+ * additionally call this method on the parent instance.
+ * Calling this method on the parent {@link DevicePolicyManager} instance would wipe the
+ * entire device, while calling it on the current profile instance would relinquish the device
+ * for personal use, removing the work profile and all policies set by the profile owner.
+ *
* @param flags Bit mask of additional options: currently supported flags are
* {@link #WIPE_EXTERNAL_STORAGE}, {@link #WIPE_RESET_PROTECTION_DATA},
* {@link #WIPE_EUICC} and {@link #WIPE_SILENTLY}.
@@ -4205,10 +4210,7 @@ public class DevicePolicyManager {
* that uses {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA}
*/
public void wipeData(int flags) {
- throwIfParentInstance("wipeData");
- final String wipeReasonForUser = mContext.getString(
- R.string.work_profile_deleted_description_dpm_wipe);
- wipeDataInternal(flags, wipeReasonForUser);
+ wipeDataInternal(flags, "");
}
/**
@@ -4221,6 +4223,12 @@ public class DevicePolicyManager {
* The calling device admin must have requested {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA} to
* be able to call this method; if it has not, a security exception will be thrown.
*
+ * If the caller is a profile owner of an organization-owned managed profile, it may
+ * additionally call this method on the parent instance.
+ * Calling this method on the parent {@link DevicePolicyManager} instance would wipe the
+ * entire device, while calling it on the current profile instance would relinquish the device
+ * for personal use, removing the work profile and all policies set by the profile owner.
+ *
* @param flags Bit mask of additional options: currently supported flags are
* {@link #WIPE_EXTERNAL_STORAGE}, {@link #WIPE_RESET_PROTECTION_DATA} and
* {@link #WIPE_EUICC}.
@@ -4232,7 +4240,6 @@ public class DevicePolicyManager {
* {@link #WIPE_SILENTLY} is set.
*/
public void wipeData(int flags, @NonNull CharSequence reason) {
- throwIfParentInstance("wipeData");
Preconditions.checkNotNull(reason, "reason string is null");
Preconditions.checkStringNotEmpty(reason, "reason string is empty");
Preconditions.checkArgument((flags & WIPE_SILENTLY) == 0, "WIPE_SILENTLY cannot be set");
@@ -4250,7 +4257,7 @@ public class DevicePolicyManager {
private void wipeDataInternal(int flags, @NonNull String wipeReasonForUser) {
if (mService != null) {
try {
- mService.wipeDataWithReason(flags, wipeReasonForUser);
+ mService.wipeDataWithReason(flags, wipeReasonForUser, mParentInstance);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -9287,6 +9294,12 @@ public class DevicePolicyManager {
* <li>{@link #setRequiredStrongAuthTimeout}</li>
* </ul>
*
+ * <p>The following methods can be called by the profile owner of a managed profile
+ * on an organization-owned device:
+ * <ul>
+ * <li>{@link #wipeData}</li>
+ * </ul>
+ *
* @return a new instance of {@link DevicePolicyManager} that acts on the parent profile.
* @throws SecurityException if {@code admin} is not a profile owner.
*/
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index 4894751b60a5..591d1510e6f4 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -102,7 +102,7 @@ interface IDevicePolicyManager {
void lockNow(int flags, boolean parent);
- void wipeDataWithReason(int flags, String wipeReasonForUser);
+ void wipeDataWithReason(int flags, String wipeReasonForUser, boolean parent);
ComponentName setGlobalProxy(in ComponentName admin, String proxySpec, String exclusionList);
ComponentName getGlobalProxyAdmin(int userHandle);