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