The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 17 | package android.app; |
| 18 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 19 | import android.annotation.IntDef; |
Evan Laird | 2c4d0cf | 2019-02-28 12:10:29 -0500 | [diff] [blame] | 20 | import android.annotation.NonNull; |
Fabian Kozynski | e3137e3 | 2018-09-28 11:20:04 -0400 | [diff] [blame] | 21 | import android.annotation.Nullable; |
Evan Laird | ab19659 | 2019-02-26 17:21:32 -0500 | [diff] [blame] | 22 | import android.annotation.RequiresPermission; |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 23 | import android.annotation.SystemApi; |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 24 | import android.annotation.SystemService; |
Evan Laird | 418ba8f | 2019-04-17 15:55:21 -0400 | [diff] [blame] | 25 | import android.annotation.TestApi; |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 26 | import android.annotation.UnsupportedAppUsage; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | import android.content.Context; |
| 28 | import android.os.Binder; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | import android.os.IBinder; |
Charles He | ede3909 | 2017-09-18 09:19:28 +0100 | [diff] [blame] | 30 | import android.os.RemoteException; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | import android.os.ServiceManager; |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 32 | import android.util.Pair; |
Daniel Sandler | 9cbd360 | 2011-10-18 22:59:00 -0400 | [diff] [blame] | 33 | import android.util.Slog; |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 34 | import android.view.View; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 36 | import com.android.internal.statusbar.IStatusBarService; |
| 37 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 38 | import java.lang.annotation.Retention; |
| 39 | import java.lang.annotation.RetentionPolicy; |
| 40 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | /** |
| 42 | * Allows an app to control the status bar. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 44 | @SystemService(Context.STATUS_BAR_SERVICE) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 45 | public class StatusBarManager { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 46 | |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 47 | /** @hide */ |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 48 | public static final int DISABLE_EXPAND = View.STATUS_BAR_DISABLE_EXPAND; |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 49 | /** @hide */ |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 50 | public static final int DISABLE_NOTIFICATION_ICONS = View.STATUS_BAR_DISABLE_NOTIFICATION_ICONS; |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 51 | /** @hide */ |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 52 | public static final int DISABLE_NOTIFICATION_ALERTS |
| 53 | = View.STATUS_BAR_DISABLE_NOTIFICATION_ALERTS; |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 54 | |
| 55 | /** @hide */ |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 56 | @Deprecated |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 57 | @UnsupportedAppUsage |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 58 | public static final int DISABLE_NOTIFICATION_TICKER |
| 59 | = View.STATUS_BAR_DISABLE_NOTIFICATION_TICKER; |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 60 | /** @hide */ |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 61 | public static final int DISABLE_SYSTEM_INFO = View.STATUS_BAR_DISABLE_SYSTEM_INFO; |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 62 | /** @hide */ |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame] | 63 | public static final int DISABLE_HOME = View.STATUS_BAR_DISABLE_HOME; |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 64 | /** @hide */ |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame] | 65 | public static final int DISABLE_RECENT = View.STATUS_BAR_DISABLE_RECENT; |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 66 | /** @hide */ |
Joe Onorato | 6478adc | 2011-01-27 21:15:01 -0800 | [diff] [blame] | 67 | public static final int DISABLE_BACK = View.STATUS_BAR_DISABLE_BACK; |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 68 | /** @hide */ |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 69 | public static final int DISABLE_CLOCK = View.STATUS_BAR_DISABLE_CLOCK; |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 70 | /** @hide */ |
Daniel Sandler | d5483c3 | 2012-10-19 16:44:15 -0400 | [diff] [blame] | 71 | public static final int DISABLE_SEARCH = View.STATUS_BAR_DISABLE_SEARCH; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 72 | |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 73 | /** @hide */ |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame] | 74 | @Deprecated |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 75 | public static final int DISABLE_NAVIGATION = |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame] | 76 | View.STATUS_BAR_DISABLE_HOME | View.STATUS_BAR_DISABLE_RECENT; |
| 77 | |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 78 | /** @hide */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 79 | public static final int DISABLE_NONE = 0x00000000; |
| 80 | |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 81 | /** @hide */ |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 82 | public static final int DISABLE_MASK = DISABLE_EXPAND | DISABLE_NOTIFICATION_ICONS |
| 83 | | DISABLE_NOTIFICATION_ALERTS | DISABLE_NOTIFICATION_TICKER |
Daniel Sandler | d5483c3 | 2012-10-19 16:44:15 -0400 | [diff] [blame] | 84 | | DISABLE_SYSTEM_INFO | DISABLE_RECENT | DISABLE_HOME | DISABLE_BACK | DISABLE_CLOCK |
| 85 | | DISABLE_SEARCH; |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 86 | |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 87 | /** @hide */ |
Charles Chen | f3d295c | 2018-11-30 18:15:21 +0800 | [diff] [blame] | 88 | @IntDef(flag = true, prefix = {"DISABLE_"}, value = { |
| 89 | DISABLE_NONE, |
| 90 | DISABLE_EXPAND, |
| 91 | DISABLE_NOTIFICATION_ICONS, |
| 92 | DISABLE_NOTIFICATION_ALERTS, |
| 93 | DISABLE_NOTIFICATION_TICKER, |
| 94 | DISABLE_SYSTEM_INFO, |
| 95 | DISABLE_HOME, |
| 96 | DISABLE_RECENT, |
| 97 | DISABLE_BACK, |
| 98 | DISABLE_CLOCK, |
| 99 | DISABLE_SEARCH |
| 100 | }) |
| 101 | @Retention(RetentionPolicy.SOURCE) |
| 102 | public @interface DisableFlags {} |
| 103 | |
Benjamin Franz | 27cf146 | 2015-04-23 19:36:42 +0100 | [diff] [blame] | 104 | /** |
| 105 | * Flag to disable quick settings. |
| 106 | * |
| 107 | * Setting this flag disables quick settings completely, but does not disable expanding the |
| 108 | * notification shade. |
| 109 | */ |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 110 | /** @hide */ |
Charles He | 6a79b0d | 2017-09-18 09:50:58 +0100 | [diff] [blame] | 111 | public static final int DISABLE2_QUICK_SETTINGS = 1; |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 112 | /** @hide */ |
Charles He | 6a79b0d | 2017-09-18 09:50:58 +0100 | [diff] [blame] | 113 | public static final int DISABLE2_SYSTEM_ICONS = 1 << 1; |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 114 | /** @hide */ |
Charles He | 2eda242 | 2017-09-24 17:55:21 +0100 | [diff] [blame] | 115 | public static final int DISABLE2_NOTIFICATION_SHADE = 1 << 2; |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 116 | /** @hide */ |
Charles He | 9851a8d | 2017-10-10 17:31:30 +0100 | [diff] [blame] | 117 | public static final int DISABLE2_GLOBAL_ACTIONS = 1 << 3; |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 118 | /** @hide */ |
Mike Digman | dd2f49e | 2018-03-16 10:54:22 -0700 | [diff] [blame] | 119 | public static final int DISABLE2_ROTATE_SUGGESTIONS = 1 << 4; |
Benjamin Franz | 27cf146 | 2015-04-23 19:36:42 +0100 | [diff] [blame] | 120 | |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 121 | /** @hide */ |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 122 | public static final int DISABLE2_NONE = 0x00000000; |
| 123 | |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 124 | /** @hide */ |
Charles He | 2eda242 | 2017-09-24 17:55:21 +0100 | [diff] [blame] | 125 | public static final int DISABLE2_MASK = DISABLE2_QUICK_SETTINGS | DISABLE2_SYSTEM_ICONS |
Mike Digman | dd2f49e | 2018-03-16 10:54:22 -0700 | [diff] [blame] | 126 | | DISABLE2_NOTIFICATION_SHADE | DISABLE2_GLOBAL_ACTIONS | DISABLE2_ROTATE_SUGGESTIONS; |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 127 | |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 128 | /** @hide */ |
Jeff Sharkey | ce8db99 | 2017-12-13 20:05:05 -0700 | [diff] [blame] | 129 | @IntDef(flag = true, prefix = { "DISABLE2_" }, value = { |
| 130 | DISABLE2_NONE, |
| 131 | DISABLE2_MASK, |
| 132 | DISABLE2_QUICK_SETTINGS, |
| 133 | DISABLE2_SYSTEM_ICONS, |
| 134 | DISABLE2_NOTIFICATION_SHADE, |
Mike Digman | dd2f49e | 2018-03-16 10:54:22 -0700 | [diff] [blame] | 135 | DISABLE2_GLOBAL_ACTIONS, |
| 136 | DISABLE2_ROTATE_SUGGESTIONS |
Jeff Sharkey | ce8db99 | 2017-12-13 20:05:05 -0700 | [diff] [blame] | 137 | }) |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 138 | @Retention(RetentionPolicy.SOURCE) |
| 139 | public @interface Disable2Flags {} |
| 140 | |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 141 | /** |
| 142 | * Default disable flags for setup |
| 143 | * |
| 144 | * @hide |
| 145 | */ |
| 146 | public static final int DEFAULT_SETUP_DISABLE_FLAGS = DISABLE_NOTIFICATION_ALERTS |
| 147 | | DISABLE_HOME | DISABLE_EXPAND | DISABLE_RECENT | DISABLE_CLOCK | DISABLE_SEARCH; |
| 148 | |
| 149 | /** |
| 150 | * Default disable2 flags for setup |
| 151 | * |
| 152 | * @hide |
| 153 | */ |
| 154 | public static final int DEFAULT_SETUP_DISABLE2_FLAGS = DISABLE2_ROTATE_SUGGESTIONS; |
| 155 | |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 156 | /** @hide */ |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 157 | public static final int NAVIGATION_HINT_BACK_ALT = 1 << 0; |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 158 | /** @hide */ |
Jason Monk | f1ff209 | 2014-04-29 16:50:53 -0400 | [diff] [blame] | 159 | public static final int NAVIGATION_HINT_IME_SHOWN = 1 << 1; |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 160 | |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 161 | /** @hide */ |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 162 | public static final int WINDOW_STATUS_BAR = 1; |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 163 | /** @hide */ |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 164 | public static final int WINDOW_NAVIGATION_BAR = 2; |
| 165 | |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 166 | /** @hide */ |
Charles Chen | f3d295c | 2018-11-30 18:15:21 +0800 | [diff] [blame] | 167 | @IntDef(flag = true, prefix = { "WINDOW_" }, value = { |
| 168 | WINDOW_STATUS_BAR, |
| 169 | WINDOW_NAVIGATION_BAR |
| 170 | }) |
| 171 | @Retention(RetentionPolicy.SOURCE) |
| 172 | public @interface WindowType {} |
| 173 | |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 174 | /** @hide */ |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 175 | public static final int WINDOW_STATE_SHOWING = 0; |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 176 | /** @hide */ |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 177 | public static final int WINDOW_STATE_HIDING = 1; |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 178 | /** @hide */ |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 179 | public static final int WINDOW_STATE_HIDDEN = 2; |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 180 | |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 181 | /** @hide */ |
Charles Chen | f3d295c | 2018-11-30 18:15:21 +0800 | [diff] [blame] | 182 | @IntDef(flag = true, prefix = { "WINDOW_STATE_" }, value = { |
| 183 | WINDOW_STATE_SHOWING, |
| 184 | WINDOW_STATE_HIDING, |
| 185 | WINDOW_STATE_HIDDEN |
| 186 | }) |
| 187 | @Retention(RetentionPolicy.SOURCE) |
| 188 | public @interface WindowVisibleState {} |
| 189 | |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 190 | /** @hide */ |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 191 | public static final int CAMERA_LAUNCH_SOURCE_WIGGLE = 0; |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 192 | /** @hide */ |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 193 | public static final int CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP = 1; |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 194 | /** @hide */ |
Jonathan Solnit | a413816 | 2017-05-10 21:06:04 -0700 | [diff] [blame] | 195 | public static final int CAMERA_LAUNCH_SOURCE_LIFT_TRIGGER = 2; |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 196 | |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 197 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 198 | private Context mContext; |
Joe Onorato | 25f95f9 | 2010-04-08 18:37:10 -0500 | [diff] [blame] | 199 | private IStatusBarService mService; |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 200 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 201 | private IBinder mToken = new Binder(); |
| 202 | |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 203 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 204 | StatusBarManager(Context context) { |
| 205 | mContext = context; |
Daniel Sandler | 9cbd360 | 2011-10-18 22:59:00 -0400 | [diff] [blame] | 206 | } |
| 207 | |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 208 | @UnsupportedAppUsage |
Daniel Sandler | 9cbd360 | 2011-10-18 22:59:00 -0400 | [diff] [blame] | 209 | private synchronized IStatusBarService getService() { |
| 210 | if (mService == null) { |
| 211 | mService = IStatusBarService.Stub.asInterface( |
| 212 | ServiceManager.getService(Context.STATUS_BAR_SERVICE)); |
| 213 | if (mService == null) { |
| 214 | Slog.w("StatusBarManager", "warning: no STATUS_BAR_SERVICE"); |
| 215 | } |
| 216 | } |
| 217 | return mService; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | /** |
| 221 | * Disable some features in the status bar. Pass the bitwise-or of the DISABLE_* flags. |
| 222 | * To re-enable everything, pass {@link #DISABLE_NONE}. |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 223 | * |
| 224 | * @hide |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 225 | */ |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 226 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 227 | public void disable(int what) { |
| 228 | try { |
Evan Laird | a6917e1 | 2018-05-29 17:28:58 -0400 | [diff] [blame] | 229 | final int userId = Binder.getCallingUserHandle().getIdentifier(); |
Daniel Sandler | 9cbd360 | 2011-10-18 22:59:00 -0400 | [diff] [blame] | 230 | final IStatusBarService svc = getService(); |
| 231 | if (svc != null) { |
Evan Laird | a6917e1 | 2018-05-29 17:28:58 -0400 | [diff] [blame] | 232 | svc.disableForUser(what, mToken, mContext.getPackageName(), userId); |
Jim Miller | 305c78c | 2011-10-16 14:54:38 -0700 | [diff] [blame] | 233 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 234 | } catch (RemoteException ex) { |
Jeff Sharkey | c53962d | 2016-03-01 19:27:23 -0700 | [diff] [blame] | 235 | throw ex.rethrowFromSystemServer(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 236 | } |
| 237 | } |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 238 | |
| 239 | /** |
| 240 | * Disable additional status bar features. Pass the bitwise-or of the DISABLE2_* flags. |
| 241 | * To re-enable everything, pass {@link #DISABLE_NONE}. |
| 242 | * |
| 243 | * Warning: Only pass DISABLE2_* flags into this function, do not use DISABLE_* flags. |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 244 | * |
| 245 | * @hide |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 246 | */ |
| 247 | public void disable2(@Disable2Flags int what) { |
| 248 | try { |
Evan Laird | a6917e1 | 2018-05-29 17:28:58 -0400 | [diff] [blame] | 249 | final int userId = Binder.getCallingUserHandle().getIdentifier(); |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 250 | final IStatusBarService svc = getService(); |
| 251 | if (svc != null) { |
Evan Laird | a6917e1 | 2018-05-29 17:28:58 -0400 | [diff] [blame] | 252 | svc.disable2ForUser(what, mToken, mContext.getPackageName(), userId); |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 253 | } |
| 254 | } catch (RemoteException ex) { |
Jeff Sharkey | c53962d | 2016-03-01 19:27:23 -0700 | [diff] [blame] | 255 | throw ex.rethrowFromSystemServer(); |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 256 | } |
| 257 | } |
| 258 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 259 | /** |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 260 | * Expand the notifications panel. |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 261 | * |
| 262 | * @hide |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 263 | */ |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 264 | @UnsupportedAppUsage |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 265 | public void expandNotificationsPanel() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 266 | try { |
Daniel Sandler | 9cbd360 | 2011-10-18 22:59:00 -0400 | [diff] [blame] | 267 | final IStatusBarService svc = getService(); |
| 268 | if (svc != null) { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 269 | svc.expandNotificationsPanel(); |
Daniel Sandler | 9cbd360 | 2011-10-18 22:59:00 -0400 | [diff] [blame] | 270 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 271 | } catch (RemoteException ex) { |
Jeff Sharkey | c53962d | 2016-03-01 19:27:23 -0700 | [diff] [blame] | 272 | throw ex.rethrowFromSystemServer(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 273 | } |
| 274 | } |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 275 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 276 | /** |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 277 | * Collapse the notifications and settings panels. |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 278 | * |
| 279 | * @hide |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 280 | */ |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 281 | @UnsupportedAppUsage |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 282 | public void collapsePanels() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 283 | try { |
Daniel Sandler | 9cbd360 | 2011-10-18 22:59:00 -0400 | [diff] [blame] | 284 | final IStatusBarService svc = getService(); |
| 285 | if (svc != null) { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 286 | svc.collapsePanels(); |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 287 | } |
| 288 | } catch (RemoteException ex) { |
Jeff Sharkey | c53962d | 2016-03-01 19:27:23 -0700 | [diff] [blame] | 289 | throw ex.rethrowFromSystemServer(); |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 290 | } |
| 291 | } |
| 292 | |
| 293 | /** |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 294 | * Expand the settings panel. |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 295 | * |
| 296 | * @hide |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 297 | */ |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 298 | @UnsupportedAppUsage |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 299 | public void expandSettingsPanel() { |
Jason Monk | a992732 | 2015-12-13 16:22:37 -0500 | [diff] [blame] | 300 | expandSettingsPanel(null); |
| 301 | } |
| 302 | |
| 303 | /** |
Fabian Kozynski | e3137e3 | 2018-09-28 11:20:04 -0400 | [diff] [blame] | 304 | * Expand the settings panel and open a subPanel. If the subpanel is null or does not have a |
| 305 | * corresponding tile, the QS panel is simply expanded |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 306 | * |
| 307 | * @hide |
Jason Monk | a992732 | 2015-12-13 16:22:37 -0500 | [diff] [blame] | 308 | */ |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 309 | @UnsupportedAppUsage |
Fabian Kozynski | e3137e3 | 2018-09-28 11:20:04 -0400 | [diff] [blame] | 310 | public void expandSettingsPanel(@Nullable String subPanel) { |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 311 | try { |
| 312 | final IStatusBarService svc = getService(); |
| 313 | if (svc != null) { |
Jason Monk | a992732 | 2015-12-13 16:22:37 -0500 | [diff] [blame] | 314 | svc.expandSettingsPanel(subPanel); |
Daniel Sandler | 9cbd360 | 2011-10-18 22:59:00 -0400 | [diff] [blame] | 315 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 316 | } catch (RemoteException ex) { |
Jeff Sharkey | c53962d | 2016-03-01 19:27:23 -0700 | [diff] [blame] | 317 | throw ex.rethrowFromSystemServer(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 318 | } |
| 319 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 320 | |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 321 | /** @hide */ |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 322 | @UnsupportedAppUsage |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 323 | public void setIcon(String slot, int iconId, int iconLevel, String contentDescription) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 324 | try { |
Daniel Sandler | 9cbd360 | 2011-10-18 22:59:00 -0400 | [diff] [blame] | 325 | final IStatusBarService svc = getService(); |
| 326 | if (svc != null) { |
| 327 | svc.setIcon(slot, mContext.getPackageName(), iconId, iconLevel, |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 328 | contentDescription); |
Daniel Sandler | 9cbd360 | 2011-10-18 22:59:00 -0400 | [diff] [blame] | 329 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 330 | } catch (RemoteException ex) { |
Jeff Sharkey | c53962d | 2016-03-01 19:27:23 -0700 | [diff] [blame] | 331 | throw ex.rethrowFromSystemServer(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 332 | } |
| 333 | } |
| 334 | |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 335 | /** @hide */ |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 336 | @UnsupportedAppUsage |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 337 | public void removeIcon(String slot) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 338 | try { |
Daniel Sandler | 9cbd360 | 2011-10-18 22:59:00 -0400 | [diff] [blame] | 339 | final IStatusBarService svc = getService(); |
| 340 | if (svc != null) { |
| 341 | svc.removeIcon(slot); |
| 342 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 343 | } catch (RemoteException ex) { |
Jeff Sharkey | c53962d | 2016-03-01 19:27:23 -0700 | [diff] [blame] | 344 | throw ex.rethrowFromSystemServer(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 345 | } |
| 346 | } |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 347 | |
Evan Laird | 2732324 | 2019-01-11 16:08:07 -0500 | [diff] [blame] | 348 | /** @hide */ |
Mathew Inwood | 61e8ae6 | 2018-08-14 14:17:44 +0100 | [diff] [blame] | 349 | @UnsupportedAppUsage |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 350 | public void setIconVisibility(String slot, boolean visible) { |
| 351 | try { |
Daniel Sandler | 9cbd360 | 2011-10-18 22:59:00 -0400 | [diff] [blame] | 352 | final IStatusBarService svc = getService(); |
| 353 | if (svc != null) { |
| 354 | svc.setIconVisibility(slot, visible); |
| 355 | } |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 356 | } catch (RemoteException ex) { |
Jeff Sharkey | c53962d | 2016-03-01 19:27:23 -0700 | [diff] [blame] | 357 | throw ex.rethrowFromSystemServer(); |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 358 | } |
| 359 | } |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 360 | |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 361 | /** |
| 362 | * Enable or disable status bar elements (notifications, clock) which are inappropriate during |
| 363 | * device setup. |
| 364 | * |
| 365 | * @param disabled whether to apply or remove the disabled flags |
| 366 | * |
| 367 | * @hide |
| 368 | */ |
| 369 | @SystemApi |
Evan Laird | 418ba8f | 2019-04-17 15:55:21 -0400 | [diff] [blame] | 370 | @TestApi |
Evan Laird | ab19659 | 2019-02-26 17:21:32 -0500 | [diff] [blame] | 371 | @RequiresPermission(android.Manifest.permission.STATUS_BAR) |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 372 | public void setDisabledForSetup(boolean disabled) { |
| 373 | try { |
| 374 | final int userId = Binder.getCallingUserHandle().getIdentifier(); |
| 375 | final IStatusBarService svc = getService(); |
| 376 | if (svc != null) { |
| 377 | svc.disableForUser(disabled ? DEFAULT_SETUP_DISABLE_FLAGS : DISABLE_NONE, |
| 378 | mToken, mContext.getPackageName(), userId); |
| 379 | svc.disable2ForUser(disabled ? DEFAULT_SETUP_DISABLE2_FLAGS : DISABLE2_NONE, |
| 380 | mToken, mContext.getPackageName(), userId); |
| 381 | } |
| 382 | } catch (RemoteException ex) { |
| 383 | throw ex.rethrowFromSystemServer(); |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | /** |
Evan Laird | ced4aeb | 2019-01-28 16:52:41 -0500 | [diff] [blame] | 388 | * Get this app's currently requested disabled components |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 389 | * |
Evan Laird | ced4aeb | 2019-01-28 16:52:41 -0500 | [diff] [blame] | 390 | * @return a new DisableInfo |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 391 | * |
| 392 | * @hide |
| 393 | */ |
| 394 | @SystemApi |
Evan Laird | 418ba8f | 2019-04-17 15:55:21 -0400 | [diff] [blame] | 395 | @TestApi |
Evan Laird | ab19659 | 2019-02-26 17:21:32 -0500 | [diff] [blame] | 396 | @RequiresPermission(android.Manifest.permission.STATUS_BAR) |
Evan Laird | 2c4d0cf | 2019-02-28 12:10:29 -0500 | [diff] [blame] | 397 | @NonNull |
Evan Laird | ced4aeb | 2019-01-28 16:52:41 -0500 | [diff] [blame] | 398 | public DisableInfo getDisableInfo() { |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 399 | try { |
| 400 | final int userId = Binder.getCallingUserHandle().getIdentifier(); |
| 401 | final IStatusBarService svc = getService(); |
| 402 | int[] flags = new int[] {0, 0}; |
| 403 | if (svc != null) { |
| 404 | flags = svc.getDisableFlags(mToken, userId); |
| 405 | } |
| 406 | |
Evan Laird | ced4aeb | 2019-01-28 16:52:41 -0500 | [diff] [blame] | 407 | return new DisableInfo(flags[0], flags[1]); |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 408 | } catch (RemoteException ex) { |
| 409 | throw ex.rethrowFromSystemServer(); |
| 410 | } |
| 411 | } |
| 412 | |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 413 | /** @hide */ |
| 414 | public static String windowStateToString(int state) { |
| 415 | if (state == WINDOW_STATE_HIDING) return "WINDOW_STATE_HIDING"; |
| 416 | if (state == WINDOW_STATE_HIDDEN) return "WINDOW_STATE_HIDDEN"; |
| 417 | if (state == WINDOW_STATE_SHOWING) return "WINDOW_STATE_SHOWING"; |
| 418 | return "WINDOW_STATE_UNKNOWN"; |
| 419 | } |
Evan Laird | ced4aeb | 2019-01-28 16:52:41 -0500 | [diff] [blame] | 420 | |
| 421 | /** |
| 422 | * DisableInfo describes this app's requested state of the StatusBar with regards to which |
| 423 | * components are enabled/disabled |
| 424 | * |
| 425 | * @hide |
| 426 | */ |
| 427 | @SystemApi |
Evan Laird | 418ba8f | 2019-04-17 15:55:21 -0400 | [diff] [blame] | 428 | @TestApi |
Evan Laird | ced4aeb | 2019-01-28 16:52:41 -0500 | [diff] [blame] | 429 | public static final class DisableInfo { |
| 430 | |
| 431 | private boolean mStatusBarExpansion; |
| 432 | private boolean mNavigateHome; |
| 433 | private boolean mNotificationPeeking; |
| 434 | private boolean mRecents; |
| 435 | private boolean mSearch; |
Beverly | 54fead8 | 2019-05-22 17:57:39 -0400 | [diff] [blame] | 436 | private boolean mSystemIcons; |
| 437 | private boolean mClock; |
| 438 | private boolean mNotificationIcons; |
Evan Laird | ced4aeb | 2019-01-28 16:52:41 -0500 | [diff] [blame] | 439 | |
| 440 | /** @hide */ |
| 441 | public DisableInfo(int flags1, int flags2) { |
| 442 | mStatusBarExpansion = (flags1 & DISABLE_EXPAND) != 0; |
| 443 | mNavigateHome = (flags1 & DISABLE_HOME) != 0; |
| 444 | mNotificationPeeking = (flags1 & DISABLE_NOTIFICATION_ALERTS) != 0; |
| 445 | mRecents = (flags1 & DISABLE_RECENT) != 0; |
| 446 | mSearch = (flags1 & DISABLE_SEARCH) != 0; |
Beverly | 54fead8 | 2019-05-22 17:57:39 -0400 | [diff] [blame] | 447 | mSystemIcons = (flags1 & DISABLE_SYSTEM_INFO) != 0; |
| 448 | mClock = (flags1 & DISABLE_CLOCK) != 0; |
| 449 | mNotificationIcons = (flags1 & DISABLE_NOTIFICATION_ICONS) != 0; |
Evan Laird | ced4aeb | 2019-01-28 16:52:41 -0500 | [diff] [blame] | 450 | } |
| 451 | |
| 452 | /** @hide */ |
| 453 | public DisableInfo() {} |
| 454 | |
| 455 | /** |
| 456 | * @return {@code true} if expanding the notification shade is disabled |
| 457 | * |
| 458 | * @hide |
| 459 | */ |
| 460 | @SystemApi |
Evan Laird | 418ba8f | 2019-04-17 15:55:21 -0400 | [diff] [blame] | 461 | @TestApi |
Evan Laird | ced4aeb | 2019-01-28 16:52:41 -0500 | [diff] [blame] | 462 | public boolean isStatusBarExpansionDisabled() { |
| 463 | return mStatusBarExpansion; |
| 464 | } |
| 465 | |
| 466 | /** * @hide */ |
| 467 | public void setStatusBarExpansionDisabled(boolean disabled) { |
| 468 | mStatusBarExpansion = disabled; |
| 469 | } |
| 470 | |
| 471 | /** |
| 472 | * @return {@code true} if navigation home is disabled |
| 473 | * |
| 474 | * @hide |
| 475 | */ |
| 476 | @SystemApi |
Evan Laird | 418ba8f | 2019-04-17 15:55:21 -0400 | [diff] [blame] | 477 | @TestApi |
Evan Laird | ced4aeb | 2019-01-28 16:52:41 -0500 | [diff] [blame] | 478 | public boolean isNavigateToHomeDisabled() { |
| 479 | return mNavigateHome; |
| 480 | } |
| 481 | |
| 482 | /** * @hide */ |
| 483 | public void setNagivationHomeDisabled(boolean disabled) { |
| 484 | mNavigateHome = disabled; |
| 485 | } |
| 486 | |
| 487 | /** |
| 488 | * @return {@code true} if notification peeking (heads-up notification) is disabled |
| 489 | * |
| 490 | * @hide |
| 491 | */ |
| 492 | @SystemApi |
Evan Laird | 418ba8f | 2019-04-17 15:55:21 -0400 | [diff] [blame] | 493 | @TestApi |
Evan Laird | ced4aeb | 2019-01-28 16:52:41 -0500 | [diff] [blame] | 494 | public boolean isNotificationPeekingDisabled() { |
| 495 | return mNotificationPeeking; |
| 496 | } |
| 497 | |
| 498 | /** @hide */ |
| 499 | public void setNotificationPeekingDisabled(boolean disabled) { |
| 500 | mNotificationPeeking = disabled; |
| 501 | } |
| 502 | |
| 503 | /** |
| 504 | * @return {@code true} if mRecents/overview is disabled |
| 505 | * |
| 506 | * @hide |
| 507 | */ |
| 508 | @SystemApi |
Evan Laird | 418ba8f | 2019-04-17 15:55:21 -0400 | [diff] [blame] | 509 | @TestApi |
Evan Laird | ced4aeb | 2019-01-28 16:52:41 -0500 | [diff] [blame] | 510 | public boolean isRecentsDisabled() { |
| 511 | return mRecents; |
| 512 | } |
| 513 | |
| 514 | /** @hide */ |
| 515 | public void setRecentsDisabled(boolean disabled) { |
| 516 | mRecents = disabled; |
| 517 | } |
| 518 | |
| 519 | /** |
| 520 | * @return {@code true} if mSearch is disabled |
| 521 | * |
| 522 | * @hide |
| 523 | */ |
| 524 | @SystemApi |
Evan Laird | 418ba8f | 2019-04-17 15:55:21 -0400 | [diff] [blame] | 525 | @TestApi |
Evan Laird | ced4aeb | 2019-01-28 16:52:41 -0500 | [diff] [blame] | 526 | public boolean isSearchDisabled() { |
| 527 | return mSearch; |
| 528 | } |
| 529 | |
| 530 | /** @hide */ |
| 531 | public void setSearchDisabled(boolean disabled) { |
| 532 | mSearch = disabled; |
| 533 | } |
| 534 | |
| 535 | /** |
Beverly | 54fead8 | 2019-05-22 17:57:39 -0400 | [diff] [blame] | 536 | * @return {@code true} if system icons are disabled |
| 537 | * |
| 538 | * @hide |
| 539 | */ |
| 540 | public boolean areSystemIconsDisabled() { |
| 541 | return mSystemIcons; |
| 542 | } |
| 543 | |
| 544 | /** * @hide */ |
| 545 | public void setSystemIconsDisabled(boolean disabled) { |
| 546 | mSystemIcons = disabled; |
| 547 | } |
| 548 | |
| 549 | /** |
| 550 | * @return {@code true} if the clock icon is disabled |
| 551 | * |
| 552 | * @hide |
| 553 | */ |
| 554 | public boolean isClockDisabled() { |
| 555 | return mClock; |
| 556 | } |
| 557 | |
| 558 | /** * @hide */ |
| 559 | public void setClockDisabled(boolean disabled) { |
| 560 | mClock = disabled; |
| 561 | } |
| 562 | |
| 563 | /** |
| 564 | * @return {@code true} if notification icons are disabled |
| 565 | * |
| 566 | * @hide |
| 567 | */ |
| 568 | public boolean areNotificationIconsDisabled() { |
| 569 | return mNotificationIcons; |
| 570 | } |
| 571 | |
| 572 | /** * @hide */ |
| 573 | public void setNotificationIconsDisabled(boolean disabled) { |
| 574 | mNotificationIcons = disabled; |
| 575 | } |
| 576 | |
| 577 | /** |
Evan Laird | ced4aeb | 2019-01-28 16:52:41 -0500 | [diff] [blame] | 578 | * @return {@code true} if no components are disabled (default state) |
| 579 | * |
| 580 | * @hide |
| 581 | */ |
| 582 | @SystemApi |
Evan Laird | 418ba8f | 2019-04-17 15:55:21 -0400 | [diff] [blame] | 583 | @TestApi |
Evan Laird | ab19659 | 2019-02-26 17:21:32 -0500 | [diff] [blame] | 584 | public boolean areAllComponentsEnabled() { |
Evan Laird | ced4aeb | 2019-01-28 16:52:41 -0500 | [diff] [blame] | 585 | return !mStatusBarExpansion && !mNavigateHome && !mNotificationPeeking && !mRecents |
Beverly | 54fead8 | 2019-05-22 17:57:39 -0400 | [diff] [blame] | 586 | && !mSearch && !mSystemIcons && !mClock && !mNotificationIcons; |
Evan Laird | ced4aeb | 2019-01-28 16:52:41 -0500 | [diff] [blame] | 587 | } |
| 588 | |
| 589 | /** @hide */ |
| 590 | public void setEnableAll() { |
| 591 | mStatusBarExpansion = false; |
| 592 | mNavigateHome = false; |
| 593 | mNotificationPeeking = false; |
| 594 | mRecents = false; |
| 595 | mSearch = false; |
Beverly | 54fead8 | 2019-05-22 17:57:39 -0400 | [diff] [blame] | 596 | mSystemIcons = false; |
| 597 | mClock = false; |
| 598 | mNotificationIcons = false; |
Evan Laird | ced4aeb | 2019-01-28 16:52:41 -0500 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | /** |
| 602 | * @return {@code true} if all status bar components are disabled |
| 603 | * |
| 604 | * @hide |
| 605 | */ |
| 606 | public boolean areAllComponentsDisabled() { |
| 607 | return mStatusBarExpansion && mNavigateHome && mNotificationPeeking |
Beverly | 54fead8 | 2019-05-22 17:57:39 -0400 | [diff] [blame] | 608 | && mRecents && mSearch && mSystemIcons && mClock && mNotificationIcons; |
Evan Laird | ced4aeb | 2019-01-28 16:52:41 -0500 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | /** @hide */ |
| 612 | public void setDisableAll() { |
| 613 | mStatusBarExpansion = true; |
| 614 | mNavigateHome = true; |
| 615 | mNotificationPeeking = true; |
| 616 | mRecents = true; |
| 617 | mSearch = true; |
Beverly | 54fead8 | 2019-05-22 17:57:39 -0400 | [diff] [blame] | 618 | mSystemIcons = true; |
| 619 | mClock = true; |
| 620 | mNotificationIcons = true; |
Evan Laird | ced4aeb | 2019-01-28 16:52:41 -0500 | [diff] [blame] | 621 | } |
| 622 | |
| 623 | @Override |
| 624 | public String toString() { |
| 625 | StringBuilder sb = new StringBuilder(); |
| 626 | sb.append("DisableInfo: "); |
| 627 | sb.append(" mStatusBarExpansion=").append(mStatusBarExpansion ? "disabled" : "enabled"); |
| 628 | sb.append(" mNavigateHome=").append(mNavigateHome ? "disabled" : "enabled"); |
| 629 | sb.append(" mNotificationPeeking=") |
| 630 | .append(mNotificationPeeking ? "disabled" : "enabled"); |
| 631 | sb.append(" mRecents=").append(mRecents ? "disabled" : "enabled"); |
| 632 | sb.append(" mSearch=").append(mSearch ? "disabled" : "enabled"); |
Beverly | 54fead8 | 2019-05-22 17:57:39 -0400 | [diff] [blame] | 633 | sb.append(" mSystemIcons=").append(mSystemIcons ? "disabled" : "enabled"); |
| 634 | sb.append(" mClock=").append(mClock ? "disabled" : "enabled"); |
| 635 | sb.append(" mNotificationIcons=").append(mNotificationIcons ? "disabled" : "enabled"); |
Evan Laird | ced4aeb | 2019-01-28 16:52:41 -0500 | [diff] [blame] | 636 | |
| 637 | return sb.toString(); |
| 638 | |
| 639 | } |
| 640 | |
| 641 | /** |
| 642 | * Convert a DisableInfo to equivalent flags |
| 643 | * @return a pair of equivalent disable flags |
| 644 | * |
| 645 | * @hide |
| 646 | */ |
| 647 | public Pair<Integer, Integer> toFlags() { |
| 648 | int disable1 = DISABLE_NONE; |
| 649 | int disable2 = DISABLE2_NONE; |
| 650 | |
| 651 | if (mStatusBarExpansion) disable1 |= DISABLE_EXPAND; |
| 652 | if (mNavigateHome) disable1 |= DISABLE_HOME; |
| 653 | if (mNotificationPeeking) disable1 |= DISABLE_NOTIFICATION_ALERTS; |
| 654 | if (mRecents) disable1 |= DISABLE_RECENT; |
| 655 | if (mSearch) disable1 |= DISABLE_SEARCH; |
Beverly | 54fead8 | 2019-05-22 17:57:39 -0400 | [diff] [blame] | 656 | if (mSystemIcons) disable1 |= DISABLE_SYSTEM_INFO; |
| 657 | if (mClock) disable1 |= DISABLE_CLOCK; |
| 658 | if (mNotificationIcons) disable1 |= DISABLE_NOTIFICATION_ICONS; |
Evan Laird | ced4aeb | 2019-01-28 16:52:41 -0500 | [diff] [blame] | 659 | |
| 660 | return new Pair<Integer, Integer>(disable1, disable2); |
| 661 | } |
| 662 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 663 | } |