Ensure we don't crash the system server when disabling/enabling package.

We shouldn't crash when trying to disable/enable a non-existent fallback
package.

Bug: 27918467
Change-Id: Ia94425ac197b17430900bb7a9e7b2d2bf65ab9b3
This commit is contained in:
Gustav Sennton
2016-04-08 18:33:30 +01:00
parent c3769ae3f3
commit ff396f2710
2 changed files with 8 additions and 3 deletions

View File

@@ -19,6 +19,7 @@ package com.android.server.webkit;
import android.app.ActivityManagerNative;
import android.app.AppGlobals;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageDeleteObserver;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
@@ -187,7 +188,8 @@ public class SystemImpl implements SystemInterface {
enablePackageForAllUsers(context, packageName, false);
try {
PackageManager pm = AppGlobals.getInitialApplication().getPackageManager();
if (pm.getApplicationInfo(packageName, 0).isUpdatedSystemApp()) {
ApplicationInfo applicationInfo = pm.getApplicationInfo(packageName, 0);
if (applicationInfo != null && applicationInfo.isUpdatedSystemApp()) {
pm.deletePackage(packageName, new IPackageDeleteObserver.Stub() {
public void packageDeleted(String packageName, int returnCode) {
enablePackageForAllUsers(context, packageName, false);
@@ -214,8 +216,9 @@ public class SystemImpl implements SystemInterface {
enable ? PackageManager.COMPONENT_ENABLED_STATE_DEFAULT :
PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER, 0,
userId, null);
} catch (RemoteException e) {
Log.w(TAG, "Tried to disable " + packageName + " for user " + userId + ": " + e);
} catch (RemoteException | IllegalArgumentException e) {
Log.w(TAG, "Tried to " + (enable ? "enable " : "disable ") + packageName
+ " for user " + userId + ": " + e);
}
}

View File

@@ -160,6 +160,8 @@ public class WebViewUpdateServiceImpl {
isFallbackEnabled = isEnabledPackage(
mSystemInterface.getPackageInfoForProvider(fallbackProvider));
} catch (NameNotFoundException e) {
// No fallback package installed -> early out.
return;
}
if (existsValidNonFallbackProvider