Merge changes from topic "PSL_TelephonyCallback"
* changes: [Telephony] Use TelephonyCallback instead of PhoneStateListener part1 [PhoneStateListener] Redesign PhoneStateListener: Use TelephonyCallback
This commit is contained in:
@@ -30,8 +30,8 @@ import android.database.ContentObserver;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.telephony.PhoneStateListener;
|
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
|
import android.telephony.TelephonyCallback;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@@ -92,8 +92,8 @@ public class MultinetworkPolicyTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected class ActiveDataSubscriptionIdChangedListener extends PhoneStateListener
|
protected class ActiveDataSubscriptionIdListener extends TelephonyCallback
|
||||||
implements PhoneStateListener.ActiveDataSubscriptionIdChangedListener {
|
implements TelephonyCallback.ActiveDataSubscriptionIdListener {
|
||||||
@Override
|
@Override
|
||||||
public void onActiveDataSubscriptionIdChanged(int subId) {
|
public void onActiveDataSubscriptionIdChanged(int subId) {
|
||||||
mActiveSubId = subId;
|
mActiveSubId = subId;
|
||||||
@@ -121,8 +121,8 @@ public class MultinetworkPolicyTracker {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ctx.getSystemService(TelephonyManager.class).registerPhoneStateListener(
|
ctx.getSystemService(TelephonyManager.class).registerTelephonyCallback(
|
||||||
new HandlerExecutor(handler), new ActiveDataSubscriptionIdChangedListener());
|
new HandlerExecutor(handler), new ActiveDataSubscriptionIdListener());
|
||||||
|
|
||||||
updateAvoidBadWifi();
|
updateAvoidBadWifi();
|
||||||
updateMeteredMultipathPreference();
|
updateMeteredMultipathPreference();
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import android.content.res.Resources
|
|||||||
import android.net.ConnectivityManager.MULTIPATH_PREFERENCE_HANDOVER
|
import android.net.ConnectivityManager.MULTIPATH_PREFERENCE_HANDOVER
|
||||||
import android.net.ConnectivityManager.MULTIPATH_PREFERENCE_PERFORMANCE
|
import android.net.ConnectivityManager.MULTIPATH_PREFERENCE_PERFORMANCE
|
||||||
import android.net.ConnectivityManager.MULTIPATH_PREFERENCE_RELIABILITY
|
import android.net.ConnectivityManager.MULTIPATH_PREFERENCE_RELIABILITY
|
||||||
import android.net.util.MultinetworkPolicyTracker.ActiveDataSubscriptionIdChangedListener
|
import android.net.util.MultinetworkPolicyTracker.ActiveDataSubscriptionIdListener
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
import android.provider.Settings.Global.NETWORK_AVOID_BAD_WIFI
|
import android.provider.Settings.Global.NETWORK_AVOID_BAD_WIFI
|
||||||
import android.provider.Settings.Global.NETWORK_METERED_MULTIPATH_PREFERENCE
|
import android.provider.Settings.Global.NETWORK_METERED_MULTIPATH_PREFERENCE
|
||||||
@@ -120,9 +120,9 @@ class MultinetworkPolicyTrackerTest {
|
|||||||
MULTIPATH_PREFERENCE_PERFORMANCE.toString())
|
MULTIPATH_PREFERENCE_PERFORMANCE.toString())
|
||||||
|
|
||||||
val listenerCaptor = ArgumentCaptor.forClass(
|
val listenerCaptor = ArgumentCaptor.forClass(
|
||||||
ActiveDataSubscriptionIdChangedListener::class.java)
|
ActiveDataSubscriptionIdListener::class.java)
|
||||||
verify(telephonyManager, times(1))
|
verify(telephonyManager, times(1))
|
||||||
.registerPhoneStateListener(any(), listenerCaptor.capture())
|
.registerTelephonyCallback(any(), listenerCaptor.capture())
|
||||||
val listener = listenerCaptor.value
|
val listener = listenerCaptor.value
|
||||||
listener.onActiveDataSubscriptionIdChanged(testSubId)
|
listener.onActiveDataSubscriptionIdChanged(testSubId)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user