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

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

Do not call updateApplicationInfo with mResourceManager lock

Otherwise it may cause a deadlock due to reversed lock ordering.

Test: create guest/switch/remove
Change-Id: Id11263ee2d358ab97b212477f896db7313605448
Fixes: 37347817
parent bd886e52
Loading
Loading
Loading
Loading
+17 −15
Original line number Diff line number Diff line
@@ -5084,24 +5084,26 @@ public final class ActivityThread {
        // caused by other sources, such as overlays. That means we want to be as conservative
        // about code changes as possible. Take the diff of the old ApplicationInfo and the new
        // to see if anything needs to change.
        synchronized (mResourcesManager) {
        LoadedApk apk;
        LoadedApk resApk;
        // Update all affected loaded packages with new package information
        synchronized (mResourcesManager) {
            WeakReference<LoadedApk> ref = mPackages.get(ai.packageName);
            LoadedApk apk = ref != null ? ref.get() : null;
            apk = ref != null ? ref.get() : null;
            ref = mResourcePackages.get(ai.packageName);
            resApk = ref != null ? ref.get() : null;
        }
        if (apk != null) {
            final ArrayList<String> oldPaths = new ArrayList<>();
            LoadedApk.makePaths(this, apk.getApplicationInfo(), oldPaths);
            apk.updateApplicationInfo(ai, oldPaths);
        }

            ref = mResourcePackages.get(ai.packageName);
            apk = ref != null ? ref.get() : null;
            if (apk != null) {
        if (resApk != null) {
            final ArrayList<String> oldPaths = new ArrayList<>();
                LoadedApk.makePaths(this, apk.getApplicationInfo(), oldPaths);
                apk.updateApplicationInfo(ai, oldPaths);
            LoadedApk.makePaths(this, resApk.getApplicationInfo(), oldPaths);
            resApk.updateApplicationInfo(ai, oldPaths);
        }

        synchronized (mResourcesManager) {
            // Update all affected Resources objects to use new ResourcesImpl
            mResourcesManager.applyNewResourceDirsLocked(ai.sourceDir, ai.resourceDirs);
        }