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