Search in sources :

Example 6 with TelephonyDisplayInfo

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

Example 7 with TelephonyDisplayInfo

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);
}
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 8 with TelephonyDisplayInfo

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

Example 9 with TelephonyDisplayInfo

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

Example 10 with TelephonyDisplayInfo

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

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