use of android.telephony.TelephonyDisplayInfo in project android_frameworks_opt_telephony by LineageOS.
the class DcTrackerTest method testIsNrUnmeteredCarrierConfigs.
@Test
public void testIsNrUnmeteredCarrierConfigs() throws Exception {
initApns(PhoneConstants.APN_TYPE_DEFAULT, new String[] { PhoneConstants.APN_TYPE_ALL });
int id = setUpDataConnection();
setUpSubscriptionPlans(false);
setUpWatchdogTimer();
doReturn(new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA)).when(mDisplayInfoController).getTelephonyDisplayInfo();
setUpTempNotMetered();
// NetCapability should be metered when connected to 5G with no unmetered plan or frequency
mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_TELEPHONY_DISPLAY_INFO_CHANGED));
waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
verify(mDataConnection, times(1)).onMeterednessChanged(false);
// Set MMWAVE frequency to unmetered
mBundle.putBoolean(CarrierConfigManager.KEY_UNMETERED_NR_NSA_BOOL, true);
mBundle.putBoolean(CarrierConfigManager.KEY_UNMETERED_NR_NSA_MMWAVE_BOOL, true);
Intent intent = new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
intent.putExtra(CarrierConfigManager.EXTRA_SLOT_INDEX, mPhone.getPhoneId());
intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, mPhone.getSubId());
mContext.sendBroadcast(intent);
waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
// NetCapability should switch to unmetered when fr=MMWAVE and MMWAVE unmetered
doReturn(new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE)).when(mDisplayInfoController).getTelephonyDisplayInfo();
mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_TELEPHONY_DISPLAY_INFO_CHANGED));
waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
verify(mDataConnection, times(1)).onMeterednessChanged(true);
// NetCapability should switch to metered when fr=SUB6 and MMWAVE unmetered
doReturn(new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA)).when(mDisplayInfoController).getTelephonyDisplayInfo();
mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_TELEPHONY_DISPLAY_INFO_CHANGED));
waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
verify(mDataConnection, times(2)).onMeterednessChanged(false);
// Set SUB6 frequency to unmetered
doReturn(2).when(mPhone).getSubId();
mBundle.putBoolean(CarrierConfigManager.KEY_UNMETERED_NR_NSA_MMWAVE_BOOL, false);
mBundle.putBoolean(CarrierConfigManager.KEY_UNMETERED_NR_NSA_SUB6_BOOL, true);
intent = new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
intent.putExtra(CarrierConfigManager.EXTRA_SLOT_INDEX, mPhone.getPhoneId());
intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, mPhone.getSubId());
mContext.sendBroadcast(intent);
waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
// NetCapability should switch to unmetered when fr=SUB6 and SUB6 unmetered
mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_TELEPHONY_DISPLAY_INFO_CHANGED));
waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
// Data connection is running on a different thread. Have to wait.
waitForMs(200);
verify(mDataConnection, times(2)).onMeterednessChanged(true);
resetDataConnection(id);
resetSubscriptionPlans();
}
use of android.telephony.TelephonyDisplayInfo in project android_packages_apps_Settings by omnirom.
the class SubscriptionsPreferenceControllerTest method onTelephonyDisplayInfoChanged_providerAndHasMultiSimAndNotActive_showRat.
@Test
@UiThreadTest
public void onTelephonyDisplayInfoChanged_providerAndHasMultiSimAndNotActive_showRat() {
final CharSequence expectedSummary = Html.fromHtml("LTE", Html.FROM_HTML_MODE_LEGACY);
final String networkType = "LTE";
final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
final TelephonyDisplayInfo telephonyDisplayInfo = new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_UNKNOWN, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE);
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true, true, ServiceState.STATE_IN_SERVICE);
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
doReturn(networkType).when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
mController.onResume();
mController.displayPreference(mPreferenceScreen);
mController.onTelephonyDisplayInfoChanged(telephonyDisplayInfo);
assertThat(mPreferenceCategory.getPreference(0).getSummary()).isEqualTo(expectedSummary);
}
use of android.telephony.TelephonyDisplayInfo in project android_packages_apps_Settings by omnirom.
the class TelephonyDisplayInfoListener method updateSubscriptionIds.
/**
* Updates the set of ids we want to be listening for, beginning to listen for any new ids and
* stopping listening for any ids not contained in the new set
*/
public void updateSubscriptionIds(Set<Integer> ids) {
Set<Integer> currentIds = new ArraySet<>(mListeners.keySet());
for (int idToRemove : Sets.difference(currentIds, ids)) {
stopListening(idToRemove);
mListeners.remove(idToRemove);
}
for (int idToAdd : Sets.difference(ids, currentIds)) {
PhoneStateListener listener = new PhoneStateListener() {
@Override
public void onDisplayInfoChanged(TelephonyDisplayInfo telephonyDisplayInfo) {
mTelephonyDisplayInfo = telephonyDisplayInfo;
mCallback.onTelephonyDisplayInfoChanged(telephonyDisplayInfo);
}
};
mListeners.put(idToAdd, listener);
startListening(idToAdd);
}
}
use of android.telephony.TelephonyDisplayInfo in project android_packages_apps_Settings by omnirom.
the class NetworkProviderWorkerTest method onDisplayInfoChanged_notifyTelephonyCallback_callUpdateSlice.
@Test
@UiThreadTest
public void onDisplayInfoChanged_notifyTelephonyCallback_callUpdateSlice() {
mMockNetworkProviderWorker.onSlicePinned();
mMockNetworkProviderWorker.receiveNotification(false);
mMockNetworkProviderWorker.mTelephonyCallback.onDisplayInfoChanged(new TelephonyDisplayInfo(14, 0));
assertThat(mMockNetworkProviderWorker.hasNotification()).isTrue();
}
use of android.telephony.TelephonyDisplayInfo in project android_packages_apps_Settings by omnirom.
the class SubscriptionsPreferenceControllerTest method onTelephonyDisplayInfoChanged_providerAndHasMultiSimAndOutOfService_noConnection.
@Test
@UiThreadTest
public void onTelephonyDisplayInfoChanged_providerAndHasMultiSimAndOutOfService_noConnection() {
final String noConnectionSummary = ResourcesUtils.getResourcesString(mContext, "mobile_data_no_connection");
final CharSequence expectedSummary = Html.fromHtml(noConnectionSummary, Html.FROM_HTML_MODE_LEGACY);
final String networkType = "LTE";
final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
final TelephonyDisplayInfo telephonyDisplayInfo = new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_UNKNOWN, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE);
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true, false, ServiceState.STATE_OUT_OF_SERVICE);
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
doReturn(networkType).when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
mController.onResume();
mController.displayPreference(mPreferenceScreen);
mController.onTelephonyDisplayInfoChanged(telephonyDisplayInfo);
assertThat(mPreferenceCategory.getPreference(0).getSummary()).isEqualTo(expectedSummary);
}
Aggregations