• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.systemui.statusbar.connectivity;
18 
19 import static com.android.settingslib.flags.Flags.newStatusBarIcons;
20 
21 import com.android.settingslib.AccessibilityContentDescriptions;
22 import com.android.settingslib.R;
23 import com.android.settingslib.SignalIcon.IconGroup;
24 
25 /** */
26 public class WifiIcons {
27 
28     public static final int[] WIFI_FULL_ICONS = getIconsBasedOnFlag();
29 
30     /**
31      * Check the aconfig flag to decide on which icons to use. Can be removed once the flag is gone
32      */
getIconsBasedOnFlag()33     private static int[] getIconsBasedOnFlag() {
34         if (newStatusBarIcons()) {
35             // TODO(b/396664075):
36             // The new wifi icons only define a range of [0, 3]. Since this array is indexed on
37             // level, we can simulate the range squash by mapping both level 3 to drawn-level 2, and
38             // level 4 to drawn-level 3
39             return new int[] {
40                 R.drawable.ic_wifi_0,
41                 R.drawable.ic_wifi_1,
42                 R.drawable.ic_wifi_2,
43                 R.drawable.ic_wifi_2,
44                 R.drawable.ic_wifi_3
45             };
46         } else {
47             return new int[] {
48                 com.android.internal.R.drawable.ic_wifi_signal_0,
49                 com.android.internal.R.drawable.ic_wifi_signal_1,
50                 com.android.internal.R.drawable.ic_wifi_signal_2,
51                 com.android.internal.R.drawable.ic_wifi_signal_3,
52                 com.android.internal.R.drawable.ic_wifi_signal_4
53             };
54         }
55     }
56 
57     public static final int[] WIFI_NO_INTERNET_ICONS = getErrorIconsBasedOnFlag();
58 
getErrorIconsBasedOnFlag()59     private static int [] getErrorIconsBasedOnFlag() {
60         if (newStatusBarIcons()) {
61             // See above note, new wifi icons only have 3 bars, so levels 2 and 3 are the same
62             return new int[] {
63                 R.drawable.ic_wifi_0_error,
64                 R.drawable.ic_wifi_1_error,
65                 R.drawable.ic_wifi_2_error,
66                 R.drawable.ic_wifi_2_error,
67                 R.drawable.ic_wifi_3_error,
68             };
69         } else {
70             return new int[] {
71                 R.drawable.ic_no_internet_wifi_signal_0,
72                 R.drawable.ic_no_internet_wifi_signal_1,
73                 R.drawable.ic_no_internet_wifi_signal_2,
74                 R.drawable.ic_no_internet_wifi_signal_3,
75                 R.drawable.ic_no_internet_wifi_signal_4
76             };
77         }
78     }
79 
80     public static final int[][] QS_WIFI_SIGNAL_STRENGTH = {
81             WIFI_NO_INTERNET_ICONS,
82             WIFI_FULL_ICONS
83     };
84 
85     static final int[][] WIFI_SIGNAL_STRENGTH = QS_WIFI_SIGNAL_STRENGTH;
86 
87     public static final int QS_WIFI_DISABLED = com.android.internal.R.drawable.ic_wifi_signal_0;
88     public static final int QS_WIFI_NO_NETWORK = com.android.internal.R.drawable.ic_wifi_signal_0;
89     public static final int WIFI_NO_NETWORK = QS_WIFI_NO_NETWORK;
90 
91     static final int WIFI_LEVEL_COUNT = WIFI_SIGNAL_STRENGTH[0].length;
92 
93     public static final IconGroup UNMERGED_WIFI = new IconGroup(
94             "Wi-Fi Icons",
95             WifiIcons.WIFI_SIGNAL_STRENGTH,
96             WifiIcons.QS_WIFI_SIGNAL_STRENGTH,
97             AccessibilityContentDescriptions.WIFI_CONNECTION_STRENGTH,
98             WifiIcons.WIFI_NO_NETWORK,
99             WifiIcons.QS_WIFI_NO_NETWORK,
100             WifiIcons.WIFI_NO_NETWORK,
101             WifiIcons.QS_WIFI_NO_NETWORK,
102             AccessibilityContentDescriptions.WIFI_NO_CONNECTION
103     );
104 }
105