Merge "Remove return value in clearApplicationUserData"
diff --git a/api/current.txt b/api/current.txt
index 292ef52..7a54e6d 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -6390,7 +6390,7 @@
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 33028e3..3b4511e 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -9078,15 +9078,15 @@
* @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 2afaaa7..7fc31b1 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -386,7 +386,7 @@
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 f238302..918a355 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -12399,9 +12399,11 @@
}
@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);
}
@@ -12409,29 +12411,24 @@
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