use of android.telephony.TelephonyDisplayInfo in project robolectric by robolectric.
the class ShadowTelephonyManagerTest method setTelephonyDisplayInfo_notifiesListeners.
@Test
@Config(minSdk = R)
public void setTelephonyDisplayInfo_notifiesListeners() {
PhoneStateListener listener = mock(PhoneStateListener.class);
TelephonyDisplayInfo displayInfo = (TelephonyDisplayInfo) createTelephonyDisplayInfo(NETWORK_TYPE_LTE, OVERRIDE_NETWORK_TYPE_NR_NSA);
telephonyManager.listen(listener, LISTEN_DISPLAY_INFO_CHANGED);
shadowTelephonyManager.setTelephonyDisplayInfo(displayInfo);
verify(listener, times(1)).onDisplayInfoChanged(displayInfo);
}
use of android.telephony.TelephonyDisplayInfo in project robolectric by robolectric.
the class ShadowTelephonyManagerTest method createTelephonyDisplayInfo_correctlyCreatesDisplayInfo.
@Test
@Config(minSdk = R)
public void createTelephonyDisplayInfo_correctlyCreatesDisplayInfo() {
TelephonyDisplayInfo displayInfo = (TelephonyDisplayInfo) createTelephonyDisplayInfo(NETWORK_TYPE_LTE, OVERRIDE_NETWORK_TYPE_LTE_CA);
assertThat(displayInfo.getNetworkType()).isEqualTo(NETWORK_TYPE_LTE);
assertThat(displayInfo.getOverrideNetworkType()).isEqualTo(OVERRIDE_NETWORK_TYPE_LTE_CA);
}
use of android.telephony.TelephonyDisplayInfo in project robolectric by robolectric.
the class ShadowTelephonyManagerTest method listen_notifiesListenerOfCurrentTelephonyDisplayInfoIfInitialized.
@Test
@Config(minSdk = R)
public void listen_notifiesListenerOfCurrentTelephonyDisplayInfoIfInitialized() {
PhoneStateListener listener = mock(PhoneStateListener.class);
TelephonyDisplayInfo displayInfo = (TelephonyDisplayInfo) createTelephonyDisplayInfo(NETWORK_TYPE_EVDO_0, OVERRIDE_NETWORK_TYPE_NONE);
shadowTelephonyManager.setTelephonyDisplayInfo(displayInfo);
telephonyManager.listen(listener, LISTEN_DISPLAY_INFO_CHANGED);
verify(listener, times(1)).onDisplayInfoChanged(displayInfo);
}
use of android.telephony.TelephonyDisplayInfo in project android_frameworks_opt_telephony by LineageOS.
the class DcTrackerTest method testIsNrUnmeteredSubscriptionPlans.
@Test
public void testIsNrUnmeteredSubscriptionPlans() 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 SubscriptionPlans unmetered
setUpSubscriptionPlans(true);
// NetCapability should switch to unmetered with an unmetered plan
mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_TELEPHONY_DISPLAY_INFO_CHANGED));
waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
verify(mDataConnection, times(1)).onMeterednessChanged(true);
// Set MMWAVE frequency to unmetered
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 metered without fr=MMWAVE
mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_TELEPHONY_DISPLAY_INFO_CHANGED));
waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
verify(mDataConnection, times(2)).onMeterednessChanged(false);
// NetCapability should switch to unmetered with fr=MMWAVE
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(2)).onMeterednessChanged(true);
resetDataConnection(id);
resetSubscriptionPlans();
}
use of android.telephony.TelephonyDisplayInfo in project android_frameworks_opt_telephony by LineageOS.
the class DcTrackerTest method testReevaluateUnmeteredConnectionsOnNetworkChange.
@Test
public void testReevaluateUnmeteredConnectionsOnNetworkChange() throws Exception {
initApns(PhoneConstants.APN_TYPE_DEFAULT, new String[] { PhoneConstants.APN_TYPE_ALL });
int id = setUpDataConnection();
setUpSubscriptionPlans(true);
setUpWatchdogTimer();
setUpTempNotMetered();
// NetCapability should be unmetered when connected to 5G
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(1)).onMeterednessChanged(true);
// NetCapability should be metered when disconnected from 5G
doReturn(new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE)).when(mDisplayInfoController).getTelephonyDisplayInfo();
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(1)).onMeterednessChanged(false);
resetDataConnection(id);
resetSubscriptionPlans();
}
Aggregations