Loading src/com/android/settings/network/MobileNetworkRepository.java +21 −25 Original line number Diff line number Diff line Loading @@ -91,7 +91,6 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions private AirplaneModeObserver mAirplaneModeObserver; private DataRoamingObserver mDataRoamingObserver; private MetricsFeatureProvider mMetricsFeatureProvider; private Map<Integer, MobileDataContentObserver> mDataContentObserverMap = new HashMap<>(); private int mPhysicalSlotIndex = SubscriptionManager.INVALID_SIM_SLOT_INDEX; private int mLogicalSlotIndex = SubscriptionManager.INVALID_SIM_SLOT_INDEX; private int mCardState = UiccSlotInfo.CARD_STATE_INFO_ABSENT; Loading Loading @@ -209,6 +208,9 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions */ public void addRegister(LifecycleOwner lifecycleOwner, MobileNetworkCallback mobileNetworkCallback, int subId) { if (DEBUG) { Log.d(TAG, "addRegister by SUB ID " + subId); } if (sCallbacks.isEmpty()) { mSubscriptionManager.addOnSubscriptionsChangedListener(mContext.getMainExecutor(), this); Loading @@ -222,7 +224,6 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions observeAllUiccInfo(lifecycleOwner); observeAllMobileNetworkInfo(lifecycleOwner); if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) { addRegisterBySubId(subId); createTelephonyManagerBySubId(subId); mDataRoamingObserver.register(mContext, subId); } Loading @@ -231,25 +232,12 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions sendAvailableSubInfoCache(mobileNetworkCallback); } public void addRegisterBySubId(int subId) { MobileDataContentObserver dataContentObserver = new MobileDataContentObserver( new Handler(Looper.getMainLooper())); dataContentObserver.setOnMobileDataChangedListener(() -> { sExecutor.execute(() -> { insertMobileNetworkInfo(mContext, subId, getTelephonyManagerBySubId(mContext, subId)); }); }); dataContentObserver.register(mContext, subId); mDataContentObserverMap.put(subId, dataContentObserver); } private void createTelephonyManagerBySubId(int subId) { if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { return; } PhoneCallStateTelephonyCallback telephonyCallback = new PhoneCallStateTelephonyCallback(); telephonyCallback = new PhoneCallStateTelephonyCallback(subId); TelephonyManager telephonyManager = mContext.getSystemService( TelephonyManager.class).createForSubscriptionId(subId); telephonyManager.registerTelephonyCallback(mContext.getMainExecutor(), Loading Loading @@ -288,10 +276,6 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions } } } if (mDataContentObserverMap.containsKey(subId)) { mDataContentObserverMap.get(subId).unRegister(mContext); mDataContentObserverMap.remove(subId); } } public void removeRegister(MobileNetworkCallback mobileNetworkCallback) { Loading @@ -300,10 +284,6 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions mSubscriptionManager.removeOnSubscriptionsChangedListener(this); mAirplaneModeObserver.unRegister(mContext); mDataRoamingObserver.unRegister(mContext); mDataContentObserverMap.forEach((id, observer) -> { observer.unRegister(mContext); }); mDataContentObserverMap.clear(); mTelephonyManagerMap.forEach((id, manager) -> { TelephonyCallback callback = mTelephonyCallbackMap.get(id); Loading Loading @@ -764,7 +744,14 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions } private class PhoneCallStateTelephonyCallback extends TelephonyCallback implements TelephonyCallback.CallStateListener { TelephonyCallback.CallStateListener, TelephonyCallback.UserMobileDataStateListener { private int mSubId; public PhoneCallStateTelephonyCallback(int subId) { mSubId = subId; } @Override public void onCallStateChanged(int state) { Loading @@ -772,6 +759,15 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions callback.onCallStateChanged(state); } } @Override public void onUserMobileDataStateChanged(boolean enabled) { Log.d(TAG, "onUserMobileDataStateChanged enabled " + enabled + " on SUB " + mSubId); sExecutor.execute(() -> { insertMobileNetworkInfo(mContext, mSubId, getTelephonyManagerBySubId(mContext, mSubId)); }); } } /** Loading src/com/android/settings/network/telephony/DefaultSubscriptionController.java +0 −3 Original line number Diff line number Diff line Loading @@ -100,9 +100,6 @@ public abstract class DefaultSubscriptionController extends TelephonyBasePrefere mMobileNetworkRepository.addRegister(mLifecycleOwner, this, SubscriptionManager.INVALID_SUBSCRIPTION_ID); mMobileNetworkRepository.updateEntity(); // Can not get default subId from database until get the callback, add register by subId // later. mMobileNetworkRepository.addRegisterBySubId(getDefaultSubscriptionId()); mDataSubscriptionChangedReceiver.registerReceiver(); } Loading Loading
src/com/android/settings/network/MobileNetworkRepository.java +21 −25 Original line number Diff line number Diff line Loading @@ -91,7 +91,6 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions private AirplaneModeObserver mAirplaneModeObserver; private DataRoamingObserver mDataRoamingObserver; private MetricsFeatureProvider mMetricsFeatureProvider; private Map<Integer, MobileDataContentObserver> mDataContentObserverMap = new HashMap<>(); private int mPhysicalSlotIndex = SubscriptionManager.INVALID_SIM_SLOT_INDEX; private int mLogicalSlotIndex = SubscriptionManager.INVALID_SIM_SLOT_INDEX; private int mCardState = UiccSlotInfo.CARD_STATE_INFO_ABSENT; Loading Loading @@ -209,6 +208,9 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions */ public void addRegister(LifecycleOwner lifecycleOwner, MobileNetworkCallback mobileNetworkCallback, int subId) { if (DEBUG) { Log.d(TAG, "addRegister by SUB ID " + subId); } if (sCallbacks.isEmpty()) { mSubscriptionManager.addOnSubscriptionsChangedListener(mContext.getMainExecutor(), this); Loading @@ -222,7 +224,6 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions observeAllUiccInfo(lifecycleOwner); observeAllMobileNetworkInfo(lifecycleOwner); if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) { addRegisterBySubId(subId); createTelephonyManagerBySubId(subId); mDataRoamingObserver.register(mContext, subId); } Loading @@ -231,25 +232,12 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions sendAvailableSubInfoCache(mobileNetworkCallback); } public void addRegisterBySubId(int subId) { MobileDataContentObserver dataContentObserver = new MobileDataContentObserver( new Handler(Looper.getMainLooper())); dataContentObserver.setOnMobileDataChangedListener(() -> { sExecutor.execute(() -> { insertMobileNetworkInfo(mContext, subId, getTelephonyManagerBySubId(mContext, subId)); }); }); dataContentObserver.register(mContext, subId); mDataContentObserverMap.put(subId, dataContentObserver); } private void createTelephonyManagerBySubId(int subId) { if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { return; } PhoneCallStateTelephonyCallback telephonyCallback = new PhoneCallStateTelephonyCallback(); telephonyCallback = new PhoneCallStateTelephonyCallback(subId); TelephonyManager telephonyManager = mContext.getSystemService( TelephonyManager.class).createForSubscriptionId(subId); telephonyManager.registerTelephonyCallback(mContext.getMainExecutor(), Loading Loading @@ -288,10 +276,6 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions } } } if (mDataContentObserverMap.containsKey(subId)) { mDataContentObserverMap.get(subId).unRegister(mContext); mDataContentObserverMap.remove(subId); } } public void removeRegister(MobileNetworkCallback mobileNetworkCallback) { Loading @@ -300,10 +284,6 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions mSubscriptionManager.removeOnSubscriptionsChangedListener(this); mAirplaneModeObserver.unRegister(mContext); mDataRoamingObserver.unRegister(mContext); mDataContentObserverMap.forEach((id, observer) -> { observer.unRegister(mContext); }); mDataContentObserverMap.clear(); mTelephonyManagerMap.forEach((id, manager) -> { TelephonyCallback callback = mTelephonyCallbackMap.get(id); Loading Loading @@ -764,7 +744,14 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions } private class PhoneCallStateTelephonyCallback extends TelephonyCallback implements TelephonyCallback.CallStateListener { TelephonyCallback.CallStateListener, TelephonyCallback.UserMobileDataStateListener { private int mSubId; public PhoneCallStateTelephonyCallback(int subId) { mSubId = subId; } @Override public void onCallStateChanged(int state) { Loading @@ -772,6 +759,15 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions callback.onCallStateChanged(state); } } @Override public void onUserMobileDataStateChanged(boolean enabled) { Log.d(TAG, "onUserMobileDataStateChanged enabled " + enabled + " on SUB " + mSubId); sExecutor.execute(() -> { insertMobileNetworkInfo(mContext, mSubId, getTelephonyManagerBySubId(mContext, mSubId)); }); } } /** Loading
src/com/android/settings/network/telephony/DefaultSubscriptionController.java +0 −3 Original line number Diff line number Diff line Loading @@ -100,9 +100,6 @@ public abstract class DefaultSubscriptionController extends TelephonyBasePrefere mMobileNetworkRepository.addRegister(mLifecycleOwner, this, SubscriptionManager.INVALID_SUBSCRIPTION_ID); mMobileNetworkRepository.updateEntity(); // Can not get default subId from database until get the callback, add register by subId // later. mMobileNetworkRepository.addRegisterBySubId(getDefaultSubscriptionId()); mDataSubscriptionChangedReceiver.registerReceiver(); } Loading