Extract the SysUI Icons and Strings

Bug: 174582703
Test: Manual tests
Change-Id: I41f7043dc24ae9d091ae6a29d3be2d2ca3801b72
This commit is contained in:
yinxu
2020-12-04 19:07:23 -08:00
parent 1d548b6df8
commit 865f44be76
34 changed files with 601 additions and 501 deletions

View File

@@ -21,4 +21,11 @@
<!-- Threshold in micro watts above which a charger is rated as "fast"; 1.5A @ 5V -->
<integer name="config_chargingFastThreshold">7500000</integer>
<!-- When true, show 1/2G networks as 3G. -->
<bool name="config_showMin3G">false</bool>
<!-- Control whether status bar should distinguish HSPA data icon form UMTS
data icon on devices -->
<bool name="config_hspa_data_distinguishable">false</bool>
</resources>

View File

@@ -1404,4 +1404,79 @@
<string name="wifi_hotspot_switch_on_text">On</string>
<!-- Label for Wifi hotspot switch off. Toggles hotspot off [CHAR LIMIT=30] -->
<string name="wifi_hotspot_switch_off_text">Off</string>
<!-- Content description of the carrier network changing icon. [CHAR LIMIT=NONE] -->
<string name="carrier_network_change_mode">Carrier network changing</string>
<!-- Content description of the data connection type 3G. [CHAR LIMIT=NONE] -->
<string name="data_connection_3g">3G</string>
<!-- Content description of the data connection type Edge. [CHAR LIMIT=NONE] -->
<string name="data_connection_edge">EDGE</string>
<!-- Content description of the data connection type CDMA. [CHAR LIMIT=NONE] -->
<string name="data_connection_cdma">1X</string>
<!-- Content description of the data connection type GPRS. [CHAR LIMIT=NONE] -->
<string name="data_connection_gprs">GPRS</string>
<!-- Content description of the data connection type 3.5G. [CHAR LIMIT=NONE] -->
<string name="data_connection_3_5g">H</string>
<!-- Content description of the data connection type 3.5G+. [CHAR LIMIT=NONE] -->
<string name="data_connection_3_5g_plus">H+</string>
<!-- Content description of the data connection type 4G . [CHAR LIMIT=NONE] -->
<string name="data_connection_4g">4G</string>
<!-- Content description of the data connection type 4G+. [CHAR LIMIT=NONE] -->
<string name="data_connection_4g_plus">4G+</string>
<!-- Content description of the data connection type LTE. [CHAR LIMIT=NONE] -->
<string name="data_connection_lte">LTE</string>
<!-- Content description of the data connection type LTE+. [CHAR LIMIT=NONE] -->
<string name="data_connection_lte_plus">LTE+</string>
<!-- Content description of the data connection type 5Ge with HTML styling. DO NOT TRANSLATE [CHAR LIMIT=NONE] -->
<string name="data_connection_5ge_html" translate="false"> &lt;i>5G &lt;small>E&lt;/small>&lt;/i> </string>
<!-- Content description of the data connection type 5G. [CHAR LIMIT=NONE] -->
<string name="data_connection_5g" translatable="false">5G</string>
<!-- Content description of the data connection type 5G+. [CHAR LIMIT=NONE] -->
<string name="data_connection_5g_plus" translatable="false">5G+</string>
<!-- 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 phone signal when no signal for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_no_phone">No phone.</string>
<!-- Content description of the phone signal when it is one bar for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_phone_one_bar">Phone one bar.</string>
<!-- Content description of the phone signal when it is two bars for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_phone_two_bars">Phone two bars.</string>
<!-- Content description of the phone signal when it is three bars for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_phone_three_bars">Phone three bars.</string>
<!-- Content description of the phone signal when it is full for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_phone_signal_full">Phone signal full.</string>
<!-- Content description of the data signal when no signal for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_no_data">No data.</string>
<!-- Content description of the data signal when it is one bar for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_data_one_bar">Data one bar.</string>
<!-- Content description of the data signal when it is two bars for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_data_two_bars">Data two bars.</string>
<!-- Content description of the data signal when it is three bars for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_data_three_bars">Data three bars.</string>
<!-- Content description of the data signal when it is full for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_data_signal_full">Data signal full.</string>
<!-- Content description of the Ethernet connection when disconnected for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_ethernet_disconnected">Ethernet disconnected.</string>
<!-- Content description of the Ethernet connection when connected for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_ethernet_connected">Ethernet connected.</string>
</resources>

View File

@@ -1,8 +1,20 @@
// Copyright 2011 Google Inc. All Rights Reserved.
/*
* Copyright (C) 2020 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.systemui.statusbar.policy;
import com.android.systemui.R;
package com.android.settingslib;
/**
* Content descriptions for accessibility support.
@@ -10,7 +22,7 @@ import com.android.systemui.R;
public class AccessibilityContentDescriptions {
private AccessibilityContentDescriptions() {}
static final int[] PHONE_SIGNAL_STRENGTH = {
public static final int[] PHONE_SIGNAL_STRENGTH = {
R.string.accessibility_no_phone,
R.string.accessibility_phone_one_bar,
R.string.accessibility_phone_two_bars,
@@ -18,7 +30,7 @@ public class AccessibilityContentDescriptions {
R.string.accessibility_phone_signal_full
};
static final int[] DATA_CONNECTION_STRENGTH = {
public static final int[] DATA_CONNECTION_STRENGTH = {
R.string.accessibility_no_data,
R.string.accessibility_data_one_bar,
R.string.accessibility_data_two_bars,
@@ -26,7 +38,7 @@ public class AccessibilityContentDescriptions {
R.string.accessibility_data_signal_full
};
static final int[] WIFI_CONNECTION_STRENGTH = {
public static final int[] WIFI_CONNECTION_STRENGTH = {
R.string.accessibility_no_wifi,
R.string.accessibility_wifi_one_bar,
R.string.accessibility_wifi_two_bars,
@@ -34,9 +46,9 @@ public class AccessibilityContentDescriptions {
R.string.accessibility_wifi_signal_full
};
static final int WIFI_NO_CONNECTION = R.string.accessibility_no_wifi;
public static final int WIFI_NO_CONNECTION = R.string.accessibility_no_wifi;
static final int[] ETHERNET_CONNECTION_VALUES = {
public static final int[] ETHERNET_CONNECTION_VALUES = {
R.string.accessibility_ethernet_disconnected,
R.string.accessibility_ethernet_connected,
};

View File

@@ -0,0 +1,224 @@
/*
* Copyright (C) 2020 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 java.text.SimpleDateFormat;
import java.util.Objects;
/**
* Icons and states for SysUI and Settings.
*/
public class SignalIcon {
/**
* Holds icons for a given state. Arrays are generally indexed as inet
* state (full connectivity or not) first, and second dimension as
* signal strength.
*/
public static class IconGroup {
public final int[][] sbIcons;
public final int[][] qsIcons;
public final int[] contentDesc;
public final int sbNullState;
public final int qsNullState;
public final int sbDiscState;
public final int qsDiscState;
public final int discContentDesc;
// 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) {
this.name = name;
this.sbIcons = sbIcons;
this.qsIcons = qsIcons;
this.contentDesc = contentDesc;
this.sbNullState = sbNullState;
this.qsNullState = qsNullState;
this.sbDiscState = sbDiscState;
this.qsDiscState = qsDiscState;
this.discContentDesc = discContentDesc;
}
@Override
public String toString() {
return "IconGroup(" + name + ")";
}
}
/**
* Holds states for SysUI.
*/
public static class State {
// No locale as it's only used for logging purposes
private static SimpleDateFormat sSDF = new SimpleDateFormat("MM-dd HH:mm:ss.SSS");
public boolean connected;
public boolean enabled;
public boolean activityIn;
public boolean activityOut;
public int level;
public IconGroup iconGroup;
public int inetCondition;
public int rssi; // Only for logging.
// Not used for comparison, just used for logging.
public long time;
/**
* Generates a copy of the source state.
*/
public void copyFrom(State state) {
connected = state.connected;
enabled = state.enabled;
level = state.level;
iconGroup = state.iconGroup;
inetCondition = state.inetCondition;
activityIn = state.activityIn;
activityOut = state.activityOut;
rssi = state.rssi;
time = state.time;
}
@Override
public String toString() {
if (time != 0) {
StringBuilder builder = new StringBuilder();
toString(builder);
return builder.toString();
} else {
return "Empty " + getClass().getSimpleName();
}
}
protected void toString(StringBuilder builder) {
builder.append("connected=").append(connected).append(',')
.append("enabled=").append(enabled).append(',')
.append("level=").append(level).append(',')
.append("inetCondition=").append(inetCondition).append(',')
.append("iconGroup=").append(iconGroup).append(',')
.append("activityIn=").append(activityIn).append(',')
.append("activityOut=").append(activityOut).append(',')
.append("rssi=").append(rssi).append(',')
.append("lastModified=").append(sSDF.format(time));
}
@Override
public boolean equals(Object o) {
if (!o.getClass().equals(getClass())) {
return false;
}
State other = (State) o;
return other.connected == connected
&& other.enabled == enabled
&& other.level == level
&& other.inetCondition == inetCondition
&& other.iconGroup == iconGroup
&& other.activityIn == activityIn
&& other.activityOut == activityOut
&& other.rssi == rssi;
}
}
/**
* Holds icons for a given MobileState.
*/
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);
this.dataContentDescription = dataContentDesc;
this.dataType = dataType;
this.isWide = isWide;
this.qsDataType = dataType; // TODO: remove this field
}
}
/**
* Holds mobile states for SysUI.
*/
public static class MobileState extends State {
public String networkName;
public String networkNameData;
public boolean dataSim;
public boolean dataConnected;
public boolean isEmergency;
public boolean airplaneMode;
public boolean carrierNetworkChangeMode;
public boolean isDefault;
public boolean userSetup;
public boolean roaming;
public boolean defaultDataOff; // Tracks the on/off state of the defaultDataSubscription
@Override
public void copyFrom(State s) {
super.copyFrom(s);
MobileState state = (MobileState) s;
dataSim = state.dataSim;
networkName = state.networkName;
networkNameData = state.networkNameData;
dataConnected = state.dataConnected;
isDefault = state.isDefault;
isEmergency = state.isEmergency;
airplaneMode = state.airplaneMode;
carrierNetworkChangeMode = state.carrierNetworkChangeMode;
userSetup = state.userSetup;
roaming = state.roaming;
defaultDataOff = state.defaultDataOff;
}
@Override
protected void toString(StringBuilder builder) {
super.toString(builder);
builder.append(',');
builder.append("dataSim=").append(dataSim).append(',');
builder.append("networkName=").append(networkName).append(',');
builder.append("networkNameData=").append(networkNameData).append(',');
builder.append("dataConnected=").append(dataConnected).append(',');
builder.append("roaming=").append(roaming).append(',');
builder.append("isDefault=").append(isDefault).append(',');
builder.append("isEmergency=").append(isEmergency).append(',');
builder.append("airplaneMode=").append(airplaneMode).append(',');
builder.append("carrierNetworkChangeMode=").append(carrierNetworkChangeMode)
.append(',');
builder.append("userSetup=").append(userSetup).append(',');
builder.append("defaultDataOff=").append(defaultDataOff);
}
@Override
public boolean equals(Object o) {
return super.equals(o)
&& Objects.equals(((MobileState) o).networkName, networkName)
&& Objects.equals(((MobileState) o).networkNameData, networkNameData)
&& ((MobileState) o).dataSim == dataSim
&& ((MobileState) o).dataConnected == dataConnected
&& ((MobileState) o).isEmergency == isEmergency
&& ((MobileState) o).airplaneMode == airplaneMode
&& ((MobileState) o).carrierNetworkChangeMode == carrierNetworkChangeMode
&& ((MobileState) o).userSetup == userSetup
&& ((MobileState) o).isDefault == isDefault
&& ((MobileState) o).roaming == roaming
&& ((MobileState) o).defaultDataOff == defaultDataOff;
}
}
}

View File

@@ -15,10 +15,21 @@
*/
package com.android.settingslib.mobile;
import android.content.Context;
import android.content.res.Resources;
import android.os.PersistableBundle;
import android.telephony.Annotation;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyManager;
import com.android.settingslib.R;
import com.android.settingslib.SignalIcon.MobileIconGroup;
import java.util.HashMap;
import java.util.Map;
/**
* Holds the utility functions to create the RAT to MobileIconGroup mappings.
*/
@@ -60,4 +71,165 @@ public class MobileMappings {
return "unsupported";
}
}
/**
* Produce the default MobileIconGroup.
*/
public static MobileIconGroup getDefaultIcons(Config config) {
if (!config.showAtLeast3G) {
return TelephonyIcons.G;
} else {
return TelephonyIcons.THREE_G;
}
}
/**
* Produce a mapping of data network types to icon groups for simple and quick use in
* updateTelephony.
*/
public static Map<String, MobileIconGroup> mapIconSets(Config config) {
final Map<String, MobileIconGroup> networkToIconLookup = new HashMap<>();
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EVDO_0),
TelephonyIcons.THREE_G);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EVDO_A),
TelephonyIcons.THREE_G);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EVDO_B),
TelephonyIcons.THREE_G);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EHRPD),
TelephonyIcons.THREE_G);
if (config.show4gFor3g) {
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_UMTS),
TelephonyIcons.FOUR_G);
} else {
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_UMTS),
TelephonyIcons.THREE_G);
}
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_TD_SCDMA),
TelephonyIcons.THREE_G);
if (!config.showAtLeast3G) {
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_UNKNOWN),
TelephonyIcons.UNKNOWN);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EDGE),
TelephonyIcons.E);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_CDMA),
TelephonyIcons.ONE_X);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_1xRTT),
TelephonyIcons.ONE_X);
} else {
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_UNKNOWN),
TelephonyIcons.THREE_G);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EDGE),
TelephonyIcons.THREE_G);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_CDMA),
TelephonyIcons.THREE_G);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_1xRTT),
TelephonyIcons.THREE_G);
}
MobileIconGroup hGroup = TelephonyIcons.THREE_G;
MobileIconGroup hPlusGroup = TelephonyIcons.THREE_G;
if (config.show4gFor3g) {
hGroup = TelephonyIcons.FOUR_G;
hPlusGroup = TelephonyIcons.FOUR_G;
} else if (config.hspaDataDistinguishable) {
hGroup = TelephonyIcons.H;
hPlusGroup = TelephonyIcons.H_PLUS;
}
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_HSDPA), hGroup);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_HSUPA), hGroup);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_HSPA), hGroup);
networkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_HSPAP), hPlusGroup);
if (config.show4gForLte) {
networkToIconLookup.put(toIconKey(
TelephonyManager.NETWORK_TYPE_LTE),
TelephonyIcons.FOUR_G);
if (config.hideLtePlus) {
networkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA),
TelephonyIcons.FOUR_G);
} else {
networkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA),
TelephonyIcons.FOUR_G_PLUS);
}
} else {
networkToIconLookup.put(toIconKey(
TelephonyManager.NETWORK_TYPE_LTE),
TelephonyIcons.LTE);
if (config.hideLtePlus) {
networkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA),
TelephonyIcons.LTE);
} else {
networkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA),
TelephonyIcons.LTE_PLUS);
}
}
networkToIconLookup.put(toIconKey(
TelephonyManager.NETWORK_TYPE_IWLAN),
TelephonyIcons.WFC);
networkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO),
TelephonyIcons.LTE_CA_5G_E);
networkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA),
TelephonyIcons.NR_5G);
networkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE),
TelephonyIcons.NR_5G_PLUS);
networkToIconLookup.put(toIconKey(
TelephonyManager.NETWORK_TYPE_NR),
TelephonyIcons.NR_5G);
return networkToIconLookup;
}
/**
* Wrapper class of system configs and Carrier configs.
*/
public static class Config {
public boolean showAtLeast3G = false;
public boolean show4gFor3g = false;
public boolean alwaysShowCdmaRssi = false;
public boolean show4gForLte = false;
public boolean hideLtePlus = false;
public boolean hspaDataDistinguishable;
public boolean alwaysShowDataRatIcon = false;
/**
* Reads the latest configs.
*/
public static Config readConfig(Context context) {
Config config = new Config();
Resources res = context.getResources();
config.showAtLeast3G = res.getBoolean(R.bool.config_showMin3G);
config.alwaysShowCdmaRssi =
res.getBoolean(com.android.internal.R.bool.config_alwaysUseCdmaRssi);
config.hspaDataDistinguishable =
res.getBoolean(R.bool.config_hspa_data_distinguishable);
CarrierConfigManager configMgr = (CarrierConfigManager)
context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
// Handle specific carrier config values for the default data SIM
int defaultDataSubId = SubscriptionManager.from(context)
.getDefaultDataSubscriptionId();
PersistableBundle b = configMgr.getConfigForSubId(defaultDataSubId);
if (b != null) {
config.alwaysShowDataRatIcon = b.getBoolean(
CarrierConfigManager.KEY_ALWAYS_SHOW_DATA_RAT_ICON_BOOL);
config.show4gForLte = b.getBoolean(
CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL);
config.show4gFor3g = b.getBoolean(
CarrierConfigManager.KEY_SHOW_4G_FOR_3G_DATA_ICON_BOOL);
config.hideLtePlus = b.getBoolean(
CarrierConfigManager.KEY_HIDE_LTE_PLUS_DATA_ICON_BOOL);
}
return config;
}
}
}

View File

@@ -14,33 +14,37 @@
* limitations under the License.
*/
package com.android.systemui.statusbar.policy;
package com.android.settingslib.mobile;
import com.android.systemui.R;
import com.android.systemui.statusbar.policy.MobileSignalController.MobileIconGroup;
import com.android.settingslib.AccessibilityContentDescriptions;
import com.android.settingslib.R;
import com.android.settingslib.SignalIcon.MobileIconGroup;
import java.util.HashMap;
import java.util.Map;
class TelephonyIcons {
/**
* Telephony related icons and strings for SysUI and Settings.
*/
public class TelephonyIcons {
//***** Data connection icons
static final int FLIGHT_MODE_ICON = R.drawable.stat_sys_airplane_mode;
public static final int FLIGHT_MODE_ICON = R.drawable.stat_sys_airplane_mode;
static final int ICON_LTE = R.drawable.ic_lte_mobiledata;
static final int ICON_LTE_PLUS = R.drawable.ic_lte_plus_mobiledata;
static final int ICON_G = R.drawable.ic_g_mobiledata;
static final int ICON_E = R.drawable.ic_e_mobiledata;
static final int ICON_H = R.drawable.ic_h_mobiledata;
static final int ICON_H_PLUS = R.drawable.ic_h_plus_mobiledata;
static final int ICON_3G = R.drawable.ic_3g_mobiledata;
static final int ICON_4G = R.drawable.ic_4g_mobiledata;
static final int ICON_4G_PLUS = R.drawable.ic_4g_plus_mobiledata;
static final int ICON_5G_E = R.drawable.ic_5g_e_mobiledata;
static final int ICON_1X = R.drawable.ic_1x_mobiledata;
static final int ICON_5G = R.drawable.ic_5g_mobiledata;
static final int ICON_5G_PLUS = R.drawable.ic_5g_plus_mobiledata;
public static final int ICON_LTE = R.drawable.ic_lte_mobiledata;
public static final int ICON_LTE_PLUS = R.drawable.ic_lte_plus_mobiledata;
public static final int ICON_G = R.drawable.ic_g_mobiledata;
public static final int ICON_E = R.drawable.ic_e_mobiledata;
public static final int ICON_H = R.drawable.ic_h_mobiledata;
public static final int ICON_H_PLUS = R.drawable.ic_h_plus_mobiledata;
public static final int ICON_3G = R.drawable.ic_3g_mobiledata;
public static final int ICON_4G = R.drawable.ic_4g_mobiledata;
public static final int ICON_4G_PLUS = R.drawable.ic_4g_plus_mobiledata;
public static final int ICON_5G_E = R.drawable.ic_5g_e_mobiledata;
public static final int ICON_1X = R.drawable.ic_1x_mobiledata;
public static final int ICON_5G = R.drawable.ic_5g_mobiledata;
public static final int ICON_5G_PLUS = R.drawable.ic_5g_plus_mobiledata;
static final MobileIconGroup CARRIER_NETWORK_CHANGE = new MobileIconGroup(
public static final MobileIconGroup CARRIER_NETWORK_CHANGE = new MobileIconGroup(
"CARRIER_NETWORK_CHANGE",
null,
null,
@@ -53,7 +57,7 @@ class TelephonyIcons {
0,
false);
static final MobileIconGroup THREE_G = new MobileIconGroup(
public static final MobileIconGroup THREE_G = new MobileIconGroup(
"3G",
null,
null,
@@ -66,7 +70,7 @@ class TelephonyIcons {
TelephonyIcons.ICON_3G,
true);
static final MobileIconGroup WFC = new MobileIconGroup(
public static final MobileIconGroup WFC = new MobileIconGroup(
"WFC",
null,
null,
@@ -77,7 +81,7 @@ class TelephonyIcons {
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
0, 0, false);
static final MobileIconGroup UNKNOWN = new MobileIconGroup(
public static final MobileIconGroup UNKNOWN = new MobileIconGroup(
"Unknown",
null,
null,
@@ -88,7 +92,7 @@ class TelephonyIcons {
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
0, 0, false);
static final MobileIconGroup E = new MobileIconGroup(
public static final MobileIconGroup E = new MobileIconGroup(
"E",
null,
null,
@@ -101,7 +105,7 @@ class TelephonyIcons {
TelephonyIcons.ICON_E,
false);
static final MobileIconGroup ONE_X = new MobileIconGroup(
public static final MobileIconGroup ONE_X = new MobileIconGroup(
"1X",
null,
null,
@@ -114,7 +118,7 @@ class TelephonyIcons {
TelephonyIcons.ICON_1X,
true);
static final MobileIconGroup G = new MobileIconGroup(
public static final MobileIconGroup G = new MobileIconGroup(
"G",
null,
null,
@@ -127,7 +131,7 @@ class TelephonyIcons {
TelephonyIcons.ICON_G,
false);
static final MobileIconGroup H = new MobileIconGroup(
public static final MobileIconGroup H = new MobileIconGroup(
"H",
null,
null,
@@ -140,7 +144,7 @@ class TelephonyIcons {
TelephonyIcons.ICON_H,
false);
static final MobileIconGroup H_PLUS = new MobileIconGroup(
public static final MobileIconGroup H_PLUS = new MobileIconGroup(
"H+",
null,
null,
@@ -153,7 +157,7 @@ class TelephonyIcons {
TelephonyIcons.ICON_H_PLUS,
false);
static final MobileIconGroup FOUR_G = new MobileIconGroup(
public static final MobileIconGroup FOUR_G = new MobileIconGroup(
"4G",
null,
null,
@@ -166,12 +170,12 @@ class TelephonyIcons {
TelephonyIcons.ICON_4G,
true);
static final MobileIconGroup FOUR_G_PLUS = new MobileIconGroup(
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],
@@ -179,7 +183,7 @@ class TelephonyIcons {
TelephonyIcons.ICON_4G_PLUS,
true);
static final MobileIconGroup LTE = new MobileIconGroup(
public static final MobileIconGroup LTE = new MobileIconGroup(
"LTE",
null,
null,
@@ -192,7 +196,7 @@ class TelephonyIcons {
TelephonyIcons.ICON_LTE,
true);
static final MobileIconGroup LTE_PLUS = new MobileIconGroup(
public static final MobileIconGroup LTE_PLUS = new MobileIconGroup(
"LTE+",
null,
null,
@@ -205,7 +209,7 @@ class TelephonyIcons {
TelephonyIcons.ICON_LTE_PLUS,
true);
static final MobileIconGroup LTE_CA_5G_E = new MobileIconGroup(
public static final MobileIconGroup LTE_CA_5G_E = new MobileIconGroup(
"5Ge",
null,
null,
@@ -218,7 +222,7 @@ class TelephonyIcons {
TelephonyIcons.ICON_5G_E,
true);
static final MobileIconGroup NR_5G = new MobileIconGroup(
public static final MobileIconGroup NR_5G = new MobileIconGroup(
"5G",
null,
null,
@@ -232,7 +236,7 @@ class TelephonyIcons {
TelephonyIcons.ICON_5G,
true);
static final MobileIconGroup NR_5G_PLUS = new MobileIconGroup(
public static final MobileIconGroup NR_5G_PLUS = new MobileIconGroup(
"5G_PLUS",
null,
null,
@@ -246,7 +250,7 @@ class TelephonyIcons {
TelephonyIcons.ICON_5G_PLUS,
true);
static final MobileIconGroup DATA_DISABLED = new MobileIconGroup(
public static final MobileIconGroup DATA_DISABLED = new MobileIconGroup(
"DataDisabled",
null,
null,
@@ -259,7 +263,7 @@ class TelephonyIcons {
0,
false);
static final MobileIconGroup NOT_DEFAULT_DATA = new MobileIconGroup(
public static final MobileIconGroup NOT_DEFAULT_DATA = new MobileIconGroup(
"NotDefaultData",
null,
null,
@@ -276,7 +280,7 @@ class TelephonyIcons {
// in QSCarrier#hasValidTypeContentDescription
/** Mapping icon name(lower case) to the icon object. */
static final Map<String, MobileIconGroup> ICON_NAME_TO_ICON;
public static final Map<String, MobileIconGroup> ICON_NAME_TO_ICON;
static {
ICON_NAME_TO_ICON = new HashMap<>();
ICON_NAME_TO_ICON.put("carrier_network_change", CARRIER_NETWORK_CHANGE);

View File

@@ -24,10 +24,6 @@
certain GPU's and thus can be turned off with only minimal visual impact. -->
<bool name="config_notifications_round_rect_clipping">true</bool>
<!-- Control whether status bar should distinguish HSPA data icon form UMTS
data icon on devices -->
<bool name="config_hspa_data_distinguishable">false</bool>
<!-- Component to be used as the status bar service. Must implement the IStatusBar
interface. This name is in the ComponentName flattened format (package/class) -->
<string name="config_statusBarComponent" translatable="false">com.android.systemui.statusbar.phone.StatusBar</string>
@@ -56,9 +52,6 @@
<!-- Show phone (voice) signal strength instead of data in mobile RSSI. -->
<bool name="config_showPhoneRSSIForData">false</bool>
<!-- When true, show 1/2G networks as 3G. -->
<bool name="config_showMin3G">false</bool>
<!-- Show rotation lock toggle in System UI-->
<bool name="config_showRotationLock">true</bool>

View File

@@ -450,28 +450,6 @@
<!-- Content description of the battery when battery state is unknown for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_battery_unknown">Battery percentage unknown.</string>
<!-- Content description of the phone signal when no signal for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_no_phone">No phone.</string>
<!-- Content description of the phone signal when it is one bar for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_phone_one_bar">Phone one bar.</string>
<!-- Content description of the phone signal when it is two bars for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_phone_two_bars">Phone two bars.</string>
<!-- Content description of the phone signal when it is three bars for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_phone_three_bars">Phone three bars.</string>
<!-- Content description of the phone signal when it is full for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_phone_signal_full">Phone signal full.</string>
<!-- Content description of the data signal when no signal for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_no_data">No data.</string>
<!-- Content description of the data signal when it is one bar for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_data_one_bar">Data one bar.</string>
<!-- Content description of the data signal when it is two bars for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_data_two_bars">Data two bars.</string>
<!-- Content description of the data signal when it is three bars for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_data_three_bars">Data three bars.</string>
<!-- Content description of the data signal when it is full for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_data_signal_full">Data signal full.</string>
<!-- Content description of the wifi label showing what we are connected to. [CHAR LIMIT=NONE] -->
<string name="accessibility_wifi_name">Connected to <xliff:g id="wifi" example="Home Network">%s</xliff:g>.</string>
@@ -493,11 +471,6 @@
<!-- Content description of the WiMAX signal when it is full for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_wimax_signal_full">WiMAX signal full.</string>
<!-- Content description of the Ethernet connection when disconnected for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_ethernet_disconnected">Ethernet disconnected.</string>
<!-- Content description of the Ethernet connection when connected for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_ethernet_connected">Ethernet connected.</string>
<!-- Content description of an item with no signal for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_no_signal">No signal.</string>
<!-- Content description of an item with no signal and no connection for accessibility (not shown on the screen) [CHAR LIMIT=NONE] -->
@@ -522,54 +495,16 @@
<!-- Content description of an item that is connecting for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_desc_connecting">Connecting.</string>
<!-- Content description of the data connection type GPRS. [CHAR LIMIT=NONE] -->
<string name="data_connection_gprs">GPRS</string>
<!-- Content description of the data connection type HSPA and its variants. [CHAR LIMIT=NONE] -->
<string name="data_connection_hspa">HSPA</string>
<!-- Content description of the data connection type 3G. [CHAR LIMIT=NONE] -->
<string name="data_connection_3g">3G</string>
<!-- Content description of the data connection type 3.5G. [CHAR LIMIT=NONE] -->
<string name="data_connection_3_5g">H</string>
<!-- Content description of the data connection type 3.5G+. [CHAR LIMIT=NONE] -->
<string name="data_connection_3_5g_plus">H+</string>
<!-- Content description of the data connection type 4G . [CHAR LIMIT=NONE] -->
<string name="data_connection_4g">4G</string>
<!-- Content description of the data connection type 4G+. [CHAR LIMIT=NONE] -->
<string name="data_connection_4g_plus">4G+</string>
<!-- Content description of the data connection type LTE. [CHAR LIMIT=NONE] -->
<string name="data_connection_lte">LTE</string>
<!-- Content description of the data connection type LTE+. [CHAR LIMIT=NONE] -->
<string name="data_connection_lte_plus">LTE+</string>
<!-- Content description of the data connection type 5Ge. [CHAR LIMIT=NONE] -->
<string name="data_connection_5ge" translatable="false">5Ge</string>
<!-- Content description of the data connection type 5Ge with HTML styling. DO NOT TRANSLATE [CHAR LIMIT=NONE] -->
<string name="data_connection_5ge_html" translate="false"> &lt;i>5G &lt;small>E&lt;/small>&lt;/i> </string>
<!-- Content description of the data connection type 5G. [CHAR LIMIT=NONE] -->
<string name="data_connection_5g" translatable="false">5G</string>
<!-- Content description of the data connection type 5G+. [CHAR LIMIT=NONE] -->
<string name="data_connection_5g_plus" translatable="false">5G+</string>
<!-- Content description of the data connection type CDMA. [CHAR LIMIT=NONE] -->
<string name="data_connection_cdma">1X</string>
<!-- Content description of the roaming data connection type. [CHAR LIMIT=NONE] -->
<string name="data_connection_roaming">Roaming</string>
<!-- Content description of the data connection type Edge. [CHAR LIMIT=NONE] -->
<string name="data_connection_edge">EDGE</string>
<!-- Content description of the data connection type WiFi for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_data_connection_wifi">Wi-Fi</string>
@@ -582,12 +517,6 @@
<!-- Content description of the cell data being enabled. [CHAR LIMIT=NONE] -->
<string name="accessibility_cell_data_on">Mobile Data On</string>
<!-- 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>
@@ -603,9 +532,6 @@
<!-- Content description of the no sim icon for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_no_sims">No SIM card.</string>
<!-- Content description of the carrier network changing icon. [CHAR LIMIT=NONE] -->
<string name="carrier_network_change_mode">Carrier network changing</string>
<!-- Content description of button to open battery details icon for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_battery_details">Open battery details</string>

View File

@@ -116,9 +116,11 @@ public class QSCarrier extends LinearLayout {
return TextUtils.equals(typeContentDescription,
mContext.getString(R.string.data_connection_no_internet))
|| TextUtils.equals(typeContentDescription,
mContext.getString(R.string.cell_data_off_content_description))
mContext.getString(
com.android.settingslib.R.string.cell_data_off_content_description))
|| TextUtils.equals(typeContentDescription,
mContext.getString(R.string.not_default_data_content_description));
mContext.getString(
com.android.settingslib.R.string.not_default_data_content_description));
}
public void setCarrierText(CharSequence text) {

View File

@@ -18,6 +18,9 @@ package com.android.systemui.statusbar.policy;
import android.content.Context;
import android.net.NetworkCapabilities;
import com.android.settingslib.AccessibilityContentDescriptions;
import com.android.settingslib.SignalIcon.IconGroup;
import com.android.settingslib.SignalIcon.State;
import com.android.systemui.statusbar.policy.NetworkController.IconState;
import com.android.systemui.statusbar.policy.NetworkController.SignalCallback;
@@ -25,7 +28,7 @@ import java.util.BitSet;
public class EthernetSignalController extends
SignalController<SignalController.State, SignalController.IconGroup> {
SignalController<State, IconGroup> {
public EthernetSignalController(Context context,
CallbackHandler callbackHandler, NetworkControllerImpl networkController) {
@@ -57,7 +60,7 @@ public class EthernetSignalController extends
}
@Override
public SignalController.State cleanState() {
return new SignalController.State();
public State cleanState() {
return new State();
}
}

View File

@@ -15,9 +15,9 @@
*/
package com.android.systemui.statusbar.policy;
import static com.android.settingslib.mobile.MobileMappings.getDefaultIcons;
import static com.android.settingslib.mobile.MobileMappings.getIconKey;
import static com.android.settingslib.mobile.MobileMappings.toDisplayIconKey;
import static com.android.settingslib.mobile.MobileMappings.toIconKey;
import static com.android.settingslib.mobile.MobileMappings.mapIconSets;
import android.content.Context;
import android.content.Intent;
@@ -39,25 +39,28 @@ import android.text.TextUtils;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settingslib.SignalIcon.MobileIconGroup;
import com.android.settingslib.SignalIcon.MobileState;
import com.android.settingslib.Utils;
import com.android.settingslib.graph.SignalDrawable;
import com.android.settingslib.mobile.MobileMappings.Config;
import com.android.settingslib.mobile.MobileStatusTracker;
import com.android.settingslib.mobile.MobileStatusTracker.SubscriptionDefaults;
import com.android.settingslib.mobile.TelephonyIcons;
import com.android.settingslib.net.SignalStrengthUtil;
import com.android.systemui.R;
import com.android.systemui.statusbar.policy.NetworkController.IconState;
import com.android.systemui.statusbar.policy.NetworkController.SignalCallback;
import com.android.systemui.statusbar.policy.NetworkControllerImpl.Config;
import java.io.PrintWriter;
import java.util.BitSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class MobileSignalController extends SignalController<
MobileSignalController.MobileState, MobileSignalController.MobileIconGroup> {
/**
* Monitors the mobile signal changes and update the SysUI icons.
*/
public class MobileSignalController extends SignalController<MobileState, MobileIconGroup> {
private final TelephonyManager mPhone;
private final SubscriptionDefaults mDefaults;
private final String mNetworkNameDefault;
@@ -66,7 +69,8 @@ public class MobileSignalController extends SignalController<
// Save entire info for logging, we only use the id.
final SubscriptionInfo mSubscriptionInfo;
// @VisibleForDemoMode
final Map<String, MobileIconGroup> mNetworkToIconLookup;
Map<String, MobileIconGroup> mNetworkToIconLookup;
// Since some pieces of the phone state are interdependent we store it locally,
// this could potentially become part of MobileState for simplification/complication
// of code.
@@ -93,7 +97,6 @@ public class MobileSignalController extends SignalController<
super("MobileSignalController(" + info.getSubscriptionId() + ")", context,
NetworkCapabilities.TRANSPORT_CELLULAR, callbackHandler,
networkController);
mNetworkToIconLookup = new HashMap<>();
mConfig = config;
mPhone = phone;
mDefaults = defaults;
@@ -102,7 +105,10 @@ public class MobileSignalController extends SignalController<
.toString();
mNetworkNameDefault = getTextIfExists(
com.android.internal.R.string.lockscreen_carrier_default).toString();
mapIconSets();
mNetworkToIconLookup = mapIconSets(mConfig);
mDefaultIcons = getDefaultIcons(mConfig);
String networkName = info.getCarrierName() != null ? info.getCarrierName().toString()
: mNetworkNameDefault;
mLastState.networkName = mCurrentState.networkName = networkName;
@@ -139,7 +145,8 @@ public class MobileSignalController extends SignalController<
public void setConfiguration(Config config) {
mConfig = config;
updateInflateSignalStrength();
mapIconSets();
mNetworkToIconLookup = mapIconSets(mConfig);
mDefaultIcons = getDefaultIcons(mConfig);
updateTelephony();
}
@@ -187,113 +194,6 @@ public class MobileSignalController extends SignalController<
mContext.getContentResolver().unregisterContentObserver(mObserver);
}
/**
* Produce a mapping of data network types to icon groups for simple and quick use in
* updateTelephony.
*/
private void mapIconSets() {
mNetworkToIconLookup.clear();
mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EVDO_0),
TelephonyIcons.THREE_G);
mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EVDO_A),
TelephonyIcons.THREE_G);
mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EVDO_B),
TelephonyIcons.THREE_G);
mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EHRPD),
TelephonyIcons.THREE_G);
if (mConfig.show4gFor3g) {
mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_UMTS),
TelephonyIcons.FOUR_G);
} else {
mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_UMTS),
TelephonyIcons.THREE_G);
}
mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_TD_SCDMA),
TelephonyIcons.THREE_G);
if (!mConfig.showAtLeast3G) {
mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_UNKNOWN),
TelephonyIcons.UNKNOWN);
mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EDGE),
TelephonyIcons.E);
mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_CDMA),
TelephonyIcons.ONE_X);
mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_1xRTT),
TelephonyIcons.ONE_X);
mDefaultIcons = TelephonyIcons.G;
} else {
mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_UNKNOWN),
TelephonyIcons.THREE_G);
mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EDGE),
TelephonyIcons.THREE_G);
mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_CDMA),
TelephonyIcons.THREE_G);
mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_1xRTT),
TelephonyIcons.THREE_G);
mDefaultIcons = TelephonyIcons.THREE_G;
}
MobileIconGroup hGroup = TelephonyIcons.THREE_G;
MobileIconGroup hPlusGroup = TelephonyIcons.THREE_G;
if (mConfig.show4gFor3g) {
hGroup = TelephonyIcons.FOUR_G;
hPlusGroup = TelephonyIcons.FOUR_G;
} else if (mConfig.hspaDataDistinguishable) {
hGroup = TelephonyIcons.H;
hPlusGroup = TelephonyIcons.H_PLUS;
}
mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_HSDPA), hGroup);
mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_HSUPA), hGroup);
mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_HSPA), hGroup);
mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_HSPAP), hPlusGroup);
if (mConfig.show4gForLte) {
mNetworkToIconLookup.put(toIconKey(
TelephonyManager.NETWORK_TYPE_LTE),
TelephonyIcons.FOUR_G);
if (mConfig.hideLtePlus) {
mNetworkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA),
TelephonyIcons.FOUR_G);
} else {
mNetworkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA),
TelephonyIcons.FOUR_G_PLUS);
}
} else {
mNetworkToIconLookup.put(toIconKey(
TelephonyManager.NETWORK_TYPE_LTE),
TelephonyIcons.LTE);
if (mConfig.hideLtePlus) {
mNetworkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA),
TelephonyIcons.LTE);
} else {
mNetworkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA),
TelephonyIcons.LTE_PLUS);
}
}
mNetworkToIconLookup.put(toIconKey(
TelephonyManager.NETWORK_TYPE_IWLAN),
TelephonyIcons.WFC);
mNetworkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO),
TelephonyIcons.LTE_CA_5G_E);
mNetworkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA),
TelephonyIcons.NR_5G);
mNetworkToIconLookup.put(toDisplayIconKey(
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE),
TelephonyIcons.NR_5G_PLUS);
mNetworkToIconLookup.put(toIconKey(
TelephonyManager.NETWORK_TYPE_NR),
TelephonyIcons.NR_5G);
}
private void updateInflateSignalStrength() {
mInflateSignalStrengths = SignalStrengthUtil.shouldInflateSignalStrength(mContext,
mSubscriptionInfo.getSubscriptionId());
@@ -339,7 +239,7 @@ public class MobileSignalController extends SignalController<
MobileIconGroup icons = getIcons();
String contentDescription = getTextIfExists(getContentDescription()).toString();
CharSequence dataContentDescriptionHtml = getTextIfExists(icons.mDataContentDescription);
CharSequence dataContentDescriptionHtml = getTextIfExists(icons.dataContentDescription);
//TODO: Hacky
// The data content description can sometimes be shown in a text view and might come to us
@@ -363,7 +263,7 @@ public class MobileSignalController extends SignalController<
CharSequence description = null;
// Only send data sim callbacks to QS.
if (mCurrentState.dataSim) {
qsTypeIcon = (showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.mQsDataType : 0;
qsTypeIcon = (showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.qsDataType : 0;
qsIcon = new IconState(mCurrentState.enabled
&& !mCurrentState.isEmergency, getQsCurrentIconId(), contentDescription);
description = mCurrentState.isEmergency ? null : mCurrentState.networkName;
@@ -375,10 +275,10 @@ public class MobileSignalController extends SignalController<
&& !mCurrentState.carrierNetworkChangeMode
&& mCurrentState.activityOut;
showDataIcon &= mCurrentState.isDefault || dataDisabled;
int typeIcon = (showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.mDataType : 0;
int typeIcon = (showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.dataType : 0;
callback.setMobileDataIndicators(statusIcon, qsIcon, typeIcon, qsTypeIcon,
activityIn, activityOut, dataContentDescription, dataContentDescriptionHtml,
description, icons.mIsWide, mSubscriptionInfo.getSubscriptionId(),
description, icons.isWide, mSubscriptionInfo.getSubscriptionId(),
mCurrentState.roaming);
}
@@ -610,87 +510,4 @@ public class MobileSignalController extends SignalController<
pw.println(" mInflateSignalStrengths=" + mInflateSignalStrengths + ",");
pw.println(" isDataDisabled=" + isDataDisabled() + ",");
}
static class MobileIconGroup extends SignalController.IconGroup {
final int mDataContentDescription; // mContentDescriptionDataType
final int mDataType;
final boolean mIsWide;
final int mQsDataType;
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);
mDataContentDescription = dataContentDesc;
mDataType = dataType;
mIsWide = isWide;
mQsDataType = dataType; // TODO: remove this field
}
}
static class MobileState extends SignalController.State {
String networkName;
String networkNameData;
boolean dataSim;
boolean dataConnected;
boolean isEmergency;
boolean airplaneMode;
boolean carrierNetworkChangeMode;
boolean isDefault;
boolean userSetup;
boolean roaming;
boolean defaultDataOff; // Tracks the on/off state of the defaultDataSubscription
@Override
public void copyFrom(State s) {
super.copyFrom(s);
MobileState state = (MobileState) s;
dataSim = state.dataSim;
networkName = state.networkName;
networkNameData = state.networkNameData;
dataConnected = state.dataConnected;
isDefault = state.isDefault;
isEmergency = state.isEmergency;
airplaneMode = state.airplaneMode;
carrierNetworkChangeMode = state.carrierNetworkChangeMode;
userSetup = state.userSetup;
roaming = state.roaming;
defaultDataOff = state.defaultDataOff;
}
@Override
protected void toString(StringBuilder builder) {
super.toString(builder);
builder.append(',');
builder.append("dataSim=").append(dataSim).append(',');
builder.append("networkName=").append(networkName).append(',');
builder.append("networkNameData=").append(networkNameData).append(',');
builder.append("dataConnected=").append(dataConnected).append(',');
builder.append("roaming=").append(roaming).append(',');
builder.append("isDefault=").append(isDefault).append(',');
builder.append("isEmergency=").append(isEmergency).append(',');
builder.append("airplaneMode=").append(airplaneMode).append(',');
builder.append("carrierNetworkChangeMode=").append(carrierNetworkChangeMode)
.append(',');
builder.append("userSetup=").append(userSetup).append(',');
builder.append("defaultDataOff=").append(defaultDataOff);
}
@Override
public boolean equals(Object o) {
return super.equals(o)
&& Objects.equals(((MobileState) o).networkName, networkName)
&& Objects.equals(((MobileState) o).networkNameData, networkNameData)
&& ((MobileState) o).dataSim == dataSim
&& ((MobileState) o).dataConnected == dataConnected
&& ((MobileState) o).isEmergency == isEmergency
&& ((MobileState) o).airplaneMode == airplaneMode
&& ((MobileState) o).carrierNetworkChangeMode == carrierNetworkChangeMode
&& ((MobileState) o).userSetup == userSetup
&& ((MobileState) o).isDefault == isDefault
&& ((MobileState) o).roaming == roaming
&& ((MobileState) o).defaultDataOff == defaultDataOff;
}
}
}

View File

@@ -30,7 +30,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkCapabilities;
@@ -40,7 +39,6 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.PersistableBundle;
import android.provider.Settings;
import android.telephony.CarrierConfigManager;
import android.telephony.CellSignalStrength;
@@ -59,7 +57,9 @@ import androidx.annotation.NonNull;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settingslib.mobile.MobileMappings.Config;
import com.android.settingslib.mobile.MobileStatusTracker.SubscriptionDefaults;
import com.android.settingslib.mobile.TelephonyIcons;
import com.android.settingslib.net.DataUsageController;
import com.android.systemui.Dumpable;
import com.android.systemui.R;
@@ -1201,45 +1201,4 @@ public class NetworkControllerImpl extends BroadcastReceiver
registerListeners();
}
};
@VisibleForTesting
static class Config {
boolean showAtLeast3G = false;
boolean show4gFor3g = false;
boolean alwaysShowCdmaRssi = false;
boolean show4gForLte = false;
boolean hideLtePlus = false;
boolean hspaDataDistinguishable;
boolean alwaysShowDataRatIcon = false;
static Config readConfig(Context context) {
Config config = new Config();
Resources res = context.getResources();
config.showAtLeast3G = res.getBoolean(R.bool.config_showMin3G);
config.alwaysShowCdmaRssi =
res.getBoolean(com.android.internal.R.bool.config_alwaysUseCdmaRssi);
config.hspaDataDistinguishable =
res.getBoolean(R.bool.config_hspa_data_distinguishable);
CarrierConfigManager configMgr = (CarrierConfigManager)
context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
// Handle specific carrier config values for the default data SIM
int defaultDataSubId = SubscriptionManager.from(context)
.getDefaultDataSubscriptionId();
PersistableBundle b = configMgr.getConfigForSubId(defaultDataSubId);
if (b != null) {
config.alwaysShowDataRatIcon = b.getBoolean(
CarrierConfigManager.KEY_ALWAYS_SHOW_DATA_RAT_ICON_BOOL);
config.show4gForLte = b.getBoolean(
CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL);
config.show4gFor3g = b.getBoolean(
CarrierConfigManager.KEY_SHOW_4G_FOR_3G_DATA_ICON_BOOL);
config.hideLtePlus = b.getBoolean(
CarrierConfigManager.KEY_HIDE_LTE_PLUS_DATA_ICON_BOOL);
}
return config;
}
}
}

View File

@@ -21,18 +21,21 @@ import android.annotation.NonNull;
import android.content.Context;
import android.util.Log;
import com.android.settingslib.SignalIcon.IconGroup;
import com.android.settingslib.SignalIcon.State;
import com.android.systemui.statusbar.policy.NetworkController.SignalCallback;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.BitSet;
/**
* Common base class for handling signal for both wifi and mobile data.
*
* @param <T> State of the SysUI controller.
* @param <I> Icon groups of the SysUI controller for a given State.
*/
public abstract class SignalController<T extends SignalController.State,
I extends SignalController.IconGroup> {
public abstract class SignalController<T extends State, I extends IconGroup> {
// Save the previous SignalController.States of all SignalControllers for dumps.
static final boolean RECORD_HISTORY = true;
// If RECORD_HISTORY how many to save, must be a power of 2.
@@ -124,11 +127,11 @@ public abstract class SignalController<T extends SignalController.State,
*/
public int getQsCurrentIconId() {
if (mCurrentState.connected) {
return getIcons().mQsIcons[mCurrentState.inetCondition][mCurrentState.level];
return getIcons().qsIcons[mCurrentState.inetCondition][mCurrentState.level];
} else if (mCurrentState.enabled) {
return getIcons().mQsDiscState;
return getIcons().qsDiscState;
} else {
return getIcons().mQsNullState;
return getIcons().qsNullState;
}
}
@@ -137,11 +140,11 @@ public abstract class SignalController<T extends SignalController.State,
*/
public int getCurrentIconId() {
if (mCurrentState.connected) {
return getIcons().mSbIcons[mCurrentState.inetCondition][mCurrentState.level];
return getIcons().sbIcons[mCurrentState.inetCondition][mCurrentState.level];
} else if (mCurrentState.enabled) {
return getIcons().mSbDiscState;
return getIcons().sbDiscState;
} else {
return getIcons().mSbNullState;
return getIcons().sbNullState;
}
}
@@ -151,9 +154,9 @@ public abstract class SignalController<T extends SignalController.State,
*/
public int getContentDescription() {
if (mCurrentState.connected) {
return getIcons().mContentDesc[mCurrentState.level];
return getIcons().contentDesc[mCurrentState.level];
} else {
return getIcons().mDiscContentDesc;
return getIcons().discContentDesc;
}
}
@@ -216,108 +219,4 @@ public abstract class SignalController<T extends SignalController.State,
* Generate a blank T.
*/
protected abstract T cleanState();
/*
* Holds icons for a given state. Arrays are generally indexed as inet
* state (full connectivity or not) first, and second dimension as
* signal strength.
*/
static class IconGroup {
final int[][] mSbIcons;
final int[][] mQsIcons;
final int[] mContentDesc;
final int mSbNullState;
final int mQsNullState;
final int mSbDiscState;
final int mQsDiscState;
final int mDiscContentDesc;
// For logging.
final String mName;
public IconGroup(String name, int[][] sbIcons, int[][] qsIcons, int[] contentDesc,
int sbNullState, int qsNullState, int sbDiscState, int qsDiscState,
int discContentDesc) {
mName = name;
mSbIcons = sbIcons;
mQsIcons = qsIcons;
mContentDesc = contentDesc;
mSbNullState = sbNullState;
mQsNullState = qsNullState;
mSbDiscState = sbDiscState;
mQsDiscState = qsDiscState;
mDiscContentDesc = discContentDesc;
}
@Override
public String toString() {
return "IconGroup(" + mName + ")";
}
}
static class State {
// No locale as it's only used for logging purposes
private static SimpleDateFormat sSDF = new SimpleDateFormat("MM-dd HH:mm:ss.SSS");
boolean connected;
boolean enabled;
boolean activityIn;
boolean activityOut;
int level;
IconGroup iconGroup;
int inetCondition;
int rssi; // Only for logging.
// Not used for comparison, just used for logging.
long time;
public void copyFrom(State state) {
connected = state.connected;
enabled = state.enabled;
level = state.level;
iconGroup = state.iconGroup;
inetCondition = state.inetCondition;
activityIn = state.activityIn;
activityOut = state.activityOut;
rssi = state.rssi;
time = state.time;
}
@Override
public String toString() {
if (time != 0) {
StringBuilder builder = new StringBuilder();
toString(builder);
return builder.toString();
} else {
return "Empty " + getClass().getSimpleName();
}
}
protected void toString(StringBuilder builder) {
builder.append("connected=").append(connected).append(',')
.append("enabled=").append(enabled).append(',')
.append("level=").append(level).append(',')
.append("inetCondition=").append(inetCondition).append(',')
.append("iconGroup=").append(iconGroup).append(',')
.append("activityIn=").append(activityIn).append(',')
.append("activityOut=").append(activityOut).append(',')
.append("rssi=").append(rssi).append(',')
.append("lastModified=").append(sSDF.format(time));
}
@Override
public boolean equals(Object o) {
if (!o.getClass().equals(getClass())) {
return false;
}
State other = (State) o;
return other.connected == connected
&& other.enabled == enabled
&& other.level == level
&& other.inetCondition == inetCondition
&& other.iconGroup == iconGroup
&& other.activityIn == activityIn
&& other.activityOut == activityOut
&& other.rssi == rssi;
}
}
}

View File

@@ -28,6 +28,9 @@ import android.net.wifi.WifiManager;
import android.text.TextUtils;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settingslib.AccessibilityContentDescriptions;
import com.android.settingslib.SignalIcon.IconGroup;
import com.android.settingslib.SignalIcon.State;
import com.android.settingslib.wifi.WifiStatusTracker;
import com.android.systemui.R;
import com.android.systemui.statusbar.policy.NetworkController.IconState;
@@ -36,7 +39,7 @@ import com.android.systemui.statusbar.policy.NetworkController.SignalCallback;
import java.util.Objects;
public class WifiSignalController extends
SignalController<WifiSignalController.WifiState, SignalController.IconGroup> {
SignalController<WifiSignalController.WifiState, IconGroup> {
private final boolean mHasMobileDataFeature;
private final WifiStatusTracker mWifiTracker;
@@ -156,7 +159,7 @@ public class WifiSignalController extends
}
}
static class WifiState extends SignalController.State {
static class WifiState extends State {
String ssid;
boolean isTransient;
boolean isDefault;

View File

@@ -26,7 +26,8 @@ import android.test.suitebuilder.annotation.SmallTest;
import androidx.test.runner.AndroidJUnit4;
import com.android.systemui.R;
import com.android.settingslib.R;
import com.android.settingslib.mobile.TelephonyIcons;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.statusbar.policy.NetworkController.EmergencyListener;
import com.android.systemui.statusbar.policy.NetworkController.IconState;

View File

@@ -60,17 +60,18 @@ import android.util.Log;
import androidx.test.InstrumentationRegistry;
import com.android.settingslib.R;
import com.android.settingslib.graph.SignalDrawable;
import com.android.settingslib.mobile.MobileMappings.Config;
import com.android.settingslib.mobile.MobileStatusTracker.SubscriptionDefaults;
import com.android.settingslib.mobile.TelephonyIcons;
import com.android.settingslib.net.DataUsageController;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.demomode.DemoModeController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController.DeviceProvisionedListener;
import com.android.systemui.statusbar.policy.NetworkController.IconState;
import com.android.systemui.statusbar.policy.NetworkController.SignalCallback;
import com.android.systemui.statusbar.policy.NetworkControllerImpl.Config;
import org.junit.Before;
import org.junit.Rule;

View File

@@ -19,6 +19,7 @@ import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
import com.android.settingslib.mobile.TelephonyIcons;
import com.android.settingslib.net.DataUsageController;
import org.junit.Test;

View File

@@ -38,6 +38,7 @@ import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper.RunWithLooper;
import com.android.settingslib.graph.SignalDrawable;
import com.android.settingslib.mobile.TelephonyIcons;
import com.android.settingslib.net.DataUsageController;
import com.android.systemui.R;