Disable fallback webview package before downgrading it.
Now that we support disabling packages before downgrading them we can
do this for the webview fallback mechanism to avoid disabling a fallback
asynchronously (downgrading a package is an asynchronous operation).
We also check that the package is an upgraded app before downgrading it,
to not try to downgrade it unnecessarily.
Bug: 27894939
Change-Id: I541c2fcfe8016e4bcc2d5afff6e393c81e2749a2
diff --git a/services/core/java/com/android/server/webkit/SystemImpl.java b/services/core/java/com/android/server/webkit/SystemImpl.java
index d82b8b4..9486cfd 100644
--- a/services/core/java/com/android/server/webkit/SystemImpl.java
+++ b/services/core/java/com/android/server/webkit/SystemImpl.java
@@ -184,15 +184,18 @@
@Override
public void uninstallAndDisablePackageForAllUsers(Context context, String packageName) {
- context.getPackageManager().deletePackage(packageName,
- new IPackageDeleteObserver.Stub() {
- public void packageDeleted(String packageName, int returnCode) {
- // Ignore returnCode since the deletion could fail, e.g. we might be trying
- // to delete a non-updated system-package (and we should still disable the
- // package)
- enablePackageForAllUsers(context, packageName, false);
+ enablePackageForAllUsers(context, packageName, false);
+ try {
+ PackageManager pm = AppGlobals.getInitialApplication().getPackageManager();
+ if (pm.getApplicationInfo(packageName, 0).isUpdatedSystemApp()) {
+ pm.deletePackage(packageName, new IPackageDeleteObserver.Stub() {
+ public void packageDeleted(String packageName, int returnCode) {
+ enablePackageForAllUsers(context, packageName, false);
+ }
+ }, PackageManager.DELETE_SYSTEM_APP | PackageManager.DELETE_ALL_USERS);
}
- }, PackageManager.DELETE_SYSTEM_APP | PackageManager.DELETE_ALL_USERS);
+ } catch (NameNotFoundException e) {
+ }
}
@Override