diff options
author | Jeff Sharkey <jsharkey@android.com> | 2014-08-06 16:34:34 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@google.com> | 2014-08-07 00:23:54 +0000 |
commit | fbd0e9fa37fc17ccd25e4c1f16195bbd27de3c4c (patch) | |
tree | fb67a6cbd7f3b39bd82f22f1763a83c776fb08d6 | |
parent | 905857f1b8708b1a7cf60a5e6b934b75ac6aea77 (diff) | |
download | frameworks_base-fbd0e9fa37fc17ccd25e4c1f16195bbd27de3c4c.zip frameworks_base-fbd0e9fa37fc17ccd25e4c1f16195bbd27de3c4c.tar.gz frameworks_base-fbd0e9fa37fc17ccd25e4c1f16195bbd27de3c4c.tar.bz2 |
Surface user action events when un/installing.
This will be used shortly to connect up with permissions
confirmation UI.
Bug: 16515814
Change-Id: If28cecc28549900d960ac107a1fba0b10ce5bd7b
-rw-r--r-- | Android.mk | 1 | ||||
-rw-r--r-- | api/current.txt | 2 | ||||
-rw-r--r-- | cmds/pm/src/com/android/commands/pm/Pm.java | 19 | ||||
-rw-r--r-- | core/java/android/app/ApplicationPackageManager.java | 21 | ||||
-rw-r--r-- | core/java/android/app/PackageDeleteObserver.java | 46 | ||||
-rw-r--r-- | core/java/android/app/PackageInstallObserver.java | 24 | ||||
-rw-r--r-- | core/java/android/content/pm/IPackageDeleteObserver2.aidl (renamed from core/java/android/app/PackageUninstallObserver.java) | 22 | ||||
-rw-r--r-- | core/java/android/content/pm/IPackageInstallObserver2.aidl | 6 | ||||
-rw-r--r-- | core/java/android/content/pm/IPackageInstaller.aidl | 6 | ||||
-rw-r--r-- | core/java/android/content/pm/IPackageManager.aidl | 9 | ||||
-rw-r--r-- | core/java/android/content/pm/PackageInstaller.java | 45 | ||||
-rw-r--r-- | services/core/java/com/android/server/pm/PackageInstallerService.java | 7 | ||||
-rw-r--r-- | services/core/java/com/android/server/pm/PackageInstallerSession.java | 16 | ||||
-rw-r--r-- | services/core/java/com/android/server/pm/PackageManagerService.java | 44 |
14 files changed, 203 insertions, 65 deletions
@@ -128,6 +128,7 @@ LOCAL_SRC_FILES += \ core/java/android/content/pm/IOnAppsChangedListener.aidl \ core/java/android/content/pm/IPackageDataObserver.aidl \ core/java/android/content/pm/IPackageDeleteObserver.aidl \ + core/java/android/content/pm/IPackageDeleteObserver2.aidl \ core/java/android/content/pm/IPackageInstallObserver.aidl \ core/java/android/content/pm/IPackageInstallObserver2.aidl \ core/java/android/content/pm/IPackageInstaller.aidl \ diff --git a/api/current.txt b/api/current.txt index e1460f2..d4f2cc5 100644 --- a/api/current.txt +++ b/api/current.txt @@ -8673,6 +8673,7 @@ package android.content.pm { ctor public PackageInstaller.CommitCallback(); method public abstract void onFailure(int, java.lang.String, android.os.Bundle); method public abstract void onSuccess(); + method public abstract void onUserActionRequired(android.content.Intent); field public static final java.lang.String EXTRA_PACKAGE_NAME = "android.content.pm.extra.PACKAGE_NAME"; field public static final int FAILURE_CONFLICT = 2; // 0x2 field public static final int FAILURE_INCOMPATIBLE = 4; // 0x4 @@ -8705,6 +8706,7 @@ package android.content.pm { ctor public PackageInstaller.UninstallCallback(); method public abstract void onFailure(java.lang.String); method public abstract void onSuccess(); + method public abstract void onUserActionRequired(android.content.Intent); } public class PackageItemInfo { diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java index 1f25dd0..c5e91e3 100644 --- a/cmds/pm/src/com/android/commands/pm/Pm.java +++ b/cmds/pm/src/com/android/commands/pm/Pm.java @@ -19,12 +19,13 @@ package com.android.commands.pm; import android.app.ActivityManager; import android.app.ActivityManagerNative; import android.app.IActivityManager; +import android.app.PackageDeleteObserver; import android.app.PackageInstallObserver; import android.content.ComponentName; +import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.FeatureInfo; import android.content.pm.IPackageDataObserver; -import android.content.pm.IPackageDeleteObserver; import android.content.pm.IPackageInstaller; import android.content.pm.IPackageManager; import android.content.pm.InstallSessionInfo; @@ -760,7 +761,7 @@ public final class Pm { String extraPackage; @Override - public void packageInstalled(String name, Bundle extras, int status) { + public void onPackageInstalled(String name, int status, String msg, Bundle extras) { synchronized (this) { finished = true; result = status; @@ -790,6 +791,11 @@ public final class Pm { } @Override + public void onUserActionRequired(Intent intent) { + setResult(false, "Unexepected user action required!"); + } + + @Override public void onSuccess() { setResult(true, null); } @@ -1268,11 +1274,12 @@ public final class Pm { } } - class PackageDeleteObserver extends IPackageDeleteObserver.Stub { + class LocalPackageDeleteObserver extends PackageDeleteObserver { boolean finished; boolean result; - public void packageDeleted(String packageName, int returnCode) { + @Override + public void onPackageDeleted(String name, int returnCode, String msg) { synchronized (this) { finished = true; result = returnCode == PackageManager.DELETE_SUCCEEDED; @@ -1346,9 +1353,9 @@ public final class Pm { } private boolean deletePackage(String packageName, int flags, int userId) { - PackageDeleteObserver obs = new PackageDeleteObserver(); + LocalPackageDeleteObserver obs = new LocalPackageDeleteObserver(); try { - mInstaller.uninstall(packageName, flags, obs, userId); + mInstaller.uninstall(packageName, flags, obs.getBinder(), userId); synchronized (obs) { while (!obs.finished) { diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java index edcfd74..84b5516 100644 --- a/core/java/android/app/ApplicationPackageManager.java +++ b/core/java/android/app/ApplicationPackageManager.java @@ -28,6 +28,7 @@ import android.content.pm.ContainerEncryptionParams; import android.content.pm.FeatureInfo; import android.content.pm.IPackageDataObserver; import android.content.pm.IPackageDeleteObserver; +import android.content.pm.IPackageDeleteObserver2; import android.content.pm.IPackageInstallObserver; import android.content.pm.IPackageManager; import android.content.pm.IPackageMoveObserver; @@ -1287,6 +1288,7 @@ final class ApplicationPackageManager extends PackageManager { // Should never happen! } } + @Override public void clearApplicationUserData(String packageName, IPackageDataObserver observer) { @@ -1661,7 +1663,8 @@ final class ApplicationPackageManager extends PackageManager { } @Override - public void packageInstalled(String basePackageName, Bundle extras, int returnCode) { + public void onPackageInstalled(String basePackageName, int returnCode, String msg, + Bundle extras) { try { mLegacy.packageInstalled(basePackageName, returnCode); } catch (RemoteException ignored) { @@ -1669,6 +1672,22 @@ final class ApplicationPackageManager extends PackageManager { } } + private static class LegacyPackageDeleteObserver extends PackageDeleteObserver { + private final IPackageDeleteObserver mLegacy; + + public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) { + mLegacy = legacy; + } + + @Override + public void onPackageDeleted(String basePackageName, int returnCode, String msg) { + try { + mLegacy.packageDeleted(basePackageName, returnCode); + } catch (RemoteException ignored) { + } + } + } + private final ContextImpl mContext; private final IPackageManager mPM; diff --git a/core/java/android/app/PackageDeleteObserver.java b/core/java/android/app/PackageDeleteObserver.java new file mode 100644 index 0000000..9b83ec1 --- /dev/null +++ b/core/java/android/app/PackageDeleteObserver.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.app; + +import android.content.Intent; +import android.content.pm.IPackageDeleteObserver2; + +/** {@hide} */ +public class PackageDeleteObserver { + private final IPackageDeleteObserver2.Stub mBinder = new IPackageDeleteObserver2.Stub() { + @Override + public void onUserActionRequired(Intent intent) { + PackageDeleteObserver.this.onUserActionRequired(intent); + } + + @Override + public void onPackageDeleted(String basePackageName, int returnCode, String msg) { + PackageDeleteObserver.this.onPackageDeleted(basePackageName, returnCode, msg); + } + }; + + /** {@hide} */ + public IPackageDeleteObserver2 getBinder() { + return mBinder; + } + + public void onUserActionRequired(Intent intent) { + } + + public void onPackageDeleted(String basePackageName, int returnCode, String msg) { + } +} diff --git a/core/java/android/app/PackageInstallObserver.java b/core/java/android/app/PackageInstallObserver.java index 1b2504e..ff28679 100644 --- a/core/java/android/app/PackageInstallObserver.java +++ b/core/java/android/app/PackageInstallObserver.java @@ -16,6 +16,7 @@ package android.app; +import android.content.Intent; import android.content.pm.IPackageInstallObserver2; import android.os.Bundle; @@ -23,9 +24,15 @@ import android.os.Bundle; public class PackageInstallObserver { private final IPackageInstallObserver2.Stub mBinder = new IPackageInstallObserver2.Stub() { @Override - public void packageInstalled(String basePackageName, Bundle extras, int returnCode, - String msg) { - PackageInstallObserver.this.packageInstalled(basePackageName, extras, returnCode, msg); + public void onUserActionRequired(Intent intent) { + PackageInstallObserver.this.onUserActionRequired(intent); + } + + @Override + public void onPackageInstalled(String basePackageName, int returnCode, + String msg, Bundle extras) { + PackageInstallObserver.this.onPackageInstalled(basePackageName, returnCode, msg, + extras); } }; @@ -34,6 +41,9 @@ public class PackageInstallObserver { return mBinder; } + public void onUserActionRequired(Intent intent) { + } + /** * This method will be called to report the result of the package * installation attempt. @@ -49,11 +59,7 @@ public class PackageInstallObserver { * basic outcome * @hide */ - public void packageInstalled(String basePackageName, Bundle extras, int returnCode) { - } - - public void packageInstalled(String basePackageName, Bundle extras, int returnCode, - String msg) { - packageInstalled(basePackageName, extras, returnCode); + public void onPackageInstalled(String basePackageName, int returnCode, String msg, + Bundle extras) { } } diff --git a/core/java/android/app/PackageUninstallObserver.java b/core/java/android/content/pm/IPackageDeleteObserver2.aidl index 83fc380..bff3baa 100644 --- a/core/java/android/app/PackageUninstallObserver.java +++ b/core/java/android/content/pm/IPackageDeleteObserver2.aidl @@ -14,24 +14,12 @@ * limitations under the License. */ -package android.app; +package android.content.pm; -import android.content.pm.IPackageDeleteObserver; +import android.content.Intent; /** {@hide} */ -public class PackageUninstallObserver { - private final IPackageDeleteObserver.Stub mBinder = new IPackageDeleteObserver.Stub() { - @Override - public void packageDeleted(String basePackageName, int returnCode) { - PackageUninstallObserver.this.onUninstallFinished(basePackageName, returnCode); - } - }; - - /** {@hide} */ - public IPackageDeleteObserver getBinder() { - return mBinder; - } - - public void onUninstallFinished(String basePackageName, int returnCode) { - } +oneway interface IPackageDeleteObserver2 { + void onUserActionRequired(in Intent intent); + void onPackageDeleted(String packageName, int returnCode, String msg); } diff --git a/core/java/android/content/pm/IPackageInstallObserver2.aidl b/core/java/android/content/pm/IPackageInstallObserver2.aidl index 824d730..bb5f22a 100644 --- a/core/java/android/content/pm/IPackageInstallObserver2.aidl +++ b/core/java/android/content/pm/IPackageInstallObserver2.aidl @@ -16,7 +16,7 @@ package android.content.pm; -import android.content.IntentSender; +import android.content.Intent; import android.os.Bundle; /** @@ -25,6 +25,8 @@ import android.os.Bundle; * @hide */ oneway interface IPackageInstallObserver2 { + void onUserActionRequired(in Intent intent); + /** * The install operation has completed. {@code returnCode} holds a numeric code * indicating success or failure. In certain cases the {@code extras} Bundle will @@ -40,5 +42,5 @@ oneway interface IPackageInstallObserver2 { * </tr> * </table> */ - void packageInstalled(String basePackageName, in Bundle extras, int returnCode, String msg); + void onPackageInstalled(String basePackageName, int returnCode, String msg, in Bundle extras); } diff --git a/core/java/android/content/pm/IPackageInstaller.aidl b/core/java/android/content/pm/IPackageInstaller.aidl index 0c65034..176a81c 100644 --- a/core/java/android/content/pm/IPackageInstaller.aidl +++ b/core/java/android/content/pm/IPackageInstaller.aidl @@ -16,7 +16,7 @@ package android.content.pm; -import android.content.pm.IPackageDeleteObserver; +import android.content.pm.IPackageDeleteObserver2; import android.content.pm.IPackageInstallerCallback; import android.content.pm.IPackageInstallerSession; import android.content.pm.InstallSessionInfo; @@ -35,6 +35,6 @@ interface IPackageInstaller { void registerCallback(IPackageInstallerCallback callback, int userId); void unregisterCallback(IPackageInstallerCallback callback); - void uninstall(String packageName, int flags, in IPackageDeleteObserver observer, int userId); - void uninstallSplit(String packageName, String splitName, int flags, in IPackageDeleteObserver observer, int userId); + void uninstall(String packageName, int flags, in IPackageDeleteObserver2 observer, int userId); + void uninstallSplit(String packageName, String splitName, int flags, in IPackageDeleteObserver2 observer, int userId); } diff --git a/core/java/android/content/pm/IPackageManager.aidl b/core/java/android/content/pm/IPackageManager.aidl index 2d6d3c9..44478d4 100644 --- a/core/java/android/content/pm/IPackageManager.aidl +++ b/core/java/android/content/pm/IPackageManager.aidl @@ -24,10 +24,10 @@ import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.ContainerEncryptionParams; import android.content.pm.FeatureInfo; -import android.content.pm.IPackageInstallObserver; import android.content.pm.IPackageInstallObserver2; import android.content.pm.IPackageInstaller; import android.content.pm.IPackageDeleteObserver; +import android.content.pm.IPackageDeleteObserver2; import android.content.pm.IPackageDataObserver; import android.content.pm.IPackageMoveObserver; import android.content.pm.IPackageStatsObserver; @@ -202,6 +202,10 @@ interface IPackageManager { void setInstallerPackageName(in String targetPackage, in String installerPackageName); + /** @deprecated rawr, don't call AIDL methods directly! */ + void deletePackageAsUser(in String packageName, IPackageDeleteObserver observer, + int userId, int flags); + /** * Delete a package for a specific user. * @@ -210,8 +214,7 @@ interface IPackageManager { * @param userId the id of the user for whom to delete the package * @param flags - possible values: {@link #DONT_DELETE_DATA} */ - void deletePackageAsUser(in String packageName, IPackageDeleteObserver observer, - int userId, int flags); + void deletePackage(in String packageName, IPackageDeleteObserver2 observer, int userId, int flags); String getInstallerPackageName(in String packageName); diff --git a/core/java/android/content/pm/PackageInstaller.java b/core/java/android/content/pm/PackageInstaller.java index 299afff..01c080d 100644 --- a/core/java/android/content/pm/PackageInstaller.java +++ b/core/java/android/content/pm/PackageInstaller.java @@ -20,8 +20,9 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; +import android.app.PackageDeleteObserver; import android.app.PackageInstallObserver; -import android.app.PackageUninstallObserver; +import android.content.Intent; import android.os.Bundle; import android.os.FileBridge; import android.os.Handler; @@ -536,15 +537,25 @@ public class PackageInstaller { } /** - * Final result of an uninstall request. + * Events for a specific uninstall request. */ public static abstract class UninstallCallback { + /** + * User action is required to proceed. You can start the given intent + * activity to involve the user and continue. + * <p> + * You may choose to immediately launch the intent if the user is + * actively using your app. However, you should use a notification to + * guide the user back into your app if not currently active. + */ + public abstract void onUserActionRequired(Intent intent); + public abstract void onSuccess(); public abstract void onFailure(String msg); } /** {@hide} */ - private static class UninstallCallbackDelegate extends PackageUninstallObserver { + private static class UninstallCallbackDelegate extends PackageDeleteObserver { private final UninstallCallback target; public UninstallCallbackDelegate(UninstallCallback target) { @@ -552,11 +563,16 @@ public class PackageInstaller { } @Override - public void onUninstallFinished(String basePackageName, int returnCode) { + public void onUserActionRequired(Intent intent) { + target.onUserActionRequired(intent); + } + + @Override + public void onPackageDeleted(String basePackageName, int returnCode, String msg) { if (returnCode == PackageManager.DELETE_SUCCEEDED) { target.onSuccess(); } else { - final String msg = PackageManager.deleteStatusToString(returnCode); + msg = PackageManager.deleteStatusToString(returnCode) + ": " + msg; target.onFailure(msg); } } @@ -612,6 +628,16 @@ public class PackageInstaller { public static final String EXTRA_PACKAGE_NAME = "android.content.pm.extra.PACKAGE_NAME"; + /** + * User action is required to proceed. You can start the given intent + * activity to involve the user and continue. + * <p> + * You may choose to immediately launch the intent if the user is + * actively using your app. However, you should use a notification to + * guide the user back into your app if not currently active. + */ + public abstract void onUserActionRequired(Intent intent); + public abstract void onSuccess(); public abstract void onFailure(int failureReason, String msg, Bundle extras); } @@ -625,8 +651,13 @@ public class PackageInstaller { } @Override - public void packageInstalled(String basePackageName, Bundle extras, int returnCode, - String msg) { + public void onUserActionRequired(Intent intent) { + target.onUserActionRequired(intent); + } + + @Override + public void onPackageInstalled(String basePackageName, int returnCode, String msg, + Bundle extras) { if (returnCode == PackageManager.INSTALL_SUCCEEDED) { target.onSuccess(); } else { diff --git a/services/core/java/com/android/server/pm/PackageInstallerService.java b/services/core/java/com/android/server/pm/PackageInstallerService.java index c673b98..b4faea1 100644 --- a/services/core/java/com/android/server/pm/PackageInstallerService.java +++ b/services/core/java/com/android/server/pm/PackageInstallerService.java @@ -38,6 +38,7 @@ import android.app.ActivityManager; import android.app.AppOpsManager; import android.content.Context; import android.content.pm.IPackageDeleteObserver; +import android.content.pm.IPackageDeleteObserver2; import android.content.pm.IPackageInstaller; import android.content.pm.IPackageInstallerCallback; import android.content.pm.IPackageInstallerSession; @@ -540,17 +541,17 @@ public class PackageInstallerService extends IPackageInstaller.Stub { } @Override - public void uninstall(String packageName, int flags, IPackageDeleteObserver observer, + public void uninstall(String packageName, int flags, IPackageDeleteObserver2 observer, int userId) { mPm.enforceCrossUserPermission(Binder.getCallingUid(), userId, true, "uninstall"); // TODO: enforce installer of record or permission - mPm.deletePackageAsUser(packageName, observer, userId, flags); + mPm.deletePackage(packageName, observer, userId, flags); } @Override public void uninstallSplit(String basePackageName, String overlayName, int flags, - IPackageDeleteObserver observer, int userId) { + IPackageDeleteObserver2 observer, int userId) { mPm.enforceCrossUserPermission(Binder.getCallingUid(), userId, true, "uninstallSplit"); // TODO: flesh out once PM has split support diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java index 26019db..5443fbc 100644 --- a/services/core/java/com/android/server/pm/PackageInstallerSession.java +++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java @@ -24,6 +24,7 @@ import static android.system.OsConstants.O_CREAT; import static android.system.OsConstants.O_RDONLY; import static android.system.OsConstants.O_WRONLY; +import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.IPackageInstallObserver2; import android.content.pm.IPackageInstallerSession; @@ -134,8 +135,8 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { Slog.e(TAG, "Install failed: " + e); destroyInternal(); try { - mRemoteObserver.packageInstalled(mPackageName, null, e.error, - e.getMessage()); + mRemoteObserver.onPackageInstalled(mPackageName, e.error, e.getMessage(), + null); } catch (RemoteException ignored) { } mCallback.onSessionFinished(PackageInstallerSession.this, false); @@ -377,11 +378,16 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { final IPackageInstallObserver2 remoteObserver = mRemoteObserver; final IPackageInstallObserver2 localObserver = new IPackageInstallObserver2.Stub() { @Override - public void packageInstalled(String basePackageName, Bundle extras, int returnCode, - String msg) { + public void onUserActionRequired(Intent intent) { + throw new IllegalStateException(); + } + + @Override + public void onPackageInstalled(String basePackageName, int returnCode, String msg, + Bundle extras) { destroyInternal(); try { - remoteObserver.packageInstalled(basePackageName, extras, returnCode, msg); + remoteObserver.onPackageInstalled(basePackageName, returnCode, msg, extras); } catch (RemoteException ignored) { } final boolean success = (returnCode == PackageManager.INSTALL_SUCCEEDED); diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 6bedcfb..df1269e 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -85,6 +85,7 @@ import org.xmlpull.v1.XmlSerializer; import android.app.ActivityManager; import android.app.ActivityManagerNative; import android.app.IActivityManager; +import android.app.PackageDeleteObserver; import android.app.admin.IDevicePolicyManager; import android.app.backup.IBackupManager; import android.content.BroadcastReceiver; @@ -101,6 +102,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.FeatureInfo; import android.content.pm.IPackageDataObserver; import android.content.pm.IPackageDeleteObserver; +import android.content.pm.IPackageDeleteObserver2; import android.content.pm.IPackageInstallObserver2; import android.content.pm.IPackageInstaller; import android.content.pm.IPackageManager; @@ -1063,8 +1065,8 @@ public class PackageManagerService extends IPackageManager.Stub { if (args.observer != null) { try { Bundle extras = extrasForInstallResult(res); - args.observer.packageInstalled(res.name, extras, res.returnCode, - res.returnMsg); + args.observer.onPackageInstalled(res.name, res.returnCode, + res.returnMsg, extras); } catch (RemoteException e) { Slog.i(TAG, "Observer no longer exists."); } @@ -7723,7 +7725,7 @@ public class PackageManagerService extends IPackageManager.Stub { if (isUserRestricted(UserHandle.getUserId(uid), UserManager.DISALLOW_INSTALL_APPS)) { try { if (observer != null) { - observer.packageInstalled("", null, INSTALL_FAILED_USER_RESTRICTED, null); + observer.onPackageInstalled("", INSTALL_FAILED_USER_RESTRICTED, null, null); } } catch (RemoteException re) { } @@ -10486,9 +10488,15 @@ public class PackageManagerService extends IPackageManager.Stub { } @Override - public void deletePackageAsUser(final String packageName, - final IPackageDeleteObserver observer, - final int userId, final int flags) { + public void deletePackageAsUser(String packageName, IPackageDeleteObserver observer, int userId, + int flags) { + deletePackage(packageName, new LegacyPackageDeleteObserver(observer).getBinder(), userId, + flags); + } + + @Override + public void deletePackage(final String packageName, + final IPackageDeleteObserver2 observer, final int userId, final int flags) { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.DELETE_PACKAGES, null); final int uid = Binder.getCallingUid(); @@ -10499,7 +10507,8 @@ public class PackageManagerService extends IPackageManager.Stub { } if (isUserRestricted(userId, UserManager.DISALLOW_UNINSTALL_APPS)) { try { - observer.packageDeleted(packageName, PackageManager.DELETE_FAILED_USER_RESTRICTED); + observer.onPackageDeleted(packageName, + PackageManager.DELETE_FAILED_USER_RESTRICTED, null); } catch (RemoteException re) { } return; @@ -10519,7 +10528,8 @@ public class PackageManagerService extends IPackageManager.Stub { } if (uninstallBlocked) { try { - observer.packageDeleted(packageName, PackageManager.DELETE_FAILED_OWNER_BLOCKED); + observer.onPackageDeleted(packageName, PackageManager.DELETE_FAILED_OWNER_BLOCKED, + null); } catch (RemoteException re) { } return; @@ -10535,7 +10545,7 @@ public class PackageManagerService extends IPackageManager.Stub { final int returnCode = deletePackageX(packageName, userId, flags); if (observer != null) { try { - observer.packageDeleted(packageName, returnCode); + observer.onPackageDeleted(packageName, returnCode, null); } catch (RemoteException e) { Log.i(TAG, "Observer no longer exists."); } //end catch @@ -13407,4 +13417,20 @@ public class PackageManagerService extends IPackageManager.Stub { return false; } } + + private static class LegacyPackageDeleteObserver extends PackageDeleteObserver { + private final IPackageDeleteObserver mLegacy; + + public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) { + mLegacy = legacy; + } + + @Override + public void onPackageDeleted(String basePackageName, int returnCode, String msg) { + try { + mLegacy.packageDeleted(basePackageName, returnCode); + } catch (RemoteException ignored) { + } + } + } } |