Loading services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +15 −9 Original line number Original line Diff line number Diff line Loading @@ -5909,35 +5909,41 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { private void forceWipeDeviceNoLock(boolean wipeExtRequested, String reason, boolean wipeEuicc) { private void forceWipeDeviceNoLock(boolean wipeExtRequested, String reason, boolean wipeEuicc) { wtfIfInLock(); wtfIfInLock(); boolean success = false; try { if (wipeExtRequested) { if (wipeExtRequested) { StorageManager sm = (StorageManager) mContext.getSystemService( StorageManager sm = (StorageManager) mContext.getSystemService( Context.STORAGE_SERVICE); Context.STORAGE_SERVICE); sm.wipeAdoptableDisks(); sm.wipeAdoptableDisks(); } } try { mInjector.recoverySystemRebootWipeUserData( mInjector.recoverySystemRebootWipeUserData( /*shutdown=*/ false, reason, /*force=*/ true, /*wipeEuicc=*/ wipeEuicc); /*shutdown=*/ false, reason, /*force=*/ true, /*wipeEuicc=*/ wipeEuicc); success = true; } catch (IOException | SecurityException e) { } catch (IOException | SecurityException e) { Slog.w(LOG_TAG, "Failed requesting data wipe", e); Slog.w(LOG_TAG, "Failed requesting data wipe", e); } finally { if (!success) SecurityLog.writeEvent(SecurityLog.TAG_WIPE_FAILURE); } } } } private void forceWipeUser(int userId, String wipeReasonForUser) { private void forceWipeUser(int userId, String wipeReasonForUser) { boolean success = false; try { try { IActivityManager am = mInjector.getIActivityManager(); IActivityManager am = mInjector.getIActivityManager(); if (am.getCurrentUser().id == userId) { if (am.getCurrentUser().id == userId) { am.switchUser(UserHandle.USER_SYSTEM); am.switchUser(UserHandle.USER_SYSTEM); } } boolean userRemoved = mUserManagerInternal.removeUserEvenWhenDisallowed(userId); success = mUserManagerInternal.removeUserEvenWhenDisallowed(userId); if (!userRemoved) { if (!success) { Slog.w(LOG_TAG, "Couldn't remove user " + userId); Slog.w(LOG_TAG, "Couldn't remove user " + userId); } else if (isManagedProfile(userId)) { } else if (isManagedProfile(userId)) { sendWipeProfileNotification(wipeReasonForUser); sendWipeProfileNotification(wipeReasonForUser); } } } catch (RemoteException re) { } catch (RemoteException re) { // Shouldn't happen // Shouldn't happen } finally { if (!success) SecurityLog.writeEvent(SecurityLog.TAG_WIPE_FAILURE); } } } } Loading Loading
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +15 −9 Original line number Original line Diff line number Diff line Loading @@ -5909,35 +5909,41 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { private void forceWipeDeviceNoLock(boolean wipeExtRequested, String reason, boolean wipeEuicc) { private void forceWipeDeviceNoLock(boolean wipeExtRequested, String reason, boolean wipeEuicc) { wtfIfInLock(); wtfIfInLock(); boolean success = false; try { if (wipeExtRequested) { if (wipeExtRequested) { StorageManager sm = (StorageManager) mContext.getSystemService( StorageManager sm = (StorageManager) mContext.getSystemService( Context.STORAGE_SERVICE); Context.STORAGE_SERVICE); sm.wipeAdoptableDisks(); sm.wipeAdoptableDisks(); } } try { mInjector.recoverySystemRebootWipeUserData( mInjector.recoverySystemRebootWipeUserData( /*shutdown=*/ false, reason, /*force=*/ true, /*wipeEuicc=*/ wipeEuicc); /*shutdown=*/ false, reason, /*force=*/ true, /*wipeEuicc=*/ wipeEuicc); success = true; } catch (IOException | SecurityException e) { } catch (IOException | SecurityException e) { Slog.w(LOG_TAG, "Failed requesting data wipe", e); Slog.w(LOG_TAG, "Failed requesting data wipe", e); } finally { if (!success) SecurityLog.writeEvent(SecurityLog.TAG_WIPE_FAILURE); } } } } private void forceWipeUser(int userId, String wipeReasonForUser) { private void forceWipeUser(int userId, String wipeReasonForUser) { boolean success = false; try { try { IActivityManager am = mInjector.getIActivityManager(); IActivityManager am = mInjector.getIActivityManager(); if (am.getCurrentUser().id == userId) { if (am.getCurrentUser().id == userId) { am.switchUser(UserHandle.USER_SYSTEM); am.switchUser(UserHandle.USER_SYSTEM); } } boolean userRemoved = mUserManagerInternal.removeUserEvenWhenDisallowed(userId); success = mUserManagerInternal.removeUserEvenWhenDisallowed(userId); if (!userRemoved) { if (!success) { Slog.w(LOG_TAG, "Couldn't remove user " + userId); Slog.w(LOG_TAG, "Couldn't remove user " + userId); } else if (isManagedProfile(userId)) { } else if (isManagedProfile(userId)) { sendWipeProfileNotification(wipeReasonForUser); sendWipeProfileNotification(wipeReasonForUser); } } } catch (RemoteException re) { } catch (RemoteException re) { // Shouldn't happen // Shouldn't happen } finally { if (!success) SecurityLog.writeEvent(SecurityLog.TAG_WIPE_FAILURE); } } } } Loading