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

Commit e93e6c81 authored by Christopher Tate's avatar Christopher Tate Committed by Android (Google) Code Review
Browse files

Merge "Don't rewrite package restrictions unconditionally in findPreferredActivity()" into lmp-dev

parents 02aa75a0 d67a78db
Loading
Loading
Loading
Loading
+100 −90
Original line number Diff line number Diff line
@@ -3035,6 +3035,8 @@ public class PackageManagerService extends IPackageManager.Stub {
                            (flags & PackageManager.MATCH_DEFAULT_ONLY) != 0, userId)
                    : null;
            if (prefs != null && prefs.size() > 0) {
                boolean changed = false;
                try {
                    // First figure out how good the original match set is.
                    // We will only allow preferred activities that came
                    // from the same match quality.
@@ -3095,6 +3097,7 @@ public class PackageManagerService extends IPackageManager.Stub {
                            Slog.w(TAG, "Removing dangling preferred activity: "
                                    + pa.mPref.mComponent);
                            pir.removeFilter(pa);
                            changed = true;
                            continue;
                        }
                        for (int j=0; j<N; j++) {
@@ -3109,6 +3112,7 @@ public class PackageManagerService extends IPackageManager.Stub {
                            if (removeMatches) {
                                pir.removeFilter(pa);
                                changed = true;
                                if (DEBUG_PREFERRED) {
                                    Slog.v(TAG, "Removing match " + pa.mPref.mComponent);
                                }
@@ -3131,20 +3135,26 @@ public class PackageManagerService extends IPackageManager.Stub {
                                PreferredActivity lastChosen = new PreferredActivity(
                                        pa, pa.mPref.mMatch, null, pa.mPref.mComponent, false);
                                pir.addFilter(lastChosen);
                            mSettings.writePackageRestrictionsLPr(userId);
                                changed = true;
                                return null;
                            }
                            // Yay! Either the set matched or we're looking for the last chosen
                            if (DEBUG_PREFERRED || debug) Slog.v(TAG, "Returning preferred activity: "
                                    + ri.activityInfo.packageName + "/" + ri.activityInfo.name);
                        mSettings.writePackageRestrictionsLPr(userId);
                            return ri;
                        }
                    }
                } finally {
                    if (changed) {
                        if (DEBUG_PREFERRED) {
                            Slog.v(TAG, "Preferred activity bookkeeping changed; writing restrictions");
                        }
                        mSettings.writePackageRestrictionsLPr(userId);
                    }
                }
            }
        }
        if (DEBUG_PREFERRED || debug) Slog.v(TAG, "No preferred activity to return");
        return null;
    }