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

Commit 974aa5ad authored by Evan Laird's avatar Evan Laird Committed by Android (Google) Code Review
Browse files

Merge changes Ibdaec230,I06d5e569,I5e2eb489,I116b5f63,I6fa7adaa into sc-v2-dev

* changes:
  Create QsInfo and SbInfo boxes for MobileSignalController
  Move some logic to MobileState
  Remove qsDataType since it was the same as dataType
  Remove isWide from MobileIconGroup
  Move callback anonymous classes out of constructor
parents 136f3aa2 1b3972d7
Loading
Loading
Loading
Loading
+99 −25
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
package com.android.settingslib;

import com.android.settingslib.mobile.TelephonyIcons;

import java.text.SimpleDateFormat;
import java.util.Objects;

@@ -40,9 +42,17 @@ public class SignalIcon {
        // For logging.
        public final String name;

        public IconGroup(String name, int[][] sbIcons, int[][] qsIcons, int[] contentDesc,
                int sbNullState, int qsNullState, int sbDiscState, int qsDiscState,
                int discContentDesc) {
        public IconGroup(
                String name,
                int[][] sbIcons,
                int[][] qsIcons,
                int[] contentDesc,
                int sbNullState,
                int qsNullState,
                int sbDiscState,
                int qsDiscState,
                int discContentDesc
        ) {
            this.name = name;
            this.sbIcons = sbIcons;
            this.qsIcons = qsIcons;
@@ -131,6 +141,19 @@ public class SignalIcon {
                    && other.activityOut == activityOut
                    && other.rssi == rssi;
        }

        @Override
        public int hashCode() {
            return Objects.hash(
                    connected,
                    enabled,
                    level,
                    inetCondition,
                    iconGroup,
                    activityIn,
                    activityOut,
                    rssi);
        }
    }

    /**
@@ -139,18 +162,31 @@ public class SignalIcon {
    public static class MobileIconGroup extends IconGroup {
        public final int dataContentDescription; // mContentDescriptionDataType
        public final int dataType;
        public final boolean isWide;
        public final int qsDataType;

        public MobileIconGroup(String name, int[][] sbIcons, int[][] qsIcons, int[] contentDesc,
                int sbNullState, int qsNullState, int sbDiscState, int qsDiscState,
                int discContentDesc, int dataContentDesc, int dataType, boolean isWide) {
            super(name, sbIcons, qsIcons, contentDesc, sbNullState, qsNullState, sbDiscState,
                qsDiscState, discContentDesc);

        public MobileIconGroup(
                String name,
                int[][] sbIcons,
                int[][] qsIcons,
                int[] contentDesc,
                int sbNullState,
                int qsNullState,
                int sbDiscState,
                int qsDiscState,
                int discContentDesc,
                int dataContentDesc,
                int dataType
        ) {
            super(name,
                    sbIcons,
                    qsIcons,
                    contentDesc,
                    sbNullState,
                    qsNullState,
                    sbDiscState,
                    qsDiscState,
                    discContentDesc);
            this.dataContentDescription = dataContentDesc;
            this.dataType = dataType;
            this.isWide = isWide;
            this.qsDataType = dataType; // TODO: remove this field
        }
    }

@@ -187,6 +223,27 @@ public class SignalIcon {
            defaultDataOff = state.defaultDataOff;
        }

        /** @return true if this state is disabled or not default data */
        public boolean isDataDisabledOrNotDefault() {
            return (iconGroup == TelephonyIcons.DATA_DISABLED
                    || (iconGroup == TelephonyIcons.NOT_DEFAULT_DATA)) && userSetup;
        }

        /** @return if this state is considered to have inbound activity */
        public boolean hasActivityIn() {
            return dataConnected && !carrierNetworkChangeMode && activityIn;
        }

        /** @return if this state is considered to have outbound activity */
        public boolean hasActivityOut() {
            return dataConnected && !carrierNetworkChangeMode && activityOut;
        }

        /** @return true if this state should show a RAT icon in quick settings */
        public boolean showQuickSettingsRatIcon() {
            return dataConnected || isDataDisabledOrNotDefault();
        }

        @Override
        protected void toString(StringBuilder builder) {
            super.toString(builder);
@@ -202,7 +259,8 @@ public class SignalIcon {
            builder.append("carrierNetworkChangeMode=").append(carrierNetworkChangeMode)
                    .append(',');
            builder.append("userSetup=").append(userSetup).append(',');
            builder.append("defaultDataOff=").append(defaultDataOff);
            builder.append("defaultDataOff=").append(defaultDataOff).append(',');
            builder.append("showQuickSettingsRatIcon=").append(showQuickSettingsRatIcon());
        }

        @Override
@@ -220,5 +278,21 @@ public class SignalIcon {
                    && ((MobileState) o).roaming == roaming
                    && ((MobileState) o).defaultDataOff == defaultDataOff;
        }

        @Override
        public int hashCode() {
            return Objects.hash(super.hashCode(),
                    networkName,
                    networkNameData,
                    dataSim,
                    dataConnected,
                    isEmergency,
                    airplaneMode,
                    carrierNetworkChangeMode,
                    userSetup,
                    isDefault,
                    roaming,
                    defaultDataOff);
        }
    }
}
+70 −52
Original line number Diff line number Diff line
@@ -50,178 +50,194 @@ public class TelephonyIcons {
            null,
            null,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
            0, 0,
            0,
            0,
            0,
            0,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
            R.string.carrier_network_change_mode,
            0,
            false);
            0
    );

    public static final MobileIconGroup THREE_G = new MobileIconGroup(
            "3G",
            null,
            null,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
            0, 0,
            0,
            0,
            0,
            0,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
            R.string.data_connection_3g,
            TelephonyIcons.ICON_3G,
            true);
            TelephonyIcons.ICON_3G
    );

    public static final MobileIconGroup WFC = new MobileIconGroup(
            "WFC",
            null,
            null,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
            0, 0,
            0,
            0,
            0,
            0,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
            0, 0, false);
            0,
            0);

    public static final MobileIconGroup UNKNOWN = new MobileIconGroup(
            "Unknown",
            null,
            null,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
            0, 0,
            0,
            0,
            0,
            0,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
            0, 0, false);
            0,
            0);

    public static final MobileIconGroup E = new MobileIconGroup(
            "E",
            null,
            null,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
            0, 0,
            0,
            0,
            0,
            0,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
            R.string.data_connection_edge,
            TelephonyIcons.ICON_E,
            false);
            TelephonyIcons.ICON_E
    );

    public static final MobileIconGroup ONE_X = new MobileIconGroup(
            "1X",
            null,
            null,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
            0, 0,
            0,
            0,
            0,
            0,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
            R.string.data_connection_cdma,
            TelephonyIcons.ICON_1X,
            true);
            TelephonyIcons.ICON_1X
    );

    public static final MobileIconGroup G = new MobileIconGroup(
            "G",
            null,
            null,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
            0, 0,
            0,
            0,
            0,
            0,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
            R.string.data_connection_gprs,
            TelephonyIcons.ICON_G,
            false);
            TelephonyIcons.ICON_G
    );

    public static final MobileIconGroup H = new MobileIconGroup(
            "H",
            null,
            null,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
            0, 0,
            0,
            0,
            0,
            0,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
            R.string.data_connection_3_5g,
            TelephonyIcons.ICON_H,
            false);
            TelephonyIcons.ICON_H
    );

    public static final MobileIconGroup H_PLUS = new MobileIconGroup(
            "H+",
            null,
            null,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
            0, 0,
            0,
            0,
            0,
            0,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
            R.string.data_connection_3_5g_plus,
            TelephonyIcons.ICON_H_PLUS,
            false);
            TelephonyIcons.ICON_H_PLUS
    );

    public static final MobileIconGroup FOUR_G = new MobileIconGroup(
            "4G",
            null,
            null,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
            0, 0,
            0,
            0,
            0,
            0,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
            R.string.data_connection_4g,
            TelephonyIcons.ICON_4G,
            true);
            TelephonyIcons.ICON_4G
    );

    public static final MobileIconGroup FOUR_G_PLUS = new MobileIconGroup(
            "4G+",
            null,
            null,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
            0, 0,
            0,
            0,
            0,
            0,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
            R.string.data_connection_4g_plus,
            TelephonyIcons.ICON_4G_PLUS,
            true);
            TelephonyIcons.ICON_4G_PLUS
    );

    public static final MobileIconGroup LTE = new MobileIconGroup(
            "LTE",
            null,
            null,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
            0, 0,
            0,
            0,
            0,
            0,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
            R.string.data_connection_lte,
            TelephonyIcons.ICON_LTE,
            true);
            TelephonyIcons.ICON_LTE
    );

    public static final MobileIconGroup LTE_PLUS = new MobileIconGroup(
            "LTE+",
            null,
            null,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
            0, 0,
            0,
            0,
            0,
            0,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
            R.string.data_connection_lte_plus,
            TelephonyIcons.ICON_LTE_PLUS,
            true);
            TelephonyIcons.ICON_LTE_PLUS
    );

    public static final MobileIconGroup LTE_CA_5G_E = new MobileIconGroup(
            "5Ge",
            null,
            null,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
            0, 0,
            0,
            0,
            0,
            0,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
            R.string.data_connection_5ge_html,
            TelephonyIcons.ICON_5G_E,
            true);
            TelephonyIcons.ICON_5G_E
    );

    public static final MobileIconGroup NR_5G = new MobileIconGroup(
            "5G",
@@ -234,8 +250,8 @@ public class TelephonyIcons {
            0,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
            R.string.data_connection_5g,
            TelephonyIcons.ICON_5G,
            true);
            TelephonyIcons.ICON_5G
    );

    public static final MobileIconGroup NR_5G_PLUS = new MobileIconGroup(
            "5G_PLUS",
@@ -248,34 +264,36 @@ public class TelephonyIcons {
            0,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
            R.string.data_connection_5g_plus,
            TelephonyIcons.ICON_5G_PLUS,
            true);
            TelephonyIcons.ICON_5G_PLUS
    );

    public static final MobileIconGroup DATA_DISABLED = new MobileIconGroup(
            "DataDisabled",
            null,
            null,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
            0, 0,
            0,
            0,
            0,
            0,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
            R.string.cell_data_off_content_description,
            0,
            false);
            0
    );

    public static final MobileIconGroup NOT_DEFAULT_DATA = new MobileIconGroup(
            "NotDefaultData",
            null,
            null,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
            0, 0,
            0,
            0,
            0,
            0,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
            R.string.not_default_data_content_description,
            0,
            false);
            0
    );

    public static final MobileIconGroup CARRIER_MERGED_WIFI = new MobileIconGroup(
            "CWF",
@@ -288,8 +306,8 @@ public class TelephonyIcons {
            /* qsDiscState= */ 0,
            AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
            R.string.data_connection_carrier_wifi,
            TelephonyIcons.ICON_CWF,
            /* isWide= */ true);
            TelephonyIcons.ICON_CWF
    );

    // When adding a new MobileIconGround, check if the dataContentDescription has to be filtered
    // in QSCarrier#hasValidTypeContentDescription
+133 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settingslib;

import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;

import com.android.settingslib.mobile.TelephonyIcons;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;

@RunWith(RobolectricTestRunner.class)
public class MobileStateTest {

    private SignalIcon.MobileState mState = new SignalIcon.MobileState();

    @Before
    public void setUp() {
    }

    @Test
    public void testIsDataDisabledOrNotDefault_dataDisabled() {
        mState.iconGroup = TelephonyIcons.DATA_DISABLED;
        mState.userSetup = true;

        assertTrue(mState.isDataDisabledOrNotDefault());
    }

    @Test
    public void testIsDataDisabledOrNotDefault_notDefaultData() {
        mState.iconGroup = TelephonyIcons.NOT_DEFAULT_DATA;
        mState.userSetup = true;

        assertTrue(mState.isDataDisabledOrNotDefault());
    }

    @Test
    public void testIsDataDisabledOrNotDefault_notDisabled() {
        mState.iconGroup = TelephonyIcons.G;
        mState.userSetup = true;

        assertFalse(mState.isDataDisabledOrNotDefault());
    }

    @Test
    public void testHasActivityIn_noData_noActivity() {
        mState.dataConnected = false;
        mState.carrierNetworkChangeMode = false;
        mState.activityIn = false;

        assertFalse(mState.hasActivityIn());
    }

    @Test
    public void testHasActivityIn_noData_activityIn() {
        mState.dataConnected = false;
        mState.carrierNetworkChangeMode = false;
        mState.activityIn = true;

        assertFalse(mState.hasActivityIn());
    }

    @Test
    public void testHasActivityIn_dataConnected_activityIn() {
        mState.dataConnected = true;
        mState.carrierNetworkChangeMode = false;
        mState.activityIn = true;

        assertTrue(mState.hasActivityIn());
    }

    @Test
    public void testHasActivityIn_carrierNetworkChange() {
        mState.dataConnected = true;
        mState.carrierNetworkChangeMode = true;
        mState.activityIn = true;

        assertFalse(mState.hasActivityIn());
    }

    @Test
    public void testHasActivityOut_noData_noActivity() {
        mState.dataConnected = false;
        mState.carrierNetworkChangeMode = false;
        mState.activityOut = false;

        assertFalse(mState.hasActivityOut());
    }

    @Test
    public void testHasActivityOut_noData_activityOut() {
        mState.dataConnected = false;
        mState.carrierNetworkChangeMode = false;
        mState.activityOut = true;

        assertFalse(mState.hasActivityOut());
    }

    @Test
    public void testHasActivityOut_dataConnected_activityOut() {
        mState.dataConnected = true;
        mState.carrierNetworkChangeMode = false;
        mState.activityOut = true;

        assertTrue(mState.hasActivityOut());
    }

    @Test
    public void testHasActivityOut_carrierNetworkChange() {
        mState.dataConnected = true;
        mState.carrierNetworkChangeMode = true;
        mState.activityOut = true;

        assertFalse(mState.hasActivityOut());
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -275,7 +275,7 @@ public class CellularTile extends QSTileImpl<SignalState> {
                return;
            }
            mInfo.dataSubscriptionName = mController.getMobileDataNetworkName();
            mInfo.dataContentDescription = indicators.description != null
            mInfo.dataContentDescription = indicators.qsDescription != null
                    ? indicators.typeContentDescriptionHtml : null;
            mInfo.activityIn = indicators.activityIn;
            mInfo.activityOut = indicators.activityOut;
+3 −3
Original line number Diff line number Diff line
@@ -279,9 +279,9 @@ public class InternetTile extends QSTileImpl<SignalState> {
                // Not data sim, don't display.
                return;
            }
            mCellularInfo.mDataSubscriptionName = indicators.description == null
                    ? mController.getMobileDataNetworkName() : indicators.description;
            mCellularInfo.mDataContentDescription = indicators.description != null
            mCellularInfo.mDataSubscriptionName = indicators.qsDescription == null
                    ? mController.getMobileDataNetworkName() : indicators.qsDescription;
            mCellularInfo.mDataContentDescription = indicators.qsDescription != null
                    ? indicators.typeContentDescriptionHtml : null;
            mCellularInfo.mMobileSignalIconId = indicators.qsIcon.icon;
            mCellularInfo.mQsTypeIcon = indicators.qsType;
Loading