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