Running PermissionMonitor#startMonitoring on handler thread
Most permission update functions are running on the handler thread. So the startMonitoring() should be running on handler thread as well to ensure the permission won't change while processing CS's works. However, startMonitoring() has a dependency with MultipathPolicyTracker. It needs to call and complete the permission update before calling MultipathPolicyTracker#start. Thus, we need to check the startMonitoring done in the end of systemReadyInternal because we are processing it on the handler thread. Bug: 232048835 Test: atest FrameworksNetTests CtsNetTestCases Change-Id: I41fef14d6c163eb5676eab3ccd43416ea1fe1414
This commit is contained in:
parent
41df7f99bb
commit
3c8c810110
1 changed files with 11 additions and 1 deletions
|
|
@ -211,6 +211,7 @@ import android.os.BatteryStatsManager;
|
|||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.ConditionVariable;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.IBinder;
|
||||
|
|
@ -3040,7 +3041,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||
// Calling PermissionMonitor#startMonitoring() in systemReadyInternal() and the
|
||||
// MultipathPolicyTracker.start() is called in NetworkPolicyManagerService#systemReady()
|
||||
// to ensure the tracking will be initialized correctly.
|
||||
mPermissionMonitor.startMonitoring();
|
||||
final ConditionVariable startMonitoringDone = new ConditionVariable();
|
||||
mHandler.post(() -> {
|
||||
mPermissionMonitor.startMonitoring();
|
||||
startMonitoringDone.open();
|
||||
});
|
||||
mProxyTracker.loadGlobalProxy();
|
||||
registerDnsResolverUnsolicitedEventListener();
|
||||
|
||||
|
|
@ -3067,6 +3072,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||
if (SdkLevel.isAtLeastT()) {
|
||||
mBpfNetMaps.setPullAtomCallback(mContext);
|
||||
}
|
||||
// Wait PermissionMonitor to finish the permission update. Then MultipathPolicyTracker won't
|
||||
// have permission problem. While CV#block() is unbounded in time and can in principle block
|
||||
// forever, this replaces a synchronous call to PermissionMonitor#startMonitoring, which
|
||||
// could have blocked forever too.
|
||||
startMonitoringDone.block();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue