Merge "[SB Refactor] Define MobileNetworkTypeIcon as an eventual replacement of MobileIconGroup and define a converter to convert from old to new." into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d4bfdcbe23
@@ -22,8 +22,11 @@ package com.android.settingslib;
|
|||||||
public class AccessibilityContentDescriptions {
|
public class AccessibilityContentDescriptions {
|
||||||
|
|
||||||
private AccessibilityContentDescriptions() {}
|
private AccessibilityContentDescriptions() {}
|
||||||
|
|
||||||
|
public static final int PHONE_SIGNAL_STRENGTH_NONE = R.string.accessibility_no_phone;
|
||||||
|
|
||||||
public static final int[] PHONE_SIGNAL_STRENGTH = {
|
public static final int[] PHONE_SIGNAL_STRENGTH = {
|
||||||
R.string.accessibility_no_phone,
|
PHONE_SIGNAL_STRENGTH_NONE,
|
||||||
R.string.accessibility_phone_one_bar,
|
R.string.accessibility_phone_one_bar,
|
||||||
R.string.accessibility_phone_two_bars,
|
R.string.accessibility_phone_two_bars,
|
||||||
R.string.accessibility_phone_three_bars,
|
R.string.accessibility_phone_three_bars,
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 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 androidx.annotation.DrawableRes
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A specification for the icon displaying the mobile network type -- 4G, 5G, LTE, etc. (aka "RAT
|
||||||
|
* icon" or "data type icon"). This is *not* the signal strength triangle.
|
||||||
|
*
|
||||||
|
* This is intended to eventually replace [SignalIcon.MobileIconGroup]. But for now,
|
||||||
|
* [MobileNetworkTypeIcons] just reads from the existing set of [SignalIcon.MobileIconGroup]
|
||||||
|
* instances to not duplicate data.
|
||||||
|
*
|
||||||
|
* TODO(b/238425913): Remove [SignalIcon.MobileIconGroup] and replace it with this class so that we
|
||||||
|
* don't need to fill in the superfluous fields from its parent [SignalIcon.IconGroup] class. Then
|
||||||
|
* this class can become either a sealed class or an enum with parameters.
|
||||||
|
*/
|
||||||
|
data class MobileNetworkTypeIcon(
|
||||||
|
/** A human-readable name for this network type, used for logging. */
|
||||||
|
val name: String,
|
||||||
|
|
||||||
|
/** The resource ID of the icon drawable to use. */
|
||||||
|
@DrawableRes val iconResId: Int,
|
||||||
|
|
||||||
|
/** The resource ID of the content description to use. */
|
||||||
|
@StringRes val contentDescriptionResId: Int,
|
||||||
|
)
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 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 com.android.settingslib.mobile.TelephonyIcons.ICON_NAME_TO_ICON
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A utility class to fetch instances of [MobileNetworkTypeIcon] given a
|
||||||
|
* [SignalIcon.MobileIconGroup].
|
||||||
|
*
|
||||||
|
* Use [getNetworkTypeIcon] to fetch the instances.
|
||||||
|
*/
|
||||||
|
class MobileNetworkTypeIcons {
|
||||||
|
companion object {
|
||||||
|
/**
|
||||||
|
* A map from a [SignalIcon.MobileIconGroup.name] to an instance of [MobileNetworkTypeIcon],
|
||||||
|
* which is the preferred class going forward.
|
||||||
|
*/
|
||||||
|
private val MOBILE_NETWORK_TYPE_ICONS: Map<String, MobileNetworkTypeIcon>
|
||||||
|
|
||||||
|
init {
|
||||||
|
// Build up the mapping from the old implementation to the new one.
|
||||||
|
val tempMap: MutableMap<String, MobileNetworkTypeIcon> = mutableMapOf()
|
||||||
|
|
||||||
|
ICON_NAME_TO_ICON.forEach { (_, mobileIconGroup) ->
|
||||||
|
tempMap[mobileIconGroup.name] = mobileIconGroup.toNetworkTypeIcon()
|
||||||
|
}
|
||||||
|
|
||||||
|
MOBILE_NETWORK_TYPE_ICONS = tempMap
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A converter function between the old mobile network type icon implementation and the new
|
||||||
|
* one. Given an instance of the old class [mobileIconGroup], outputs an instance of the
|
||||||
|
* new class [MobileNetworkTypeIcon].
|
||||||
|
*/
|
||||||
|
@JvmStatic
|
||||||
|
fun getNetworkTypeIcon(
|
||||||
|
mobileIconGroup: SignalIcon.MobileIconGroup
|
||||||
|
): MobileNetworkTypeIcon {
|
||||||
|
return MOBILE_NETWORK_TYPE_ICONS[mobileIconGroup.name]
|
||||||
|
?: mobileIconGroup.toNetworkTypeIcon()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun SignalIcon.MobileIconGroup.toNetworkTypeIcon(): MobileNetworkTypeIcon {
|
||||||
|
return MobileNetworkTypeIcon(
|
||||||
|
name = this.name,
|
||||||
|
iconResId = this.dataType,
|
||||||
|
contentDescriptionResId = this.dataContentDescription
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.settingslib;
|
package com.android.settingslib;
|
||||||
|
|
||||||
|
import androidx.annotation.DrawableRes;
|
||||||
|
import androidx.annotation.StringRes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Icons for SysUI and Settings.
|
* Icons for SysUI and Settings.
|
||||||
*/
|
*/
|
||||||
@@ -66,34 +69,31 @@ public class SignalIcon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds icons for a given MobileState.
|
* Holds RAT icons for a given MobileState.
|
||||||
*/
|
*/
|
||||||
public static class MobileIconGroup extends IconGroup {
|
public static class MobileIconGroup extends IconGroup {
|
||||||
public final int dataContentDescription; // mContentDescriptionDataType
|
@StringRes public final int dataContentDescription;
|
||||||
public final int dataType;
|
@DrawableRes public final int dataType;
|
||||||
|
|
||||||
public MobileIconGroup(
|
public MobileIconGroup(
|
||||||
String name,
|
String name,
|
||||||
int[][] sbIcons,
|
|
||||||
int[][] qsIcons,
|
|
||||||
int[] contentDesc,
|
|
||||||
int sbNullState,
|
|
||||||
int qsNullState,
|
|
||||||
int sbDiscState,
|
|
||||||
int qsDiscState,
|
|
||||||
int discContentDesc,
|
|
||||||
int dataContentDesc,
|
int dataContentDesc,
|
||||||
int dataType
|
int dataType
|
||||||
) {
|
) {
|
||||||
super(name,
|
super(name,
|
||||||
sbIcons,
|
// The rest of the values are the same for every type of MobileIconGroup, so
|
||||||
qsIcons,
|
// just provide them here.
|
||||||
contentDesc,
|
// TODO(b/238425913): Eventually replace with {@link MobileNetworkTypeIcon} so
|
||||||
sbNullState,
|
// that we don't have to fill in these superfluous fields.
|
||||||
qsNullState,
|
/* sbIcons= */ null,
|
||||||
sbDiscState,
|
/* qsIcons= */ null,
|
||||||
qsDiscState,
|
/* contentDesc= */ AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
||||||
discContentDesc);
|
/* sbNullState= */ 0,
|
||||||
|
/* qsNullState= */ 0,
|
||||||
|
/* sbDiscState= */ 0,
|
||||||
|
/* qsDiscState= */ 0,
|
||||||
|
/* discContentDesc= */
|
||||||
|
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH_NONE);
|
||||||
this.dataContentDescription = dataContentDesc;
|
this.dataContentDescription = dataContentDesc;
|
||||||
this.dataType = dataType;
|
this.dataType = dataType;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settingslib.mobile;
|
package com.android.settingslib.mobile;
|
||||||
|
|
||||||
import com.android.settingslib.AccessibilityContentDescriptions;
|
|
||||||
import com.android.settingslib.R;
|
import com.android.settingslib.R;
|
||||||
import com.android.settingslib.SignalIcon.MobileIconGroup;
|
import com.android.settingslib.SignalIcon.MobileIconGroup;
|
||||||
|
|
||||||
@@ -49,297 +48,129 @@ public class TelephonyIcons {
|
|||||||
|
|
||||||
public static final MobileIconGroup CARRIER_NETWORK_CHANGE = new MobileIconGroup(
|
public static final MobileIconGroup CARRIER_NETWORK_CHANGE = new MobileIconGroup(
|
||||||
"CARRIER_NETWORK_CHANGE",
|
"CARRIER_NETWORK_CHANGE",
|
||||||
null,
|
|
||||||
null,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
|
|
||||||
R.string.carrier_network_change_mode,
|
R.string.carrier_network_change_mode,
|
||||||
0
|
/* dataType= */ 0
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final MobileIconGroup THREE_G = new MobileIconGroup(
|
public static final MobileIconGroup THREE_G = new MobileIconGroup(
|
||||||
"3G",
|
"3G",
|
||||||
null,
|
|
||||||
null,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
|
|
||||||
R.string.data_connection_3g,
|
R.string.data_connection_3g,
|
||||||
TelephonyIcons.ICON_3G
|
TelephonyIcons.ICON_3G
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final MobileIconGroup WFC = new MobileIconGroup(
|
public static final MobileIconGroup WFC = new MobileIconGroup(
|
||||||
"WFC",
|
"WFC",
|
||||||
null,
|
/* dataContentDescription= */ 0,
|
||||||
null,
|
/* dataType= */ 0);
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
|
|
||||||
public static final MobileIconGroup UNKNOWN = new MobileIconGroup(
|
public static final MobileIconGroup UNKNOWN = new MobileIconGroup(
|
||||||
"Unknown",
|
"Unknown",
|
||||||
null,
|
/* dataContentDescription= */ 0,
|
||||||
null,
|
/* dataType= */ 0);
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
|
|
||||||
public static final MobileIconGroup E = new MobileIconGroup(
|
public static final MobileIconGroup E = new MobileIconGroup(
|
||||||
"E",
|
"E",
|
||||||
null,
|
|
||||||
null,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
|
|
||||||
R.string.data_connection_edge,
|
R.string.data_connection_edge,
|
||||||
TelephonyIcons.ICON_E
|
TelephonyIcons.ICON_E
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final MobileIconGroup ONE_X = new MobileIconGroup(
|
public static final MobileIconGroup ONE_X = new MobileIconGroup(
|
||||||
"1X",
|
"1X",
|
||||||
null,
|
|
||||||
null,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
|
|
||||||
R.string.data_connection_cdma,
|
R.string.data_connection_cdma,
|
||||||
TelephonyIcons.ICON_1X
|
TelephonyIcons.ICON_1X
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final MobileIconGroup G = new MobileIconGroup(
|
public static final MobileIconGroup G = new MobileIconGroup(
|
||||||
"G",
|
"G",
|
||||||
null,
|
|
||||||
null,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
|
|
||||||
R.string.data_connection_gprs,
|
R.string.data_connection_gprs,
|
||||||
TelephonyIcons.ICON_G
|
TelephonyIcons.ICON_G
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final MobileIconGroup H = new MobileIconGroup(
|
public static final MobileIconGroup H = new MobileIconGroup(
|
||||||
"H",
|
"H",
|
||||||
null,
|
|
||||||
null,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
|
|
||||||
R.string.data_connection_3_5g,
|
R.string.data_connection_3_5g,
|
||||||
TelephonyIcons.ICON_H
|
TelephonyIcons.ICON_H
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final MobileIconGroup H_PLUS = new MobileIconGroup(
|
public static final MobileIconGroup H_PLUS = new MobileIconGroup(
|
||||||
"H+",
|
"H+",
|
||||||
null,
|
|
||||||
null,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
|
|
||||||
R.string.data_connection_3_5g_plus,
|
R.string.data_connection_3_5g_plus,
|
||||||
TelephonyIcons.ICON_H_PLUS
|
TelephonyIcons.ICON_H_PLUS
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final MobileIconGroup FOUR_G = new MobileIconGroup(
|
public static final MobileIconGroup FOUR_G = new MobileIconGroup(
|
||||||
"4G",
|
"4G",
|
||||||
null,
|
|
||||||
null,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
|
|
||||||
R.string.data_connection_4g,
|
R.string.data_connection_4g,
|
||||||
TelephonyIcons.ICON_4G
|
TelephonyIcons.ICON_4G
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final MobileIconGroup FOUR_G_PLUS = new MobileIconGroup(
|
public static final MobileIconGroup FOUR_G_PLUS = new MobileIconGroup(
|
||||||
"4G+",
|
"4G+",
|
||||||
null,
|
|
||||||
null,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
|
|
||||||
R.string.data_connection_4g_plus,
|
R.string.data_connection_4g_plus,
|
||||||
TelephonyIcons.ICON_4G_PLUS
|
TelephonyIcons.ICON_4G_PLUS
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final MobileIconGroup LTE = new MobileIconGroup(
|
public static final MobileIconGroup LTE = new MobileIconGroup(
|
||||||
"LTE",
|
"LTE",
|
||||||
null,
|
|
||||||
null,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
|
|
||||||
R.string.data_connection_lte,
|
R.string.data_connection_lte,
|
||||||
TelephonyIcons.ICON_LTE
|
TelephonyIcons.ICON_LTE
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final MobileIconGroup LTE_PLUS = new MobileIconGroup(
|
public static final MobileIconGroup LTE_PLUS = new MobileIconGroup(
|
||||||
"LTE+",
|
"LTE+",
|
||||||
null,
|
|
||||||
null,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
|
|
||||||
R.string.data_connection_lte_plus,
|
R.string.data_connection_lte_plus,
|
||||||
TelephonyIcons.ICON_LTE_PLUS
|
TelephonyIcons.ICON_LTE_PLUS
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final MobileIconGroup FOUR_G_LTE = new MobileIconGroup(
|
public static final MobileIconGroup FOUR_G_LTE = new MobileIconGroup(
|
||||||
"4G LTE",
|
"4G LTE",
|
||||||
null,
|
|
||||||
null,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
|
|
||||||
R.string.data_connection_4g_lte,
|
R.string.data_connection_4g_lte,
|
||||||
TelephonyIcons.ICON_4G_LTE
|
TelephonyIcons.ICON_4G_LTE
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final MobileIconGroup FOUR_G_LTE_PLUS = new MobileIconGroup(
|
public static final MobileIconGroup FOUR_G_LTE_PLUS = new MobileIconGroup(
|
||||||
"4G LTE+",
|
"4G LTE+",
|
||||||
null,
|
|
||||||
null,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
|
|
||||||
R.string.data_connection_4g_lte_plus,
|
R.string.data_connection_4g_lte_plus,
|
||||||
TelephonyIcons.ICON_4G_LTE_PLUS
|
TelephonyIcons.ICON_4G_LTE_PLUS
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final MobileIconGroup LTE_CA_5G_E = new MobileIconGroup(
|
public static final MobileIconGroup LTE_CA_5G_E = new MobileIconGroup(
|
||||||
"5Ge",
|
"5Ge",
|
||||||
null,
|
|
||||||
null,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
|
|
||||||
R.string.data_connection_5ge_html,
|
R.string.data_connection_5ge_html,
|
||||||
TelephonyIcons.ICON_5G_E
|
TelephonyIcons.ICON_5G_E
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final MobileIconGroup NR_5G = new MobileIconGroup(
|
public static final MobileIconGroup NR_5G = new MobileIconGroup(
|
||||||
"5G",
|
"5G",
|
||||||
null,
|
|
||||||
null,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
|
|
||||||
R.string.data_connection_5g,
|
R.string.data_connection_5g,
|
||||||
TelephonyIcons.ICON_5G
|
TelephonyIcons.ICON_5G
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final MobileIconGroup NR_5G_PLUS = new MobileIconGroup(
|
public static final MobileIconGroup NR_5G_PLUS = new MobileIconGroup(
|
||||||
"5G_PLUS",
|
"5G_PLUS",
|
||||||
null,
|
|
||||||
null,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
|
|
||||||
R.string.data_connection_5g_plus,
|
R.string.data_connection_5g_plus,
|
||||||
TelephonyIcons.ICON_5G_PLUS
|
TelephonyIcons.ICON_5G_PLUS
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final MobileIconGroup DATA_DISABLED = new MobileIconGroup(
|
public static final MobileIconGroup DATA_DISABLED = new MobileIconGroup(
|
||||||
"DataDisabled",
|
"DataDisabled",
|
||||||
null,
|
|
||||||
null,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
|
|
||||||
R.string.cell_data_off_content_description,
|
R.string.cell_data_off_content_description,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final MobileIconGroup NOT_DEFAULT_DATA = new MobileIconGroup(
|
public static final MobileIconGroup NOT_DEFAULT_DATA = new MobileIconGroup(
|
||||||
"NotDefaultData",
|
"NotDefaultData",
|
||||||
null,
|
|
||||||
null,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
|
|
||||||
R.string.not_default_data_content_description,
|
R.string.not_default_data_content_description,
|
||||||
0
|
/* dataType= */ 0
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final MobileIconGroup CARRIER_MERGED_WIFI = new MobileIconGroup(
|
public static final MobileIconGroup CARRIER_MERGED_WIFI = new MobileIconGroup(
|
||||||
"CWF",
|
"CWF",
|
||||||
/* sbIcons= */ null,
|
|
||||||
/* qsIcons= */ null,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
|
|
||||||
/* sbNullState= */ 0,
|
|
||||||
/* qsNullState= */ 0,
|
|
||||||
/* sbDiscState= */ 0,
|
|
||||||
/* qsDiscState= */ 0,
|
|
||||||
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
|
|
||||||
R.string.data_connection_carrier_wifi,
|
R.string.data_connection_carrier_wifi,
|
||||||
TelephonyIcons.ICON_CWF
|
TelephonyIcons.ICON_CWF
|
||||||
);
|
);
|
||||||
|
|
||||||
// When adding a new MobileIconGround, check if the dataContentDescription has to be filtered
|
// When adding a new MobileIconGroup, check if the dataContentDescription has to be filtered
|
||||||
// in QSCarrier#hasValidTypeContentDescription
|
// in QSCarrier#hasValidTypeContentDescription
|
||||||
|
|
||||||
/** Mapping icon name(lower case) to the icon object. */
|
/** Mapping icon name(lower case) to the icon object. */
|
||||||
@@ -368,14 +199,6 @@ public class TelephonyIcons {
|
|||||||
ICON_NAME_TO_ICON.put("notdefaultdata", NOT_DEFAULT_DATA);
|
ICON_NAME_TO_ICON.put("notdefaultdata", NOT_DEFAULT_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final int[] WIFI_CALL_STRENGTH_ICONS = {
|
|
||||||
R.drawable.ic_wifi_call_strength_0,
|
|
||||||
R.drawable.ic_wifi_call_strength_1,
|
|
||||||
R.drawable.ic_wifi_call_strength_2,
|
|
||||||
R.drawable.ic_wifi_call_strength_3,
|
|
||||||
R.drawable.ic_wifi_call_strength_4
|
|
||||||
};
|
|
||||||
|
|
||||||
public static final int[] MOBILE_CALL_STRENGTH_ICONS = {
|
public static final int[] MOBILE_CALL_STRENGTH_ICONS = {
|
||||||
R.drawable.ic_mobile_call_strength_0,
|
R.drawable.ic_mobile_call_strength_0,
|
||||||
R.drawable.ic_mobile_call_strength_1,
|
R.drawable.ic_mobile_call_strength_1,
|
||||||
@@ -384,4 +207,3 @@ public class TelephonyIcons {
|
|||||||
R.drawable.ic_mobile_call_strength_4
|
R.drawable.ic_mobile_call_strength_4
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 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 com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import com.android.settingslib.mobile.TelephonyIcons;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
public class MobileNetworkTypeIconsTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getNetworkTypeIcon_hPlus_returnsHPlus() {
|
||||||
|
MobileNetworkTypeIcon icon =
|
||||||
|
MobileNetworkTypeIcons.getNetworkTypeIcon(TelephonyIcons.H_PLUS);
|
||||||
|
|
||||||
|
assertThat(icon.getName()).isEqualTo(TelephonyIcons.H_PLUS.name);
|
||||||
|
assertThat(icon.getIconResId()).isEqualTo(TelephonyIcons.ICON_H_PLUS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getNetworkTypeIcon_fourG_returnsFourG() {
|
||||||
|
MobileNetworkTypeIcon icon =
|
||||||
|
MobileNetworkTypeIcons.getNetworkTypeIcon(TelephonyIcons.FOUR_G);
|
||||||
|
|
||||||
|
assertThat(icon.getName()).isEqualTo(TelephonyIcons.H_PLUS.name);
|
||||||
|
assertThat(icon.getIconResId()).isEqualTo(TelephonyIcons.ICON_4G);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getNetworkTypeIcon_unknown_returnsUnknown() {
|
||||||
|
SignalIcon.MobileIconGroup unknownGroup =
|
||||||
|
new SignalIcon.MobileIconGroup("testUnknownNameHere", 45, 6);
|
||||||
|
|
||||||
|
MobileNetworkTypeIcon icon = MobileNetworkTypeIcons.getNetworkTypeIcon(unknownGroup);
|
||||||
|
|
||||||
|
assertThat(icon.getName()).isEqualTo("testUnknownNameHere");
|
||||||
|
assertThat(icon.getIconResId()).isEqualTo(45);
|
||||||
|
assertThat(icon.getContentDescriptionResId()).isEqualTo(6);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user