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

Commit 339189dc authored by Jeremy Meyer's avatar Jeremy Meyer
Browse files

make Context.setResources() null safe

It had previously been ok to pass null to ContextImpl.setResources() but
the multilocale changes made that no longer true. This adds a null check
so it is safe again.

Fixes: 309832031
Test: automated
Change-Id: I7e74b7ddf2280ef055e75371226410ac0f67fc63
parent 07c812e2
Loading
Loading
Loading
Loading
+18 −16
Original line number Diff line number Diff line
@@ -3481,6 +3481,7 @@ class ContextImpl extends Context {
        }
        mResources = r;

        if (r != null) {
            // only do this if the user already has more than one preferred locale
            if (android.content.res.Flags.defaultLocale()
                    && r.getConfiguration().getLocales().size() > 1) {
@@ -3488,9 +3489,9 @@ class ContextImpl extends Context {
                if (getUserId() < 0) {
                    lc = LocaleConfig.fromContextIgnoringOverride(this);
                } else {
                // This is needed because the app might have locale config overrides that need to
                // be read from disk in order for resources to correctly choose which values to
                // load.
                    // This is needed because the app might have locale config overrides that need
                    // to be read from disk in order for resources to correctly choose which values
                    // to load.
                    StrictMode.ThreadPolicy policy = StrictMode.allowThreadDiskReads();
                    try {
                        lc = new LocaleConfig(this);
@@ -3501,6 +3502,7 @@ class ContextImpl extends Context {
                mResourcesManager.setLocaleConfig(lc);
            }
        }
    }

    void installSystemApplicationInfo(ApplicationInfo info, ClassLoader classLoader) {
        mPackageInfo.installSystemApplicationInfo(info, classLoader);