blob: 205e7a13092b785d831deaae7bf4337a919f0546 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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 Project9066cfe2009-03-03 19:31:44 -080017package android.app;
18
Benjamin Franzcde0a2a2015-04-23 17:19:48 +010019import android.annotation.IntDef;
Evan Laird2c4d0cf2019-02-28 12:10:29 -050020import android.annotation.NonNull;
Fabian Kozynskie3137e32018-09-28 11:20:04 -040021import android.annotation.Nullable;
Evan Lairdab196592019-02-26 17:21:32 -050022import android.annotation.RequiresPermission;
Evan Lairdedd016f2019-01-23 18:36:29 -050023import android.annotation.SystemApi;
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -060024import android.annotation.SystemService;
Evan Laird418ba8f2019-04-17 15:55:21 -040025import android.annotation.TestApi;
Mathew Inwood61e8ae62018-08-14 14:17:44 +010026import android.annotation.UnsupportedAppUsage;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080027import android.content.Context;
28import android.os.Binder;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029import android.os.IBinder;
Charles Heede39092017-09-18 09:19:28 +010030import android.os.RemoteException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080031import android.os.ServiceManager;
Evan Lairdedd016f2019-01-23 18:36:29 -050032import android.util.Pair;
Daniel Sandler9cbd3602011-10-18 22:59:00 -040033import android.util.Slog;
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080034import android.view.View;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080035
Joe Onorato0cbda992010-05-02 16:28:15 -070036import com.android.internal.statusbar.IStatusBarService;
37
Benjamin Franzcde0a2a2015-04-23 17:19:48 +010038import java.lang.annotation.Retention;
39import java.lang.annotation.RetentionPolicy;
40
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041/**
42 * Allows an app to control the status bar.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043 */
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -060044@SystemService(Context.STATUS_BAR_SERVICE)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080045public class StatusBarManager {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080046
Evan Laird27323242019-01-11 16:08:07 -050047 /** @hide */
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080048 public static final int DISABLE_EXPAND = View.STATUS_BAR_DISABLE_EXPAND;
Evan Laird27323242019-01-11 16:08:07 -050049 /** @hide */
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080050 public static final int DISABLE_NOTIFICATION_ICONS = View.STATUS_BAR_DISABLE_NOTIFICATION_ICONS;
Evan Laird27323242019-01-11 16:08:07 -050051 /** @hide */
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080052 public static final int DISABLE_NOTIFICATION_ALERTS
53 = View.STATUS_BAR_DISABLE_NOTIFICATION_ALERTS;
Evan Laird27323242019-01-11 16:08:07 -050054
55 /** @hide */
Dan Sandlera5e0f412014-01-23 15:11:54 -050056 @Deprecated
Mathew Inwood61e8ae62018-08-14 14:17:44 +010057 @UnsupportedAppUsage
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080058 public static final int DISABLE_NOTIFICATION_TICKER
59 = View.STATUS_BAR_DISABLE_NOTIFICATION_TICKER;
Evan Laird27323242019-01-11 16:08:07 -050060 /** @hide */
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080061 public static final int DISABLE_SYSTEM_INFO = View.STATUS_BAR_DISABLE_SYSTEM_INFO;
Evan Laird27323242019-01-11 16:08:07 -050062 /** @hide */
Daniel Sandlerdba93562011-10-06 16:39:58 -040063 public static final int DISABLE_HOME = View.STATUS_BAR_DISABLE_HOME;
Evan Laird27323242019-01-11 16:08:07 -050064 /** @hide */
Daniel Sandlerdba93562011-10-06 16:39:58 -040065 public static final int DISABLE_RECENT = View.STATUS_BAR_DISABLE_RECENT;
Evan Laird27323242019-01-11 16:08:07 -050066 /** @hide */
Joe Onorato6478adc2011-01-27 21:15:01 -080067 public static final int DISABLE_BACK = View.STATUS_BAR_DISABLE_BACK;
Evan Laird27323242019-01-11 16:08:07 -050068 /** @hide */
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080069 public static final int DISABLE_CLOCK = View.STATUS_BAR_DISABLE_CLOCK;
Evan Laird27323242019-01-11 16:08:07 -050070 /** @hide */
Daniel Sandlerd5483c32012-10-19 16:44:15 -040071 public static final int DISABLE_SEARCH = View.STATUS_BAR_DISABLE_SEARCH;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080072
Evan Laird27323242019-01-11 16:08:07 -050073 /** @hide */
Daniel Sandlerdba93562011-10-06 16:39:58 -040074 @Deprecated
Evan Laird27323242019-01-11 16:08:07 -050075 public static final int DISABLE_NAVIGATION =
Daniel Sandlerdba93562011-10-06 16:39:58 -040076 View.STATUS_BAR_DISABLE_HOME | View.STATUS_BAR_DISABLE_RECENT;
77
Evan Laird27323242019-01-11 16:08:07 -050078 /** @hide */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080079 public static final int DISABLE_NONE = 0x00000000;
80
Evan Laird27323242019-01-11 16:08:07 -050081 /** @hide */
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080082 public static final int DISABLE_MASK = DISABLE_EXPAND | DISABLE_NOTIFICATION_ICONS
83 | DISABLE_NOTIFICATION_ALERTS | DISABLE_NOTIFICATION_TICKER
Daniel Sandlerd5483c32012-10-19 16:44:15 -040084 | DISABLE_SYSTEM_INFO | DISABLE_RECENT | DISABLE_HOME | DISABLE_BACK | DISABLE_CLOCK
85 | DISABLE_SEARCH;
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080086
Evan Laird27323242019-01-11 16:08:07 -050087 /** @hide */
Charles Chenf3d295c2018-11-30 18:15:21 +080088 @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 Franz27cf1462015-04-23 19:36:42 +0100104 /**
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 Laird27323242019-01-11 16:08:07 -0500110 /** @hide */
Charles He6a79b0d2017-09-18 09:50:58 +0100111 public static final int DISABLE2_QUICK_SETTINGS = 1;
Evan Laird27323242019-01-11 16:08:07 -0500112 /** @hide */
Charles He6a79b0d2017-09-18 09:50:58 +0100113 public static final int DISABLE2_SYSTEM_ICONS = 1 << 1;
Evan Laird27323242019-01-11 16:08:07 -0500114 /** @hide */
Charles He2eda2422017-09-24 17:55:21 +0100115 public static final int DISABLE2_NOTIFICATION_SHADE = 1 << 2;
Evan Laird27323242019-01-11 16:08:07 -0500116 /** @hide */
Charles He9851a8d2017-10-10 17:31:30 +0100117 public static final int DISABLE2_GLOBAL_ACTIONS = 1 << 3;
Evan Laird27323242019-01-11 16:08:07 -0500118 /** @hide */
Mike Digmandd2f49e2018-03-16 10:54:22 -0700119 public static final int DISABLE2_ROTATE_SUGGESTIONS = 1 << 4;
Benjamin Franz27cf1462015-04-23 19:36:42 +0100120
Evan Laird27323242019-01-11 16:08:07 -0500121 /** @hide */
Benjamin Franzcde0a2a2015-04-23 17:19:48 +0100122 public static final int DISABLE2_NONE = 0x00000000;
123
Evan Laird27323242019-01-11 16:08:07 -0500124 /** @hide */
Charles He2eda2422017-09-24 17:55:21 +0100125 public static final int DISABLE2_MASK = DISABLE2_QUICK_SETTINGS | DISABLE2_SYSTEM_ICONS
Mike Digmandd2f49e2018-03-16 10:54:22 -0700126 | DISABLE2_NOTIFICATION_SHADE | DISABLE2_GLOBAL_ACTIONS | DISABLE2_ROTATE_SUGGESTIONS;
Benjamin Franzcde0a2a2015-04-23 17:19:48 +0100127
Evan Laird27323242019-01-11 16:08:07 -0500128 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -0700129 @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 Digmandd2f49e2018-03-16 10:54:22 -0700135 DISABLE2_GLOBAL_ACTIONS,
136 DISABLE2_ROTATE_SUGGESTIONS
Jeff Sharkeyce8db992017-12-13 20:05:05 -0700137 })
Benjamin Franzcde0a2a2015-04-23 17:19:48 +0100138 @Retention(RetentionPolicy.SOURCE)
139 public @interface Disable2Flags {}
140
Evan Lairdedd016f2019-01-23 18:36:29 -0500141 /**
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 Laird27323242019-01-11 16:08:07 -0500156 /** @hide */
John Spurlock56d007b2013-10-28 18:40:56 -0400157 public static final int NAVIGATION_HINT_BACK_ALT = 1 << 0;
Evan Laird27323242019-01-11 16:08:07 -0500158 /** @hide */
Jason Monkf1ff2092014-04-29 16:50:53 -0400159 public static final int NAVIGATION_HINT_IME_SHOWN = 1 << 1;
Daniel Sandler328310c2011-09-23 15:56:52 -0400160
Evan Laird27323242019-01-11 16:08:07 -0500161 /** @hide */
John Spurlock97642182013-07-29 17:58:39 -0400162 public static final int WINDOW_STATUS_BAR = 1;
Evan Laird27323242019-01-11 16:08:07 -0500163 /** @hide */
John Spurlock97642182013-07-29 17:58:39 -0400164 public static final int WINDOW_NAVIGATION_BAR = 2;
165
Evan Laird27323242019-01-11 16:08:07 -0500166 /** @hide */
Charles Chenf3d295c2018-11-30 18:15:21 +0800167 @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 Laird27323242019-01-11 16:08:07 -0500174 /** @hide */
John Spurlock5b9145b2013-08-20 15:13:47 -0400175 public static final int WINDOW_STATE_SHOWING = 0;
Evan Laird27323242019-01-11 16:08:07 -0500176 /** @hide */
John Spurlock97642182013-07-29 17:58:39 -0400177 public static final int WINDOW_STATE_HIDING = 1;
Evan Laird27323242019-01-11 16:08:07 -0500178 /** @hide */
John Spurlock5b9145b2013-08-20 15:13:47 -0400179 public static final int WINDOW_STATE_HIDDEN = 2;
John Spurlock97642182013-07-29 17:58:39 -0400180
Evan Laird27323242019-01-11 16:08:07 -0500181 /** @hide */
Charles Chenf3d295c2018-11-30 18:15:21 +0800182 @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 Laird27323242019-01-11 16:08:07 -0500190 /** @hide */
Jorim Jaggi40aa8812015-09-23 12:59:22 -0700191 public static final int CAMERA_LAUNCH_SOURCE_WIGGLE = 0;
Evan Laird27323242019-01-11 16:08:07 -0500192 /** @hide */
Jorim Jaggi40aa8812015-09-23 12:59:22 -0700193 public static final int CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP = 1;
Evan Laird27323242019-01-11 16:08:07 -0500194 /** @hide */
Jonathan Solnita4138162017-05-10 21:06:04 -0700195 public static final int CAMERA_LAUNCH_SOURCE_LIFT_TRIGGER = 2;
Jorim Jaggi40aa8812015-09-23 12:59:22 -0700196
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100197 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800198 private Context mContext;
Joe Onorato25f95f92010-04-08 18:37:10 -0500199 private IStatusBarService mService;
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100200 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800201 private IBinder mToken = new Binder();
202
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100203 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800204 StatusBarManager(Context context) {
205 mContext = context;
Daniel Sandler9cbd3602011-10-18 22:59:00 -0400206 }
207
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100208 @UnsupportedAppUsage
Daniel Sandler9cbd3602011-10-18 22:59:00 -0400209 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 Project9066cfe2009-03-03 19:31:44 -0800218 }
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 Laird27323242019-01-11 16:08:07 -0500223 *
224 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800225 */
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100226 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800227 public void disable(int what) {
228 try {
Evan Lairda6917e12018-05-29 17:28:58 -0400229 final int userId = Binder.getCallingUserHandle().getIdentifier();
Daniel Sandler9cbd3602011-10-18 22:59:00 -0400230 final IStatusBarService svc = getService();
231 if (svc != null) {
Evan Lairda6917e12018-05-29 17:28:58 -0400232 svc.disableForUser(what, mToken, mContext.getPackageName(), userId);
Jim Miller305c78c2011-10-16 14:54:38 -0700233 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800234 } catch (RemoteException ex) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700235 throw ex.rethrowFromSystemServer();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800236 }
237 }
Benjamin Franzcde0a2a2015-04-23 17:19:48 +0100238
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 Laird27323242019-01-11 16:08:07 -0500244 *
245 * @hide
Benjamin Franzcde0a2a2015-04-23 17:19:48 +0100246 */
247 public void disable2(@Disable2Flags int what) {
248 try {
Evan Lairda6917e12018-05-29 17:28:58 -0400249 final int userId = Binder.getCallingUserHandle().getIdentifier();
Benjamin Franzcde0a2a2015-04-23 17:19:48 +0100250 final IStatusBarService svc = getService();
251 if (svc != null) {
Evan Lairda6917e12018-05-29 17:28:58 -0400252 svc.disable2ForUser(what, mToken, mContext.getPackageName(), userId);
Benjamin Franzcde0a2a2015-04-23 17:19:48 +0100253 }
254 } catch (RemoteException ex) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700255 throw ex.rethrowFromSystemServer();
Benjamin Franzcde0a2a2015-04-23 17:19:48 +0100256 }
257 }
258
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800259 /**
Daniel Sandler11cf1782012-09-27 14:03:08 -0400260 * Expand the notifications panel.
Evan Laird27323242019-01-11 16:08:07 -0500261 *
262 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800263 */
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100264 @UnsupportedAppUsage
Daniel Sandler11cf1782012-09-27 14:03:08 -0400265 public void expandNotificationsPanel() {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800266 try {
Daniel Sandler9cbd3602011-10-18 22:59:00 -0400267 final IStatusBarService svc = getService();
268 if (svc != null) {
Daniel Sandler11cf1782012-09-27 14:03:08 -0400269 svc.expandNotificationsPanel();
Daniel Sandler9cbd3602011-10-18 22:59:00 -0400270 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800271 } catch (RemoteException ex) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700272 throw ex.rethrowFromSystemServer();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800273 }
274 }
Evan Laird27323242019-01-11 16:08:07 -0500275
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800276 /**
Daniel Sandler11cf1782012-09-27 14:03:08 -0400277 * Collapse the notifications and settings panels.
Evan Laird27323242019-01-11 16:08:07 -0500278 *
279 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800280 */
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100281 @UnsupportedAppUsage
Daniel Sandler11cf1782012-09-27 14:03:08 -0400282 public void collapsePanels() {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800283 try {
Daniel Sandler9cbd3602011-10-18 22:59:00 -0400284 final IStatusBarService svc = getService();
285 if (svc != null) {
Daniel Sandler11cf1782012-09-27 14:03:08 -0400286 svc.collapsePanels();
Svetoslav Ganove20a1772012-09-25 16:07:46 -0700287 }
288 } catch (RemoteException ex) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700289 throw ex.rethrowFromSystemServer();
Svetoslav Ganove20a1772012-09-25 16:07:46 -0700290 }
291 }
292
293 /**
Daniel Sandler11cf1782012-09-27 14:03:08 -0400294 * Expand the settings panel.
Evan Laird27323242019-01-11 16:08:07 -0500295 *
296 * @hide
Svetoslav Ganove20a1772012-09-25 16:07:46 -0700297 */
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100298 @UnsupportedAppUsage
Daniel Sandler11cf1782012-09-27 14:03:08 -0400299 public void expandSettingsPanel() {
Jason Monka9927322015-12-13 16:22:37 -0500300 expandSettingsPanel(null);
301 }
302
303 /**
Fabian Kozynskie3137e32018-09-28 11:20:04 -0400304 * 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 Laird27323242019-01-11 16:08:07 -0500306 *
307 * @hide
Jason Monka9927322015-12-13 16:22:37 -0500308 */
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100309 @UnsupportedAppUsage
Fabian Kozynskie3137e32018-09-28 11:20:04 -0400310 public void expandSettingsPanel(@Nullable String subPanel) {
Svetoslav Ganove20a1772012-09-25 16:07:46 -0700311 try {
312 final IStatusBarService svc = getService();
313 if (svc != null) {
Jason Monka9927322015-12-13 16:22:37 -0500314 svc.expandSettingsPanel(subPanel);
Daniel Sandler9cbd3602011-10-18 22:59:00 -0400315 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800316 } catch (RemoteException ex) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700317 throw ex.rethrowFromSystemServer();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800318 }
319 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800320
Evan Laird27323242019-01-11 16:08:07 -0500321 /** @hide */
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100322 @UnsupportedAppUsage
Svetoslav Ganov6179ea32011-06-28 01:12:41 -0700323 public void setIcon(String slot, int iconId, int iconLevel, String contentDescription) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800324 try {
Daniel Sandler9cbd3602011-10-18 22:59:00 -0400325 final IStatusBarService svc = getService();
326 if (svc != null) {
327 svc.setIcon(slot, mContext.getPackageName(), iconId, iconLevel,
Svetoslav Ganov6179ea32011-06-28 01:12:41 -0700328 contentDescription);
Daniel Sandler9cbd3602011-10-18 22:59:00 -0400329 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800330 } catch (RemoteException ex) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700331 throw ex.rethrowFromSystemServer();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800332 }
333 }
334
Evan Laird27323242019-01-11 16:08:07 -0500335 /** @hide */
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100336 @UnsupportedAppUsage
Joe Onorato0cbda992010-05-02 16:28:15 -0700337 public void removeIcon(String slot) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800338 try {
Daniel Sandler9cbd3602011-10-18 22:59:00 -0400339 final IStatusBarService svc = getService();
340 if (svc != null) {
341 svc.removeIcon(slot);
342 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800343 } catch (RemoteException ex) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700344 throw ex.rethrowFromSystemServer();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800345 }
346 }
Joe Onorato798ac4c2010-05-27 16:39:00 -0400347
Evan Laird27323242019-01-11 16:08:07 -0500348 /** @hide */
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100349 @UnsupportedAppUsage
Joe Onorato798ac4c2010-05-27 16:39:00 -0400350 public void setIconVisibility(String slot, boolean visible) {
351 try {
Daniel Sandler9cbd3602011-10-18 22:59:00 -0400352 final IStatusBarService svc = getService();
353 if (svc != null) {
354 svc.setIconVisibility(slot, visible);
355 }
Joe Onorato798ac4c2010-05-27 16:39:00 -0400356 } catch (RemoteException ex) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700357 throw ex.rethrowFromSystemServer();
Joe Onorato798ac4c2010-05-27 16:39:00 -0400358 }
359 }
John Spurlock5b9145b2013-08-20 15:13:47 -0400360
Evan Lairdedd016f2019-01-23 18:36:29 -0500361 /**
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 Laird418ba8f2019-04-17 15:55:21 -0400370 @TestApi
Evan Lairdab196592019-02-26 17:21:32 -0500371 @RequiresPermission(android.Manifest.permission.STATUS_BAR)
Evan Lairdedd016f2019-01-23 18:36:29 -0500372 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 Lairdced4aeb2019-01-28 16:52:41 -0500388 * Get this app's currently requested disabled components
Evan Lairdedd016f2019-01-23 18:36:29 -0500389 *
Evan Lairdced4aeb2019-01-28 16:52:41 -0500390 * @return a new DisableInfo
Evan Lairdedd016f2019-01-23 18:36:29 -0500391 *
392 * @hide
393 */
394 @SystemApi
Evan Laird418ba8f2019-04-17 15:55:21 -0400395 @TestApi
Evan Lairdab196592019-02-26 17:21:32 -0500396 @RequiresPermission(android.Manifest.permission.STATUS_BAR)
Evan Laird2c4d0cf2019-02-28 12:10:29 -0500397 @NonNull
Evan Lairdced4aeb2019-01-28 16:52:41 -0500398 public DisableInfo getDisableInfo() {
Evan Lairdedd016f2019-01-23 18:36:29 -0500399 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 Lairdced4aeb2019-01-28 16:52:41 -0500407 return new DisableInfo(flags[0], flags[1]);
Evan Lairdedd016f2019-01-23 18:36:29 -0500408 } catch (RemoteException ex) {
409 throw ex.rethrowFromSystemServer();
410 }
411 }
412
John Spurlock5b9145b2013-08-20 15:13:47 -0400413 /** @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 Lairdced4aeb2019-01-28 16:52:41 -0500420
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 Laird418ba8f2019-04-17 15:55:21 -0400428 @TestApi
Evan Lairdced4aeb2019-01-28 16:52:41 -0500429 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;
Beverly54fead82019-05-22 17:57:39 -0400436 private boolean mSystemIcons;
437 private boolean mClock;
438 private boolean mNotificationIcons;
Evan Lairdced4aeb2019-01-28 16:52:41 -0500439
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;
Beverly54fead82019-05-22 17:57:39 -0400447 mSystemIcons = (flags1 & DISABLE_SYSTEM_INFO) != 0;
448 mClock = (flags1 & DISABLE_CLOCK) != 0;
449 mNotificationIcons = (flags1 & DISABLE_NOTIFICATION_ICONS) != 0;
Evan Lairdced4aeb2019-01-28 16:52:41 -0500450 }
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 Laird418ba8f2019-04-17 15:55:21 -0400461 @TestApi
Evan Lairdced4aeb2019-01-28 16:52:41 -0500462 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 Laird418ba8f2019-04-17 15:55:21 -0400477 @TestApi
Evan Lairdced4aeb2019-01-28 16:52:41 -0500478 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 Laird418ba8f2019-04-17 15:55:21 -0400493 @TestApi
Evan Lairdced4aeb2019-01-28 16:52:41 -0500494 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 Laird418ba8f2019-04-17 15:55:21 -0400509 @TestApi
Evan Lairdced4aeb2019-01-28 16:52:41 -0500510 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 Laird418ba8f2019-04-17 15:55:21 -0400525 @TestApi
Evan Lairdced4aeb2019-01-28 16:52:41 -0500526 public boolean isSearchDisabled() {
527 return mSearch;
528 }
529
530 /** @hide */
531 public void setSearchDisabled(boolean disabled) {
532 mSearch = disabled;
533 }
534
535 /**
Beverly54fead82019-05-22 17:57:39 -0400536 * @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 Lairdced4aeb2019-01-28 16:52:41 -0500578 * @return {@code true} if no components are disabled (default state)
579 *
580 * @hide
581 */
582 @SystemApi
Evan Laird418ba8f2019-04-17 15:55:21 -0400583 @TestApi
Evan Lairdab196592019-02-26 17:21:32 -0500584 public boolean areAllComponentsEnabled() {
Evan Lairdced4aeb2019-01-28 16:52:41 -0500585 return !mStatusBarExpansion && !mNavigateHome && !mNotificationPeeking && !mRecents
Beverly54fead82019-05-22 17:57:39 -0400586 && !mSearch && !mSystemIcons && !mClock && !mNotificationIcons;
Evan Lairdced4aeb2019-01-28 16:52:41 -0500587 }
588
589 /** @hide */
590 public void setEnableAll() {
591 mStatusBarExpansion = false;
592 mNavigateHome = false;
593 mNotificationPeeking = false;
594 mRecents = false;
595 mSearch = false;
Beverly54fead82019-05-22 17:57:39 -0400596 mSystemIcons = false;
597 mClock = false;
598 mNotificationIcons = false;
Evan Lairdced4aeb2019-01-28 16:52:41 -0500599 }
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
Beverly54fead82019-05-22 17:57:39 -0400608 && mRecents && mSearch && mSystemIcons && mClock && mNotificationIcons;
Evan Lairdced4aeb2019-01-28 16:52:41 -0500609 }
610
611 /** @hide */
612 public void setDisableAll() {
613 mStatusBarExpansion = true;
614 mNavigateHome = true;
615 mNotificationPeeking = true;
616 mRecents = true;
617 mSearch = true;
Beverly54fead82019-05-22 17:57:39 -0400618 mSystemIcons = true;
619 mClock = true;
620 mNotificationIcons = true;
Evan Lairdced4aeb2019-01-28 16:52:41 -0500621 }
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");
Beverly54fead82019-05-22 17:57:39 -0400633 sb.append(" mSystemIcons=").append(mSystemIcons ? "disabled" : "enabled");
634 sb.append(" mClock=").append(mClock ? "disabled" : "enabled");
635 sb.append(" mNotificationIcons=").append(mNotificationIcons ? "disabled" : "enabled");
Evan Lairdced4aeb2019-01-28 16:52:41 -0500636
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;
Beverly54fead82019-05-22 17:57:39 -0400656 if (mSystemIcons) disable1 |= DISABLE_SYSTEM_INFO;
657 if (mClock) disable1 |= DISABLE_CLOCK;
658 if (mNotificationIcons) disable1 |= DISABLE_NOTIFICATION_ICONS;
Evan Lairdced4aeb2019-01-28 16:52:41 -0500659
660 return new Pair<Integer, Integer>(disable1, disable2);
661 }
662 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800663}