Handle null IPackageDeleteObserver.
Bug: 16862614
Change-Id: I0c197a994b89d49123027f24fe46827c2b994ab6
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java
index 84b5516..a935dc0 100644
--- a/core/java/android/app/ApplicationPackageManager.java
+++ b/core/java/android/app/ApplicationPackageManager.java
@@ -28,7 +28,6 @@
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;
@@ -53,7 +52,6 @@
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
-import android.os.Bundle;
import android.os.IBinder;
import android.os.Process;
import android.os.RemoteException;
@@ -1655,39 +1653,6 @@
new UserHandle(mContext.getUserId()));
}
- private static class LegacyPackageInstallObserver extends PackageInstallObserver {
- private final IPackageInstallObserver mLegacy;
-
- public LegacyPackageInstallObserver(IPackageInstallObserver legacy) {
- mLegacy = legacy;
- }
-
- @Override
- public void onPackageInstalled(String basePackageName, int returnCode, String msg,
- Bundle extras) {
- try {
- mLegacy.packageInstalled(basePackageName, returnCode);
- } catch (RemoteException ignored) {
- }
- }
- }
-
- 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/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 7dad367..b957a15 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -21,6 +21,7 @@
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
+import android.app.PackageDeleteObserver;
import android.app.PackageInstallObserver;
import android.content.ComponentName;
import android.content.Context;
@@ -36,6 +37,7 @@
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
+import android.os.RemoteException;
import android.os.UserHandle;
import android.util.AndroidException;
@@ -3913,4 +3915,41 @@
default: return UninstallCallback.FAILURE_UNKNOWN;
}
}
+
+ /** {@hide} */
+ public static class LegacyPackageInstallObserver extends PackageInstallObserver {
+ private final IPackageInstallObserver mLegacy;
+
+ public LegacyPackageInstallObserver(IPackageInstallObserver legacy) {
+ mLegacy = legacy;
+ }
+
+ @Override
+ public void onPackageInstalled(String basePackageName, int returnCode, String msg,
+ Bundle extras) {
+ if (mLegacy == null) return;
+ try {
+ mLegacy.packageInstalled(basePackageName, returnCode);
+ } catch (RemoteException ignored) {
+ }
+ }
+ }
+
+ /** {@hide} */
+ public 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) {
+ if (mLegacy == null) return;
+ try {
+ mLegacy.packageDeleted(basePackageName, returnCode);
+ } catch (RemoteException ignored) {
+ }
+ }
+ }
}
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 6802fac..cef127e 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -85,7 +85,6 @@
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;
@@ -115,6 +114,7 @@
import android.content.pm.PackageInfo;
import android.content.pm.PackageInfoLite;
import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.LegacyPackageDeleteObserver;
import android.content.pm.PackageParser.ActivityIntentInfo;
import android.content.pm.PackageParser.PackageLite;
import android.content.pm.PackageParser.PackageParserException;
@@ -13451,20 +13451,4 @@
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) {
- }
- }
- }
}