1 /* 2 * Copyright (C) 2024 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.phone.ui; 18 19 import android.annotation.Nullable; 20 import android.content.Context; 21 import android.text.TextUtils; 22 import android.util.ArraySet; 23 24 import com.android.internal.statusbar.StatusBarIcon; 25 import com.android.systemui.res.R; 26 import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.CallIndicatorIconState; 27 28 import java.util.List; 29 30 /** Interface controlling the icons shown in the status bar. */ 31 public interface StatusBarIconController { 32 33 /** 34 * When an icon is added with TAG_PRIMARY, it will be treated as the primary icon 35 * in that slot and not added as a sub slot. 36 */ 37 int TAG_PRIMARY = 0; 38 39 /** */ addIconGroup(IconManager iconManager)40 void addIconGroup(IconManager iconManager); 41 /** */ removeIconGroup(IconManager iconManager)42 void removeIconGroup(IconManager iconManager); 43 44 /** Refresh the state of an IconManager by recreating the views */ refreshIconGroup(IconManager iconManager)45 void refreshIconGroup(IconManager iconManager); 46 47 /** 48 * Adds or updates an icon that comes from an active tile service. 49 * 50 * If the icon is null, the icon will be removed. 51 */ setIconFromTile(String slot, @Nullable StatusBarIcon icon)52 void setIconFromTile(String slot, @Nullable StatusBarIcon icon); 53 54 /** Removes an icon that had come from an active tile service. */ removeIconForTile(String slot)55 void removeIconForTile(String slot); 56 57 /** Adds or updates an icon for the given slot for **internal system icons**. */ setIcon(String slot, int resourceId, CharSequence contentDescription)58 void setIcon(String slot, int resourceId, CharSequence contentDescription); 59 60 /** 61 * Sets up a wifi icon using the new data pipeline. No effect if the wifi icon has already been 62 * set up (inflated and added to the view hierarchy). 63 */ setNewWifiIcon()64 void setNewWifiIcon(); 65 66 /** 67 * Notify this class that there is a new set of mobile icons to display, keyed off of this list 68 * of subIds. The icons will be added and bound to the mobile data pipeline via 69 * {@link com.android.systemui.statusbar.pipeline.mobile.ui.binder.MobileIconBinder}. 70 */ setNewMobileIconSubIds(List<Integer> subIds)71 void setNewMobileIconSubIds(List<Integer> subIds); 72 /** 73 * Display the no calling & SMS icons. 74 */ setCallStrengthIcons(String slot, List<CallIndicatorIconState> states)75 void setCallStrengthIcons(String slot, List<CallIndicatorIconState> states); 76 77 /** 78 * Display the no calling & SMS icons. 79 */ setNoCallingIcons(String slot, List<CallIndicatorIconState> states)80 void setNoCallingIcons(String slot, List<CallIndicatorIconState> states); 81 82 /** Sets whether the icon in the given slot should be visible or not. */ setIconVisibility(String slot, boolean b)83 void setIconVisibility(String slot, boolean b); 84 85 /** 86 * Sets the live region mode for the icon 87 * 88 * @param slot Icon slot to set region for 89 * @param accessibilityLiveRegion live region mode for the icon 90 * @see android.view.View#setAccessibilityLiveRegion(int) 91 */ setIconAccessibilityLiveRegion(String slot, int accessibilityLiveRegion)92 void setIconAccessibilityLiveRegion(String slot, int accessibilityLiveRegion); 93 94 /** 95 * If you don't know what to pass for `tag`, either remove all icons for slot, or use 96 * TAG_PRIMARY to refer to the first icon at a given slot. 97 */ removeIcon(String slot, int tag)98 void removeIcon(String slot, int tag); 99 100 // TODO: See if we can rename this tunable name. 101 String ICON_HIDE_LIST = "icon_blacklist"; 102 103 /** Reads the default hide list from config value unless hideListStr is provided. */ getIconHideList(Context context, String hideListStr)104 static ArraySet<String> getIconHideList(Context context, String hideListStr) { 105 ArraySet<String> ret = new ArraySet<>(); 106 String[] hideList = hideListStr == null 107 ? context.getResources().getStringArray(R.array.config_statusBarIconsToExclude) 108 : hideListStr.split(","); 109 for (String slot : hideList) { 110 if (!TextUtils.isEmpty(slot)) { 111 ret.add(slot); 112 } 113 } 114 return ret; 115 } 116 117 } 118