Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bfc0a8de authored by SongFerng Wang's avatar SongFerng Wang Committed by android-build-merger
Browse files

Merge "Extends carrier config KEY_5G_ICON_CONFIGURATION_STRING to support more...

Merge "Extends carrier config KEY_5G_ICON_CONFIGURATION_STRING to support more scenarios." into qt-qpr1-dev
am: 052a08bc

Change-Id: I48b5d230015a4d61556fda1f4bd65681136c12d7
parents b6d51f11 052a08bc
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -537,8 +537,14 @@ public class MobileSignalController extends SignalController<
                return mConfig.nr5GIconMap.get(Config.NR_CONNECTED);
            }
        } else if (nrState == NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED) {
            if (mConfig.nr5GIconMap.containsKey(Config.NR_NOT_RESTRICTED)) {
                return mConfig.nr5GIconMap.get(Config.NR_NOT_RESTRICTED);
            if (mCurrentState.activityDormant) {
                if (mConfig.nr5GIconMap.containsKey(Config.NR_NOT_RESTRICTED_RRC_IDLE)) {
                    return mConfig.nr5GIconMap.get(Config.NR_NOT_RESTRICTED_RRC_IDLE);
                }
            } else {
                if (mConfig.nr5GIconMap.containsKey(Config.NR_NOT_RESTRICTED_RRC_CON)) {
                    return mConfig.nr5GIconMap.get(Config.NR_NOT_RESTRICTED_RRC_CON);
                }
            }
        } else if (nrState == NetworkRegistrationInfo.NR_STATE_RESTRICTED) {
            if (mConfig.nr5GIconMap.containsKey(Config.NR_RESTRICTED)) {
@@ -559,6 +565,8 @@ public class MobileSignalController extends SignalController<
                || activity == TelephonyManager.DATA_ACTIVITY_IN;
        mCurrentState.activityOut = activity == TelephonyManager.DATA_ACTIVITY_INOUT
                || activity == TelephonyManager.DATA_ACTIVITY_OUT;
        mCurrentState.activityDormant = activity == TelephonyManager.DATA_ACTIVITY_DORMANT;

        notifyListenersIfNecessary();
    }

+6 −4
Original line number Diff line number Diff line
@@ -1108,8 +1108,9 @@ public class NetworkControllerImpl extends BroadcastReceiver
    static class Config {
        static final int NR_CONNECTED_MMWAVE = 1;
        static final int NR_CONNECTED = 2;
        static final int NR_NOT_RESTRICTED = 3;
        static final int NR_RESTRICTED = 4;
        static final int NR_NOT_RESTRICTED_RRC_IDLE = 3;
        static final int NR_NOT_RESTRICTED_RRC_CON = 4;
        static final int NR_RESTRICTED = 5;

        Map<Integer, MobileIconGroup> nr5GIconMap = new HashMap<>();

@@ -1129,10 +1130,11 @@ public class NetworkControllerImpl extends BroadcastReceiver
         */
        private static final Map<String, Integer> NR_STATUS_STRING_TO_INDEX;
        static {
            NR_STATUS_STRING_TO_INDEX = new HashMap<>(4);
            NR_STATUS_STRING_TO_INDEX = new HashMap<>(5);
            NR_STATUS_STRING_TO_INDEX.put("connected_mmwave", NR_CONNECTED_MMWAVE);
            NR_STATUS_STRING_TO_INDEX.put("connected", NR_CONNECTED);
            NR_STATUS_STRING_TO_INDEX.put("not_restricted", NR_NOT_RESTRICTED);
            NR_STATUS_STRING_TO_INDEX.put("not_restricted_rrc_idle", NR_NOT_RESTRICTED_RRC_IDLE);
            NR_STATUS_STRING_TO_INDEX.put("not_restricted_rrc_con", NR_NOT_RESTRICTED_RRC_CON);
            NR_STATUS_STRING_TO_INDEX.put("restricted", NR_RESTRICTED);
        }

+4 −0
Original line number Diff line number Diff line
@@ -258,6 +258,7 @@ public abstract class SignalController<T extends SignalController.State,
        boolean enabled;
        boolean activityIn;
        boolean activityOut;
        public boolean activityDormant;
        int level;
        IconGroup iconGroup;
        int inetCondition;
@@ -274,6 +275,7 @@ public abstract class SignalController<T extends SignalController.State,
            inetCondition = state.inetCondition;
            activityIn = state.activityIn;
            activityOut = state.activityOut;
            activityDormant = state.activityDormant;
            rssi = state.rssi;
            time = state.time;
        }
@@ -297,6 +299,7 @@ public abstract class SignalController<T extends SignalController.State,
                    .append("iconGroup=").append(iconGroup).append(',')
                    .append("activityIn=").append(activityIn).append(',')
                    .append("activityOut=").append(activityOut).append(',')
                    .append("activityDormant=").append(activityDormant).append(',')
                    .append("rssi=").append(rssi).append(',')
                    .append("lastModified=").append(DateFormat.format("MM-dd HH:mm:ss", time));
        }
@@ -314,6 +317,7 @@ public abstract class SignalController<T extends SignalController.State,
                    && other.iconGroup == iconGroup
                    && other.activityIn == activityIn
                    && other.activityOut == activityOut
                    && other.activityDormant == activityDormant
                    && other.rssi == rssi;
        }
    }
+12 −0
Original line number Diff line number Diff line
@@ -228,6 +228,18 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
        NetworkControllerImpl.Config.add5GIconMapping("connected:5g", mConfig);
    }

    public void setupNr5GIconConfigurationForNotRestrictedRrcCon() {
        NetworkControllerImpl.Config.add5GIconMapping("connected_mmwave:5g_plus", mConfig);
        NetworkControllerImpl.Config.add5GIconMapping("connected:5g_plus", mConfig);
        NetworkControllerImpl.Config.add5GIconMapping("not_restricted_rrc_con:5g", mConfig);
    }

    public void setupNr5GIconConfigurationForNotRestrictedRrcIdle() {
        NetworkControllerImpl.Config.add5GIconMapping("connected_mmwave:5g_plus", mConfig);
        NetworkControllerImpl.Config.add5GIconMapping("connected:5g_plus", mConfig);
        NetworkControllerImpl.Config.add5GIconMapping("not_restricted_rrc_idle:5g", mConfig);
    }

    public void setConnectivityViaBroadcast(
        int networkType, boolean validated, boolean isConnected) {
        setConnectivityCommon(networkType, validated, isConnected);
+29 −0
Original line number Diff line number Diff line
@@ -174,6 +174,35 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest {
                false, true, NOT_DEFAULT_DATA_STRING);
    }

    @Test
    public void testNr5GIcon_NrNotRestrictedRrcCon_show5GIcon() {
        setupNr5GIconConfigurationForNotRestrictedRrcCon();
        setupDefaultSignal();
        updateDataConnectionState(TelephonyManager.DATA_CONNECTED,
                TelephonyManager.NETWORK_TYPE_LTE);
        updateDataActivity(TelephonyManager.DATA_ACTIVITY_INOUT);
        ServiceState ss = Mockito.mock(ServiceState.class);
        doReturn(NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED).when(ss).getNrState();
        mPhoneStateListener.onServiceStateChanged(ss);

        verifyLastMobileDataIndicators(true, DEFAULT_SIGNAL_STRENGTH, TelephonyIcons.ICON_5G,
                true, DEFAULT_QS_SIGNAL_STRENGTH, TelephonyIcons.ICON_5G, true, true);
    }

    @Test
    public void testNr5GIcon_NrNotRestrictedRrcIdle_show5GIcon() {
        setupNr5GIconConfigurationForNotRestrictedRrcIdle();
        setupDefaultSignal();
        updateDataConnectionState(TelephonyManager.DATA_CONNECTED,
                TelephonyManager.NETWORK_TYPE_LTE);
        updateDataActivity(TelephonyManager.DATA_ACTIVITY_DORMANT);
        ServiceState ss = Mockito.mock(ServiceState.class);
        doReturn(NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED).when(ss).getNrState();
        mPhoneStateListener.onServiceStateChanged(ss);

        verifyDataIndicators(TelephonyIcons.ICON_5G);
    }

    @Test
    public void testNr5GIcon_NrConnectedWithoutMMWave_show5GIcon() {
        setupDefaultNr5GIconConfiguration();
Loading