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 17 package android.app; 18 19 import android.annotation.IntDef; 20 import android.annotation.NonNull; 21 import android.annotation.Nullable; 22 import android.annotation.RequiresPermission; 23 import android.annotation.SystemApi; 24 import android.annotation.SystemService; 25 import android.annotation.TestApi; 26 import android.compat.annotation.UnsupportedAppUsage; 27 import android.content.Context; 28 import android.os.Binder; 29 import android.os.Build; 30 import android.os.Bundle; 31 import android.os.IBinder; 32 import android.os.RemoteException; 33 import android.os.ServiceManager; 34 import android.util.Pair; 35 import android.util.Slog; 36 import android.view.View; 37 38 import com.android.internal.statusbar.IStatusBarService; 39 import com.android.internal.statusbar.NotificationVisibility; 40 41 import java.lang.annotation.Retention; 42 import java.lang.annotation.RetentionPolicy; 43 44 /** 45 * Allows an app to control the status bar. 46 */ 47 @SystemService(Context.STATUS_BAR_SERVICE) 48 public class StatusBarManager { 49 // LINT.IfChange 50 /** @hide */ 51 public static final int DISABLE_EXPAND = View.STATUS_BAR_DISABLE_EXPAND; 52 /** @hide */ 53 public static final int DISABLE_NOTIFICATION_ICONS = View.STATUS_BAR_DISABLE_NOTIFICATION_ICONS; 54 /** @hide */ 55 public static final int DISABLE_NOTIFICATION_ALERTS 56 = View.STATUS_BAR_DISABLE_NOTIFICATION_ALERTS; 57 58 /** @hide */ 59 @Deprecated 60 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 61 public static final int DISABLE_NOTIFICATION_TICKER 62 = View.STATUS_BAR_DISABLE_NOTIFICATION_TICKER; 63 /** @hide */ 64 public static final int DISABLE_SYSTEM_INFO = View.STATUS_BAR_DISABLE_SYSTEM_INFO; 65 /** @hide */ 66 public static final int DISABLE_HOME = View.STATUS_BAR_DISABLE_HOME; 67 /** @hide */ 68 public static final int DISABLE_RECENT = View.STATUS_BAR_DISABLE_RECENT; 69 /** @hide */ 70 public static final int DISABLE_BACK = View.STATUS_BAR_DISABLE_BACK; 71 /** @hide */ 72 public static final int DISABLE_CLOCK = View.STATUS_BAR_DISABLE_CLOCK; 73 /** @hide */ 74 public static final int DISABLE_SEARCH = View.STATUS_BAR_DISABLE_SEARCH; 75 76 /** @hide */ 77 public static final int DISABLE_ONGOING_CALL_CHIP = View.STATUS_BAR_DISABLE_ONGOING_CALL_CHIP; 78 79 /** @hide */ 80 @Deprecated 81 public static final int DISABLE_NAVIGATION = 82 View.STATUS_BAR_DISABLE_HOME | View.STATUS_BAR_DISABLE_RECENT; 83 84 /** @hide */ 85 public static final int DISABLE_NONE = 0x00000000; 86 87 /** @hide */ 88 public static final int DISABLE_MASK = DISABLE_EXPAND | DISABLE_NOTIFICATION_ICONS 89 | DISABLE_NOTIFICATION_ALERTS | DISABLE_NOTIFICATION_TICKER 90 | DISABLE_SYSTEM_INFO | DISABLE_RECENT | DISABLE_HOME | DISABLE_BACK | DISABLE_CLOCK 91 | DISABLE_SEARCH | DISABLE_ONGOING_CALL_CHIP; 92 93 /** @hide */ 94 @IntDef(flag = true, prefix = {"DISABLE_"}, value = { 95 DISABLE_NONE, 96 DISABLE_EXPAND, 97 DISABLE_NOTIFICATION_ICONS, 98 DISABLE_NOTIFICATION_ALERTS, 99 DISABLE_NOTIFICATION_TICKER, 100 DISABLE_SYSTEM_INFO, 101 DISABLE_HOME, 102 DISABLE_RECENT, 103 DISABLE_BACK, 104 DISABLE_CLOCK, 105 DISABLE_SEARCH, 106 DISABLE_ONGOING_CALL_CHIP 107 }) 108 @Retention(RetentionPolicy.SOURCE) 109 public @interface DisableFlags {} 110 111 /** 112 * Flag to disable quick settings. 113 * 114 * Setting this flag disables quick settings completely, but does not disable expanding the 115 * notification shade. 116 */ 117 /** @hide */ 118 public static final int DISABLE2_QUICK_SETTINGS = 1; 119 /** @hide */ 120 public static final int DISABLE2_SYSTEM_ICONS = 1 << 1; 121 /** @hide */ 122 public static final int DISABLE2_NOTIFICATION_SHADE = 1 << 2; 123 /** @hide */ 124 public static final int DISABLE2_GLOBAL_ACTIONS = 1 << 3; 125 /** @hide */ 126 public static final int DISABLE2_ROTATE_SUGGESTIONS = 1 << 4; 127 128 /** @hide */ 129 public static final int DISABLE2_NONE = 0x00000000; 130 131 /** @hide */ 132 public static final int DISABLE2_MASK = DISABLE2_QUICK_SETTINGS | DISABLE2_SYSTEM_ICONS 133 | DISABLE2_NOTIFICATION_SHADE | DISABLE2_GLOBAL_ACTIONS | DISABLE2_ROTATE_SUGGESTIONS; 134 135 /** @hide */ 136 @IntDef(flag = true, prefix = { "DISABLE2_" }, value = { 137 DISABLE2_NONE, 138 DISABLE2_MASK, 139 DISABLE2_QUICK_SETTINGS, 140 DISABLE2_SYSTEM_ICONS, 141 DISABLE2_NOTIFICATION_SHADE, 142 DISABLE2_GLOBAL_ACTIONS, 143 DISABLE2_ROTATE_SUGGESTIONS 144 }) 145 @Retention(RetentionPolicy.SOURCE) 146 public @interface Disable2Flags {} 147 // LINT.ThenChange(frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/DisableFlagsLogger.kt) 148 149 /** 150 * Default disable flags for setup 151 * 152 * @hide 153 */ 154 public static final int DEFAULT_SETUP_DISABLE_FLAGS = DISABLE_NOTIFICATION_ALERTS 155 | DISABLE_HOME | DISABLE_EXPAND | DISABLE_RECENT | DISABLE_CLOCK | DISABLE_SEARCH; 156 157 /** 158 * Default disable2 flags for setup 159 * 160 * @hide 161 */ 162 public static final int DEFAULT_SETUP_DISABLE2_FLAGS = DISABLE2_ROTATE_SUGGESTIONS; 163 164 /** 165 * disable flags to be applied when the device is sim-locked. 166 */ 167 private static final int DEFAULT_SIM_LOCKED_DISABLED_FLAGS = DISABLE_EXPAND; 168 169 /** @hide */ 170 public static final int NAVIGATION_HINT_BACK_ALT = 1 << 0; 171 /** @hide */ 172 public static final int NAVIGATION_HINT_IME_SHOWN = 1 << 1; 173 174 /** @hide */ 175 public static final int WINDOW_STATUS_BAR = 1; 176 /** @hide */ 177 public static final int WINDOW_NAVIGATION_BAR = 2; 178 179 /** @hide */ 180 @IntDef(flag = true, prefix = { "WINDOW_" }, value = { 181 WINDOW_STATUS_BAR, 182 WINDOW_NAVIGATION_BAR 183 }) 184 @Retention(RetentionPolicy.SOURCE) 185 public @interface WindowType {} 186 187 /** @hide */ 188 public static final int WINDOW_STATE_SHOWING = 0; 189 /** @hide */ 190 public static final int WINDOW_STATE_HIDING = 1; 191 /** @hide */ 192 public static final int WINDOW_STATE_HIDDEN = 2; 193 194 /** @hide */ 195 @IntDef(flag = true, prefix = { "WINDOW_STATE_" }, value = { 196 WINDOW_STATE_SHOWING, 197 WINDOW_STATE_HIDING, 198 WINDOW_STATE_HIDDEN 199 }) 200 @Retention(RetentionPolicy.SOURCE) 201 public @interface WindowVisibleState {} 202 203 /** @hide */ 204 public static final int CAMERA_LAUNCH_SOURCE_WIGGLE = 0; 205 /** @hide */ 206 public static final int CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP = 1; 207 /** @hide */ 208 public static final int CAMERA_LAUNCH_SOURCE_LIFT_TRIGGER = 2; 209 210 @UnsupportedAppUsage 211 private Context mContext; 212 private IStatusBarService mService; 213 @UnsupportedAppUsage 214 private IBinder mToken = new Binder(); 215 216 @UnsupportedAppUsage StatusBarManager(Context context)217 StatusBarManager(Context context) { 218 mContext = context; 219 } 220 221 @UnsupportedAppUsage getService()222 private synchronized IStatusBarService getService() { 223 if (mService == null) { 224 mService = IStatusBarService.Stub.asInterface( 225 ServiceManager.getService(Context.STATUS_BAR_SERVICE)); 226 if (mService == null) { 227 Slog.w("StatusBarManager", "warning: no STATUS_BAR_SERVICE"); 228 } 229 } 230 return mService; 231 } 232 233 /** 234 * Disable some features in the status bar. Pass the bitwise-or of the DISABLE_* flags. 235 * To re-enable everything, pass {@link #DISABLE_NONE}. 236 * 237 * @hide 238 */ 239 @UnsupportedAppUsage disable(int what)240 public void disable(int what) { 241 try { 242 final int userId = Binder.getCallingUserHandle().getIdentifier(); 243 final IStatusBarService svc = getService(); 244 if (svc != null) { 245 svc.disableForUser(what, mToken, mContext.getPackageName(), userId); 246 } 247 } catch (RemoteException ex) { 248 throw ex.rethrowFromSystemServer(); 249 } 250 } 251 252 /** 253 * Disable additional status bar features. Pass the bitwise-or of the DISABLE2_* flags. 254 * To re-enable everything, pass {@link #DISABLE_NONE}. 255 * 256 * Warning: Only pass DISABLE2_* flags into this function, do not use DISABLE_* flags. 257 * 258 * @hide 259 */ disable2(@isable2Flags int what)260 public void disable2(@Disable2Flags int what) { 261 try { 262 final int userId = Binder.getCallingUserHandle().getIdentifier(); 263 final IStatusBarService svc = getService(); 264 if (svc != null) { 265 svc.disable2ForUser(what, mToken, mContext.getPackageName(), userId); 266 } 267 } catch (RemoteException ex) { 268 throw ex.rethrowFromSystemServer(); 269 } 270 } 271 272 /** 273 * Simulate notification click for testing 274 * 275 * @hide 276 */ 277 @TestApi clickNotification(@ullable String key, int rank, int count, boolean visible)278 public void clickNotification(@Nullable String key, int rank, int count, boolean visible) { 279 clickNotificationInternal(key, rank, count, visible); 280 } 281 clickNotificationInternal(String key, int rank, int count, boolean visible)282 private void clickNotificationInternal(String key, int rank, int count, boolean visible) { 283 try { 284 final IStatusBarService svc = getService(); 285 if (svc != null) { 286 svc.onNotificationClick(key, 287 NotificationVisibility.obtain(key, rank, count, visible)); 288 } 289 } catch (RemoteException ex) { 290 throw ex.rethrowFromSystemServer(); 291 } 292 } 293 294 /** 295 * Simulate notification feedback for testing 296 * 297 * @hide 298 */ 299 @TestApi sendNotificationFeedback(@ullable String key, @Nullable Bundle feedback)300 public void sendNotificationFeedback(@Nullable String key, @Nullable Bundle feedback) { 301 try { 302 final IStatusBarService svc = getService(); 303 if (svc != null) { 304 svc.onNotificationFeedbackReceived(key, feedback); 305 } 306 } catch (RemoteException ex) { 307 throw ex.rethrowFromSystemServer(); 308 } 309 } 310 311 /** 312 * Expand the notifications panel. 313 * 314 * @hide 315 */ 316 @UnsupportedAppUsage 317 @TestApi expandNotificationsPanel()318 public void expandNotificationsPanel() { 319 try { 320 final IStatusBarService svc = getService(); 321 if (svc != null) { 322 svc.expandNotificationsPanel(); 323 } 324 } catch (RemoteException ex) { 325 throw ex.rethrowFromSystemServer(); 326 } 327 } 328 329 /** 330 * Collapse the notifications and settings panels. 331 * 332 * Starting in Android {@link Build.VERSION_CODES.S}, apps targeting SDK level {@link 333 * Build.VERSION_CODES.S} or higher will need {@link android.Manifest.permission.STATUS_BAR} 334 * permission to call this API. 335 * 336 * @hide 337 */ 338 @RequiresPermission(android.Manifest.permission.STATUS_BAR) 339 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, publicAlternatives = "This operation" 340 + " is not allowed anymore, please see {@link android.content" 341 + ".Intent#ACTION_CLOSE_SYSTEM_DIALOGS} for more details.") 342 @TestApi collapsePanels()343 public void collapsePanels() { 344 345 try { 346 final IStatusBarService svc = getService(); 347 if (svc != null) { 348 svc.collapsePanels(); 349 } 350 } catch (RemoteException ex) { 351 throw ex.rethrowFromSystemServer(); 352 } 353 } 354 355 /** 356 * Toggles the notification panel. 357 * 358 * @hide 359 */ 360 @RequiresPermission(android.Manifest.permission.STATUS_BAR) 361 @TestApi togglePanel()362 public void togglePanel() { 363 try { 364 final IStatusBarService svc = getService(); 365 if (svc != null) { 366 svc.togglePanel(); 367 } 368 } catch (RemoteException ex) { 369 throw ex.rethrowFromSystemServer(); 370 } 371 } 372 373 /** 374 * Sends system keys to the status bar. 375 * 376 * @hide 377 */ 378 @RequiresPermission(android.Manifest.permission.STATUS_BAR) 379 @TestApi handleSystemKey(int key)380 public void handleSystemKey(int key) { 381 try { 382 final IStatusBarService svc = getService(); 383 if (svc != null) { 384 svc.handleSystemKey(key); 385 } 386 } catch (RemoteException ex) { 387 throw ex.rethrowFromSystemServer(); 388 } 389 } 390 391 /** 392 * Expand the settings panel. 393 * 394 * @hide 395 */ 396 @UnsupportedAppUsage expandSettingsPanel()397 public void expandSettingsPanel() { 398 expandSettingsPanel(null); 399 } 400 401 /** 402 * Expand the settings panel and open a subPanel. If the subpanel is null or does not have a 403 * corresponding tile, the QS panel is simply expanded 404 * 405 * @hide 406 */ 407 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) expandSettingsPanel(@ullable String subPanel)408 public void expandSettingsPanel(@Nullable String subPanel) { 409 try { 410 final IStatusBarService svc = getService(); 411 if (svc != null) { 412 svc.expandSettingsPanel(subPanel); 413 } 414 } catch (RemoteException ex) { 415 throw ex.rethrowFromSystemServer(); 416 } 417 } 418 419 /** @hide */ 420 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) setIcon(String slot, int iconId, int iconLevel, String contentDescription)421 public void setIcon(String slot, int iconId, int iconLevel, String contentDescription) { 422 try { 423 final IStatusBarService svc = getService(); 424 if (svc != null) { 425 svc.setIcon(slot, mContext.getPackageName(), iconId, iconLevel, 426 contentDescription); 427 } 428 } catch (RemoteException ex) { 429 throw ex.rethrowFromSystemServer(); 430 } 431 } 432 433 /** @hide */ 434 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) removeIcon(String slot)435 public void removeIcon(String slot) { 436 try { 437 final IStatusBarService svc = getService(); 438 if (svc != null) { 439 svc.removeIcon(slot); 440 } 441 } catch (RemoteException ex) { 442 throw ex.rethrowFromSystemServer(); 443 } 444 } 445 446 /** @hide */ 447 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) setIconVisibility(String slot, boolean visible)448 public void setIconVisibility(String slot, boolean visible) { 449 try { 450 final IStatusBarService svc = getService(); 451 if (svc != null) { 452 svc.setIconVisibility(slot, visible); 453 } 454 } catch (RemoteException ex) { 455 throw ex.rethrowFromSystemServer(); 456 } 457 } 458 459 /** 460 * Enable or disable status bar elements (notifications, clock) which are inappropriate during 461 * device setup. 462 * 463 * @param disabled whether to apply or remove the disabled flags 464 * 465 * @hide 466 */ 467 @SystemApi 468 @RequiresPermission(android.Manifest.permission.STATUS_BAR) setDisabledForSetup(boolean disabled)469 public void setDisabledForSetup(boolean disabled) { 470 try { 471 final int userId = Binder.getCallingUserHandle().getIdentifier(); 472 final IStatusBarService svc = getService(); 473 if (svc != null) { 474 svc.disableForUser(disabled ? DEFAULT_SETUP_DISABLE_FLAGS : DISABLE_NONE, 475 mToken, mContext.getPackageName(), userId); 476 svc.disable2ForUser(disabled ? DEFAULT_SETUP_DISABLE2_FLAGS : DISABLE2_NONE, 477 mToken, mContext.getPackageName(), userId); 478 } 479 } catch (RemoteException ex) { 480 throw ex.rethrowFromSystemServer(); 481 } 482 } 483 484 /** 485 * Enable or disable expansion of the status bar. When the device is SIM-locked, the status 486 * bar should not be expandable. 487 * 488 * @param disabled If {@code true}, the status bar will be set to non-expandable. If 489 * {@code false}, re-enables expansion of the status bar. 490 * @hide 491 */ 492 @TestApi 493 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 494 @RequiresPermission(android.Manifest.permission.STATUS_BAR) setExpansionDisabledForSimNetworkLock(boolean disabled)495 public void setExpansionDisabledForSimNetworkLock(boolean disabled) { 496 try { 497 final int userId = Binder.getCallingUserHandle().getIdentifier(); 498 final IStatusBarService svc = getService(); 499 if (svc != null) { 500 svc.disableForUser(disabled ? DEFAULT_SIM_LOCKED_DISABLED_FLAGS : DISABLE_NONE, 501 mToken, mContext.getPackageName(), userId); 502 } 503 } catch (RemoteException ex) { 504 throw ex.rethrowFromSystemServer(); 505 } 506 } 507 508 /** 509 * Get this app's currently requested disabled components 510 * 511 * @return a new DisableInfo 512 * 513 * @hide 514 */ 515 @SystemApi 516 @RequiresPermission(android.Manifest.permission.STATUS_BAR) 517 @NonNull getDisableInfo()518 public DisableInfo getDisableInfo() { 519 try { 520 final int userId = Binder.getCallingUserHandle().getIdentifier(); 521 final IStatusBarService svc = getService(); 522 int[] flags = new int[] {0, 0}; 523 if (svc != null) { 524 flags = svc.getDisableFlags(mToken, userId); 525 } 526 527 return new DisableInfo(flags[0], flags[1]); 528 } catch (RemoteException ex) { 529 throw ex.rethrowFromSystemServer(); 530 } 531 } 532 533 /** @hide */ windowStateToString(int state)534 public static String windowStateToString(int state) { 535 if (state == WINDOW_STATE_HIDING) return "WINDOW_STATE_HIDING"; 536 if (state == WINDOW_STATE_HIDDEN) return "WINDOW_STATE_HIDDEN"; 537 if (state == WINDOW_STATE_SHOWING) return "WINDOW_STATE_SHOWING"; 538 return "WINDOW_STATE_UNKNOWN"; 539 } 540 541 /** 542 * DisableInfo describes this app's requested state of the StatusBar with regards to which 543 * components are enabled/disabled 544 * 545 * @hide 546 */ 547 @SystemApi 548 public static final class DisableInfo { 549 550 private boolean mStatusBarExpansion; 551 private boolean mNavigateHome; 552 private boolean mNotificationPeeking; 553 private boolean mRecents; 554 private boolean mSearch; 555 private boolean mSystemIcons; 556 private boolean mClock; 557 private boolean mNotificationIcons; 558 559 /** @hide */ DisableInfo(int flags1, int flags2)560 public DisableInfo(int flags1, int flags2) { 561 mStatusBarExpansion = (flags1 & DISABLE_EXPAND) != 0; 562 mNavigateHome = (flags1 & DISABLE_HOME) != 0; 563 mNotificationPeeking = (flags1 & DISABLE_NOTIFICATION_ALERTS) != 0; 564 mRecents = (flags1 & DISABLE_RECENT) != 0; 565 mSearch = (flags1 & DISABLE_SEARCH) != 0; 566 mSystemIcons = (flags1 & DISABLE_SYSTEM_INFO) != 0; 567 mClock = (flags1 & DISABLE_CLOCK) != 0; 568 mNotificationIcons = (flags1 & DISABLE_NOTIFICATION_ICONS) != 0; 569 } 570 571 /** @hide */ DisableInfo()572 public DisableInfo() {} 573 574 /** 575 * @return {@code true} if expanding the notification shade is disabled 576 * 577 * @hide 578 */ 579 @SystemApi isStatusBarExpansionDisabled()580 public boolean isStatusBarExpansionDisabled() { 581 return mStatusBarExpansion; 582 } 583 584 /** * @hide */ setStatusBarExpansionDisabled(boolean disabled)585 public void setStatusBarExpansionDisabled(boolean disabled) { 586 mStatusBarExpansion = disabled; 587 } 588 589 /** 590 * @return {@code true} if navigation home is disabled 591 * 592 * @hide 593 */ 594 @SystemApi isNavigateToHomeDisabled()595 public boolean isNavigateToHomeDisabled() { 596 return mNavigateHome; 597 } 598 599 /** * @hide */ setNagivationHomeDisabled(boolean disabled)600 public void setNagivationHomeDisabled(boolean disabled) { 601 mNavigateHome = disabled; 602 } 603 604 /** 605 * @return {@code true} if notification peeking (heads-up notification) is disabled 606 * 607 * @hide 608 */ 609 @SystemApi isNotificationPeekingDisabled()610 public boolean isNotificationPeekingDisabled() { 611 return mNotificationPeeking; 612 } 613 614 /** @hide */ setNotificationPeekingDisabled(boolean disabled)615 public void setNotificationPeekingDisabled(boolean disabled) { 616 mNotificationPeeking = disabled; 617 } 618 619 /** 620 * @return {@code true} if mRecents/overview is disabled 621 * 622 * @hide 623 */ 624 @SystemApi isRecentsDisabled()625 public boolean isRecentsDisabled() { 626 return mRecents; 627 } 628 629 /** @hide */ setRecentsDisabled(boolean disabled)630 public void setRecentsDisabled(boolean disabled) { 631 mRecents = disabled; 632 } 633 634 /** 635 * @return {@code true} if mSearch is disabled 636 * 637 * @hide 638 */ 639 @SystemApi isSearchDisabled()640 public boolean isSearchDisabled() { 641 return mSearch; 642 } 643 644 /** @hide */ setSearchDisabled(boolean disabled)645 public void setSearchDisabled(boolean disabled) { 646 mSearch = disabled; 647 } 648 649 /** 650 * @return {@code true} if system icons are disabled 651 * 652 * @hide 653 */ areSystemIconsDisabled()654 public boolean areSystemIconsDisabled() { 655 return mSystemIcons; 656 } 657 658 /** * @hide */ setSystemIconsDisabled(boolean disabled)659 public void setSystemIconsDisabled(boolean disabled) { 660 mSystemIcons = disabled; 661 } 662 663 /** 664 * @return {@code true} if the clock icon is disabled 665 * 666 * @hide 667 */ isClockDisabled()668 public boolean isClockDisabled() { 669 return mClock; 670 } 671 672 /** * @hide */ setClockDisabled(boolean disabled)673 public void setClockDisabled(boolean disabled) { 674 mClock = disabled; 675 } 676 677 /** 678 * @return {@code true} if notification icons are disabled 679 * 680 * @hide 681 */ areNotificationIconsDisabled()682 public boolean areNotificationIconsDisabled() { 683 return mNotificationIcons; 684 } 685 686 /** * @hide */ setNotificationIconsDisabled(boolean disabled)687 public void setNotificationIconsDisabled(boolean disabled) { 688 mNotificationIcons = disabled; 689 } 690 691 /** 692 * @return {@code true} if no components are disabled (default state) 693 * 694 * @hide 695 */ 696 @SystemApi areAllComponentsEnabled()697 public boolean areAllComponentsEnabled() { 698 return !mStatusBarExpansion && !mNavigateHome && !mNotificationPeeking && !mRecents 699 && !mSearch && !mSystemIcons && !mClock && !mNotificationIcons; 700 } 701 702 /** @hide */ setEnableAll()703 public void setEnableAll() { 704 mStatusBarExpansion = false; 705 mNavigateHome = false; 706 mNotificationPeeking = false; 707 mRecents = false; 708 mSearch = false; 709 mSystemIcons = false; 710 mClock = false; 711 mNotificationIcons = false; 712 } 713 714 /** 715 * @return {@code true} if all status bar components are disabled 716 * 717 * @hide 718 */ areAllComponentsDisabled()719 public boolean areAllComponentsDisabled() { 720 return mStatusBarExpansion && mNavigateHome && mNotificationPeeking 721 && mRecents && mSearch && mSystemIcons && mClock && mNotificationIcons; 722 } 723 724 /** @hide */ setDisableAll()725 public void setDisableAll() { 726 mStatusBarExpansion = true; 727 mNavigateHome = true; 728 mNotificationPeeking = true; 729 mRecents = true; 730 mSearch = true; 731 mSystemIcons = true; 732 mClock = true; 733 mNotificationIcons = true; 734 } 735 736 @NonNull 737 @Override toString()738 public String toString() { 739 StringBuilder sb = new StringBuilder(); 740 sb.append("DisableInfo: "); 741 sb.append(" mStatusBarExpansion=").append(mStatusBarExpansion ? "disabled" : "enabled"); 742 sb.append(" mNavigateHome=").append(mNavigateHome ? "disabled" : "enabled"); 743 sb.append(" mNotificationPeeking=") 744 .append(mNotificationPeeking ? "disabled" : "enabled"); 745 sb.append(" mRecents=").append(mRecents ? "disabled" : "enabled"); 746 sb.append(" mSearch=").append(mSearch ? "disabled" : "enabled"); 747 sb.append(" mSystemIcons=").append(mSystemIcons ? "disabled" : "enabled"); 748 sb.append(" mClock=").append(mClock ? "disabled" : "enabled"); 749 sb.append(" mNotificationIcons=").append(mNotificationIcons ? "disabled" : "enabled"); 750 751 return sb.toString(); 752 753 } 754 755 /** 756 * Convert a DisableInfo to equivalent flags 757 * @return a pair of equivalent disable flags 758 * 759 * @hide 760 */ toFlags()761 public Pair<Integer, Integer> toFlags() { 762 int disable1 = DISABLE_NONE; 763 int disable2 = DISABLE2_NONE; 764 765 if (mStatusBarExpansion) disable1 |= DISABLE_EXPAND; 766 if (mNavigateHome) disable1 |= DISABLE_HOME; 767 if (mNotificationPeeking) disable1 |= DISABLE_NOTIFICATION_ALERTS; 768 if (mRecents) disable1 |= DISABLE_RECENT; 769 if (mSearch) disable1 |= DISABLE_SEARCH; 770 if (mSystemIcons) disable1 |= DISABLE_SYSTEM_INFO; 771 if (mClock) disable1 |= DISABLE_CLOCK; 772 if (mNotificationIcons) disable1 |= DISABLE_NOTIFICATION_ICONS; 773 774 return new Pair<Integer, Integer>(disable1, disable2); 775 } 776 } 777 } 778