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

Commit 9ec9fc01 authored by Songchun Fan's avatar Songchun Fan
Browse files

[pm/incremental] handle package setting nullptr

Due to asynchronous, when a package state change propagates to
package manager service, the package might have been removed already.

Test: atest android.content.pm.cts.PackageManagerShellCommandTest
BUG: 170199764
Change-Id: Iceee3ada587675091488299e769d2894b183ef84
parent ccfe7f82
Loading
Loading
Loading
Loading
+18 −9
Original line number Diff line number Diff line
@@ -17322,11 +17322,14 @@ public class PackageManagerService extends IPackageManager.Stub
            mIncrementalManager.unregisterCallback(mPathString, this);
            final SparseArray<int[]> newBroadcastAllowList;
            synchronized (mLock) {
                final PackageSetting ps = mSettings.mPackages.get(mPackageName);
                if (ps == null) {
                    return;
                }
                newBroadcastAllowList = mAppsFilter.getVisibilityAllowList(
                        getPackageSettingInternal(mPackageName, Process.SYSTEM_UID),
                        mInstalledUserIds, mSettings.mPackages);
                        ps, mInstalledUserIds, mSettings.mPackages);
            }
            Bundle extras = new Bundle(1);
            Bundle extras = new Bundle();
            extras.putInt(Intent.EXTRA_UID, mUserId);
            extras.putString(Intent.EXTRA_PACKAGE_NAME, mPackageName);
            sendPackageBroadcast(Intent.ACTION_PACKAGE_FULLY_LOADED, mPackageName,
@@ -17339,11 +17342,14 @@ public class PackageManagerService extends IPackageManager.Stub
        public void onPackageUnstartable(int reason) {
            final SparseArray<int[]> newBroadcastAllowList;
            synchronized (mLock) {
                final PackageSetting ps = mSettings.mPackages.get(mPackageName);
                if (ps == null) {
                    return;
                }
                newBroadcastAllowList = mAppsFilter.getVisibilityAllowList(
                        getPackageSettingInternal(mPackageName, Process.SYSTEM_UID),
                        mInstalledUserIds, mSettings.mPackages);
                        ps, mInstalledUserIds, mSettings.mPackages);
            }
            Bundle extras = new Bundle(1);
            Bundle extras = new Bundle();
            extras.putInt(Intent.EXTRA_UID, mUserId);
            extras.putString(Intent.EXTRA_PACKAGE_NAME, mPackageName);
            extras.putInt(Intent.EXTRA_REASON, reason);
@@ -17358,11 +17364,14 @@ public class PackageManagerService extends IPackageManager.Stub
        public void onPackageStartable() {
            final SparseArray<int[]> newBroadcastAllowList;
            synchronized (mLock) {
                final PackageSetting ps = mSettings.mPackages.get(mPackageName);
                if (ps == null) {
                    return;
                }
                newBroadcastAllowList = mAppsFilter.getVisibilityAllowList(
                        getPackageSettingInternal(mPackageName, Process.SYSTEM_UID),
                        mInstalledUserIds, mSettings.mPackages);
                        ps, mInstalledUserIds, mSettings.mPackages);
            }
            Bundle extras = new Bundle(1);
            Bundle extras = new Bundle();
            extras.putInt(Intent.EXTRA_UID, mUserId);
            extras.putString(Intent.EXTRA_PACKAGE_NAME, mPackageName);
            // send broadcast to users with this app installed