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

Commit 995b2688 authored by Kurt Nelson's avatar Kurt Nelson Committed by android-build-merger
Browse files

Merge "Version guard Application.onCreate strict mode fix" into oc-mr1-dev am: e002f440

am: ef5a4ca4

Change-Id: Icd4e4434901eecf0825421291791fc89b14ffea7
parents e417eb08 ef5a4ca4
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -5732,6 +5732,7 @@ public final class ActivityThread {
        // probably end up doing the same disk access.
        Application app;
        final StrictMode.ThreadPolicy savedPolicy = StrictMode.allowThreadDiskWrites();
        final StrictMode.ThreadPolicy writesAllowedPolicy = StrictMode.getThreadPolicy();
        try {
            // If the app is being launched for full backup or restore, bring it up in
            // a restricted environment with the base application class.
@@ -5759,10 +5760,6 @@ public final class ActivityThread {
                    "Exception thrown in onCreate() of "
                    + data.instrumentationName + ": " + e.toString(), e);
            }
        } finally {
            StrictMode.setThreadPolicy(savedPolicy);
        }

            try {
                mInstrumentation.callApplicationOnCreate(app);
            } catch (Exception e) {
@@ -5772,6 +5769,14 @@ public final class ActivityThread {
                      + ": " + e.toString(), e);
                }
            }
        } finally {
            // If the app targets < O-MR1, or doesn't change the thread policy
            // during startup, clobber the policy to maintain behavior of b/36951662
            if (data.appInfo.targetSdkVersion <= Build.VERSION_CODES.O
                    || StrictMode.getThreadPolicy().equals(writesAllowedPolicy)) {
                StrictMode.setThreadPolicy(savedPolicy);
            }
        }

        // Preload fonts resources
        FontsContract.setApplicationContextForResources(appContext);