diff options
4 files changed, 13 insertions, 16 deletions
diff --git a/api/current.txt b/api/current.txt index b7016a2221f1..3b790b0aa48a 100644 --- a/api/current.txt +++ b/api/current.txt @@ -6390,7 +6390,7 @@ package android.app.admin { method public void addPersistentPreferredActivity(android.content.ComponentName, android.content.IntentFilter, android.content.ComponentName); method public void addUserRestriction(android.content.ComponentName, java.lang.String); method public boolean bindDeviceAdminServiceAsUser(android.content.ComponentName, android.content.Intent, android.content.ServiceConnection, int, android.os.UserHandle); - method public boolean clearApplicationUserData(android.content.ComponentName, java.lang.String, java.util.concurrent.Executor, android.app.admin.DevicePolicyManager.OnClearApplicationUserDataListener); + method public void clearApplicationUserData(android.content.ComponentName, java.lang.String, java.util.concurrent.Executor, android.app.admin.DevicePolicyManager.OnClearApplicationUserDataListener); method public void clearCrossProfileIntentFilters(android.content.ComponentName); method public deprecated void clearDeviceOwnerApp(java.lang.String); method public void clearPackagePersistentPreferredActivities(android.content.ComponentName, java.lang.String); diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index 8f76032b4c62..3eda582e66c5 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -9045,15 +9045,15 @@ public class DevicePolicyManager { * @param executor The executor through which the listener should be invoked. * @param listener A callback object that will inform the caller when the clearing is done. * @throws SecurityException if the caller is not the device owner/profile owner. - * @return whether the clearing succeeded. */ - public boolean clearApplicationUserData(@NonNull ComponentName admin, + public void clearApplicationUserData(@NonNull ComponentName admin, @NonNull String packageName, @NonNull @CallbackExecutor Executor executor, @NonNull OnClearApplicationUserDataListener listener) { throwIfParentInstance("clearAppData"); Preconditions.checkNotNull(executor); + Preconditions.checkNotNull(listener); try { - return mService.clearApplicationUserData(admin, packageName, + mService.clearApplicationUserData(admin, packageName, new IPackageDataObserver.Stub() { public void onRemoveCompleted(String pkg, boolean succeeded) { executor.execute(() -> diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl index daee6b41a365..d844ec3cd5c4 100644 --- a/core/java/android/app/admin/IDevicePolicyManager.aidl +++ b/core/java/android/app/admin/IDevicePolicyManager.aidl @@ -385,7 +385,7 @@ interface IDevicePolicyManager { boolean isCurrentInputMethodSetByOwner(); StringParceledListSlice getOwnerInstalledCaCerts(in UserHandle user); - boolean clearApplicationUserData(in ComponentName admin, in String packageName, in IPackageDataObserver callback); + void clearApplicationUserData(in ComponentName admin, in String packageName, in IPackageDataObserver callback); void setLogoutEnabled(in ComponentName admin, boolean enabled); boolean isLogoutEnabled(); diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 99712a5173db..d2c0ff2d12cb 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -12301,9 +12301,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } @Override - public boolean clearApplicationUserData(ComponentName admin, String packageName, + public void clearApplicationUserData(ComponentName admin, String packageName, IPackageDataObserver callback) { Preconditions.checkNotNull(admin, "ComponentName is null"); + Preconditions.checkNotNull(packageName, "packageName is null"); + Preconditions.checkNotNull(callback, "callback is null"); synchronized (this) { getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER); } @@ -12311,29 +12313,24 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { long ident = mInjector.binderClearCallingIdentity(); try { - return ActivityManager.getService().clearApplicationUserData(packageName, false, - callback, userId); + ActivityManager.getService().clearApplicationUserData(packageName, false, callback, + userId); } catch(RemoteException re) { // Same process, should not happen. } catch (SecurityException se) { // This can happen e.g. for device admin packages, do not throw out the exception, // because callers have no means to know beforehand for which packages this might - // happen. + // happen. If so, we send back that removal failed. Slog.w(LOG_TAG, "Not allowed to clear application user data for package " + packageName, se); - } finally { - mInjector.binderRestoreCallingIdentity(ident); - } - - if (callback != null) { try { - // If there was a throw above, we send back that removal failed callback.onRemoveCompleted(packageName, false); } catch (RemoteException re) { // Caller is no longer available, ignore } + } finally { + mInjector.binderRestoreCallingIdentity(ident); } - return false; } @Override |