Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ff396f27 authored by Gustav Sennton's avatar Gustav Sennton
Browse files

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
parent c3769ae3
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -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);
        }
    }

+2 −0
Original line number Diff line number Diff line
@@ -160,6 +160,8 @@ public class WebViewUpdateServiceImpl {
            isFallbackEnabled = isEnabledPackage(
                    mSystemInterface.getPackageInfoForProvider(fallbackProvider));
        } catch (NameNotFoundException e) {
            // No fallback package installed -> early out.
            return;
        }

        if (existsValidNonFallbackProvider