diff options
Diffstat (limited to 'core/java/android/app/ActivityThread.java')
| -rw-r--r-- | core/java/android/app/ActivityThread.java | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 3915abe1e9eb..dbaf2757a9e2 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -369,11 +369,12 @@ public final class ActivityThread extends ClientTransactionHandler @UnsupportedAppUsage(trackingBug = 176961850, maxTargetSdk = Build.VERSION_CODES.R, publicAlternatives = "Use {@code Context#getResources()#getConfiguration()} instead.") Configuration mConfiguration; + @GuardedBy("this") + private boolean mUpdateHttpProxyOnBind = false; @UnsupportedAppUsage Application mInitialApplication; @UnsupportedAppUsage - final ArrayList<Application> mAllApplications - = new ArrayList<Application>(); + final ArrayList<Application> mAllApplications = new ArrayList<>(); /** * Bookkeeping of instantiated backup agents indexed first by user id, then by package name. * Indexing by user id supports parallel backups across users on system packages as they run in @@ -1187,8 +1188,18 @@ public final class ActivityThread extends ClientTransactionHandler } public void updateHttpProxy() { - ActivityThread.updateHttpProxy( - getApplication() != null ? getApplication() : getSystemContext()); + final Application app; + synchronized (ActivityThread.this) { + app = getApplication(); + if (null == app) { + // The app is not bound yet. Make a note to update the HTTP proxy when the + // app is bound. + mUpdateHttpProxyOnBind = true; + return; + } + } + // App is present, update the proxy inline. + ActivityThread.updateHttpProxy(app); } public void processInBackground() { @@ -6685,6 +6696,15 @@ public final class ActivityThread extends ClientTransactionHandler sendMessage(H.SET_CONTENT_CAPTURE_OPTIONS_CALLBACK, data.appInfo.packageName); mInitialApplication = app; + final boolean updateHttpProxy; + synchronized (this) { + updateHttpProxy = mUpdateHttpProxyOnBind; + // This synchronized block ensures that any subsequent call to updateHttpProxy() + // will see a non-null mInitialApplication. + } + if (updateHttpProxy) { + ActivityThread.updateHttpProxy(app); + } // don't bring up providers in restricted mode; they may depend on the // app's custom Application class |
