Added correct TalkBack support for QSCarrier
Added new MobileIconGroup to TelephonyIcons for SIMs that are not set as default for mobile data. This group behaves identically to DATA_DISABLES except that is checked before it so we can assign it correctly. This addition was made for properly providing content description of carriers that are not set as default for data. Previously it said "Mobile Data Off" which could be misleading. Test: manual with 1 and 2 sims Test: atest NetworkControllerDataTest NetworkControllerSignalTest Bug: 123299825 Change-Id: Ia9e085b6296ff8df861e1e40bf8004b20b0d2c11
This commit is contained in:
@@ -24,7 +24,8 @@
|
||||
android:background="@android:color/transparent"
|
||||
android:clickable="false"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false" >
|
||||
android:clipToPadding="false"
|
||||
android:focusable="true" >
|
||||
|
||||
<include
|
||||
layout="@layout/mobile_signal_group"
|
||||
|
||||
@@ -34,7 +34,8 @@
|
||||
android:id="@+id/qs_carrier_divider1"
|
||||
android:layout_width="@dimen/qs_header_carrier_separator_width"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone" />
|
||||
android:visibility="gone"
|
||||
android:importantForAccessibility="no"/>
|
||||
|
||||
<include
|
||||
layout="@layout/qs_carrier"
|
||||
@@ -47,7 +48,8 @@
|
||||
android:layout_width="@dimen/qs_header_carrier_separator_width"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:visibility="gone" />
|
||||
android:visibility="gone"
|
||||
android:importantForAccessibility="no"/>
|
||||
|
||||
<include
|
||||
layout="@layout/qs_carrier"
|
||||
|
||||
@@ -445,6 +445,9 @@
|
||||
<!-- Content description of the cell data being disabled. [CHAR LIMIT=NONE] -->
|
||||
<string name="cell_data_off_content_description">Mobile data off</string>
|
||||
|
||||
<!-- Content description of the cell data for not default subscription. [CHAR LIMIT=NONE] -->
|
||||
<string name="not_default_data_content_description">Not set to use data</string>
|
||||
|
||||
<!-- Content description of the cell data being disabled but shortened. [CHAR LIMIT=20] -->
|
||||
<string name="cell_data_off">Off</string>
|
||||
|
||||
|
||||
@@ -89,16 +89,22 @@ public class QSCarrier extends LinearLayout {
|
||||
.append(", ");
|
||||
}
|
||||
// TODO: show mobile data off/no internet text for 5 seconds before carrier text
|
||||
if (TextUtils.equals(state.typeContentDescription,
|
||||
mContext.getString(R.string.data_connection_no_internet))
|
||||
|| TextUtils.equals(state.typeContentDescription,
|
||||
mContext.getString(R.string.cell_data_off_content_description))) {
|
||||
if (hasValidTypeContentDescription(state.typeContentDescription)) {
|
||||
contentDescription.append(state.typeContentDescription);
|
||||
}
|
||||
mMobileSignal.setContentDescription(contentDescription);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasValidTypeContentDescription(String typeContentDescription) {
|
||||
return TextUtils.equals(typeContentDescription,
|
||||
mContext.getString(R.string.data_connection_no_internet))
|
||||
|| TextUtils.equals(typeContentDescription,
|
||||
mContext.getString(R.string.cell_data_off_content_description))
|
||||
|| TextUtils.equals(typeContentDescription,
|
||||
mContext.getString(R.string.not_default_data_content_description));
|
||||
}
|
||||
|
||||
public void setCarrierText(CharSequence text) {
|
||||
mCarrierText.setText(text);
|
||||
}
|
||||
|
||||
@@ -256,7 +256,8 @@ public class MobileSignalController extends SignalController<
|
||||
level++;
|
||||
}
|
||||
boolean dataDisabled = mCurrentState.userSetup
|
||||
&& mCurrentState.iconGroup == TelephonyIcons.DATA_DISABLED;
|
||||
&& (mCurrentState.iconGroup == TelephonyIcons.DATA_DISABLED
|
||||
|| mCurrentState.iconGroup == TelephonyIcons.NOT_DEFAULT_DATA);
|
||||
boolean noInternet = mCurrentState.inetCondition == 0;
|
||||
boolean cutOut = dataDisabled || noInternet;
|
||||
return SignalDrawable.getState(level, getNumLevels(), cutOut);
|
||||
@@ -285,7 +286,8 @@ public class MobileSignalController extends SignalController<
|
||||
if (mCurrentState.inetCondition == 0) {
|
||||
dataContentDescription = mContext.getString(R.string.data_connection_no_internet);
|
||||
}
|
||||
final boolean dataDisabled = mCurrentState.iconGroup == TelephonyIcons.DATA_DISABLED
|
||||
final boolean dataDisabled = (mCurrentState.iconGroup == TelephonyIcons.DATA_DISABLED
|
||||
|| mCurrentState.iconGroup == TelephonyIcons.NOT_DEFAULT_DATA)
|
||||
&& mCurrentState.userSetup;
|
||||
|
||||
// Show icon in QS when we are connected or data is disabled.
|
||||
@@ -456,7 +458,12 @@ public class MobileSignalController extends SignalController<
|
||||
if (isCarrierNetworkChangeActive()) {
|
||||
mCurrentState.iconGroup = TelephonyIcons.CARRIER_NETWORK_CHANGE;
|
||||
} else if (isDataDisabled() && !mConfig.alwaysShowDataRatIcon) {
|
||||
mCurrentState.iconGroup = TelephonyIcons.DATA_DISABLED;
|
||||
if (mSubscriptionInfo.getSubscriptionId()
|
||||
!= mDefaults.getDefaultDataSubId()) {
|
||||
mCurrentState.iconGroup = TelephonyIcons.NOT_DEFAULT_DATA;
|
||||
} else {
|
||||
mCurrentState.iconGroup = TelephonyIcons.DATA_DISABLED;
|
||||
}
|
||||
}
|
||||
if (isEmergencyOnly() != mCurrentState.isEmergency) {
|
||||
mCurrentState.isEmergency = isEmergencyOnly();
|
||||
|
||||
@@ -987,6 +987,7 @@ public class NetworkControllerImpl extends BroadcastReceiver
|
||||
datatype.equals("lte") ? TelephonyIcons.LTE :
|
||||
datatype.equals("lte+") ? TelephonyIcons.LTE_PLUS :
|
||||
datatype.equals("dis") ? TelephonyIcons.DATA_DISABLED :
|
||||
datatype.equals("not") ? TelephonyIcons.NOT_DEFAULT_DATA :
|
||||
TelephonyIcons.UNKNOWN;
|
||||
}
|
||||
if (args.containsKey("roam")) {
|
||||
|
||||
@@ -245,6 +245,22 @@ class TelephonyIcons {
|
||||
0,
|
||||
false);
|
||||
|
||||
static final MobileIconGroup NOT_DEFAULT_DATA = new MobileIconGroup(
|
||||
"NotDefaultData",
|
||||
null,
|
||||
null,
|
||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
||||
0, 0,
|
||||
0,
|
||||
0,
|
||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
|
||||
R.string.not_default_data_content_description,
|
||||
0,
|
||||
false);
|
||||
|
||||
// When adding a new MobileIconGround, check if the dataContentDescription has to be filtered
|
||||
// in QSCarrier#hasValidTypeContentDescription
|
||||
|
||||
/** Mapping icon name(lower case) to the icon object. */
|
||||
static final Map<String, MobileIconGroup> ICON_NAME_TO_ICON;
|
||||
static {
|
||||
@@ -265,6 +281,7 @@ class TelephonyIcons {
|
||||
ICON_NAME_TO_ICON.put("5g", NR_5G);
|
||||
ICON_NAME_TO_ICON.put("5g_plus", NR_5G_PLUS);
|
||||
ICON_NAME_TO_ICON.put("datadisable", DATA_DISABLED);
|
||||
ICON_NAME_TO_ICON.put("notdefaultdata", NOT_DEFAULT_DATA);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,11 +45,13 @@ import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.testing.TestableLooper;
|
||||
import android.testing.TestableResources;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.telephony.cdma.EriInfo;
|
||||
import com.android.settingslib.graph.SignalDrawable;
|
||||
import com.android.settingslib.net.DataUsageController;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.statusbar.policy.DeviceProvisionedController.DeviceProvisionedListener;
|
||||
import com.android.systemui.statusbar.policy.NetworkController.IconState;
|
||||
@@ -76,6 +78,8 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
|
||||
protected static final int DEFAULT_QS_SIGNAL_STRENGTH = DEFAULT_LEVEL;
|
||||
protected static final int DEFAULT_ICON = TelephonyIcons.ICON_3G;
|
||||
protected static final int DEFAULT_QS_ICON = TelephonyIcons.ICON_3G;
|
||||
protected static final String NO_DATA_STRING = "Data disabled";
|
||||
protected static final String NOT_DEFAULT_DATA_STRING = "Not default data";
|
||||
|
||||
protected NetworkControllerImpl mNetworkController;
|
||||
protected MobileSignalController mMobileSignalController;
|
||||
@@ -113,6 +117,10 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), Global.AIRPLANE_MODE_ON, 0);
|
||||
TestableResources res = mContext.getOrCreateTestableResources();
|
||||
res.addOverride(R.string.cell_data_off_content_description, NO_DATA_STRING);
|
||||
res.addOverride(R.string.not_default_data_content_description, NOT_DEFAULT_DATA_STRING);
|
||||
|
||||
mMockWm = mock(WifiManager.class);
|
||||
mMockTm = mock(TelephonyManager.class);
|
||||
mMockSm = mock(SubscriptionManager.class);
|
||||
@@ -392,12 +400,21 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
|
||||
protected void verifyLastMobileDataIndicators(boolean visible, int icon, int typeIcon,
|
||||
boolean qsVisible, int qsIcon, int qsTypeIcon, boolean dataIn, boolean dataOut,
|
||||
boolean cutOut) {
|
||||
verifyLastMobileDataIndicators(
|
||||
visible, icon, typeIcon, qsVisible, qsIcon, qsTypeIcon, dataIn, dataOut, cutOut,
|
||||
null);
|
||||
}
|
||||
|
||||
protected void verifyLastMobileDataIndicators(boolean visible, int icon, int typeIcon,
|
||||
boolean qsVisible, int qsIcon, int qsTypeIcon, boolean dataIn, boolean dataOut,
|
||||
boolean cutOut, String typeContentDescription) {
|
||||
ArgumentCaptor<IconState> iconArg = ArgumentCaptor.forClass(IconState.class);
|
||||
ArgumentCaptor<Integer> typeIconArg = ArgumentCaptor.forClass(Integer.class);
|
||||
ArgumentCaptor<IconState> qsIconArg = ArgumentCaptor.forClass(IconState.class);
|
||||
ArgumentCaptor<Integer> qsTypeIconArg = ArgumentCaptor.forClass(Integer.class);
|
||||
ArgumentCaptor<Boolean> dataInArg = ArgumentCaptor.forClass(Boolean.class);
|
||||
ArgumentCaptor<Boolean> dataOutArg = ArgumentCaptor.forClass(Boolean.class);
|
||||
ArgumentCaptor<String> typeContentDescriptionArg = ArgumentCaptor.forClass(String.class);
|
||||
|
||||
Mockito.verify(mCallbackHandler, Mockito.atLeastOnce()).setMobileDataIndicators(
|
||||
iconArg.capture(),
|
||||
@@ -406,7 +423,8 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
|
||||
qsTypeIconArg.capture(),
|
||||
dataInArg.capture(),
|
||||
dataOutArg.capture(),
|
||||
anyString(), anyString(), anyBoolean(), anyInt(), anyBoolean());
|
||||
typeContentDescriptionArg.capture(),
|
||||
anyString(), anyBoolean(), anyInt(), anyBoolean());
|
||||
|
||||
IconState iconState = iconArg.getValue();
|
||||
|
||||
@@ -424,6 +442,10 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
|
||||
(boolean) dataInArg.getValue());
|
||||
assertEquals("Data direction out in quick settings", dataOut,
|
||||
(boolean) dataOutArg.getValue());
|
||||
if (typeContentDescription != null) { // Only check if it was provided
|
||||
assertEquals("Type content description", typeContentDescription,
|
||||
typeContentDescriptionArg.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
protected void assertNetworkNameEquals(String expected) {
|
||||
|
||||
@@ -117,7 +117,7 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoInternetIcon() {
|
||||
public void testNoInternetIcon_withDefaultSub() {
|
||||
setupNetworkController();
|
||||
when(mMockTm.getDataEnabled(mSubId)).thenReturn(false);
|
||||
setupDefaultSignal();
|
||||
@@ -127,11 +127,11 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest {
|
||||
// Verify that a SignalDrawable with a cut out is used to display data disabled.
|
||||
verifyLastMobileDataIndicators(true, DEFAULT_SIGNAL_STRENGTH, 0,
|
||||
true, DEFAULT_QS_SIGNAL_STRENGTH, 0, false,
|
||||
false, true);
|
||||
false, true, NO_DATA_STRING);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDataDisabledIcon() {
|
||||
public void testDataDisabledIcon_withDefaultSub() {
|
||||
setupNetworkController();
|
||||
when(mMockTm.getDataEnabled(mSubId)).thenReturn(false);
|
||||
setupDefaultSignal();
|
||||
@@ -141,7 +141,37 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest {
|
||||
// Verify that a SignalDrawable with a cut out is used to display data disabled.
|
||||
verifyLastMobileDataIndicators(true, DEFAULT_SIGNAL_STRENGTH, 0,
|
||||
true, DEFAULT_QS_SIGNAL_STRENGTH, 0, false,
|
||||
false, true);
|
||||
false, true, NO_DATA_STRING);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoInternetIcon_withoutDefaultSub() {
|
||||
setupNetworkController();
|
||||
when(mMockTm.getDataEnabled(mSubId)).thenReturn(false);
|
||||
setupDefaultSignal();
|
||||
setDefaultSubId(mSubId + 1);
|
||||
updateDataConnectionState(TelephonyManager.DATA_CONNECTED, 0);
|
||||
setConnectivityViaBroadcast(NetworkCapabilities.TRANSPORT_CELLULAR, false, false);
|
||||
|
||||
// Verify that a SignalDrawable with a cut out is used to display data disabled.
|
||||
verifyLastMobileDataIndicators(true, DEFAULT_SIGNAL_STRENGTH, 0,
|
||||
true, DEFAULT_QS_SIGNAL_STRENGTH, 0, false,
|
||||
false, true, NOT_DEFAULT_DATA_STRING);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDataDisabledIcon_withoutDefaultSub() {
|
||||
setupNetworkController();
|
||||
when(mMockTm.getDataEnabled(mSubId)).thenReturn(false);
|
||||
setupDefaultSignal();
|
||||
setDefaultSubId(mSubId + 1);
|
||||
updateDataConnectionState(TelephonyManager.DATA_DISCONNECTED, 0);
|
||||
setConnectivityViaBroadcast(NetworkCapabilities.TRANSPORT_CELLULAR, false, false);
|
||||
|
||||
// Verify that a SignalDrawable with a cut out is used to display data disabled.
|
||||
verifyLastMobileDataIndicators(true, DEFAULT_SIGNAL_STRENGTH, 0,
|
||||
true, DEFAULT_QS_SIGNAL_STRENGTH, 0, false,
|
||||
false, true, NOT_DEFAULT_DATA_STRING);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user