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