Merge "Fix: ConnectivityManager methods crashing with SecurityException"

This commit is contained in:
Chalard Jean
2021-07-30 05:28:33 +00:00
committed by Gerrit Code Review

View File

@@ -352,11 +352,12 @@ public final class ActivityThread extends ClientTransactionHandler {
@UnsupportedAppUsage
Configuration mConfiguration;
Configuration mCompatConfiguration;
@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
@@ -1127,8 +1128,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() {
@@ -6697,6 +6708,15 @@ public final class ActivityThread extends ClientTransactionHandler {
app.setContentCaptureOptions(data.contentCaptureOptions);
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