Start listening to telephony changes in #start()
Starting to listen on the handler races with the rest of
the constructor. The class already has a #start() method
meant to start listening, so implement better practices
by leveraging this method.
Test: CtsNetTestCases
FrameworksNetIntegrationTests
FrameworksNetTests
Change-Id: I772f761d3ca5f9711b9d988e6330b0878814f491
This commit is contained in:
@@ -109,8 +109,6 @@ public class MultinetworkPolicyTracker {
|
||||
this(ctx, handler, null);
|
||||
}
|
||||
|
||||
// TODO: Set the mini sdk to 31 and remove @TargetApi annotation when b/205923322 is addressed.
|
||||
@TargetApi(Build.VERSION_CODES.S)
|
||||
public MultinetworkPolicyTracker(Context ctx, Handler handler, Runnable avoidBadWifiCallback) {
|
||||
mContext = ctx;
|
||||
mResources = new ConnectivityResources(ctx);
|
||||
@@ -128,13 +126,12 @@ public class MultinetworkPolicyTracker {
|
||||
}
|
||||
};
|
||||
|
||||
ctx.getSystemService(TelephonyManager.class).registerTelephonyCallback(
|
||||
new HandlerExecutor(handler), new ActiveDataSubscriptionIdListener());
|
||||
|
||||
updateAvoidBadWifi();
|
||||
updateMeteredMultipathPreference();
|
||||
}
|
||||
|
||||
// TODO: Set the mini sdk to 31 and remove @TargetApi annotation when b/205923322 is addressed.
|
||||
@TargetApi(Build.VERSION_CODES.S)
|
||||
public void start() {
|
||||
for (Uri uri : mSettingsUris) {
|
||||
mResolver.registerContentObserver(uri, false, mSettingObserver);
|
||||
@@ -145,6 +142,9 @@ public class MultinetworkPolicyTracker {
|
||||
mContext.registerReceiverForAllUsers(mBroadcastReceiver, intentFilter,
|
||||
null /* broadcastPermission */, mHandler);
|
||||
|
||||
mContext.getSystemService(TelephonyManager.class).registerTelephonyCallback(
|
||||
new HandlerExecutor(mHandler), new ActiveDataSubscriptionIdListener());
|
||||
|
||||
reevaluate();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user