blob: 077652cacc2d7718e95583a01a75a1cacc62b801 [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;
Fabian Kozynskie3137e32018-09-28 11:20:04 -040020import android.annotation.Nullable;
Evan Lairdedd016f2019-01-23 18:36:29 -050021import android.annotation.SystemApi;
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -060022import android.annotation.SystemService;
Mathew Inwood61e8ae62018-08-14 14:17:44 +010023import android.annotation.UnsupportedAppUsage;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080024import android.content.Context;
25import android.os.Binder;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080026import android.os.IBinder;
Charles Heede39092017-09-18 09:19:28 +010027import android.os.RemoteException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080028import android.os.ServiceManager;
Evan Lairdedd016f2019-01-23 18:36:29 -050029import android.util.Pair;
Daniel Sandler9cbd3602011-10-18 22:59:00 -040030import android.util.Slog;
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080031import android.view.View;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032
Joe Onorato0cbda992010-05-02 16:28:15 -070033import com.android.internal.statusbar.IStatusBarService;
34
Benjamin Franzcde0a2a2015-04-23 17:19:48 +010035import java.lang.annotation.Retention;
36import java.lang.annotation.RetentionPolicy;
37
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080038/**
39 * Allows an app to control the status bar.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080040 */
Jeff Sharkeyd86b8fe2017-06-02 17:36:26 -060041@SystemService(Context.STATUS_BAR_SERVICE)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080042public class StatusBarManager {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043
Evan Laird27323242019-01-11 16:08:07 -050044 /** @hide */
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080045 public static final int DISABLE_EXPAND = View.STATUS_BAR_DISABLE_EXPAND;
Evan Laird27323242019-01-11 16:08:07 -050046 /** @hide */
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080047 public static final int DISABLE_NOTIFICATION_ICONS = View.STATUS_BAR_DISABLE_NOTIFICATION_ICONS;
Evan Laird27323242019-01-11 16:08:07 -050048 /** @hide */
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080049 public static final int DISABLE_NOTIFICATION_ALERTS
50 = View.STATUS_BAR_DISABLE_NOTIFICATION_ALERTS;
Evan Laird27323242019-01-11 16:08:07 -050051
52 /** @hide */
Dan Sandlera5e0f412014-01-23 15:11:54 -050053 @Deprecated
Mathew Inwood61e8ae62018-08-14 14:17:44 +010054 @UnsupportedAppUsage
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080055 public static final int DISABLE_NOTIFICATION_TICKER
56 = View.STATUS_BAR_DISABLE_NOTIFICATION_TICKER;
Evan Laird27323242019-01-11 16:08:07 -050057 /** @hide */
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080058 public static final int DISABLE_SYSTEM_INFO = View.STATUS_BAR_DISABLE_SYSTEM_INFO;
Evan Laird27323242019-01-11 16:08:07 -050059 /** @hide */
Daniel Sandlerdba93562011-10-06 16:39:58 -040060 public static final int DISABLE_HOME = View.STATUS_BAR_DISABLE_HOME;
Evan Laird27323242019-01-11 16:08:07 -050061 /** @hide */
Daniel Sandlerdba93562011-10-06 16:39:58 -040062 public static final int DISABLE_RECENT = View.STATUS_BAR_DISABLE_RECENT;
Evan Laird27323242019-01-11 16:08:07 -050063 /** @hide */
Joe Onorato6478adc2011-01-27 21:15:01 -080064 public static final int DISABLE_BACK = View.STATUS_BAR_DISABLE_BACK;
Evan Laird27323242019-01-11 16:08:07 -050065 /** @hide */
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080066 public static final int DISABLE_CLOCK = View.STATUS_BAR_DISABLE_CLOCK;
Evan Laird27323242019-01-11 16:08:07 -050067 /** @hide */
Daniel Sandlerd5483c32012-10-19 16:44:15 -040068 public static final int DISABLE_SEARCH = View.STATUS_BAR_DISABLE_SEARCH;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080069
Evan Laird27323242019-01-11 16:08:07 -050070 /** @hide */
Daniel Sandlerdba93562011-10-06 16:39:58 -040071 @Deprecated
Evan Laird27323242019-01-11 16:08:07 -050072 public static final int DISABLE_NAVIGATION =
Daniel Sandlerdba93562011-10-06 16:39:58 -040073 View.STATUS_BAR_DISABLE_HOME | View.STATUS_BAR_DISABLE_RECENT;
74
Evan Laird27323242019-01-11 16:08:07 -050075 /** @hide */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080076 public static final int DISABLE_NONE = 0x00000000;
77
Evan Laird27323242019-01-11 16:08:07 -050078 /** @hide */
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080079 public static final int DISABLE_MASK = DISABLE_EXPAND | DISABLE_NOTIFICATION_ICONS
80 | DISABLE_NOTIFICATION_ALERTS | DISABLE_NOTIFICATION_TICKER
Daniel Sandlerd5483c32012-10-19 16:44:15 -040081 | DISABLE_SYSTEM_INFO | DISABLE_RECENT | DISABLE_HOME | DISABLE_BACK | DISABLE_CLOCK
82 | DISABLE_SEARCH;
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080083
Evan Laird27323242019-01-11 16:08:07 -050084 /** @hide */
Charles Chenf3d295c2018-11-30 18:15:21 +080085 @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 Franz27cf1462015-04-23 19:36:42 +0100101 /**
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 Laird27323242019-01-11 16:08:07 -0500107 /** @hide */
Charles He6a79b0d2017-09-18 09:50:58 +0100108 public static final int DISABLE2_QUICK_SETTINGS = 1;
Evan Laird27323242019-01-11 16:08:07 -0500109 /** @hide */
Charles He6a79b0d2017-09-18 09:50:58 +0100110 public static final int DISABLE2_SYSTEM_ICONS = 1 << 1;
Evan Laird27323242019-01-11 16:08:07 -0500111 /** @hide */
Charles He2eda2422017-09-24 17:55:21 +0100112 public static final int DISABLE2_NOTIFICATION_SHADE = 1 << 2;
Evan Laird27323242019-01-11 16:08:07 -0500113 /** @hide */
Charles He9851a8d2017-10-10 17:31:30 +0100114 public static final int DISABLE2_GLOBAL_ACTIONS = 1 << 3;
Evan Laird27323242019-01-11 16:08:07 -0500115 /** @hide */
Mike Digmandd2f49e2018-03-16 10:54:22 -0700116 public static final int DISABLE2_ROTATE_SUGGESTIONS = 1 << 4;
Benjamin Franz27cf1462015-04-23 19:36:42 +0100117
Evan Laird27323242019-01-11 16:08:07 -0500118 /** @hide */
Benjamin Franzcde0a2a2015-04-23 17:19:48 +0100119 public static final int DISABLE2_NONE = 0x00000000;
120
Evan Laird27323242019-01-11 16:08:07 -0500121 /** @hide */
Charles He2eda2422017-09-24 17:55:21 +0100122 public static final int DISABLE2_MASK = DISABLE2_QUICK_SETTINGS | DISABLE2_SYSTEM_ICONS
Mike Digmandd2f49e2018-03-16 10:54:22 -0700123 | DISABLE2_NOTIFICATION_SHADE | DISABLE2_GLOBAL_ACTIONS | DISABLE2_ROTATE_SUGGESTIONS;
Benjamin Franzcde0a2a2015-04-23 17:19:48 +0100124
Evan Laird27323242019-01-11 16:08:07 -0500125 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -0700126 @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 Digmandd2f49e2018-03-16 10:54:22 -0700132 DISABLE2_GLOBAL_ACTIONS,
133 DISABLE2_ROTATE_SUGGESTIONS
Jeff Sharkeyce8db992017-12-13 20:05:05 -0700134 })
Benjamin Franzcde0a2a2015-04-23 17:19:48 +0100135 @Retention(RetentionPolicy.SOURCE)
136 public @interface Disable2Flags {}
137
Evan Lairdedd016f2019-01-23 18:36:29 -0500138 /**
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 Laird27323242019-01-11 16:08:07 -0500153 /** @hide */
John Spurlock56d007b2013-10-28 18:40:56 -0400154 public static final int NAVIGATION_HINT_BACK_ALT = 1 << 0;
Evan Laird27323242019-01-11 16:08:07 -0500155 /** @hide */
Jason Monkf1ff2092014-04-29 16:50:53 -0400156 public static final int NAVIGATION_HINT_IME_SHOWN = 1 << 1;
Daniel Sandler328310c2011-09-23 15:56:52 -0400157
Evan Laird27323242019-01-11 16:08:07 -0500158 /** @hide */
John Spurlock97642182013-07-29 17:58:39 -0400159 public static final int WINDOW_STATUS_BAR = 1;
Evan Laird27323242019-01-11 16:08:07 -0500160 /** @hide */
John Spurlock97642182013-07-29 17:58:39 -0400161 public static final int WINDOW_NAVIGATION_BAR = 2;
162
Evan Laird27323242019-01-11 16:08:07 -0500163 /** @hide */
Charles Chenf3d295c2018-11-30 18:15:21 +0800164 @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 Laird27323242019-01-11 16:08:07 -0500171 /** @hide */
John Spurlock5b9145b2013-08-20 15:13:47 -0400172 public static final int WINDOW_STATE_SHOWING = 0;
Evan Laird27323242019-01-11 16:08:07 -0500173 /** @hide */
John Spurlock97642182013-07-29 17:58:39 -0400174 public static final int WINDOW_STATE_HIDING = 1;
Evan Laird27323242019-01-11 16:08:07 -0500175 /** @hide */
John Spurlock5b9145b2013-08-20 15:13:47 -0400176 public static final int WINDOW_STATE_HIDDEN = 2;
John Spurlock97642182013-07-29 17:58:39 -0400177
Evan Laird27323242019-01-11 16:08:07 -0500178 /** @hide */
Charles Chenf3d295c2018-11-30 18:15:21 +0800179 @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 Laird27323242019-01-11 16:08:07 -0500187 /** @hide */
Jorim Jaggi40aa8812015-09-23 12:59:22 -0700188 public static final int CAMERA_LAUNCH_SOURCE_WIGGLE = 0;
Evan Laird27323242019-01-11 16:08:07 -0500189 /** @hide */
Jorim Jaggi40aa8812015-09-23 12:59:22 -0700190 public static final int CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP = 1;
Evan Laird27323242019-01-11 16:08:07 -0500191 /** @hide */
Jonathan Solnita4138162017-05-10 21:06:04 -0700192 public static final int CAMERA_LAUNCH_SOURCE_LIFT_TRIGGER = 2;
Jorim Jaggi40aa8812015-09-23 12:59:22 -0700193
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100194 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800195 private Context mContext;
Joe Onorato25f95f92010-04-08 18:37:10 -0500196 private IStatusBarService mService;
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100197 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800198 private IBinder mToken = new Binder();
199
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100200 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800201 StatusBarManager(Context context) {
202 mContext = context;
Daniel Sandler9cbd3602011-10-18 22:59:00 -0400203 }
204
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100205 @UnsupportedAppUsage
Daniel Sandler9cbd3602011-10-18 22:59:00 -0400206 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 Project9066cfe2009-03-03 19:31:44 -0800215 }
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 Laird27323242019-01-11 16:08:07 -0500220 *
221 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800222 */
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100223 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800224 public void disable(int what) {
225 try {
Evan Lairda6917e12018-05-29 17:28:58 -0400226 final int userId = Binder.getCallingUserHandle().getIdentifier();
Daniel Sandler9cbd3602011-10-18 22:59:00 -0400227 final IStatusBarService svc = getService();
228 if (svc != null) {
Evan Lairda6917e12018-05-29 17:28:58 -0400229 svc.disableForUser(what, mToken, mContext.getPackageName(), userId);
Jim Miller305c78c2011-10-16 14:54:38 -0700230 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800231 } catch (RemoteException ex) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700232 throw ex.rethrowFromSystemServer();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800233 }
234 }
Benjamin Franzcde0a2a2015-04-23 17:19:48 +0100235
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 Laird27323242019-01-11 16:08:07 -0500241 *
242 * @hide
Benjamin Franzcde0a2a2015-04-23 17:19:48 +0100243 */
244 public void disable2(@Disable2Flags int what) {
245 try {
Evan Lairda6917e12018-05-29 17:28:58 -0400246 final int userId = Binder.getCallingUserHandle().getIdentifier();
Benjamin Franzcde0a2a2015-04-23 17:19:48 +0100247 final IStatusBarService svc = getService();
248 if (svc != null) {
Evan Lairda6917e12018-05-29 17:28:58 -0400249 svc.disable2ForUser(what, mToken, mContext.getPackageName(), userId);
Benjamin Franzcde0a2a2015-04-23 17:19:48 +0100250 }
251 } catch (RemoteException ex) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700252 throw ex.rethrowFromSystemServer();
Benjamin Franzcde0a2a2015-04-23 17:19:48 +0100253 }
254 }
255
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800256 /**
Daniel Sandler11cf1782012-09-27 14:03:08 -0400257 * Expand the notifications panel.
Evan Laird27323242019-01-11 16:08:07 -0500258 *
259 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800260 */
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100261 @UnsupportedAppUsage
Daniel Sandler11cf1782012-09-27 14:03:08 -0400262 public void expandNotificationsPanel() {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800263 try {
Daniel Sandler9cbd3602011-10-18 22:59:00 -0400264 final IStatusBarService svc = getService();
265 if (svc != null) {
Daniel Sandler11cf1782012-09-27 14:03:08 -0400266 svc.expandNotificationsPanel();
Daniel Sandler9cbd3602011-10-18 22:59:00 -0400267 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800268 } catch (RemoteException ex) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700269 throw ex.rethrowFromSystemServer();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800270 }
271 }
Evan Laird27323242019-01-11 16:08:07 -0500272
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800273 /**
Daniel Sandler11cf1782012-09-27 14:03:08 -0400274 * Collapse the notifications and settings panels.
Evan Laird27323242019-01-11 16:08:07 -0500275 *
276 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800277 */
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100278 @UnsupportedAppUsage
Daniel Sandler11cf1782012-09-27 14:03:08 -0400279 public void collapsePanels() {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800280 try {
Daniel Sandler9cbd3602011-10-18 22:59:00 -0400281 final IStatusBarService svc = getService();
282 if (svc != null) {
Daniel Sandler11cf1782012-09-27 14:03:08 -0400283 svc.collapsePanels();
Svetoslav Ganove20a1772012-09-25 16:07:46 -0700284 }
285 } catch (RemoteException ex) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700286 throw ex.rethrowFromSystemServer();
Svetoslav Ganove20a1772012-09-25 16:07:46 -0700287 }
288 }
289
290 /**
Daniel Sandler11cf1782012-09-27 14:03:08 -0400291 * Expand the settings panel.
Evan Laird27323242019-01-11 16:08:07 -0500292 *
293 * @hide
Svetoslav Ganove20a1772012-09-25 16:07:46 -0700294 */
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100295 @UnsupportedAppUsage
Daniel Sandler11cf1782012-09-27 14:03:08 -0400296 public void expandSettingsPanel() {
Jason Monka9927322015-12-13 16:22:37 -0500297 expandSettingsPanel(null);
298 }
299
300 /**
Fabian Kozynskie3137e32018-09-28 11:20:04 -0400301 * 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 Laird27323242019-01-11 16:08:07 -0500303 *
304 * @hide
Jason Monka9927322015-12-13 16:22:37 -0500305 */
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100306 @UnsupportedAppUsage
Fabian Kozynskie3137e32018-09-28 11:20:04 -0400307 public void expandSettingsPanel(@Nullable String subPanel) {
Svetoslav Ganove20a1772012-09-25 16:07:46 -0700308 try {
309 final IStatusBarService svc = getService();
310 if (svc != null) {
Jason Monka9927322015-12-13 16:22:37 -0500311 svc.expandSettingsPanel(subPanel);
Daniel Sandler9cbd3602011-10-18 22:59:00 -0400312 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800313 } catch (RemoteException ex) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700314 throw ex.rethrowFromSystemServer();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800315 }
316 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800317
Evan Laird27323242019-01-11 16:08:07 -0500318 /** @hide */
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100319 @UnsupportedAppUsage
Svetoslav Ganov6179ea32011-06-28 01:12:41 -0700320 public void setIcon(String slot, int iconId, int iconLevel, String contentDescription) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800321 try {
Daniel Sandler9cbd3602011-10-18 22:59:00 -0400322 final IStatusBarService svc = getService();
323 if (svc != null) {
324 svc.setIcon(slot, mContext.getPackageName(), iconId, iconLevel,
Svetoslav Ganov6179ea32011-06-28 01:12:41 -0700325 contentDescription);
Daniel Sandler9cbd3602011-10-18 22:59:00 -0400326 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800327 } catch (RemoteException ex) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700328 throw ex.rethrowFromSystemServer();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800329 }
330 }
331
Evan Laird27323242019-01-11 16:08:07 -0500332 /** @hide */
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100333 @UnsupportedAppUsage
Joe Onorato0cbda992010-05-02 16:28:15 -0700334 public void removeIcon(String slot) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800335 try {
Daniel Sandler9cbd3602011-10-18 22:59:00 -0400336 final IStatusBarService svc = getService();
337 if (svc != null) {
338 svc.removeIcon(slot);
339 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800340 } catch (RemoteException ex) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700341 throw ex.rethrowFromSystemServer();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800342 }
343 }
Joe Onorato798ac4c2010-05-27 16:39:00 -0400344
Evan Laird27323242019-01-11 16:08:07 -0500345 /** @hide */
Mathew Inwood61e8ae62018-08-14 14:17:44 +0100346 @UnsupportedAppUsage
Joe Onorato798ac4c2010-05-27 16:39:00 -0400347 public void setIconVisibility(String slot, boolean visible) {
348 try {
Daniel Sandler9cbd3602011-10-18 22:59:00 -0400349 final IStatusBarService svc = getService();
350 if (svc != null) {
351 svc.setIconVisibility(slot, visible);
352 }
Joe Onorato798ac4c2010-05-27 16:39:00 -0400353 } catch (RemoteException ex) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700354 throw ex.rethrowFromSystemServer();
Joe Onorato798ac4c2010-05-27 16:39:00 -0400355 }
356 }
John Spurlock5b9145b2013-08-20 15:13:47 -0400357
Evan Lairdedd016f2019-01-23 18:36:29 -0500358 /**
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 Lairdced4aeb2019-01-28 16:52:41 -0500383 * Get this app's currently requested disabled components
Evan Lairdedd016f2019-01-23 18:36:29 -0500384 *
Evan Lairdced4aeb2019-01-28 16:52:41 -0500385 * @return a new DisableInfo
Evan Lairdedd016f2019-01-23 18:36:29 -0500386 *
387 * @hide
388 */
389 @SystemApi
Evan Lairdced4aeb2019-01-28 16:52:41 -0500390 public DisableInfo getDisableInfo() {
Evan Lairdedd016f2019-01-23 18:36:29 -0500391 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 Lairdced4aeb2019-01-28 16:52:41 -0500399 return new DisableInfo(flags[0], flags[1]);
Evan Lairdedd016f2019-01-23 18:36:29 -0500400 } catch (RemoteException ex) {
401 throw ex.rethrowFromSystemServer();
402 }
403 }
404
John Spurlock5b9145b2013-08-20 15:13:47 -0400405 /** @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 Lairdced4aeb2019-01-28 16:52:41 -0500412
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 Project9066cfe2009-03-03 19:31:44 -0800588}