Clear TelephonyManagerMap onStop
The change clears all telephony manager related maps onStop, in order for future callbacks/information to be registered properly. Fix: 281529123 Test: manual reproduce and verify fix Test: test task b/281884811 Test: included in daily validation test Change-Id: Ie6e4ec7d5a03920dc07ff9e0300d3399181a602a
This commit is contained in:
@@ -153,14 +153,16 @@ public class InternetDialogController implements AccessPointController.AccessPoi
|
||||
@VisibleForTesting
|
||||
/** Should be accessible only to the main thread. */
|
||||
final Map<Integer, TelephonyDisplayInfo> mSubIdTelephonyDisplayInfoMap = new HashMap<>();
|
||||
@VisibleForTesting
|
||||
/** Should be accessible only to the main thread. */
|
||||
final Map<Integer, TelephonyManager> mSubIdTelephonyManagerMap = new HashMap<>();
|
||||
@VisibleForTesting
|
||||
/** Should be accessible only to the main thread. */
|
||||
final Map<Integer, TelephonyCallback> mSubIdTelephonyCallbackMap = new HashMap<>();
|
||||
|
||||
private WifiManager mWifiManager;
|
||||
private Context mContext;
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
/** Should be accessible only to the main thread. */
|
||||
private Map<Integer, TelephonyManager> mSubIdTelephonyManagerMap = new HashMap<>();
|
||||
/** Should be accessible only to the main thread. */
|
||||
private Map<Integer, TelephonyCallback> mSubIdTelephonyCallbackMap = new HashMap<>();
|
||||
private TelephonyManager mTelephonyManager;
|
||||
private ConnectivityManager mConnectivityManager;
|
||||
private CarrierConfigTracker mCarrierConfigTracker;
|
||||
@@ -320,6 +322,9 @@ public class InternetDialogController implements AccessPointController.AccessPoi
|
||||
Log.e(TAG, "Unexpected null telephony call back for Sub " + tm.getSubscriptionId());
|
||||
}
|
||||
}
|
||||
mSubIdTelephonyManagerMap.clear();
|
||||
mSubIdTelephonyCallbackMap.clear();
|
||||
mSubIdTelephonyDisplayInfoMap.clear();
|
||||
mSubscriptionManager.removeOnSubscriptionsChangedListener(
|
||||
mOnSubscriptionsChangedListener);
|
||||
mAccessPointController.removeAccessPointCallback(this);
|
||||
|
||||
@@ -43,6 +43,7 @@ import android.telephony.ServiceState;
|
||||
import android.telephony.SignalStrength;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyCallback;
|
||||
import android.telephony.TelephonyDisplayInfo;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
@@ -961,6 +962,26 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
||||
assertThat(dds).contains(mContext.getString(R.string.carrier_network_change_mode));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onStop_cleanUp() {
|
||||
doReturn(SUB_ID).when(mTelephonyManager).getSubscriptionId();
|
||||
assertThat(mInternetDialogController.mSubIdTelephonyManagerMap.get(SUB_ID)).isEqualTo(
|
||||
mTelephonyManager);
|
||||
assertThat(mInternetDialogController.mSubIdTelephonyCallbackMap.get(SUB_ID)).isNotNull();
|
||||
|
||||
mInternetDialogController.onStop();
|
||||
|
||||
verify(mTelephonyManager).unregisterTelephonyCallback(any(TelephonyCallback.class));
|
||||
assertThat(mInternetDialogController.mSubIdTelephonyDisplayInfoMap.isEmpty()).isTrue();
|
||||
assertThat(mInternetDialogController.mSubIdTelephonyManagerMap.isEmpty()).isTrue();
|
||||
assertThat(mInternetDialogController.mSubIdTelephonyCallbackMap.isEmpty()).isTrue();
|
||||
verify(mSubscriptionManager).removeOnSubscriptionsChangedListener(mInternetDialogController
|
||||
.mOnSubscriptionsChangedListener);
|
||||
verify(mAccessPointController).removeAccessPointCallback(mInternetDialogController);
|
||||
verify(mConnectivityManager).unregisterNetworkCallback(
|
||||
any(ConnectivityManager.NetworkCallback.class));
|
||||
}
|
||||
|
||||
private String getResourcesString(String name) {
|
||||
return mContext.getResources().getString(getResourcesId(name));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user