Search in sources :

Example 11 with TelephonyDisplayInfo

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);
}
Also used : TelephonyDisplayInfo(android.telephony.TelephonyDisplayInfo) SubscriptionInfo(android.telephony.SubscriptionInfo) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 12 with TelephonyDisplayInfo

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;
}
Also used : TelephonyDisplayInfo(android.telephony.TelephonyDisplayInfo) NetworkRegistrationInfo(android.telephony.NetworkRegistrationInfo)

Example 13 with TelephonyDisplayInfo

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);
}
Also used : TelephonyDisplayInfo(android.telephony.TelephonyDisplayInfo) Intent(android.content.Intent) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test)

Example 14 with TelephonyDisplayInfo

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);
    }
}
Also used : TelephonyDisplayInfo(android.telephony.TelephonyDisplayInfo)

Example 15 with TelephonyDisplayInfo

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();
}
Also used : TelephonyDisplayInfo(android.telephony.TelephonyDisplayInfo) FlakyTest(androidx.test.filters.FlakyTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) MediumTest(android.test.suitebuilder.annotation.MediumTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test)

Aggregations

TelephonyDisplayInfo (android.telephony.TelephonyDisplayInfo)15 Test (org.junit.Test)12 SmallTest (android.test.suitebuilder.annotation.SmallTest)5 MediumTest (android.test.suitebuilder.annotation.MediumTest)4 UiThreadTest (androidx.test.annotation.UiThreadTest)4 FlakyTest (androidx.test.filters.FlakyTest)4 TelephonyTest (com.android.internal.telephony.TelephonyTest)4 Intent (android.content.Intent)3 PhoneStateListener (android.telephony.PhoneStateListener)3 SubscriptionInfo (android.telephony.SubscriptionInfo)3 Config (org.robolectric.annotation.Config)3 ShadowTelephonyManager.createTelephonyDisplayInfo (org.robolectric.shadows.ShadowTelephonyManager.createTelephonyDisplayInfo)3 PendingIntent (android.app.PendingIntent)2 NetworkRegistrationInfo (android.telephony.NetworkRegistrationInfo)1 ArraySet (android.util.ArraySet)1