Merge "Clear TelephonyManagerMap onStop" into udc-dev
This commit is contained in:
@@ -153,14 +153,16 @@ public class InternetDialogController implements AccessPointController.AccessPoi
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
/** Should be accessible only to the main thread. */
|
/** Should be accessible only to the main thread. */
|
||||||
final Map<Integer, TelephonyDisplayInfo> mSubIdTelephonyDisplayInfoMap = new HashMap<>();
|
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 WifiManager mWifiManager;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private SubscriptionManager mSubscriptionManager;
|
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 TelephonyManager mTelephonyManager;
|
||||||
private ConnectivityManager mConnectivityManager;
|
private ConnectivityManager mConnectivityManager;
|
||||||
private CarrierConfigTracker mCarrierConfigTracker;
|
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());
|
Log.e(TAG, "Unexpected null telephony call back for Sub " + tm.getSubscriptionId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mSubIdTelephonyManagerMap.clear();
|
||||||
|
mSubIdTelephonyCallbackMap.clear();
|
||||||
|
mSubIdTelephonyDisplayInfoMap.clear();
|
||||||
mSubscriptionManager.removeOnSubscriptionsChangedListener(
|
mSubscriptionManager.removeOnSubscriptionsChangedListener(
|
||||||
mOnSubscriptionsChangedListener);
|
mOnSubscriptionsChangedListener);
|
||||||
mAccessPointController.removeAccessPointCallback(this);
|
mAccessPointController.removeAccessPointCallback(this);
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import android.telephony.ServiceState;
|
|||||||
import android.telephony.SignalStrength;
|
import android.telephony.SignalStrength;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
|
import android.telephony.TelephonyCallback;
|
||||||
import android.telephony.TelephonyDisplayInfo;
|
import android.telephony.TelephonyDisplayInfo;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.testing.AndroidTestingRunner;
|
import android.testing.AndroidTestingRunner;
|
||||||
@@ -961,6 +962,26 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
assertThat(dds).contains(mContext.getString(R.string.carrier_network_change_mode));
|
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) {
|
private String getResourcesString(String name) {
|
||||||
return mContext.getResources().getString(getResourcesId(name));
|
return mContext.getResources().getString(getResourcesId(name));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user