use of android.telephony.TelephonyDisplayInfo in project android_packages_apps_Settings by omnirom.
the class SubscriptionsPreferenceControllerTest method onTelephonyDisplayInfoChanged_providerAndHasMultiSimAndActive_connectedAndRat.
@Test
@UiThreadTest
public void onTelephonyDisplayInfoChanged_providerAndHasMultiSimAndActive_connectedAndRat() {
final CharSequence expectedSummary = Html.fromHtml("Connected / 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(), true, 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));
when(mTelephonyManager.isDataEnabled()).thenReturn(true);
mController.onResume();
mController.displayPreference(mPreferenceScreen);
mController.onTelephonyDisplayInfoChanged(telephonyDisplayInfo);
assertThat(mPreferenceCategory.getPreference(0).getSummary()).isEqualTo(expectedSummary);
}
use of android.telephony.TelephonyDisplayInfo in project android_frameworks_opt_telephony by LineageOS.
the class DcTracker method isCampedOn5G.
// TODO: Remove this after b/176119724 is fixed. This is just a workaround to prevent
// NET_CAPABILITY_TEMPORARILY_NOT_METERED incorrectly set on devices that are not supposed
// to use 5G unmetered network. Currently TEMPORARILY_NOT_METERED can only happen on few devices
// and carriers.
private boolean isCampedOn5G() {
TelephonyDisplayInfo displayInfo = mPhone.getDisplayInfoController().getTelephonyDisplayInfo();
int overrideNetworkType = displayInfo.getOverrideNetworkType();
NetworkRegistrationInfo nri = mPhone.getServiceState().getNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
int networkType = nri == null ? TelephonyManager.NETWORK_TYPE_UNKNOWN : nri.getAccessNetworkTechnology();
boolean isNrSa = networkType == TelephonyManager.NETWORK_TYPE_NR;
boolean isNrNsa = (networkType == TelephonyManager.NETWORK_TYPE_LTE || networkType == TelephonyManager.NETWORK_TYPE_LTE_CA) && (overrideNetworkType == TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA || overrideNetworkType == TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE);
boolean is5GHysteresisActive = mPhone.getDisplayInfoController().is5GHysteresisActive();
// True if device is on NR SA or NR NSA, or neither but 5G hysteresis is active
return isNrSa || isNrNsa || is5GHysteresisActive;
}
use of android.telephony.TelephonyDisplayInfo in project android_frameworks_opt_telephony by LineageOS.
the class TelephonyRegistryTest method testNotifyDisplayInfoChanged.
@Test
public void testNotifyDisplayInfoChanged() {
mContext.sendBroadcast(new Intent(ACTION_DEFAULT_SUBSCRIPTION_CHANGED).putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, 12).putExtra(SubscriptionManager.EXTRA_SLOT_INDEX, 0));
processAllMessages();
mTelephonyRegistry.listenForSubscriber(2, mContext.getOpPackageName(), mContext.getAttributionTag(), mPhoneStateListener.callback, PhoneStateListener.LISTEN_DISPLAY_INFO_CHANGED, false);
// Notify with invalid subId on default phone. Should NOT trigger callback.
TelephonyDisplayInfo displayInfo = new TelephonyDisplayInfo(0, 0);
mTelephonyRegistry.notifyDisplayInfoChanged(0, INVALID_SUBSCRIPTION_ID, displayInfo);
processAllMessages();
assertEquals(null, mTelephonyDisplayInfo);
// Notify with the matching subId on default phone. Should trigger callback.
mTelephonyRegistry.notifyDisplayInfoChanged(0, 2, displayInfo);
processAllMessages();
assertEquals(displayInfo, mTelephonyDisplayInfo);
}
use of android.telephony.TelephonyDisplayInfo in project android_frameworks_opt_telephony by LineageOS.
the class DisplayInfoController method updateTelephonyDisplayInfo.
/**
* Update TelephonyDisplayInfo based on network type and override network type, received from
* NetworkTypeController.
*/
public void updateTelephonyDisplayInfo() {
TelephonyDisplayInfo newDisplayInfo = new TelephonyDisplayInfo(mPhone.getServiceState().getDataNetworkType(), mNetworkTypeController.getOverrideNetworkType());
if (!newDisplayInfo.equals(mTelephonyDisplayInfo)) {
Rlog.d(TAG, "TelephonyDisplayInfo[" + mPhone.getPhoneId() + "] changed from " + mTelephonyDisplayInfo + " to " + newDisplayInfo);
mTelephonyDisplayInfo = newDisplayInfo;
mTelephonyDisplayInfoChangedRegistrants.notifyRegistrants();
mPhone.notifyDisplayInfoChanged(mTelephonyDisplayInfo);
}
}
use of android.telephony.TelephonyDisplayInfo in project android_frameworks_opt_telephony by LineageOS.
the class DcTrackerTest method testReevaluateUnmeteredConnectionsOnWatchdog.
@Test
public void testReevaluateUnmeteredConnectionsOnWatchdog() throws Exception {
initApns(PhoneConstants.APN_TYPE_DEFAULT, new String[] { PhoneConstants.APN_TYPE_ALL });
int id = setUpDataConnection();
setUpSubscriptionPlans(true);
setUpWatchdogTimer();
// Watchdog inactive when unmetered and not connected to 5G
doReturn(new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE)).when(mDisplayInfoController).getTelephonyDisplayInfo();
mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_NR_TIMER_WATCHDOG));
waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
assertFalse(getWatchdogStatus());
// Watchdog active when unmetered and 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());
assertTrue(getWatchdogStatus());
// Watchdog inactive when metered
setUpSubscriptionPlans(false);
mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_TELEPHONY_DISPLAY_INFO_CHANGED));
waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
assertFalse(getWatchdogStatus());
resetDataConnection(id);
resetSubscriptionPlans();
}
Aggregations