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

Commit f1b34a58 authored by Fyodor Kupolov's avatar Fyodor Kupolov
Browse files

Use synchronization when accessing mPackages state

In the context of this bug, enableComponentLPw was concurrently
 modifying arraylist.

Test: manual - multiple reboots
Bug: 64986285
Change-Id: Ifab137c9572a2eb4ec7417309f6674a08425833c
parent d1736cb2
Loading
Loading
Loading
Loading
+62 −54
Original line number Diff line number Diff line
@@ -21822,6 +21822,7 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
            }
        }
        synchronized (mPackages) {
            if (callingUid == Process.SHELL_UID
                    && (pkgSetting.pkgFlags & ApplicationInfo.FLAG_TEST_ONLY) == 0) {
                // Shell can only change whole packages between ENABLED and DISABLED_USER states
@@ -21843,12 +21844,15 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
                                    + className + " to " + newState);
                }
            }
        }
        if (className == null) {
            // We're dealing with an application/package level state change
            synchronized (mPackages) {
                if (pkgSetting.getEnabled(userId) == newState) {
                    // Nothing to do
                    return;
                }
            }
            // If we're enabling a system stub, there's a little more work to do.
            // Prior to enabling the package, we need to decompress the APK(s) to the
            // data partition and then replace the version on the system partition.
@@ -21961,8 +21965,11 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
                // Don't care about who enables an app.
                callingPackage = null;
            }
            synchronized (mPackages) {
                pkgSetting.setEnabled(newState, userId, callingPackage);
            }
        } else {
            synchronized (mPackages) {
                // We're dealing with a component level state change
                // First, verify that this is a valid class name.
                PackageParser.Package pkg = pkgSetting.pkg;
@@ -21998,6 +22005,7 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
                        return;
                }
            }
        }
        synchronized (mPackages) {
            scheduleWritePackageRestrictionsLocked(userId);
            updateSequenceNumberLP(pkgSetting, new int[] { userId });