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

Commit eb9e9ec0 authored by Christopher Tate's avatar Christopher Tate
Browse files

Return the right thing from Context.getApplicationContext()

Previously, this would always return the app context for the first application
ever instantiated in the process.  Usually this is fine, since usually there
will be one process per application, but in the case of shared-process apps,
it causes activities/views to try to access the wrong set of resources, be
unable to access their proper derived-class Application objects, etc.

Fixes bug #2513901

Change-Id: Ie19f2a86583c5d927db4d84a4262077450e37539
parent 23aea6df
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -278,6 +278,10 @@ public final class ActivityThread {

        int mClientCount = 0;

        Application getApplication() {
            return mApplication;
        }

        public PackageInfo(ActivityThread activityThread, ApplicationInfo aInfo,
                ActivityThread mainThread, ClassLoader baseLoader,
                boolean securityViolation, boolean includeCode) {
+2 −1
Original line number Diff line number Diff line
@@ -260,7 +260,8 @@ class ContextImpl extends Context {
    
    @Override
    public Context getApplicationContext() {
        return mMainThread.getApplication();
        return (mPackageInfo != null) ?
                mPackageInfo.getApplication() : mMainThread.getApplication();
    }
    
    @Override