Merge "Add back @NonNull to DevicePolicyManager.wipeData"
This commit is contained in:
committed by
Android (Google) Code Review
commit
356227b0f6
@@ -6790,7 +6790,7 @@ package android.app.admin {
|
||||
method public void uninstallCaCert(@Nullable android.content.ComponentName, byte[]);
|
||||
method public boolean updateOverrideApn(@NonNull android.content.ComponentName, int, @NonNull android.telephony.data.ApnSetting);
|
||||
method public void wipeData(int);
|
||||
method public void wipeData(int, CharSequence);
|
||||
method public void wipeData(int, @NonNull CharSequence);
|
||||
field public static final String ACTION_ADD_DEVICE_ADMIN = "android.app.action.ADD_DEVICE_ADMIN";
|
||||
field public static final String ACTION_ADMIN_POLICY_COMPLIANCE = "android.app.action.ADMIN_POLICY_COMPLIANCE";
|
||||
field public static final String ACTION_APPLICATION_DELEGATION_SCOPES_CHANGED = "android.app.action.APPLICATION_DELEGATION_SCOPES_CHANGED";
|
||||
@@ -6934,6 +6934,7 @@ package android.app.admin {
|
||||
field public static final int WIPE_EUICC = 4; // 0x4
|
||||
field public static final int WIPE_EXTERNAL_STORAGE = 1; // 0x1
|
||||
field public static final int WIPE_RESET_PROTECTION_DATA = 2; // 0x2
|
||||
field public static final int WIPE_SILENTLY = 8; // 0x8
|
||||
}
|
||||
|
||||
public abstract static class DevicePolicyManager.InstallUpdateCallback {
|
||||
|
||||
@@ -3980,6 +3980,10 @@ public class DevicePolicyManager {
|
||||
*/
|
||||
public static final int WIPE_EUICC = 0x0004;
|
||||
|
||||
/**
|
||||
* Flag for {@link #wipeData(int)}: won't show reason for wiping to the user.
|
||||
*/
|
||||
public static final int WIPE_SILENTLY = 0x0008;
|
||||
|
||||
/**
|
||||
* Ask that all user data be wiped. If called as a secondary user, the user will be removed and
|
||||
@@ -3991,9 +3995,10 @@ public class DevicePolicyManager {
|
||||
* be able to call this method; if it has not, a security exception will be thrown.
|
||||
*
|
||||
* @param flags Bit mask of additional options: currently supported flags are
|
||||
* {@link #WIPE_EXTERNAL_STORAGE} and {@link #WIPE_RESET_PROTECTION_DATA}.
|
||||
* {@link #WIPE_EXTERNAL_STORAGE}, {@link #WIPE_RESET_PROTECTION_DATA},
|
||||
* {@link #WIPE_EUICC} and {@link #WIPE_SILENTLY}.
|
||||
* @throws SecurityException if the calling application does not own an active administrator
|
||||
* that uses {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA}
|
||||
* that uses {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA}
|
||||
*/
|
||||
public void wipeData(int flags) {
|
||||
throwIfParentInstance("wipeData");
|
||||
@@ -4013,16 +4018,21 @@ public class DevicePolicyManager {
|
||||
* be able to call this method; if it has not, a security exception will be thrown.
|
||||
*
|
||||
* @param flags Bit mask of additional options: currently supported flags are
|
||||
* {@link #WIPE_EXTERNAL_STORAGE} and {@link #WIPE_RESET_PROTECTION_DATA}.
|
||||
* {@link #WIPE_EXTERNAL_STORAGE}, {@link #WIPE_RESET_PROTECTION_DATA} and
|
||||
* {@link #WIPE_EUICC}.
|
||||
* @param reason a string that contains the reason for wiping data, which can be
|
||||
* presented to the user. If the string is null or empty, user won't be notified.
|
||||
* presented to the user.
|
||||
* @throws SecurityException if the calling application does not own an active administrator
|
||||
* that uses {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA}
|
||||
* @throws IllegalArgumentException if the input reason string is null or empty.
|
||||
* that uses {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA}
|
||||
* @throws IllegalArgumentException if the input reason string is null or empty, or if
|
||||
* {@link #WIPE_SILENTLY} is set.
|
||||
*/
|
||||
public void wipeData(int flags, CharSequence reason) {
|
||||
public void wipeData(int flags, @NonNull CharSequence reason) {
|
||||
throwIfParentInstance("wipeData");
|
||||
wipeDataInternal(flags, reason != null ? reason.toString() : null);
|
||||
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");
|
||||
wipeDataInternal(flags, reason.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4033,7 +4043,7 @@ public class DevicePolicyManager {
|
||||
* @see #wipeData(int, CharSequence)
|
||||
* @hide
|
||||
*/
|
||||
private void wipeDataInternal(int flags, String wipeReasonForUser) {
|
||||
private void wipeDataInternal(int flags, @NonNull String wipeReasonForUser) {
|
||||
if (mService != null) {
|
||||
try {
|
||||
mService.wipeDataWithReason(flags, wipeReasonForUser);
|
||||
|
||||
@@ -70,6 +70,7 @@ import static android.app.admin.DevicePolicyManager.PROFILE_KEYGUARD_FEATURES_AF
|
||||
import static android.app.admin.DevicePolicyManager.WIPE_EUICC;
|
||||
import static android.app.admin.DevicePolicyManager.WIPE_EXTERNAL_STORAGE;
|
||||
import static android.app.admin.DevicePolicyManager.WIPE_RESET_PROTECTION_DATA;
|
||||
import static android.app.admin.DevicePolicyManager.WIPE_SILENTLY;
|
||||
import static android.content.pm.PackageManager.MATCH_UNINSTALLED_PACKAGES;
|
||||
import static android.provider.Settings.Global.PRIVATE_DNS_MODE;
|
||||
import static android.provider.Settings.Global.PRIVATE_DNS_SPECIFIER;
|
||||
@@ -6405,7 +6406,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void forceWipeUser(int userId, String wipeReasonForUser) {
|
||||
private void forceWipeUser(int userId, String wipeReasonForUser, boolean wipeSilently) {
|
||||
boolean success = false;
|
||||
try {
|
||||
IActivityManager am = mInjector.getIActivityManager();
|
||||
@@ -6416,7 +6417,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
success = mUserManagerInternal.removeUserEvenWhenDisallowed(userId);
|
||||
if (!success) {
|
||||
Slog.w(LOG_TAG, "Couldn't remove user " + userId);
|
||||
} else if (isManagedProfile(userId) && !TextUtils.isEmpty(wipeReasonForUser)) {
|
||||
} else if (isManagedProfile(userId) && !wipeSilently) {
|
||||
sendWipeProfileNotification(wipeReasonForUser);
|
||||
}
|
||||
} catch (RemoteException re) {
|
||||
@@ -6431,6 +6432,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
if (!mHasFeature) {
|
||||
return;
|
||||
}
|
||||
Preconditions.checkStringNotEmpty(wipeReasonForUser, "wipeReasonForUser is null or empty");
|
||||
enforceFullCrossUsersPermission(mInjector.userHandleGetCallingUserId());
|
||||
|
||||
final ActiveAdmin admin;
|
||||
@@ -6490,7 +6492,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
internalReason,
|
||||
/*wipeEuicc=*/ (flags & WIPE_EUICC) != 0);
|
||||
} else {
|
||||
forceWipeUser(userId, wipeReasonForUser);
|
||||
forceWipeUser(userId, wipeReasonForUser, (flags & WIPE_SILENTLY) != 0);
|
||||
}
|
||||
} finally {
|
||||
mInjector.binderRestoreCallingIdentity(ident);
|
||||
|
||||
Reference in New Issue
Block a user