1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.settingslib.mobile;
18 
19 import com.android.settingslib.AccessibilityContentDescriptions;
20 import com.android.settingslib.R;
21 import com.android.settingslib.SignalIcon.MobileIconGroup;
22 
23 import java.util.HashMap;
24 import java.util.Map;
25 
26 /**
27  * Telephony related icons and strings for SysUI and Settings.
28  */
29 public class TelephonyIcons {
30     //***** Data connection icons
31     public static final int FLIGHT_MODE_ICON = R.drawable.stat_sys_airplane_mode;
32 
33     public static final int ICON_LTE = R.drawable.ic_lte_mobiledata;
34     public static final int ICON_LTE_PLUS = R.drawable.ic_lte_plus_mobiledata;
35     public static final int ICON_G = R.drawable.ic_g_mobiledata;
36     public static final int ICON_E = R.drawable.ic_e_mobiledata;
37     public static final int ICON_H = R.drawable.ic_h_mobiledata;
38     public static final int ICON_H_PLUS = R.drawable.ic_h_plus_mobiledata;
39     public static final int ICON_3G = R.drawable.ic_3g_mobiledata;
40     public static final int ICON_4G = R.drawable.ic_4g_mobiledata;
41     public static final int ICON_4G_PLUS = R.drawable.ic_4g_plus_mobiledata;
42     public static final int ICON_5G_E = R.drawable.ic_5g_e_mobiledata;
43     public static final int ICON_1X = R.drawable.ic_1x_mobiledata;
44     public static final int ICON_5G = R.drawable.ic_5g_mobiledata;
45     public static final int ICON_5G_PLUS = R.drawable.ic_5g_plus_mobiledata;
46     public static final int ICON_CWF = R.drawable.ic_carrier_wifi;
47 
48     public static final MobileIconGroup CARRIER_NETWORK_CHANGE = new MobileIconGroup(
49             "CARRIER_NETWORK_CHANGE",
50             null,
51             null,
52             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
53             0,
54             0,
55             0,
56             0,
57             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
58             R.string.carrier_network_change_mode,
59             0
60     );
61 
62     public static final MobileIconGroup THREE_G = new MobileIconGroup(
63             "3G",
64             null,
65             null,
66             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
67             0,
68             0,
69             0,
70             0,
71             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
72             R.string.data_connection_3g,
73             TelephonyIcons.ICON_3G
74     );
75 
76     public static final MobileIconGroup WFC = new MobileIconGroup(
77             "WFC",
78             null,
79             null,
80             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
81             0,
82             0,
83             0,
84             0,
85             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
86             0,
87             0);
88 
89     public static final MobileIconGroup UNKNOWN = new MobileIconGroup(
90             "Unknown",
91             null,
92             null,
93             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
94             0,
95             0,
96             0,
97             0,
98             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
99             0,
100             0);
101 
102     public static final MobileIconGroup E = new MobileIconGroup(
103             "E",
104             null,
105             null,
106             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
107             0,
108             0,
109             0,
110             0,
111             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
112             R.string.data_connection_edge,
113             TelephonyIcons.ICON_E
114     );
115 
116     public static final MobileIconGroup ONE_X = new MobileIconGroup(
117             "1X",
118             null,
119             null,
120             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
121             0,
122             0,
123             0,
124             0,
125             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
126             R.string.data_connection_cdma,
127             TelephonyIcons.ICON_1X
128     );
129 
130     public static final MobileIconGroup G = new MobileIconGroup(
131             "G",
132             null,
133             null,
134             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
135             0,
136             0,
137             0,
138             0,
139             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
140             R.string.data_connection_gprs,
141             TelephonyIcons.ICON_G
142     );
143 
144     public static final MobileIconGroup H = new MobileIconGroup(
145             "H",
146             null,
147             null,
148             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
149             0,
150             0,
151             0,
152             0,
153             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
154             R.string.data_connection_3_5g,
155             TelephonyIcons.ICON_H
156     );
157 
158     public static final MobileIconGroup H_PLUS = new MobileIconGroup(
159             "H+",
160             null,
161             null,
162             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
163             0,
164             0,
165             0,
166             0,
167             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
168             R.string.data_connection_3_5g_plus,
169             TelephonyIcons.ICON_H_PLUS
170     );
171 
172     public static final MobileIconGroup FOUR_G = new MobileIconGroup(
173             "4G",
174             null,
175             null,
176             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
177             0,
178             0,
179             0,
180             0,
181             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
182             R.string.data_connection_4g,
183             TelephonyIcons.ICON_4G
184     );
185 
186     public static final MobileIconGroup FOUR_G_PLUS = new MobileIconGroup(
187             "4G+",
188             null,
189             null,
190             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
191             0,
192             0,
193             0,
194             0,
195             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
196             R.string.data_connection_4g_plus,
197             TelephonyIcons.ICON_4G_PLUS
198     );
199 
200     public static final MobileIconGroup LTE = new MobileIconGroup(
201             "LTE",
202             null,
203             null,
204             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
205             0,
206             0,
207             0,
208             0,
209             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
210             R.string.data_connection_lte,
211             TelephonyIcons.ICON_LTE
212     );
213 
214     public static final MobileIconGroup LTE_PLUS = new MobileIconGroup(
215             "LTE+",
216             null,
217             null,
218             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
219             0,
220             0,
221             0,
222             0,
223             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
224             R.string.data_connection_lte_plus,
225             TelephonyIcons.ICON_LTE_PLUS
226     );
227 
228     public static final MobileIconGroup LTE_CA_5G_E = new MobileIconGroup(
229             "5Ge",
230             null,
231             null,
232             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
233             0,
234             0,
235             0,
236             0,
237             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
238             R.string.data_connection_5ge_html,
239             TelephonyIcons.ICON_5G_E
240     );
241 
242     public static final MobileIconGroup NR_5G = new MobileIconGroup(
243             "5G",
244             null,
245             null,
246             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
247             0,
248             0,
249             0,
250             0,
251             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
252             R.string.data_connection_5g,
253             TelephonyIcons.ICON_5G
254     );
255 
256     public static final MobileIconGroup NR_5G_PLUS = new MobileIconGroup(
257             "5G_PLUS",
258             null,
259             null,
260             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
261             0,
262             0,
263             0,
264             0,
265             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
266             R.string.data_connection_5g_plus,
267             TelephonyIcons.ICON_5G_PLUS
268     );
269 
270     public static final MobileIconGroup DATA_DISABLED = new MobileIconGroup(
271             "DataDisabled",
272             null,
273             null,
274             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
275             0,
276             0,
277             0,
278             0,
279             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
280             R.string.cell_data_off_content_description,
281             0
282     );
283 
284     public static final MobileIconGroup NOT_DEFAULT_DATA = new MobileIconGroup(
285             "NotDefaultData",
286             null,
287             null,
288             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
289             0,
290             0,
291             0,
292             0,
293             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
294             R.string.not_default_data_content_description,
295             0
296     );
297 
298     public static final MobileIconGroup CARRIER_MERGED_WIFI = new MobileIconGroup(
299             "CWF",
300             /* sbIcons= */ null,
301             /* qsIcons= */ null,
302             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
303             /* sbNullState= */ 0,
304             /* qsNullState= */ 0,
305             /* sbDiscState= */ 0,
306             /* qsDiscState= */ 0,
307             AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
308             R.string.data_connection_carrier_wifi,
309             TelephonyIcons.ICON_CWF
310     );
311 
312     // When adding a new MobileIconGround, check if the dataContentDescription has to be filtered
313     // in QSCarrier#hasValidTypeContentDescription
314 
315     /** Mapping icon name(lower case) to the icon object. */
316     public static final Map<String, MobileIconGroup> ICON_NAME_TO_ICON;
317     static {
318         ICON_NAME_TO_ICON = new HashMap<>();
319         ICON_NAME_TO_ICON.put("carrier_network_change", CARRIER_NETWORK_CHANGE);
320         ICON_NAME_TO_ICON.put("3g", THREE_G);
321         ICON_NAME_TO_ICON.put("wfc", WFC);
322         ICON_NAME_TO_ICON.put("unknown", UNKNOWN);
323         ICON_NAME_TO_ICON.put("e", E);
324         ICON_NAME_TO_ICON.put("1x", ONE_X);
325         ICON_NAME_TO_ICON.put("g", G);
326         ICON_NAME_TO_ICON.put("h", H);
327         ICON_NAME_TO_ICON.put("h+", H_PLUS);
328         ICON_NAME_TO_ICON.put("4g", FOUR_G);
329         ICON_NAME_TO_ICON.put("4g+", FOUR_G_PLUS);
330         ICON_NAME_TO_ICON.put("5ge", LTE_CA_5G_E);
331         ICON_NAME_TO_ICON.put("lte", LTE);
332         ICON_NAME_TO_ICON.put("lte+", LTE_PLUS);
333         ICON_NAME_TO_ICON.put("5g", NR_5G);
334         ICON_NAME_TO_ICON.put("5g_plus", NR_5G_PLUS);
335         ICON_NAME_TO_ICON.put("datadisable", DATA_DISABLED);
336         ICON_NAME_TO_ICON.put("notdefaultdata", NOT_DEFAULT_DATA);
337     }
338 
339     public static final int[] WIFI_CALL_STRENGTH_ICONS = {
340         R.drawable.ic_wifi_call_strength_0,
341         R.drawable.ic_wifi_call_strength_1,
342         R.drawable.ic_wifi_call_strength_2,
343         R.drawable.ic_wifi_call_strength_3,
344         R.drawable.ic_wifi_call_strength_4
345     };
346 
347     public static final int[] MOBILE_CALL_STRENGTH_ICONS = {
348         R.drawable.ic_mobile_call_strength_0,
349         R.drawable.ic_mobile_call_strength_1,
350         R.drawable.ic_mobile_call_strength_2,
351         R.drawable.ic_mobile_call_strength_3,
352         R.drawable.ic_mobile_call_strength_4
353     };
354 }
355 
356