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 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 17 | package com.android.server.statusbar; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 18 | |
Charles He | 9851a8d | 2017-10-10 17:31:30 +0100 | [diff] [blame] | 19 | import static android.app.StatusBarManager.DISABLE2_GLOBAL_ACTIONS; |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 20 | import static android.view.Display.DEFAULT_DISPLAY; |
Charles He | 9851a8d | 2017-10-10 17:31:30 +0100 | [diff] [blame] | 21 | |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 22 | import android.annotation.Nullable; |
Adam Lesinski | a82b626 | 2017-03-21 16:56:17 -0700 | [diff] [blame] | 23 | import android.app.ActivityThread; |
Tony Mak | 7d4b3a5 | 2018-11-27 17:29:36 +0000 | [diff] [blame] | 24 | import android.app.Notification; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | import android.app.StatusBarManager; |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 26 | import android.content.ComponentName; |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 27 | import android.content.Context; |
Kevin Chyn | 23289ef | 2018-11-28 16:32:36 -0800 | [diff] [blame] | 28 | import android.hardware.biometrics.IBiometricServiceReceiverInternal; |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 29 | import android.hardware.display.DisplayManager; |
| 30 | import android.hardware.display.DisplayManager.DisplayListener; |
Aran Ink | fd2bfd3 | 2019-10-04 16:30:01 -0400 | [diff] [blame] | 31 | import android.net.Uri; |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 32 | import android.os.Binder; |
Jorim Jaggi | 165ce06 | 2015-07-06 16:18:11 -0700 | [diff] [blame] | 33 | import android.os.Bundle; |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 34 | import android.os.Handler; |
| 35 | import android.os.IBinder; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 36 | import android.os.PowerManager; |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 37 | import android.os.Process; |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 38 | import android.os.RemoteException; |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 39 | import android.os.ResultReceiver; |
Dianne Hackborn | 354736e | 2016-08-22 17:00:05 -0700 | [diff] [blame] | 40 | import android.os.ShellCallback; |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 41 | import android.os.UserHandle; |
Julia Reynolds | 503ed94 | 2017-10-04 16:04:56 -0400 | [diff] [blame] | 42 | import android.service.notification.NotificationStats; |
Dan Sandler | f3a1f2c | 2016-06-26 15:59:13 -0400 | [diff] [blame] | 43 | import android.text.TextUtils; |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 44 | import android.util.ArrayMap; |
Tiger Huang | 0dbd537 | 2019-10-26 00:24:22 +0800 | [diff] [blame] | 45 | import android.util.ArraySet; |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 46 | import android.util.Pair; |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 47 | import android.util.Slog; |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 48 | import android.util.SparseArray; |
Tiger Huang | 0dbd537 | 2019-10-26 00:24:22 +0800 | [diff] [blame] | 49 | import android.view.InsetsState.InternalInsetType; |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 50 | import android.view.WindowInsetsController.Appearance; |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 51 | |
Jason Monk | b430218 | 2017-08-04 13:39:17 -0400 | [diff] [blame] | 52 | import com.android.internal.R; |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 53 | import com.android.internal.annotations.GuardedBy; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 54 | import com.android.internal.statusbar.IStatusBar; |
| 55 | import com.android.internal.statusbar.IStatusBarService; |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 56 | import com.android.internal.statusbar.NotificationVisibility; |
Yohei Yukawa | 49efa71 | 2019-04-04 11:49:02 -0700 | [diff] [blame] | 57 | import com.android.internal.statusbar.RegisterStatusBarResult; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 58 | import com.android.internal.statusbar.StatusBarIcon; |
Jeff Sharkey | fe9a53b | 2017-03-31 14:08:23 -0600 | [diff] [blame] | 59 | import com.android.internal.util.DumpUtils; |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 60 | import com.android.internal.view.AppearanceRegion; |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 61 | import com.android.server.LocalServices; |
| 62 | import com.android.server.notification.NotificationDelegate; |
Michael Kwan | 2decbf7 | 2018-02-22 07:40:11 -0800 | [diff] [blame] | 63 | import com.android.server.policy.GlobalActionsProvider; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 64 | import com.android.server.power.ShutdownThread; |
Dianne Hackborn | a924dc0d | 2011-02-17 14:22:17 -0800 | [diff] [blame] | 65 | import com.android.server.wm.WindowManagerService; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 66 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 67 | import java.io.FileDescriptor; |
| 68 | import java.io.PrintWriter; |
| 69 | import java.util.ArrayList; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 70 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 71 | /** |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 72 | * A note on locking: We rely on the fact that calls onto mBar are oneway or |
| 73 | * if they are local, that they just enqueue messages to not deadlock. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 74 | */ |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 75 | public class StatusBarManagerService extends IStatusBarService.Stub implements DisplayListener { |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 76 | private static final String TAG = "StatusBarManagerService"; |
| 77 | private static final boolean SPEW = false; |
Joe Onorato | df7dbb6 | 2009-11-17 10:43:37 -0800 | [diff] [blame] | 78 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 79 | private final Context mContext; |
Adam Lesinski | a82b626 | 2017-03-21 16:56:17 -0700 | [diff] [blame] | 80 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 81 | private final WindowManagerService mWindowManager; |
| 82 | private Handler mHandler = new Handler(); |
| 83 | private NotificationDelegate mNotificationDelegate; |
| 84 | private volatile IStatusBar mBar; |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 85 | private ArrayMap<String, StatusBarIcon> mIcons = new ArrayMap<>(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 86 | |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 87 | // for disabling the status bar |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 88 | private final ArrayList<DisableRecord> mDisableRecords = new ArrayList<DisableRecord>(); |
Michael Kwan | 2decbf7 | 2018-02-22 07:40:11 -0800 | [diff] [blame] | 89 | private GlobalActionsProvider.GlobalActionsListener mGlobalActionListener; |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 90 | private IBinder mSysUiVisToken = new Binder(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 91 | |
Adrian Roos | 2a62910 | 2016-04-15 16:28:03 -0700 | [diff] [blame] | 92 | private final Object mLock = new Object(); |
Gopal Krishna Shukla | e5c8379 | 2018-06-29 18:20:36 +0530 | [diff] [blame] | 93 | private final DeathRecipient mDeathRecipient = new DeathRecipient(); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 94 | private int mCurrentUserId; |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 95 | |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 96 | private SparseArray<UiState> mDisplayUiState = new SparseArray<>(); |
| 97 | |
Gopal Krishna Shukla | e5c8379 | 2018-06-29 18:20:36 +0530 | [diff] [blame] | 98 | private class DeathRecipient implements IBinder.DeathRecipient { |
| 99 | public void binderDied() { |
| 100 | mBar.asBinder().unlinkToDeath(this,0); |
| 101 | mBar = null; |
| 102 | notifyBarAttachChanged(); |
| 103 | } |
| 104 | |
| 105 | public void linkToDeath() { |
| 106 | try { |
| 107 | mBar.asBinder().linkToDeath(mDeathRecipient,0); |
| 108 | } catch (RemoteException e) { |
| 109 | Slog.e(TAG,"Unable to register Death Recipient for status bar", e); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | } |
| 114 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 115 | private class DisableRecord implements IBinder.DeathRecipient { |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 116 | int userId; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 117 | String pkg; |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 118 | int what1; |
| 119 | int what2; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 120 | IBinder token; |
| 121 | |
Charles He | ede3909 | 2017-09-18 09:19:28 +0100 | [diff] [blame] | 122 | public DisableRecord(int userId, IBinder token) { |
| 123 | this.userId = userId; |
| 124 | this.token = token; |
| 125 | try { |
| 126 | token.linkToDeath(this, 0); |
| 127 | } catch (RemoteException re) { |
| 128 | // Give up |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 133 | public void binderDied() { |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 134 | Slog.i(TAG, "binder died for pkg=" + pkg); |
Benjamin Franz | ea2ec97 | 2015-03-16 17:18:09 +0000 | [diff] [blame] | 135 | disableForUser(0, token, pkg, userId); |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 136 | disable2ForUser(0, token, pkg, userId); |
Suchi Amalapurapu | fff2fda | 2009-06-30 21:36:16 -0700 | [diff] [blame] | 137 | token.unlinkToDeath(this, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 138 | } |
Charles He | ede3909 | 2017-09-18 09:19:28 +0100 | [diff] [blame] | 139 | |
| 140 | public void setFlags(int what, int which, String pkg) { |
| 141 | switch (which) { |
| 142 | case 1: |
| 143 | what1 = what; |
JiangDongya | b1352cd | 2018-11-09 18:23:54 +0800 | [diff] [blame] | 144 | break; |
Charles He | ede3909 | 2017-09-18 09:19:28 +0100 | [diff] [blame] | 145 | case 2: |
| 146 | what2 = what; |
JiangDongya | b1352cd | 2018-11-09 18:23:54 +0800 | [diff] [blame] | 147 | break; |
Charles He | ede3909 | 2017-09-18 09:19:28 +0100 | [diff] [blame] | 148 | default: |
| 149 | Slog.w(TAG, "Can't set unsupported disable flag " + which |
| 150 | + ": 0x" + Integer.toHexString(what)); |
JiangDongya | b1352cd | 2018-11-09 18:23:54 +0800 | [diff] [blame] | 151 | break; |
Charles He | ede3909 | 2017-09-18 09:19:28 +0100 | [diff] [blame] | 152 | } |
| 153 | this.pkg = pkg; |
| 154 | } |
| 155 | |
| 156 | public int getFlags(int which) { |
| 157 | switch (which) { |
| 158 | case 1: return what1; |
| 159 | case 2: return what2; |
| 160 | default: |
| 161 | Slog.w(TAG, "Can't get unsupported disable flag " + which); |
| 162 | return 0; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | public boolean isEmpty() { |
| 167 | return what1 == 0 && what2 == 0; |
| 168 | } |
| 169 | |
| 170 | @Override |
| 171 | public String toString() { |
| 172 | return String.format("userId=%d what1=0x%08X what2=0x%08X pkg=%s token=%s", |
| 173 | userId, what1, what2, pkg, token); |
| 174 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 175 | } |
| 176 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 177 | /** |
| 178 | * Construct the service, add the status bar view to the window manager |
| 179 | */ |
Jeff Brown | 2992ea7 | 2011-01-28 22:04:14 -0800 | [diff] [blame] | 180 | public StatusBarManagerService(Context context, WindowManagerService windowManager) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 181 | mContext = context; |
Jeff Brown | 2992ea7 | 2011-01-28 22:04:14 -0800 | [diff] [blame] | 182 | mWindowManager = windowManager; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 183 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 184 | LocalServices.addService(StatusBarManagerInternal.class, mInternalService); |
Michael Kwan | 2decbf7 | 2018-02-22 07:40:11 -0800 | [diff] [blame] | 185 | LocalServices.addService(GlobalActionsProvider.class, mGlobalActionsProvider); |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 186 | |
| 187 | // We always have a default display. |
| 188 | final UiState state = new UiState(); |
| 189 | mDisplayUiState.put(DEFAULT_DISPLAY, state); |
| 190 | |
| 191 | final DisplayManager displayManager = |
| 192 | (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE); |
| 193 | displayManager.registerDisplayListener(this, mHandler); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 194 | } |
| 195 | |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 196 | @Override |
| 197 | public void onDisplayAdded(int displayId) {} |
| 198 | |
| 199 | @Override |
| 200 | public void onDisplayRemoved(int displayId) { |
| 201 | synchronized (mLock) { |
| 202 | mDisplayUiState.remove(displayId); |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | @Override |
| 207 | public void onDisplayChanged(int displayId) {} |
| 208 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 209 | /** |
| 210 | * Private API used by NotificationManagerService. |
| 211 | */ |
| 212 | private final StatusBarManagerInternal mInternalService = new StatusBarManagerInternal() { |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 213 | private boolean mNotificationLightOn; |
| 214 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 215 | @Override |
| 216 | public void setNotificationDelegate(NotificationDelegate delegate) { |
Christoph Studer | e71fefc | 2014-06-24 16:16:49 +0200 | [diff] [blame] | 217 | mNotificationDelegate = delegate; |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 218 | } |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 219 | |
John Spurlock | cad5768 | 2014-07-26 17:09:56 -0400 | [diff] [blame] | 220 | @Override |
Andrii Kulian | 0f051f5 | 2016-04-14 00:41:51 -0700 | [diff] [blame] | 221 | public void showScreenPinningRequest(int taskId) { |
Jason Monk | 5565cb4 | 2014-09-12 10:59:21 -0400 | [diff] [blame] | 222 | if (mBar != null) { |
| 223 | try { |
Andrii Kulian | 0f051f5 | 2016-04-14 00:41:51 -0700 | [diff] [blame] | 224 | mBar.showScreenPinningRequest(taskId); |
Jason Monk | 5565cb4 | 2014-09-12 10:59:21 -0400 | [diff] [blame] | 225 | } catch (RemoteException e) { |
| 226 | } |
| 227 | } |
| 228 | } |
Adrian Roos | 4f43dc0 | 2015-06-17 16:43:38 -0700 | [diff] [blame] | 229 | |
| 230 | @Override |
| 231 | public void showAssistDisclosure() { |
| 232 | if (mBar != null) { |
| 233 | try { |
| 234 | mBar.showAssistDisclosure(); |
| 235 | } catch (RemoteException e) { |
| 236 | } |
| 237 | } |
| 238 | } |
Jorim Jaggi | 165ce06 | 2015-07-06 16:18:11 -0700 | [diff] [blame] | 239 | |
| 240 | @Override |
| 241 | public void startAssist(Bundle args) { |
| 242 | if (mBar != null) { |
| 243 | try { |
| 244 | mBar.startAssist(args); |
| 245 | } catch (RemoteException e) { |
| 246 | } |
| 247 | } |
| 248 | } |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 249 | |
| 250 | @Override |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 251 | public void onCameraLaunchGestureDetected(int source) { |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 252 | if (mBar != null) { |
| 253 | try { |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 254 | mBar.onCameraLaunchGestureDetected(source); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 255 | } catch (RemoteException e) { |
| 256 | } |
| 257 | } |
| 258 | } |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 259 | |
| 260 | @Override |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 261 | public void topAppWindowChanged(int displayId, boolean isFullscreen, boolean isImmersive) { |
| 262 | StatusBarManagerService.this.topAppWindowChanged(displayId, isFullscreen, isImmersive); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | @Override |
Tiger Huang | 0dbd537 | 2019-10-26 00:24:22 +0800 | [diff] [blame] | 266 | public void setDisableFlags(int displayId, int flags, String cause) { |
| 267 | StatusBarManagerService.this.setDisableFlags(displayId, flags, cause); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 268 | } |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 269 | |
| 270 | @Override |
| 271 | public void toggleSplitScreen() { |
| 272 | enforceStatusBarService(); |
| 273 | if (mBar != null) { |
| 274 | try { |
| 275 | mBar.toggleSplitScreen(); |
| 276 | } catch (RemoteException ex) {} |
| 277 | } |
| 278 | } |
Jorim Jaggi | 2adba07 | 2016-03-03 13:43:39 +0100 | [diff] [blame] | 279 | |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 280 | @Override |
| 281 | public void appTransitionFinished(int displayId) { |
Jorim Jaggi | 2adba07 | 2016-03-03 13:43:39 +0100 | [diff] [blame] | 282 | enforceStatusBarService(); |
| 283 | if (mBar != null) { |
| 284 | try { |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 285 | mBar.appTransitionFinished(displayId); |
Jorim Jaggi | 2adba07 | 2016-03-03 13:43:39 +0100 | [diff] [blame] | 286 | } catch (RemoteException ex) {} |
| 287 | } |
| 288 | } |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 289 | |
| 290 | @Override |
| 291 | public void toggleRecentApps() { |
| 292 | if (mBar != null) { |
| 293 | try { |
| 294 | mBar.toggleRecentApps(); |
| 295 | } catch (RemoteException ex) {} |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | @Override |
| 300 | public void setCurrentUser(int newUserId) { |
| 301 | if (SPEW) Slog.d(TAG, "Setting current user to user " + newUserId); |
| 302 | mCurrentUserId = newUserId; |
| 303 | } |
| 304 | |
| 305 | |
| 306 | @Override |
| 307 | public void preloadRecentApps() { |
| 308 | if (mBar != null) { |
| 309 | try { |
| 310 | mBar.preloadRecentApps(); |
| 311 | } catch (RemoteException ex) {} |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | @Override |
| 316 | public void cancelPreloadRecentApps() { |
| 317 | if (mBar != null) { |
| 318 | try { |
| 319 | mBar.cancelPreloadRecentApps(); |
| 320 | } catch (RemoteException ex) {} |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | @Override |
Winson Chung | dff7a73 | 2017-12-11 12:17:06 -0800 | [diff] [blame] | 325 | public void showRecentApps(boolean triggeredFromAltTab) { |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 326 | if (mBar != null) { |
| 327 | try { |
Winson Chung | dff7a73 | 2017-12-11 12:17:06 -0800 | [diff] [blame] | 328 | mBar.showRecentApps(triggeredFromAltTab); |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 329 | } catch (RemoteException ex) {} |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | @Override |
| 334 | public void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) { |
| 335 | if (mBar != null) { |
| 336 | try { |
| 337 | mBar.hideRecentApps(triggeredFromAltTab, triggeredFromHomeKey); |
| 338 | } catch (RemoteException ex) {} |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | @Override |
Andrei Stingaceanu | 0bf096f | 2016-04-14 18:11:57 +0100 | [diff] [blame] | 343 | public void dismissKeyboardShortcutsMenu() { |
| 344 | if (mBar != null) { |
| 345 | try { |
| 346 | mBar.dismissKeyboardShortcutsMenu(); |
| 347 | } catch (RemoteException ex) {} |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | @Override |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 352 | public void toggleKeyboardShortcutsMenu(int deviceId) { |
| 353 | if (mBar != null) { |
| 354 | try { |
| 355 | mBar.toggleKeyboardShortcutsMenu(deviceId); |
| 356 | } catch (RemoteException ex) {} |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | @Override |
Beverly | ae79ab9 | 2017-12-11 09:20:02 -0500 | [diff] [blame] | 361 | public void showChargingAnimation(int batteryLevel) { |
| 362 | if (mBar != null) { |
| 363 | try { |
Beverly | ac32c9a | 2018-01-31 16:10:41 -0500 | [diff] [blame] | 364 | mBar.showWirelessChargingAnimation(batteryLevel); |
Beverly | ae79ab9 | 2017-12-11 09:20:02 -0500 | [diff] [blame] | 365 | } catch (RemoteException ex){ |
| 366 | } |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | @Override |
Winson Chung | ac52f28 | 2017-03-30 14:44:52 -0700 | [diff] [blame] | 371 | public void showPictureInPictureMenu() { |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 372 | if (mBar != null) { |
| 373 | try { |
Winson Chung | ac52f28 | 2017-03-30 14:44:52 -0700 | [diff] [blame] | 374 | mBar.showPictureInPictureMenu(); |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 375 | } catch (RemoteException ex) {} |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | @Override |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 380 | public void setWindowState(int displayId, int window, int state) { |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 381 | if (mBar != null) { |
| 382 | try { |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 383 | mBar.setWindowState(displayId, window, state); |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 384 | } catch (RemoteException ex) {} |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | @Override |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 389 | public void appTransitionPending(int displayId) { |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 390 | if (mBar != null) { |
| 391 | try { |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 392 | mBar.appTransitionPending(displayId); |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 393 | } catch (RemoteException ex) {} |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | @Override |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 398 | public void appTransitionCancelled(int displayId) { |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 399 | if (mBar != null) { |
| 400 | try { |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 401 | mBar.appTransitionCancelled(displayId); |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 402 | } catch (RemoteException ex) {} |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | @Override |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 407 | public void appTransitionStarting(int displayId, long statusBarAnimationsStartTime, |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 408 | long statusBarAnimationsDuration) { |
| 409 | if (mBar != null) { |
| 410 | try { |
| 411 | mBar.appTransitionStarting( |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 412 | displayId, statusBarAnimationsStartTime, statusBarAnimationsDuration); |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 413 | } catch (RemoteException ex) {} |
| 414 | } |
| 415 | } |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 416 | |
| 417 | @Override |
Selim Cinek | 3a49ba2 | 2017-08-10 11:17:39 -0700 | [diff] [blame] | 418 | public void setTopAppHidesStatusBar(boolean hidesStatusBar) { |
| 419 | if (mBar != null) { |
| 420 | try { |
| 421 | mBar.setTopAppHidesStatusBar(hidesStatusBar); |
| 422 | } catch (RemoteException ex) {} |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | @Override |
Jason Monk | b430218 | 2017-08-04 13:39:17 -0400 | [diff] [blame] | 427 | public boolean showShutdownUi(boolean isReboot, String reason) { |
| 428 | if (!mContext.getResources().getBoolean(R.bool.config_showSysuiShutdown)) { |
| 429 | return false; |
| 430 | } |
| 431 | if (mBar != null) { |
| 432 | try { |
| 433 | mBar.showShutdownUi(isReboot, reason); |
| 434 | return true; |
| 435 | } catch (RemoteException ex) {} |
| 436 | } |
| 437 | return false; |
| 438 | } |
Mike Digman | 93f0834 | 2017-11-24 21:46:53 -0800 | [diff] [blame] | 439 | |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 440 | // TODO(b/118592525): support it per display if necessary. |
Mike Digman | 93f0834 | 2017-11-24 21:46:53 -0800 | [diff] [blame] | 441 | @Override |
Mike Digman | e077731 | 2018-01-19 12:41:51 -0800 | [diff] [blame] | 442 | public void onProposedRotationChanged(int rotation, boolean isValid) { |
Mike Digman | 93f0834 | 2017-11-24 21:46:53 -0800 | [diff] [blame] | 443 | if (mBar != null){ |
| 444 | try { |
Mike Digman | e077731 | 2018-01-19 12:41:51 -0800 | [diff] [blame] | 445 | mBar.onProposedRotationChanged(rotation, isValid); |
Mike Digman | 93f0834 | 2017-11-24 21:46:53 -0800 | [diff] [blame] | 446 | } catch (RemoteException ex) {} |
| 447 | } |
| 448 | } |
Charles Chen | 3dedec3 | 2019-01-24 22:19:37 +0800 | [diff] [blame] | 449 | |
| 450 | @Override |
| 451 | public void onDisplayReady(int displayId) { |
| 452 | if (mBar != null) { |
| 453 | try { |
| 454 | mBar.onDisplayReady(displayId); |
Winson Chung | 67e4936 | 2019-05-17 16:40:38 -0700 | [diff] [blame] | 455 | } catch (RemoteException ex) {} |
Charles Chen | 3dedec3 | 2019-01-24 22:19:37 +0800 | [diff] [blame] | 456 | } |
| 457 | } |
Winson Chung | 67e4936 | 2019-05-17 16:40:38 -0700 | [diff] [blame] | 458 | |
| 459 | @Override |
| 460 | public void onRecentsAnimationStateChanged(boolean running) { |
| 461 | if (mBar != null) { |
| 462 | try { |
| 463 | mBar.onRecentsAnimationStateChanged(running); |
| 464 | } catch (RemoteException ex) {} |
| 465 | } |
| 466 | |
| 467 | } |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 468 | |
| 469 | @Override |
| 470 | public void onSystemBarAppearanceChanged(int displayId, @Appearance int appearance, |
| 471 | AppearanceRegion[] appearanceRegions, boolean navbarColorManagedByIme) { |
Tiger Huang | 0dbd537 | 2019-10-26 00:24:22 +0800 | [diff] [blame] | 472 | final UiState state = getUiState(displayId); |
| 473 | if (!state.appearanceEquals(appearance, appearanceRegions, navbarColorManagedByIme)) { |
| 474 | state.setAppearance(appearance, appearanceRegions, navbarColorManagedByIme); |
| 475 | } |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 476 | if (mBar != null) { |
| 477 | try { |
| 478 | mBar.onSystemBarAppearanceChanged(displayId, appearance, appearanceRegions, |
| 479 | navbarColorManagedByIme); |
| 480 | } catch (RemoteException ex) { } |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | @Override |
Tiger Huang | 0dbd537 | 2019-10-26 00:24:22 +0800 | [diff] [blame] | 485 | public void showTransient(int displayId, @InternalInsetType int[] types) { |
| 486 | getUiState(displayId).showTransient(types); |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 487 | if (mBar != null) { |
| 488 | try { |
| 489 | mBar.showTransient(displayId, types); |
| 490 | } catch (RemoteException ex) { } |
| 491 | } |
| 492 | } |
| 493 | |
| 494 | @Override |
Tiger Huang | 0dbd537 | 2019-10-26 00:24:22 +0800 | [diff] [blame] | 495 | public void abortTransient(int displayId, @InternalInsetType int[] types) { |
| 496 | getUiState(displayId).clearTransient(types); |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 497 | if (mBar != null) { |
| 498 | try { |
| 499 | mBar.abortTransient(displayId, types); |
| 500 | } catch (RemoteException ex) { } |
| 501 | } |
| 502 | } |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 503 | }; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 504 | |
Michael Kwan | 2decbf7 | 2018-02-22 07:40:11 -0800 | [diff] [blame] | 505 | private final GlobalActionsProvider mGlobalActionsProvider = new GlobalActionsProvider() { |
| 506 | @Override |
| 507 | public boolean isGlobalActionsDisabled() { |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 508 | // TODO(b/118592525): support global actions for multi-display. |
| 509 | final int disabled2 = mDisplayUiState.get(DEFAULT_DISPLAY).getDisabled2(); |
| 510 | return (disabled2 & DISABLE2_GLOBAL_ACTIONS) != 0; |
Michael Kwan | 2decbf7 | 2018-02-22 07:40:11 -0800 | [diff] [blame] | 511 | } |
| 512 | |
| 513 | @Override |
| 514 | public void setGlobalActionsListener(GlobalActionsProvider.GlobalActionsListener listener) { |
| 515 | mGlobalActionListener = listener; |
| 516 | mGlobalActionListener.onGlobalActionsAvailableChanged(mBar != null); |
| 517 | } |
| 518 | |
| 519 | @Override |
| 520 | public void showGlobalActions() { |
| 521 | if (mBar != null) { |
| 522 | try { |
| 523 | mBar.showGlobalActionsMenu(); |
| 524 | } catch (RemoteException ex) {} |
| 525 | } |
| 526 | } |
| 527 | }; |
| 528 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 529 | // ================================================================================ |
Joe Onorato | 25f95f9 | 2010-04-08 18:37:10 -0500 | [diff] [blame] | 530 | // From IStatusBarService |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 531 | // ================================================================================ |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 532 | @Override |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 533 | public void expandNotificationsPanel() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 534 | enforceExpandStatusBar(); |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 535 | |
| 536 | if (mBar != null) { |
| 537 | try { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 538 | mBar.animateExpandNotificationsPanel(); |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 539 | } catch (RemoteException ex) { |
| 540 | } |
| 541 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 542 | } |
| 543 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 544 | @Override |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 545 | public void collapsePanels() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 546 | enforceExpandStatusBar(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 547 | |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 548 | if (mBar != null) { |
| 549 | try { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 550 | mBar.animateCollapsePanels(); |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 551 | } catch (RemoteException ex) { |
| 552 | } |
| 553 | } |
| 554 | } |
| 555 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 556 | @Override |
Anthony Chen | 9ad00e0 | 2017-05-12 15:53:36 -0700 | [diff] [blame] | 557 | public void togglePanel() { |
| 558 | enforceExpandStatusBar(); |
| 559 | |
| 560 | if (mBar != null) { |
| 561 | try { |
| 562 | mBar.togglePanel(); |
| 563 | } catch (RemoteException ex) { |
| 564 | } |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | @Override |
Jason Monk | a992732 | 2015-12-13 16:22:37 -0500 | [diff] [blame] | 569 | public void expandSettingsPanel(String subPanel) { |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 570 | enforceExpandStatusBar(); |
| 571 | |
| 572 | if (mBar != null) { |
| 573 | try { |
Jason Monk | a992732 | 2015-12-13 16:22:37 -0500 | [diff] [blame] | 574 | mBar.animateExpandSettingsPanel(subPanel); |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 575 | } catch (RemoteException ex) { |
| 576 | } |
| 577 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 578 | } |
| 579 | |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 580 | public void addTile(ComponentName component) { |
| 581 | enforceStatusBarOrShell(); |
| 582 | |
| 583 | if (mBar != null) { |
| 584 | try { |
| 585 | mBar.addQsTile(component); |
| 586 | } catch (RemoteException ex) { |
| 587 | } |
| 588 | } |
| 589 | } |
| 590 | |
| 591 | public void remTile(ComponentName component) { |
| 592 | enforceStatusBarOrShell(); |
| 593 | |
| 594 | if (mBar != null) { |
| 595 | try { |
| 596 | mBar.remQsTile(component); |
| 597 | } catch (RemoteException ex) { |
| 598 | } |
| 599 | } |
| 600 | } |
| 601 | |
| 602 | public void clickTile(ComponentName component) { |
| 603 | enforceStatusBarOrShell(); |
| 604 | |
| 605 | if (mBar != null) { |
| 606 | try { |
| 607 | mBar.clickQsTile(component); |
| 608 | } catch (RemoteException ex) { |
| 609 | } |
| 610 | } |
| 611 | } |
| 612 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 613 | @Override |
Philip Quinn | c3a503d | 2017-07-18 23:23:41 -0700 | [diff] [blame] | 614 | public void handleSystemKey(int key) throws RemoteException { |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 615 | enforceExpandStatusBar(); |
| 616 | |
| 617 | if (mBar != null) { |
| 618 | try { |
Philip Quinn | c3a503d | 2017-07-18 23:23:41 -0700 | [diff] [blame] | 619 | mBar.handleSystemKey(key); |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 620 | } catch (RemoteException ex) { |
| 621 | } |
| 622 | } |
| 623 | } |
| 624 | |
| 625 | @Override |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 626 | public void showPinningEnterExitToast(boolean entering) throws RemoteException { |
| 627 | if (mBar != null) { |
| 628 | try { |
| 629 | mBar.showPinningEnterExitToast(entering); |
| 630 | } catch (RemoteException ex) { |
| 631 | } |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | @Override |
| 636 | public void showPinningEscapeToast() throws RemoteException { |
| 637 | if (mBar != null) { |
| 638 | try { |
| 639 | mBar.showPinningEscapeToast(); |
| 640 | } catch (RemoteException ex) { |
| 641 | } |
| 642 | } |
| 643 | } |
| 644 | |
| 645 | @Override |
Kevin Chyn | 86f1b8e | 2019-09-24 19:00:49 -0700 | [diff] [blame] | 646 | public void showAuthenticationDialog(Bundle bundle, IBiometricServiceReceiverInternal receiver, |
| 647 | int biometricModality, boolean requireConfirmation, int userId, String opPackageName) { |
Kevin Chyn | 95c27e0 | 2018-09-12 01:46:16 -0700 | [diff] [blame] | 648 | enforceBiometricDialog(); |
Kevin Chyn | aae4a15 | 2018-01-18 11:48:09 -0800 | [diff] [blame] | 649 | if (mBar != null) { |
| 650 | try { |
Kevin Chyn | 86f1b8e | 2019-09-24 19:00:49 -0700 | [diff] [blame] | 651 | mBar.showAuthenticationDialog(bundle, receiver, biometricModality, |
| 652 | requireConfirmation, userId, opPackageName); |
Kevin Chyn | aae4a15 | 2018-01-18 11:48:09 -0800 | [diff] [blame] | 653 | } catch (RemoteException ex) { |
| 654 | } |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | @Override |
Ilya Matyukhin | 0f9da35 | 2019-10-03 14:10:01 -0700 | [diff] [blame] | 659 | public void onBiometricAuthenticated() { |
Kevin Chyn | 95c27e0 | 2018-09-12 01:46:16 -0700 | [diff] [blame] | 660 | enforceBiometricDialog(); |
Kevin Chyn | aae4a15 | 2018-01-18 11:48:09 -0800 | [diff] [blame] | 661 | if (mBar != null) { |
| 662 | try { |
Ilya Matyukhin | 0f9da35 | 2019-10-03 14:10:01 -0700 | [diff] [blame] | 663 | mBar.onBiometricAuthenticated(); |
Kevin Chyn | aae4a15 | 2018-01-18 11:48:09 -0800 | [diff] [blame] | 664 | } catch (RemoteException ex) { |
| 665 | } |
| 666 | } |
| 667 | } |
| 668 | |
| 669 | @Override |
Kevin Chyn | e927566 | 2018-07-23 16:42:06 -0700 | [diff] [blame] | 670 | public void onBiometricHelp(String message) { |
Kevin Chyn | 95c27e0 | 2018-09-12 01:46:16 -0700 | [diff] [blame] | 671 | enforceBiometricDialog(); |
Kevin Chyn | aae4a15 | 2018-01-18 11:48:09 -0800 | [diff] [blame] | 672 | if (mBar != null) { |
| 673 | try { |
Kevin Chyn | e927566 | 2018-07-23 16:42:06 -0700 | [diff] [blame] | 674 | mBar.onBiometricHelp(message); |
Kevin Chyn | aae4a15 | 2018-01-18 11:48:09 -0800 | [diff] [blame] | 675 | } catch (RemoteException ex) { |
| 676 | } |
| 677 | } |
| 678 | } |
| 679 | |
| 680 | @Override |
Ilya Matyukhin | 0f9da35 | 2019-10-03 14:10:01 -0700 | [diff] [blame] | 681 | public void onBiometricError(int modality, int error, int vendorCode) { |
Kevin Chyn | 95c27e0 | 2018-09-12 01:46:16 -0700 | [diff] [blame] | 682 | enforceBiometricDialog(); |
Kevin Chyn | aae4a15 | 2018-01-18 11:48:09 -0800 | [diff] [blame] | 683 | if (mBar != null) { |
| 684 | try { |
Ilya Matyukhin | 0f9da35 | 2019-10-03 14:10:01 -0700 | [diff] [blame] | 685 | mBar.onBiometricError(modality, error, vendorCode); |
Kevin Chyn | aae4a15 | 2018-01-18 11:48:09 -0800 | [diff] [blame] | 686 | } catch (RemoteException ex) { |
| 687 | } |
| 688 | } |
| 689 | } |
| 690 | |
| 691 | @Override |
Kevin Chyn | 86f1b8e | 2019-09-24 19:00:49 -0700 | [diff] [blame] | 692 | public void hideAuthenticationDialog() { |
Kevin Chyn | 95c27e0 | 2018-09-12 01:46:16 -0700 | [diff] [blame] | 693 | enforceBiometricDialog(); |
Kevin Chyn | aae4a15 | 2018-01-18 11:48:09 -0800 | [diff] [blame] | 694 | if (mBar != null) { |
| 695 | try { |
Kevin Chyn | 86f1b8e | 2019-09-24 19:00:49 -0700 | [diff] [blame] | 696 | mBar.hideAuthenticationDialog(); |
Kevin Chyn | aae4a15 | 2018-01-18 11:48:09 -0800 | [diff] [blame] | 697 | } catch (RemoteException ex) { |
| 698 | } |
| 699 | } |
| 700 | } |
| 701 | |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 702 | // TODO(b/117478341): make it aware of multi-display if needed. |
Kevin Chyn | 23289ef | 2018-11-28 16:32:36 -0800 | [diff] [blame] | 703 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 704 | public void disable(int what, IBinder token, String pkg) { |
Benjamin Franz | ea2ec97 | 2015-03-16 17:18:09 +0000 | [diff] [blame] | 705 | disableForUser(what, token, pkg, mCurrentUserId); |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 706 | } |
| 707 | |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 708 | // TODO(b/117478341): make it aware of multi-display if needed. |
Benjamin Franz | ea2ec97 | 2015-03-16 17:18:09 +0000 | [diff] [blame] | 709 | @Override |
| 710 | public void disableForUser(int what, IBinder token, String pkg, int userId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 711 | enforceStatusBar(); |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 712 | |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 713 | synchronized (mLock) { |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 714 | disableLocked(DEFAULT_DISPLAY, userId, what, token, pkg, 1); |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 715 | } |
| 716 | } |
| 717 | |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 718 | // TODO(b/117478341): make it aware of multi-display if needed. |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 719 | /** |
| 720 | * Disable additional status bar features. Pass the bitwise-or of the DISABLE2_* flags. |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 721 | * To re-enable everything, pass {@link #DISABLE2_NONE}. |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 722 | * |
| 723 | * Warning: Only pass DISABLE2_* flags into this function, do not use DISABLE_* flags. |
| 724 | */ |
| 725 | @Override |
| 726 | public void disable2(int what, IBinder token, String pkg) { |
Benjamin Franz | 292a0a9 | 2016-03-30 13:41:57 +0100 | [diff] [blame] | 727 | disable2ForUser(what, token, pkg, mCurrentUserId); |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 728 | } |
| 729 | |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 730 | // TODO(b/117478341): make it aware of multi-display if needed. |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 731 | /** |
| 732 | * Disable additional status bar features for a given user. Pass the bitwise-or of the |
| 733 | * DISABLE2_* flags. To re-enable everything, pass {@link #DISABLE_NONE}. |
| 734 | * |
| 735 | * Warning: Only pass DISABLE2_* flags into this function, do not use DISABLE_* flags. |
| 736 | */ |
| 737 | @Override |
| 738 | public void disable2ForUser(int what, IBinder token, String pkg, int userId) { |
Mike Digman | dd2f49e | 2018-03-16 10:54:22 -0700 | [diff] [blame] | 739 | enforceStatusBar(); |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 740 | |
| 741 | synchronized (mLock) { |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 742 | disableLocked(DEFAULT_DISPLAY, userId, what, token, pkg, 2); |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 743 | } |
| 744 | } |
| 745 | |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 746 | private void disableLocked(int displayId, int userId, int what, IBinder token, String pkg, |
| 747 | int whichFlag) { |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 748 | // It's important that the the callback and the call to mBar get done |
| 749 | // in the same order when multiple threads are calling this function |
| 750 | // so they are paired correctly. The messages on the handler will be |
| 751 | // handled in the order they were enqueued, but will be outside the lock. |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 752 | manageDisableListLocked(userId, what, token, pkg, whichFlag); |
John Spurlock | 8f3e6d5 | 2012-11-29 13:56:24 -0500 | [diff] [blame] | 753 | |
| 754 | // Ensure state for the current user is applied, even if passed a non-current user. |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 755 | final int net1 = gatherDisableActionsLocked(mCurrentUserId, 1); |
| 756 | final int net2 = gatherDisableActionsLocked(mCurrentUserId, 2); |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 757 | final UiState state = getUiState(displayId); |
Charles Chen | 1313fee | 2018-12-12 23:36:21 +0800 | [diff] [blame] | 758 | if (!state.disableEquals(net1, net2)) { |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 759 | state.setDisabled(net1, net2); |
| 760 | mHandler.post(() -> mNotificationDelegate.onSetDisabled(net1)); |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 761 | if (mBar != null) { |
| 762 | try { |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 763 | mBar.disable(displayId, net1, net2); |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 764 | } catch (RemoteException ex) { |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 765 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 766 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 767 | } |
| 768 | } |
| 769 | |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 770 | /** |
| 771 | * Get the currently applied disable flags, in the form of one Pair<Integer, Integer>. |
| 772 | * |
| 773 | * @return pair of disable flags in the form of (disabled1, disabled2), where (0, 0) indicates |
| 774 | * no flags are set for this token. |
| 775 | */ |
| 776 | @Override |
| 777 | public int[] getDisableFlags(IBinder token, int userId) { |
| 778 | enforceStatusBar(); |
| 779 | |
| 780 | int disable1 = 0; |
| 781 | int disable2 = 0; |
| 782 | synchronized (mLock) { |
| 783 | // Find a matching record if it exists |
| 784 | DisableRecord record = findMatchingRecordLocked(token, userId).second; |
| 785 | if (record != null) { |
| 786 | disable1 = record.what1; |
| 787 | disable2 = record.what2; |
| 788 | } |
| 789 | } |
| 790 | |
| 791 | return new int[] {disable1, disable2}; |
| 792 | } |
| 793 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 794 | @Override |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 795 | public void setIcon(String slot, String iconPackage, int iconId, int iconLevel, |
| 796 | String contentDescription) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 797 | enforceStatusBar(); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 798 | |
| 799 | synchronized (mIcons) { |
Xiaohui Chen | e4de5a0 | 2015-09-22 15:33:31 -0700 | [diff] [blame] | 800 | StatusBarIcon icon = new StatusBarIcon(iconPackage, UserHandle.SYSTEM, iconId, |
| 801 | iconLevel, 0, contentDescription); |
Joe Onorato | 66d7d01 | 2010-05-14 10:05:10 -0700 | [diff] [blame] | 802 | //Slog.d(TAG, "setIcon slot=" + slot + " index=" + index + " icon=" + icon); |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 803 | mIcons.put(slot, icon); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 804 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 805 | if (mBar != null) { |
| 806 | try { |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 807 | mBar.setIcon(slot, icon); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 808 | } catch (RemoteException ex) { |
| 809 | } |
| 810 | } |
| 811 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 812 | } |
| 813 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 814 | @Override |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 815 | public void setIconVisibility(String slot, boolean visibility) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 816 | enforceStatusBar(); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 817 | |
Joe Onorato | 514ad663 | 2010-05-13 18:49:00 -0700 | [diff] [blame] | 818 | synchronized (mIcons) { |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 819 | StatusBarIcon icon = mIcons.get(slot); |
Joe Onorato | 514ad663 | 2010-05-13 18:49:00 -0700 | [diff] [blame] | 820 | if (icon == null) { |
| 821 | return; |
| 822 | } |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 823 | if (icon.visible != visibility) { |
| 824 | icon.visible = visibility; |
Joe Onorato | 514ad663 | 2010-05-13 18:49:00 -0700 | [diff] [blame] | 825 | |
Joe Onorato | 514ad663 | 2010-05-13 18:49:00 -0700 | [diff] [blame] | 826 | if (mBar != null) { |
| 827 | try { |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 828 | mBar.setIcon(slot, icon); |
Joe Onorato | 514ad663 | 2010-05-13 18:49:00 -0700 | [diff] [blame] | 829 | } catch (RemoteException ex) { |
| 830 | } |
| 831 | } |
| 832 | } |
| 833 | } |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 834 | } |
| 835 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 836 | @Override |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 837 | public void removeIcon(String slot) { |
| 838 | enforceStatusBar(); |
| 839 | |
| 840 | synchronized (mIcons) { |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 841 | mIcons.remove(slot); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 842 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 843 | if (mBar != null) { |
| 844 | try { |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 845 | mBar.removeIcon(slot); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 846 | } catch (RemoteException ex) { |
| 847 | } |
| 848 | } |
| 849 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 850 | } |
| 851 | |
Wale Ogunwale | 393b1c1 | 2014-10-18 16:22:01 -0700 | [diff] [blame] | 852 | /** |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 853 | * Enables System UI to know whether the top app is fullscreen or not, and whether this app is |
| 854 | * in immersive mode or not. |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 855 | */ |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 856 | private void topAppWindowChanged(int displayId, boolean isFullscreen, boolean isImmersive) { |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 857 | enforceStatusBar(); |
| 858 | |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 859 | synchronized(mLock) { |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 860 | getUiState(displayId).setFullscreen(isFullscreen); |
| 861 | getUiState(displayId).setImmersive(isImmersive); |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 862 | mHandler.post(() -> { |
| 863 | if (mBar != null) { |
| 864 | try { |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 865 | mBar.topAppWindowChanged(displayId, isFullscreen, isImmersive); |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 866 | } catch (RemoteException ex) { |
Dianne Hackborn | 7d04932 | 2011-06-14 15:00:32 -0700 | [diff] [blame] | 867 | } |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 868 | } |
| 869 | }); |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 870 | } |
| 871 | } |
| 872 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 873 | @Override |
lumark | 7570cac | 2019-03-07 22:14:38 +0800 | [diff] [blame] | 874 | public void setImeWindowStatus(int displayId, final IBinder token, final int vis, |
Tarandeep Singh | 07b318b | 2019-07-17 11:12:04 -0700 | [diff] [blame] | 875 | final int backDisposition, final boolean showImeSwitcher, |
| 876 | boolean isMultiClientImeEnabled) { |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 877 | enforceStatusBar(); |
| 878 | |
Joe Onorato | 857fd9b | 2011-01-27 15:08:35 -0800 | [diff] [blame] | 879 | if (SPEW) { |
| 880 | Slog.d(TAG, "swetImeWindowStatus vis=" + vis + " backDisposition=" + backDisposition); |
| 881 | } |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 882 | |
| 883 | synchronized(mLock) { |
Joe Onorato | 857fd9b | 2011-01-27 15:08:35 -0800 | [diff] [blame] | 884 | // In case of IME change, we need to call up setImeWindowStatus() regardless of |
| 885 | // mImeWindowVis because mImeWindowVis may not have been set to false when the |
satok | 06e0744 | 2010-11-02 19:46:55 +0900 | [diff] [blame] | 886 | // previous IME was destroyed. |
lumark | 7570cac | 2019-03-07 22:14:38 +0800 | [diff] [blame] | 887 | getUiState(displayId).setImeWindowState(vis, backDisposition, showImeSwitcher, token); |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 888 | |
| 889 | mHandler.post(() -> { |
| 890 | if (mBar == null) return; |
| 891 | try { |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 892 | mBar.setImeWindowStatus( |
Tarandeep Singh | 07b318b | 2019-07-17 11:12:04 -0700 | [diff] [blame] | 893 | displayId, token, vis, backDisposition, showImeSwitcher, |
| 894 | isMultiClientImeEnabled); |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 895 | } catch (RemoteException ex) { } |
satok | 06e0744 | 2010-11-02 19:46:55 +0900 | [diff] [blame] | 896 | }); |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 897 | } |
| 898 | } |
| 899 | |
Tiger Huang | 0dbd537 | 2019-10-26 00:24:22 +0800 | [diff] [blame] | 900 | private void setDisableFlags(int displayId, int flags, String cause) { |
Joe Onorato | 55bf380 | 2011-01-25 13:42:10 -0800 | [diff] [blame] | 901 | // also allows calls from window manager which is in this process. |
Joe Onorato | f63b0f4 | 2010-09-12 17:03:19 -0400 | [diff] [blame] | 902 | enforceStatusBarService(); |
| 903 | |
Tiger Huang | 0dbd537 | 2019-10-26 00:24:22 +0800 | [diff] [blame] | 904 | final int unknownFlags = flags & ~StatusBarManager.DISABLE_MASK; |
| 905 | if (unknownFlags != 0) { |
| 906 | Slog.e(TAG, "Unknown disable flags: 0x" + Integer.toHexString(unknownFlags), |
| 907 | new RuntimeException()); |
| 908 | } |
| 909 | |
| 910 | if (SPEW) Slog.d(TAG, "setDisableFlags(0x" + Integer.toHexString(flags) + ")"); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 911 | |
Joe Onorato | f63b0f4 | 2010-09-12 17:03:19 -0400 | [diff] [blame] | 912 | synchronized (mLock) { |
Tiger Huang | 0dbd537 | 2019-10-26 00:24:22 +0800 | [diff] [blame] | 913 | disableLocked(displayId, mCurrentUserId, flags, mSysUiVisToken, cause, 1); |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 914 | } |
| 915 | } |
| 916 | |
| 917 | /** |
| 918 | * @return {@link UiState} specified by {@code displayId}. |
| 919 | * |
| 920 | * <p> |
| 921 | * Note: If {@link UiState} specified by {@code displayId} does not exist, {@link UiState} |
| 922 | * will be allocated and {@code mDisplayUiState} will be updated accordingly. |
| 923 | * <p/> |
| 924 | */ |
| 925 | private UiState getUiState(int displayId) { |
| 926 | UiState state = mDisplayUiState.get(displayId); |
| 927 | if (state == null) { |
| 928 | state = new UiState(); |
| 929 | mDisplayUiState.put(displayId, state); |
| 930 | } |
| 931 | return state; |
| 932 | } |
| 933 | |
| 934 | private class UiState { |
Tiger Huang | 0dbd537 | 2019-10-26 00:24:22 +0800 | [diff] [blame] | 935 | private @Appearance int mAppearance = 0; |
| 936 | private AppearanceRegion[] mAppearanceRegions = new AppearanceRegion[0]; |
| 937 | private ArraySet<Integer> mTransientBarTypes = new ArraySet<>(); |
| 938 | private boolean mNavbarColorManagedByIme = false; |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 939 | private boolean mFullscreen = false; |
| 940 | private boolean mImmersive = false; |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 941 | private int mDisabled1 = 0; |
| 942 | private int mDisabled2 = 0; |
| 943 | private int mImeWindowVis = 0; |
| 944 | private int mImeBackDisposition = 0; |
| 945 | private boolean mShowImeSwitcher = false; |
| 946 | private IBinder mImeToken = null; |
Tiger Huang | 0dbd537 | 2019-10-26 00:24:22 +0800 | [diff] [blame] | 947 | |
| 948 | private void setAppearance(@Appearance int appearance, |
| 949 | AppearanceRegion[] appearanceRegions, boolean navbarColorManagedByIme) { |
| 950 | mAppearance = appearance; |
| 951 | mAppearanceRegions = appearanceRegions; |
| 952 | mNavbarColorManagedByIme = navbarColorManagedByIme; |
| 953 | } |
| 954 | |
| 955 | private boolean appearanceEquals(@Appearance int appearance, |
| 956 | AppearanceRegion[] appearanceRegions, boolean navbarColorManagedByIme) { |
| 957 | if (mAppearance != appearance || mAppearanceRegions.length != appearanceRegions.length |
| 958 | || mNavbarColorManagedByIme != navbarColorManagedByIme) { |
| 959 | return false; |
| 960 | } |
| 961 | for (int i = appearanceRegions.length - 1; i >= 0; i--) { |
| 962 | if (!mAppearanceRegions[i].equals(appearanceRegions[i])) { |
| 963 | return false; |
| 964 | } |
| 965 | } |
| 966 | return true; |
| 967 | } |
| 968 | |
| 969 | private void showTransient(@InternalInsetType int[] types) { |
| 970 | for (int type : types) { |
| 971 | mTransientBarTypes.add(type); |
| 972 | } |
| 973 | } |
| 974 | |
| 975 | private void clearTransient(@InternalInsetType int[] types) { |
| 976 | for (int type : types) { |
| 977 | mTransientBarTypes.remove(type); |
| 978 | } |
| 979 | } |
| 980 | |
| 981 | private void setFullscreen(boolean isFullscreen) { |
| 982 | mFullscreen = isFullscreen; |
| 983 | } |
| 984 | |
| 985 | private void setImmersive(boolean isImmersive) { |
| 986 | mImmersive = isImmersive; |
| 987 | } |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 988 | |
| 989 | private int getDisabled1() { |
| 990 | return mDisabled1; |
| 991 | } |
| 992 | |
| 993 | private int getDisabled2() { |
| 994 | return mDisabled2; |
| 995 | } |
| 996 | |
| 997 | private void setDisabled(int disabled1, int disabled2) { |
| 998 | mDisabled1 = disabled1; |
| 999 | mDisabled2 = disabled2; |
| 1000 | } |
| 1001 | |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 1002 | private boolean disableEquals(int disabled1, int disabled2) { |
| 1003 | return mDisabled1 == disabled1 && mDisabled2 == disabled2; |
| 1004 | } |
| 1005 | |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 1006 | private void setImeWindowState(final int vis, final int backDisposition, |
| 1007 | final boolean showImeSwitcher, final IBinder token) { |
| 1008 | mImeWindowVis = vis; |
| 1009 | mImeBackDisposition = backDisposition; |
| 1010 | mShowImeSwitcher = showImeSwitcher; |
| 1011 | mImeToken = token; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 1012 | } |
| 1013 | } |
| 1014 | |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 1015 | private void enforceStatusBarOrShell() { |
| 1016 | if (Binder.getCallingUid() == Process.SHELL_UID) { |
| 1017 | return; |
| 1018 | } |
| 1019 | enforceStatusBar(); |
| 1020 | } |
| 1021 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1022 | private void enforceStatusBar() { |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 1023 | mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR, |
Joe Onorato | 089de88 | 2010-04-12 08:18:45 -0700 | [diff] [blame] | 1024 | "StatusBarManagerService"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1025 | } |
| 1026 | |
| 1027 | private void enforceExpandStatusBar() { |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 1028 | mContext.enforceCallingOrSelfPermission(android.Manifest.permission.EXPAND_STATUS_BAR, |
Joe Onorato | 089de88 | 2010-04-12 08:18:45 -0700 | [diff] [blame] | 1029 | "StatusBarManagerService"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1030 | } |
| 1031 | |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 1032 | private void enforceStatusBarService() { |
| 1033 | mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1034 | "StatusBarManagerService"); |
| 1035 | } |
| 1036 | |
Kevin Chyn | 95c27e0 | 2018-09-12 01:46:16 -0700 | [diff] [blame] | 1037 | private void enforceBiometricDialog() { |
| 1038 | mContext.enforceCallingOrSelfPermission( |
| 1039 | android.Manifest.permission.MANAGE_BIOMETRIC_DIALOG, |
| 1040 | "StatusBarManagerService"); |
| 1041 | } |
| 1042 | |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 1043 | // ================================================================================ |
| 1044 | // Callbacks from the status bar service. |
| 1045 | // ================================================================================ |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 1046 | // TODO(b/118592525): refactor it as an IStatusBar API. |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 1047 | @Override |
Yohei Yukawa | 49efa71 | 2019-04-04 11:49:02 -0700 | [diff] [blame] | 1048 | public RegisterStatusBarResult registerStatusBar(IStatusBar bar) { |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 1049 | enforceStatusBarService(); |
| 1050 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 1051 | Slog.i(TAG, "registerStatusBar bar=" + bar); |
| 1052 | mBar = bar; |
Gopal Krishna Shukla | e5c8379 | 2018-06-29 18:20:36 +0530 | [diff] [blame] | 1053 | mDeathRecipient.linkToDeath(); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1054 | notifyBarAttachChanged(); |
Yohei Yukawa | 49efa71 | 2019-04-04 11:49:02 -0700 | [diff] [blame] | 1055 | final ArrayMap<String, StatusBarIcon> icons; |
Joe Onorato | 75199e3 | 2010-05-29 17:22:51 -0400 | [diff] [blame] | 1056 | synchronized (mIcons) { |
Yohei Yukawa | 49efa71 | 2019-04-04 11:49:02 -0700 | [diff] [blame] | 1057 | icons = new ArrayMap<>(mIcons); |
Joe Onorato | 75199e3 | 2010-05-29 17:22:51 -0400 | [diff] [blame] | 1058 | } |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 1059 | synchronized (mLock) { |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 1060 | // TODO(b/118592525): Currently, status bar only works on the default display. |
| 1061 | // Make it aware of multi-display if needed. |
| 1062 | final UiState state = mDisplayUiState.get(DEFAULT_DISPLAY); |
Tiger Huang | 0dbd537 | 2019-10-26 00:24:22 +0800 | [diff] [blame] | 1063 | final int[] transientBarTypes = new int[state.mTransientBarTypes.size()]; |
| 1064 | for (int i = 0; i < transientBarTypes.length; i++) { |
| 1065 | transientBarTypes[i] = state.mTransientBarTypes.valueAt(i); |
| 1066 | } |
Yohei Yukawa | 49efa71 | 2019-04-04 11:49:02 -0700 | [diff] [blame] | 1067 | return new RegisterStatusBarResult(icons, gatherDisableActionsLocked(mCurrentUserId, 1), |
Tiger Huang | 0dbd537 | 2019-10-26 00:24:22 +0800 | [diff] [blame] | 1068 | state.mAppearance, state.mAppearanceRegions, state.mImeWindowVis, |
Yohei Yukawa | 49efa71 | 2019-04-04 11:49:02 -0700 | [diff] [blame] | 1069 | state.mImeBackDisposition, state.mShowImeSwitcher, |
Tiger Huang | 0dbd537 | 2019-10-26 00:24:22 +0800 | [diff] [blame] | 1070 | gatherDisableActionsLocked(mCurrentUserId, 2), state.mImeToken, |
| 1071 | state.mNavbarColorManagedByIme, state.mFullscreen, state.mImmersive, |
| 1072 | transientBarTypes); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 1073 | } |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 1074 | } |
Joe Onorato | aaba60b | 2010-05-23 15:18:41 -0400 | [diff] [blame] | 1075 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1076 | private void notifyBarAttachChanged() { |
| 1077 | mHandler.post(() -> { |
| 1078 | if (mGlobalActionListener == null) return; |
Michael Kwan | 2decbf7 | 2018-02-22 07:40:11 -0800 | [diff] [blame] | 1079 | mGlobalActionListener.onGlobalActionsAvailableChanged(mBar != null); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1080 | }); |
| 1081 | } |
| 1082 | |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 1083 | /** |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 1084 | * @param clearNotificationEffects whether to consider notifications as "shown" and stop |
| 1085 | * LED, vibration, and ringing |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 1086 | */ |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 1087 | @Override |
Chris Wren | b659c4f | 2015-06-25 17:12:27 -0400 | [diff] [blame] | 1088 | public void onPanelRevealed(boolean clearNotificationEffects, int numItems) { |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 1089 | enforceStatusBarService(); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 1090 | long identity = Binder.clearCallingIdentity(); |
| 1091 | try { |
Chris Wren | b659c4f | 2015-06-25 17:12:27 -0400 | [diff] [blame] | 1092 | mNotificationDelegate.onPanelRevealed(clearNotificationEffects, numItems); |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 1093 | } finally { |
| 1094 | Binder.restoreCallingIdentity(identity); |
| 1095 | } |
| 1096 | } |
| 1097 | |
| 1098 | @Override |
| 1099 | public void clearNotificationEffects() throws RemoteException { |
| 1100 | enforceStatusBarService(); |
| 1101 | long identity = Binder.clearCallingIdentity(); |
| 1102 | try { |
| 1103 | mNotificationDelegate.clearEffects(); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 1104 | } finally { |
| 1105 | Binder.restoreCallingIdentity(identity); |
| 1106 | } |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 1107 | } |
| 1108 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 1109 | @Override |
Christoph Studer | 760ea55 | 2014-03-21 13:10:21 +0100 | [diff] [blame] | 1110 | public void onPanelHidden() throws RemoteException { |
| 1111 | enforceStatusBarService(); |
| 1112 | long identity = Binder.clearCallingIdentity(); |
| 1113 | try { |
| 1114 | mNotificationDelegate.onPanelHidden(); |
| 1115 | } finally { |
| 1116 | Binder.restoreCallingIdentity(identity); |
| 1117 | } |
| 1118 | } |
| 1119 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1120 | /** |
| 1121 | * Allows the status bar to shutdown the device. |
| 1122 | */ |
| 1123 | @Override |
| 1124 | public void shutdown() { |
| 1125 | enforceStatusBarService(); |
| 1126 | long identity = Binder.clearCallingIdentity(); |
| 1127 | try { |
Michael Wright | 6cd1026 | 2017-04-04 17:44:56 +0100 | [diff] [blame] | 1128 | // ShutdownThread displays UI, so give it a UI context. |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1129 | mHandler.post(() -> |
Michael Wright | 6cd1026 | 2017-04-04 17:44:56 +0100 | [diff] [blame] | 1130 | ShutdownThread.shutdown(getUiContext(), |
| 1131 | PowerManager.SHUTDOWN_USER_REQUESTED, false)); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1132 | } finally { |
| 1133 | Binder.restoreCallingIdentity(identity); |
| 1134 | } |
| 1135 | } |
| 1136 | |
| 1137 | /** |
| 1138 | * Allows the status bar to reboot the device. |
| 1139 | */ |
| 1140 | @Override |
| 1141 | public void reboot(boolean safeMode) { |
| 1142 | enforceStatusBarService(); |
| 1143 | long identity = Binder.clearCallingIdentity(); |
| 1144 | try { |
| 1145 | mHandler.post(() -> { |
Adam Lesinski | a82b626 | 2017-03-21 16:56:17 -0700 | [diff] [blame] | 1146 | // ShutdownThread displays UI, so give it a UI context. |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1147 | if (safeMode) { |
Shunta Sato | bdb0e49 | 2017-04-14 16:01:54 +0900 | [diff] [blame] | 1148 | ShutdownThread.rebootSafeMode(getUiContext(), true); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1149 | } else { |
Michael Wright | 6cd1026 | 2017-04-04 17:44:56 +0100 | [diff] [blame] | 1150 | ShutdownThread.reboot(getUiContext(), |
| 1151 | PowerManager.SHUTDOWN_USER_REQUESTED, false); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1152 | } |
| 1153 | }); |
| 1154 | } finally { |
| 1155 | Binder.restoreCallingIdentity(identity); |
| 1156 | } |
| 1157 | } |
| 1158 | |
| 1159 | @Override |
| 1160 | public void onGlobalActionsShown() { |
| 1161 | enforceStatusBarService(); |
| 1162 | long identity = Binder.clearCallingIdentity(); |
| 1163 | try { |
| 1164 | if (mGlobalActionListener == null) return; |
| 1165 | mGlobalActionListener.onGlobalActionsShown(); |
| 1166 | } finally { |
| 1167 | Binder.restoreCallingIdentity(identity); |
| 1168 | } |
| 1169 | } |
| 1170 | |
| 1171 | @Override |
| 1172 | public void onGlobalActionsHidden() { |
| 1173 | enforceStatusBarService(); |
| 1174 | long identity = Binder.clearCallingIdentity(); |
| 1175 | try { |
| 1176 | if (mGlobalActionListener == null) return; |
| 1177 | mGlobalActionListener.onGlobalActionsDismissed(); |
| 1178 | } finally { |
| 1179 | Binder.restoreCallingIdentity(identity); |
| 1180 | } |
| 1181 | } |
| 1182 | |
Christoph Studer | 760ea55 | 2014-03-21 13:10:21 +0100 | [diff] [blame] | 1183 | @Override |
Dieter Hsu | d39f0d5 | 2018-04-14 02:08:30 +0800 | [diff] [blame] | 1184 | public void onNotificationClick(String key, NotificationVisibility nv) { |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 1185 | enforceStatusBarService(); |
John Spurlock | e6a7d93 | 2014-03-13 12:29:00 -0400 | [diff] [blame] | 1186 | final int callingUid = Binder.getCallingUid(); |
| 1187 | final int callingPid = Binder.getCallingPid(); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 1188 | long identity = Binder.clearCallingIdentity(); |
| 1189 | try { |
Dieter Hsu | d39f0d5 | 2018-04-14 02:08:30 +0800 | [diff] [blame] | 1190 | mNotificationDelegate.onNotificationClick(callingUid, callingPid, key, nv); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 1191 | } finally { |
| 1192 | Binder.restoreCallingIdentity(identity); |
| 1193 | } |
Joe Onorato | aaba60b | 2010-05-23 15:18:41 -0400 | [diff] [blame] | 1194 | } |
| 1195 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 1196 | @Override |
Tony Mak | 7d4b3a5 | 2018-11-27 17:29:36 +0000 | [diff] [blame] | 1197 | public void onNotificationActionClick( |
| 1198 | String key, int actionIndex, Notification.Action action, NotificationVisibility nv, |
| 1199 | boolean generatedByAssistant) { |
Christoph Studer | 4da84cd | 2014-10-21 17:24:20 +0200 | [diff] [blame] | 1200 | enforceStatusBarService(); |
| 1201 | final int callingUid = Binder.getCallingUid(); |
| 1202 | final int callingPid = Binder.getCallingPid(); |
| 1203 | long identity = Binder.clearCallingIdentity(); |
| 1204 | try { |
| 1205 | mNotificationDelegate.onNotificationActionClick(callingUid, callingPid, key, |
Tony Mak | 7d4b3a5 | 2018-11-27 17:29:36 +0000 | [diff] [blame] | 1206 | actionIndex, action, nv, generatedByAssistant); |
Christoph Studer | 4da84cd | 2014-10-21 17:24:20 +0200 | [diff] [blame] | 1207 | } finally { |
| 1208 | Binder.restoreCallingIdentity(identity); |
| 1209 | } |
| 1210 | } |
| 1211 | |
| 1212 | @Override |
Dianne Hackborn | 9d39d0c | 2010-06-24 15:57:42 -0700 | [diff] [blame] | 1213 | public void onNotificationError(String pkg, String tag, int id, |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 1214 | int uid, int initialPid, String message, int userId) { |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 1215 | enforceStatusBarService(); |
John Spurlock | e6a7d93 | 2014-03-13 12:29:00 -0400 | [diff] [blame] | 1216 | final int callingUid = Binder.getCallingUid(); |
| 1217 | final int callingPid = Binder.getCallingPid(); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 1218 | long identity = Binder.clearCallingIdentity(); |
| 1219 | try { |
| 1220 | // WARNING: this will call back into us to do the remove. Don't hold any locks. |
John Spurlock | e6a7d93 | 2014-03-13 12:29:00 -0400 | [diff] [blame] | 1221 | mNotificationDelegate.onNotificationError(callingUid, callingPid, |
| 1222 | pkg, tag, id, uid, initialPid, message, userId); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 1223 | } finally { |
| 1224 | Binder.restoreCallingIdentity(identity); |
| 1225 | } |
Joe Onorato | 005847b | 2010-06-04 16:08:02 -0400 | [diff] [blame] | 1226 | } |
| 1227 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 1228 | @Override |
Julia Reynolds | 503ed94 | 2017-10-04 16:04:56 -0400 | [diff] [blame] | 1229 | public void onNotificationClear(String pkg, String tag, int id, int userId, String key, |
Julia Reynolds | fd4099d | 2018-08-21 11:06:06 -0400 | [diff] [blame] | 1230 | @NotificationStats.DismissalSurface int dismissalSurface, |
| 1231 | @NotificationStats.DismissalSentiment int dismissalSentiment, |
| 1232 | NotificationVisibility nv) { |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 1233 | enforceStatusBarService(); |
John Spurlock | e6a7d93 | 2014-03-13 12:29:00 -0400 | [diff] [blame] | 1234 | final int callingUid = Binder.getCallingUid(); |
| 1235 | final int callingPid = Binder.getCallingPid(); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 1236 | long identity = Binder.clearCallingIdentity(); |
| 1237 | try { |
Dieter Hsu | d39f0d5 | 2018-04-14 02:08:30 +0800 | [diff] [blame] | 1238 | mNotificationDelegate.onNotificationClear(callingUid, callingPid, pkg, tag, id, userId, |
Julia Reynolds | fd4099d | 2018-08-21 11:06:06 -0400 | [diff] [blame] | 1239 | key, dismissalSurface, dismissalSentiment, nv); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 1240 | } finally { |
| 1241 | Binder.restoreCallingIdentity(identity); |
| 1242 | } |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 1243 | } |
| 1244 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 1245 | @Override |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 1246 | public void onNotificationVisibilityChanged( |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 1247 | NotificationVisibility[] newlyVisibleKeys, NotificationVisibility[] noLongerVisibleKeys) |
| 1248 | throws RemoteException { |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 1249 | enforceStatusBarService(); |
| 1250 | long identity = Binder.clearCallingIdentity(); |
| 1251 | try { |
| 1252 | mNotificationDelegate.onNotificationVisibilityChanged( |
| 1253 | newlyVisibleKeys, noLongerVisibleKeys); |
| 1254 | } finally { |
| 1255 | Binder.restoreCallingIdentity(identity); |
| 1256 | } |
| 1257 | } |
| 1258 | |
| 1259 | @Override |
Gustav Sennton | a8e38aa | 2019-01-22 14:55:39 +0000 | [diff] [blame] | 1260 | public void onNotificationExpansionChanged(String key, boolean userAction, boolean expanded, |
| 1261 | int location) throws RemoteException { |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 1262 | enforceStatusBarService(); |
| 1263 | long identity = Binder.clearCallingIdentity(); |
| 1264 | try { |
| 1265 | mNotificationDelegate.onNotificationExpansionChanged( |
Gustav Sennton | a8e38aa | 2019-01-22 14:55:39 +0000 | [diff] [blame] | 1266 | key, userAction, expanded, location); |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 1267 | } finally { |
| 1268 | Binder.restoreCallingIdentity(identity); |
| 1269 | } |
| 1270 | } |
| 1271 | |
| 1272 | @Override |
Julia Reynolds | 503ed94 | 2017-10-04 16:04:56 -0400 | [diff] [blame] | 1273 | public void onNotificationDirectReplied(String key) throws RemoteException { |
| 1274 | enforceStatusBarService(); |
| 1275 | long identity = Binder.clearCallingIdentity(); |
| 1276 | try { |
| 1277 | mNotificationDelegate.onNotificationDirectReplied(key); |
| 1278 | } finally { |
| 1279 | Binder.restoreCallingIdentity(identity); |
| 1280 | } |
| 1281 | } |
| 1282 | |
| 1283 | @Override |
Gustav Sennton | d25a64d | 2018-12-07 10:58:39 +0000 | [diff] [blame] | 1284 | public void onNotificationSmartSuggestionsAdded(String key, int smartReplyCount, |
Milo Sredkov | 13d8811 | 2019-02-01 12:23:24 +0000 | [diff] [blame] | 1285 | int smartActionCount, boolean generatedByAssistant, boolean editBeforeSending) { |
Kenny Guy | 2399110 | 2018-04-05 21:18:38 +0100 | [diff] [blame] | 1286 | enforceStatusBarService(); |
| 1287 | long identity = Binder.clearCallingIdentity(); |
| 1288 | try { |
Gustav Sennton | d25a64d | 2018-12-07 10:58:39 +0000 | [diff] [blame] | 1289 | mNotificationDelegate.onNotificationSmartSuggestionsAdded(key, smartReplyCount, |
Milo Sredkov | 13d8811 | 2019-02-01 12:23:24 +0000 | [diff] [blame] | 1290 | smartActionCount, generatedByAssistant, editBeforeSending); |
Kenny Guy | 2399110 | 2018-04-05 21:18:38 +0100 | [diff] [blame] | 1291 | } finally { |
| 1292 | Binder.restoreCallingIdentity(identity); |
| 1293 | } |
| 1294 | } |
| 1295 | |
| 1296 | @Override |
Tony Mak | 2999670 | 2018-11-26 16:23:34 +0000 | [diff] [blame] | 1297 | public void onNotificationSmartReplySent( |
Milo Sredkov | 13d8811 | 2019-02-01 12:23:24 +0000 | [diff] [blame] | 1298 | String key, int replyIndex, CharSequence reply, int notificationLocation, |
| 1299 | boolean modifiedBeforeSending) throws RemoteException { |
Kenny Guy | 2399110 | 2018-04-05 21:18:38 +0100 | [diff] [blame] | 1300 | enforceStatusBarService(); |
| 1301 | long identity = Binder.clearCallingIdentity(); |
| 1302 | try { |
Tony Mak | 2999670 | 2018-11-26 16:23:34 +0000 | [diff] [blame] | 1303 | mNotificationDelegate.onNotificationSmartReplySent(key, replyIndex, reply, |
Milo Sredkov | 13d8811 | 2019-02-01 12:23:24 +0000 | [diff] [blame] | 1304 | notificationLocation, modifiedBeforeSending); |
Kenny Guy | 2399110 | 2018-04-05 21:18:38 +0100 | [diff] [blame] | 1305 | } finally { |
| 1306 | Binder.restoreCallingIdentity(identity); |
| 1307 | } |
| 1308 | } |
| 1309 | |
| 1310 | @Override |
Julia Reynolds | 503ed94 | 2017-10-04 16:04:56 -0400 | [diff] [blame] | 1311 | public void onNotificationSettingsViewed(String key) throws RemoteException { |
| 1312 | enforceStatusBarService(); |
| 1313 | long identity = Binder.clearCallingIdentity(); |
| 1314 | try { |
| 1315 | mNotificationDelegate.onNotificationSettingsViewed(key); |
| 1316 | } finally { |
| 1317 | Binder.restoreCallingIdentity(identity); |
| 1318 | } |
| 1319 | } |
| 1320 | |
| 1321 | @Override |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 1322 | public void onClearAllNotifications(int userId) { |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 1323 | enforceStatusBarService(); |
John Spurlock | e6a7d93 | 2014-03-13 12:29:00 -0400 | [diff] [blame] | 1324 | final int callingUid = Binder.getCallingUid(); |
| 1325 | final int callingPid = Binder.getCallingPid(); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 1326 | long identity = Binder.clearCallingIdentity(); |
| 1327 | try { |
John Spurlock | e6a7d93 | 2014-03-13 12:29:00 -0400 | [diff] [blame] | 1328 | mNotificationDelegate.onClearAll(callingUid, callingPid, userId); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 1329 | } finally { |
| 1330 | Binder.restoreCallingIdentity(identity); |
Joe Onorato | 18e69df | 2010-05-17 22:26:12 -0700 | [diff] [blame] | 1331 | } |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 1332 | } |
| 1333 | |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 1334 | @Override |
Mady Mellor | a54e9fa | 2019-04-18 13:26:18 -0700 | [diff] [blame] | 1335 | public void onNotificationBubbleChanged(String key, boolean isBubble) { |
| 1336 | enforceStatusBarService(); |
| 1337 | long identity = Binder.clearCallingIdentity(); |
| 1338 | try { |
| 1339 | mNotificationDelegate.onNotificationBubbleChanged(key, isBubble); |
| 1340 | } finally { |
| 1341 | Binder.restoreCallingIdentity(identity); |
| 1342 | } |
| 1343 | } |
| 1344 | |
| 1345 | @Override |
Aran Ink | 979c976 | 2019-10-24 16:09:45 -0400 | [diff] [blame] | 1346 | public void grantInlineReplyUriPermission(String key, Uri uri, UserHandle user, |
| 1347 | String packageName) { |
Aran Ink | fd2bfd3 | 2019-10-04 16:30:01 -0400 | [diff] [blame] | 1348 | enforceStatusBarService(); |
| 1349 | int callingUid = Binder.getCallingUid(); |
| 1350 | long identity = Binder.clearCallingIdentity(); |
| 1351 | try { |
Aran Ink | 979c976 | 2019-10-24 16:09:45 -0400 | [diff] [blame] | 1352 | mNotificationDelegate.grantInlineReplyUriPermission(key, uri, user, packageName, |
| 1353 | callingUid); |
| 1354 | } finally { |
| 1355 | Binder.restoreCallingIdentity(identity); |
| 1356 | } |
| 1357 | } |
| 1358 | |
| 1359 | @Override |
| 1360 | public void clearInlineReplyUriPermissions(String key) { |
| 1361 | enforceStatusBarService(); |
| 1362 | int callingUid = Binder.getCallingUid(); |
| 1363 | long identity = Binder.clearCallingIdentity(); |
| 1364 | try { |
| 1365 | mNotificationDelegate.clearInlineReplyUriPermissions(key, callingUid); |
Aran Ink | fd2bfd3 | 2019-10-04 16:30:01 -0400 | [diff] [blame] | 1366 | } finally { |
| 1367 | Binder.restoreCallingIdentity(identity); |
| 1368 | } |
| 1369 | } |
| 1370 | |
| 1371 | @Override |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 1372 | public void onShellCommand(FileDescriptor in, FileDescriptor out, FileDescriptor err, |
Dianne Hackborn | 354736e | 2016-08-22 17:00:05 -0700 | [diff] [blame] | 1373 | String[] args, ShellCallback callback, ResultReceiver resultReceiver) { |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 1374 | (new StatusBarShellCommand(this, mContext)).exec( |
Dianne Hackborn | 354736e | 2016-08-22 17:00:05 -0700 | [diff] [blame] | 1375 | this, in, out, err, args, callback, resultReceiver); |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 1376 | } |
| 1377 | |
Robert Horvath | 5560f38 | 2019-07-10 10:46:38 +0200 | [diff] [blame] | 1378 | @Override |
| 1379 | public void showInattentiveSleepWarning() { |
| 1380 | enforceStatusBarService(); |
| 1381 | if (mBar != null) { |
| 1382 | try { |
| 1383 | mBar.showInattentiveSleepWarning(); |
| 1384 | } catch (RemoteException ex) { |
| 1385 | } |
| 1386 | } |
| 1387 | } |
| 1388 | |
| 1389 | @Override |
Robert Horvath | 60e51fe | 2019-08-20 13:10:34 +0200 | [diff] [blame] | 1390 | public void dismissInattentiveSleepWarning(boolean animated) { |
Robert Horvath | 5560f38 | 2019-07-10 10:46:38 +0200 | [diff] [blame] | 1391 | enforceStatusBarService(); |
| 1392 | if (mBar != null) { |
| 1393 | try { |
Robert Horvath | 60e51fe | 2019-08-20 13:10:34 +0200 | [diff] [blame] | 1394 | mBar.dismissInattentiveSleepWarning(animated); |
Robert Horvath | 5560f38 | 2019-07-10 10:46:38 +0200 | [diff] [blame] | 1395 | } catch (RemoteException ex) { |
| 1396 | } |
| 1397 | } |
| 1398 | } |
| 1399 | |
Jason Monk | f8c2f7b | 2017-09-06 09:22:29 -0400 | [diff] [blame] | 1400 | public String[] getStatusBarIcons() { |
| 1401 | return mContext.getResources().getStringArray(R.array.config_statusBarIcons); |
| 1402 | } |
| 1403 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1404 | // ================================================================================ |
| 1405 | // Can be called from any thread |
| 1406 | // ================================================================================ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1407 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1408 | // lock on mDisableRecords |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 1409 | void manageDisableListLocked(int userId, int what, IBinder token, String pkg, int which) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1410 | if (SPEW) { |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 1411 | Slog.d(TAG, "manageDisableList userId=" + userId |
| 1412 | + " what=0x" + Integer.toHexString(what) + " pkg=" + pkg); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1413 | } |
Charles He | ede3909 | 2017-09-18 09:19:28 +0100 | [diff] [blame] | 1414 | |
| 1415 | // Find matching record, if any |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 1416 | Pair<Integer, DisableRecord> match = findMatchingRecordLocked(token, userId); |
| 1417 | int i = match.first; |
| 1418 | DisableRecord record = match.second; |
Charles He | ede3909 | 2017-09-18 09:19:28 +0100 | [diff] [blame] | 1419 | |
| 1420 | // Remove record if binder is already dead |
| 1421 | if (!token.isBinderAlive()) { |
| 1422 | if (record != null) { |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 1423 | mDisableRecords.remove(i); |
Charles He | ede3909 | 2017-09-18 09:19:28 +0100 | [diff] [blame] | 1424 | record.token.unlinkToDeath(record, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1425 | } |
Charles He | ede3909 | 2017-09-18 09:19:28 +0100 | [diff] [blame] | 1426 | return; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1427 | } |
Charles He | ede3909 | 2017-09-18 09:19:28 +0100 | [diff] [blame] | 1428 | |
| 1429 | // Update existing record |
| 1430 | if (record != null) { |
| 1431 | record.setFlags(what, which, pkg); |
| 1432 | if (record.isEmpty()) { |
| 1433 | mDisableRecords.remove(i); |
| 1434 | record.token.unlinkToDeath(record, 0); |
| 1435 | } |
| 1436 | return; |
| 1437 | } |
| 1438 | |
| 1439 | // Record doesn't exist, so we create a new one |
| 1440 | record = new DisableRecord(userId, token); |
| 1441 | record.setFlags(what, which, pkg); |
| 1442 | mDisableRecords.add(record); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1443 | } |
| 1444 | |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 1445 | @Nullable |
| 1446 | @GuardedBy("mLock") |
| 1447 | private Pair<Integer, DisableRecord> findMatchingRecordLocked(IBinder token, int userId) { |
| 1448 | final int numRecords = mDisableRecords.size(); |
| 1449 | DisableRecord record = null; |
| 1450 | int i; |
| 1451 | for (i = 0; i < numRecords; i++) { |
| 1452 | DisableRecord r = mDisableRecords.get(i); |
| 1453 | if (r.token == token && r.userId == userId) { |
| 1454 | record = r; |
| 1455 | break; |
| 1456 | } |
| 1457 | } |
| 1458 | |
| 1459 | return new Pair<Integer, DisableRecord>(i, record); |
| 1460 | } |
| 1461 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1462 | // lock on mDisableRecords |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 1463 | int gatherDisableActionsLocked(int userId, int which) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1464 | final int N = mDisableRecords.size(); |
| 1465 | // gather the new net flags |
| 1466 | int net = 0; |
| 1467 | for (int i=0; i<N; i++) { |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 1468 | final DisableRecord rec = mDisableRecords.get(i); |
| 1469 | if (rec.userId == userId) { |
Charles He | ede3909 | 2017-09-18 09:19:28 +0100 | [diff] [blame] | 1470 | net |= rec.getFlags(which); |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 1471 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1472 | } |
| 1473 | return net; |
| 1474 | } |
| 1475 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1476 | // ================================================================================ |
| 1477 | // Always called from UI thread |
| 1478 | // ================================================================================ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1479 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1480 | protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
Jeff Sharkey | fe9a53b | 2017-03-31 14:08:23 -0600 | [diff] [blame] | 1481 | if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 1482 | |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 1483 | synchronized (mLock) { |
Charles Chen | 24e7a9f | 2018-11-21 11:59:07 +0800 | [diff] [blame] | 1484 | for (int i = 0; i < mDisplayUiState.size(); i++) { |
| 1485 | final int key = mDisplayUiState.keyAt(i); |
| 1486 | final UiState state = mDisplayUiState.get(key); |
| 1487 | pw.println(" displayId=" + key); |
| 1488 | pw.println(" mDisabled1=0x" + Integer.toHexString(state.getDisabled1())); |
| 1489 | pw.println(" mDisabled2=0x" + Integer.toHexString(state.getDisabled2())); |
| 1490 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1491 | final int N = mDisableRecords.size(); |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 1492 | pw.println(" mDisableRecords.size=" + N); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1493 | for (int i=0; i<N; i++) { |
| 1494 | DisableRecord tok = mDisableRecords.get(i); |
Charles He | ede3909 | 2017-09-18 09:19:28 +0100 | [diff] [blame] | 1495 | pw.println(" [" + i + "] " + tok); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1496 | } |
Adrian Roos | 2a62910 | 2016-04-15 16:28:03 -0700 | [diff] [blame] | 1497 | pw.println(" mCurrentUserId=" + mCurrentUserId); |
Dan Sandler | f3a1f2c | 2016-06-26 15:59:13 -0400 | [diff] [blame] | 1498 | pw.println(" mIcons="); |
| 1499 | for (String slot : mIcons.keySet()) { |
| 1500 | pw.println(" "); |
| 1501 | pw.print(slot); |
| 1502 | pw.print(" -> "); |
| 1503 | final StatusBarIcon icon = mIcons.get(slot); |
| 1504 | pw.print(icon); |
| 1505 | if (!TextUtils.isEmpty(icon.contentDescription)) { |
| 1506 | pw.print(" \""); |
| 1507 | pw.print(icon.contentDescription); |
| 1508 | pw.print("\""); |
| 1509 | } |
| 1510 | pw.println(); |
| 1511 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1512 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1513 | } |
Michael Wright | 6cd1026 | 2017-04-04 17:44:56 +0100 | [diff] [blame] | 1514 | |
| 1515 | private static final Context getUiContext() { |
| 1516 | return ActivityThread.currentActivityThread().getSystemUiContext(); |
| 1517 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1518 | } |