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
This commit is contained in:
Gustav Sennton
2016-04-06 17:53:04 +01:00
parent 3ed501c12a
commit 5c153c5172

View File

@@ -184,15 +184,18 @@ public class SystemImpl implements SystemInterface {
@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