1 /* <lambda>null2 * Copyright (C) 2022 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 package com.android.systemui.statusbar.phone.fragment 17 18 import android.content.res.Resources 19 import android.os.UserHandle 20 import android.provider.Settings 21 import com.android.internal.R 22 import com.android.systemui.util.settings.SecureSettings 23 24 /** 25 * Centralize the logic for the status bar / keyguard status bar icon blocklist. The default is 26 * loaded from the config, and we currently support a system setting for the vibrate icon. It's 27 * pretty likely that we would end up supporting more user-configurable settings in the future, so 28 * breaking this out into its own file for now. 29 * 30 * Note for the future: it might be reasonable to turn this into its own class that can listen to 31 * the system setting and execute a callback when it changes instead of having multiple content 32 * observers. 33 */ 34 fun getStatusBarIconBlocklist( 35 res: Resources, 36 settings: SecureSettings 37 ): List<String> { 38 // Load the default blocklist from res 39 val blocklist = res.getStringArray( 40 com.android.systemui.res.R.array.config_collapsed_statusbar_icon_blocklist).toList() 41 42 val vibrateIconSlot: String = res.getString(R.string.status_bar_volume) 43 val showVibrateIcon = settings.getIntForUser( 44 Settings.Secure.STATUS_BAR_SHOW_VIBRATE_ICON, 45 0, 46 UserHandle.USER_CURRENT) == 0 47 48 // Filter out vibrate icon from the blocklist if the setting is on 49 return blocklist.filter { icon -> 50 !icon.equals(vibrateIconSlot) || showVibrateIcon 51 } 52 }