Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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 | package com.android.systemui.statusbar; |
| 17 | |
Evan Laird | 181de62 | 2019-10-24 09:53:02 -0400 | [diff] [blame] | 18 | import static android.app.Notification.VISIBILITY_SECRET; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 19 | import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED; |
| 20 | |
Lucas Dupin | 8968f6a | 2019-08-09 17:41:15 -0700 | [diff] [blame] | 21 | import static com.android.systemui.DejankUtils.whitelistIpcs; |
Evan Laird | 25f0275 | 2019-08-14 19:25:06 -0400 | [diff] [blame] | 22 | import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_SILENT; |
Lucas Dupin | 8968f6a | 2019-08-09 17:41:15 -0700 | [diff] [blame] | 23 | |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 24 | import android.app.ActivityManager; |
| 25 | import android.app.KeyguardManager; |
| 26 | import android.app.Notification; |
| 27 | import android.app.admin.DevicePolicyManager; |
| 28 | import android.content.BroadcastReceiver; |
| 29 | import android.content.Context; |
| 30 | import android.content.Intent; |
| 31 | import android.content.IntentFilter; |
| 32 | import android.content.IntentSender; |
| 33 | import android.content.pm.UserInfo; |
| 34 | import android.database.ContentObserver; |
Dave Mankoff | 9427d1f | 2019-11-19 21:52:51 -0500 | [diff] [blame] | 35 | import android.os.Handler; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 36 | import android.os.RemoteException; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 37 | import android.os.UserHandle; |
| 38 | import android.os.UserManager; |
| 39 | import android.provider.Settings; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 40 | import android.util.Log; |
| 41 | import android.util.SparseArray; |
| 42 | import android.util.SparseBooleanArray; |
| 43 | |
| 44 | import com.android.internal.statusbar.IStatusBarService; |
| 45 | import com.android.internal.statusbar.NotificationVisibility; |
| 46 | import com.android.internal.widget.LockPatternUtils; |
| 47 | import com.android.keyguard.KeyguardUpdateMonitor; |
| 48 | import com.android.systemui.Dependency; |
| 49 | import com.android.systemui.Dumpable; |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 50 | import com.android.systemui.broadcast.BroadcastDispatcher; |
Dave Mankoff | 00e8a2f | 2019-12-18 16:59:49 -0500 | [diff] [blame] | 51 | import com.android.systemui.dagger.qualifiers.Main; |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 52 | import com.android.systemui.plugins.statusbar.StatusBarStateController; |
| 53 | import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener; |
Winson Chung | 2dbcf09 | 2018-10-24 13:00:41 -0700 | [diff] [blame] | 54 | import com.android.systemui.recents.OverviewProxyService; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 55 | import com.android.systemui.statusbar.notification.NotificationEntryManager; |
Gus Prevas | 415376b | 2018-11-08 10:43:27 -0500 | [diff] [blame] | 56 | import com.android.systemui.statusbar.notification.NotificationUtils; |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 57 | import com.android.systemui.statusbar.notification.collection.NotificationEntry; |
Gustav Sennton | f892fe9 | 2019-01-22 15:31:42 +0000 | [diff] [blame] | 58 | import com.android.systemui.statusbar.notification.logging.NotificationLogger; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 59 | import com.android.systemui.statusbar.policy.DeviceProvisionedController; |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 60 | import com.android.systemui.statusbar.policy.KeyguardStateController; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 61 | |
| 62 | import java.io.FileDescriptor; |
| 63 | import java.io.PrintWriter; |
Gus Prevas | a18dc57 | 2019-01-14 16:11:22 -0500 | [diff] [blame] | 64 | import java.util.ArrayList; |
| 65 | import java.util.List; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 66 | |
Govinda Wasserman | 2e86fb6 | 2019-08-13 11:35:44 -0400 | [diff] [blame] | 67 | import javax.inject.Inject; |
| 68 | import javax.inject.Singleton; |
| 69 | |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 70 | /** |
| 71 | * Handles keeping track of the current user, profiles, and various things related to hiding |
| 72 | * contents, redacting notifications, and the lockscreen. |
| 73 | */ |
Govinda Wasserman | 2e86fb6 | 2019-08-13 11:35:44 -0400 | [diff] [blame] | 74 | @Singleton |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 75 | public class NotificationLockscreenUserManagerImpl implements |
| 76 | Dumpable, NotificationLockscreenUserManager, StateListener { |
| 77 | private static final String TAG = "LockscreenUserManager"; |
| 78 | private static final boolean ENABLE_LOCK_SCREEN_ALLOW_REMOTE_INPUT = false; |
| 79 | |
Dave Mankoff | 9427d1f | 2019-11-19 21:52:51 -0500 | [diff] [blame] | 80 | private final DeviceProvisionedController mDeviceProvisionedController; |
| 81 | private final KeyguardStateController mKeyguardStateController; |
Lucas Dupin | 960b7e7f | 2020-01-24 15:47:28 -0800 | [diff] [blame] | 82 | private final Object mLock = new Object(); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 83 | |
| 84 | // Lazy |
| 85 | private NotificationEntryManager mEntryManager; |
| 86 | |
| 87 | private final DevicePolicyManager mDevicePolicyManager; |
| 88 | private final SparseBooleanArray mLockscreenPublicMode = new SparseBooleanArray(); |
Selim Cinek | 6f0a62a | 2019-04-09 18:40:12 -0700 | [diff] [blame] | 89 | private final SparseBooleanArray mUsersWithSeperateWorkChallenge = new SparseBooleanArray(); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 90 | private final SparseBooleanArray mUsersAllowingPrivateNotifications = new SparseBooleanArray(); |
| 91 | private final SparseBooleanArray mUsersAllowingNotifications = new SparseBooleanArray(); |
| 92 | private final UserManager mUserManager; |
| 93 | private final IStatusBarService mBarService; |
Gus Prevas | a18dc57 | 2019-01-14 16:11:22 -0500 | [diff] [blame] | 94 | private final List<UserChangedListener> mListeners = new ArrayList<>(); |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 95 | private final BroadcastDispatcher mBroadcastDispatcher; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 96 | |
| 97 | private boolean mShowLockscreenNotifications; |
| 98 | private boolean mAllowLockscreenRemoteInput; |
| 99 | private LockPatternUtils mLockPatternUtils; |
| 100 | protected KeyguardManager mKeyguardManager; |
| 101 | private int mState = StatusBarState.SHADE; |
| 102 | |
| 103 | protected final BroadcastReceiver mAllUsersReceiver = new BroadcastReceiver() { |
| 104 | @Override |
| 105 | public void onReceive(Context context, Intent intent) { |
| 106 | final String action = intent.getAction(); |
| 107 | |
| 108 | if (ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED.equals(action) && |
| 109 | isCurrentProfile(getSendingUserId())) { |
| 110 | mUsersAllowingPrivateNotifications.clear(); |
| 111 | updateLockscreenNotificationSetting(); |
Beverly | 85d4c19 | 2019-09-30 11:40:39 -0400 | [diff] [blame] | 112 | getEntryManager().updateNotifications("ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED"); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 113 | } |
| 114 | } |
| 115 | }; |
| 116 | |
| 117 | protected final BroadcastReceiver mBaseBroadcastReceiver = new BroadcastReceiver() { |
| 118 | @Override |
| 119 | public void onReceive(Context context, Intent intent) { |
| 120 | String action = intent.getAction(); |
Steve Elliott | b47f1c7 | 2019-12-19 12:39:26 -0500 | [diff] [blame] | 121 | switch (action) { |
| 122 | case Intent.ACTION_USER_SWITCHED: |
| 123 | mCurrentUserId = intent.getIntExtra( |
| 124 | Intent.EXTRA_USER_HANDLE, UserHandle.USER_ALL); |
| 125 | updateCurrentProfilesCache(); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 126 | |
Steve Elliott | b47f1c7 | 2019-12-19 12:39:26 -0500 | [diff] [blame] | 127 | Log.v(TAG, "userId " + mCurrentUserId + " is in the house"); |
Gus Prevas | a18dc57 | 2019-01-14 16:11:22 -0500 | [diff] [blame] | 128 | |
Steve Elliott | b47f1c7 | 2019-12-19 12:39:26 -0500 | [diff] [blame] | 129 | updateLockscreenNotificationSetting(); |
| 130 | updatePublicMode(); |
| 131 | // The filtering needs to happen before the update call below in order to |
| 132 | // make sure |
| 133 | // the presenter has the updated notifications from the new user |
| 134 | getEntryManager().reapplyFilterAndSort("user switched"); |
| 135 | mPresenter.onUserSwitched(mCurrentUserId); |
| 136 | |
| 137 | for (UserChangedListener listener : mListeners) { |
| 138 | listener.onUserChanged(mCurrentUserId); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 139 | } |
Steve Elliott | b47f1c7 | 2019-12-19 12:39:26 -0500 | [diff] [blame] | 140 | break; |
| 141 | case Intent.ACTION_USER_ADDED: |
| 142 | case Intent.ACTION_MANAGED_PROFILE_AVAILABLE: |
| 143 | case Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE: |
| 144 | updateCurrentProfilesCache(); |
| 145 | break; |
| 146 | case Intent.ACTION_USER_UNLOCKED: |
| 147 | // Start the overview connection to the launcher service |
| 148 | Dependency.get(OverviewProxyService.class).startConnectionToCurrentUser(); |
| 149 | break; |
| 150 | case NOTIFICATION_UNLOCKED_BY_WORK_CHALLENGE_ACTION: |
| 151 | final IntentSender intentSender = intent.getParcelableExtra( |
| 152 | Intent.EXTRA_INTENT); |
| 153 | final String notificationKey = intent.getStringExtra(Intent.EXTRA_INDEX); |
| 154 | if (intentSender != null) { |
| 155 | try { |
| 156 | mContext.startIntentSender(intentSender, null, 0, 0, 0); |
| 157 | } catch (IntentSender.SendIntentException e) { |
| 158 | /* ignore */ |
| 159 | } |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 160 | } |
Steve Elliott | b47f1c7 | 2019-12-19 12:39:26 -0500 | [diff] [blame] | 161 | if (notificationKey != null) { |
| 162 | NotificationEntry entry = |
| 163 | getEntryManager().getActiveNotificationUnfiltered(notificationKey); |
| 164 | final int count = getEntryManager().getActiveNotificationsCount(); |
| 165 | final int rank = entry != null ? entry.getRanking().getRank() : 0; |
| 166 | NotificationVisibility.NotificationLocation location = |
| 167 | NotificationLogger.getNotificationLocation(entry); |
| 168 | final NotificationVisibility nv = NotificationVisibility.obtain( |
| 169 | notificationKey, |
| 170 | rank, count, true, location); |
| 171 | try { |
| 172 | mBarService.onNotificationClick(notificationKey, nv); |
| 173 | } catch (RemoteException exception) { |
| 174 | /* ignore */ |
| 175 | } |
| 176 | } |
| 177 | break; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 178 | } |
| 179 | } |
| 180 | }; |
| 181 | |
| 182 | protected final Context mContext; |
Dave Mankoff | 9427d1f | 2019-11-19 21:52:51 -0500 | [diff] [blame] | 183 | private final Handler mMainHandler; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 184 | protected final SparseArray<UserInfo> mCurrentProfiles = new SparseArray<>(); |
Lucas Dupin | 960b7e7f | 2020-01-24 15:47:28 -0800 | [diff] [blame] | 185 | protected final ArrayList<UserInfo> mCurrentManagedProfiles = new ArrayList<>(); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 186 | |
| 187 | protected int mCurrentUserId = 0; |
| 188 | protected NotificationPresenter mPresenter; |
| 189 | protected ContentObserver mLockscreenSettingsObserver; |
| 190 | protected ContentObserver mSettingsObserver; |
| 191 | |
| 192 | private NotificationEntryManager getEntryManager() { |
| 193 | if (mEntryManager == null) { |
| 194 | mEntryManager = Dependency.get(NotificationEntryManager.class); |
| 195 | } |
| 196 | return mEntryManager; |
| 197 | } |
| 198 | |
Govinda Wasserman | 2e86fb6 | 2019-08-13 11:35:44 -0400 | [diff] [blame] | 199 | @Inject |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 200 | public NotificationLockscreenUserManagerImpl(Context context, |
Dave Mankoff | 9427d1f | 2019-11-19 21:52:51 -0500 | [diff] [blame] | 201 | BroadcastDispatcher broadcastDispatcher, |
| 202 | DevicePolicyManager devicePolicyManager, |
| 203 | UserManager userManager, |
| 204 | IStatusBarService iStatusBarService, |
| 205 | KeyguardManager keyguardManager, |
| 206 | StatusBarStateController statusBarStateController, |
Dave Mankoff | 00e8a2f | 2019-12-18 16:59:49 -0500 | [diff] [blame] | 207 | @Main Handler mainHandler, |
Dave Mankoff | 9427d1f | 2019-11-19 21:52:51 -0500 | [diff] [blame] | 208 | DeviceProvisionedController deviceProvisionedController, |
| 209 | KeyguardStateController keyguardStateController) { |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 210 | mContext = context; |
Dave Mankoff | 9427d1f | 2019-11-19 21:52:51 -0500 | [diff] [blame] | 211 | mMainHandler = mainHandler; |
| 212 | mDevicePolicyManager = devicePolicyManager; |
| 213 | mUserManager = userManager; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 214 | mCurrentUserId = ActivityManager.getCurrentUser(); |
Dave Mankoff | 9427d1f | 2019-11-19 21:52:51 -0500 | [diff] [blame] | 215 | mBarService = iStatusBarService; |
| 216 | statusBarStateController.addCallback(this); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 217 | mLockPatternUtils = new LockPatternUtils(context); |
Dave Mankoff | 9427d1f | 2019-11-19 21:52:51 -0500 | [diff] [blame] | 218 | mKeyguardManager = keyguardManager; |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 219 | mBroadcastDispatcher = broadcastDispatcher; |
Dave Mankoff | 9427d1f | 2019-11-19 21:52:51 -0500 | [diff] [blame] | 220 | mDeviceProvisionedController = deviceProvisionedController; |
| 221 | mKeyguardStateController = keyguardStateController; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | public void setUpWithPresenter(NotificationPresenter presenter) { |
| 225 | mPresenter = presenter; |
| 226 | |
Dave Mankoff | 9427d1f | 2019-11-19 21:52:51 -0500 | [diff] [blame] | 227 | mLockscreenSettingsObserver = new ContentObserver(mMainHandler) { |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 228 | @Override |
| 229 | public void onChange(boolean selfChange) { |
| 230 | // We don't know which user changed LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS or |
| 231 | // LOCK_SCREEN_SHOW_NOTIFICATIONS, so we just dump our cache ... |
| 232 | mUsersAllowingPrivateNotifications.clear(); |
| 233 | mUsersAllowingNotifications.clear(); |
| 234 | // ... and refresh all the notifications |
| 235 | updateLockscreenNotificationSetting(); |
Beverly | 85d4c19 | 2019-09-30 11:40:39 -0400 | [diff] [blame] | 236 | getEntryManager().updateNotifications("LOCK_SCREEN_SHOW_NOTIFICATIONS," |
| 237 | + " or LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS change"); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 238 | } |
| 239 | }; |
| 240 | |
Dave Mankoff | 9427d1f | 2019-11-19 21:52:51 -0500 | [diff] [blame] | 241 | mSettingsObserver = new ContentObserver(mMainHandler) { |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 242 | @Override |
| 243 | public void onChange(boolean selfChange) { |
| 244 | updateLockscreenNotificationSetting(); |
| 245 | if (mDeviceProvisionedController.isDeviceProvisioned()) { |
Beverly | 85d4c19 | 2019-09-30 11:40:39 -0400 | [diff] [blame] | 246 | getEntryManager().updateNotifications("LOCK_SCREEN_ALLOW_REMOTE_INPUT" |
| 247 | + " or ZEN_MODE change"); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 248 | } |
| 249 | } |
| 250 | }; |
| 251 | |
| 252 | mContext.getContentResolver().registerContentObserver( |
| 253 | Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS), false, |
| 254 | mLockscreenSettingsObserver, |
| 255 | UserHandle.USER_ALL); |
| 256 | |
| 257 | mContext.getContentResolver().registerContentObserver( |
| 258 | Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS), |
| 259 | true, |
| 260 | mLockscreenSettingsObserver, |
| 261 | UserHandle.USER_ALL); |
| 262 | |
| 263 | mContext.getContentResolver().registerContentObserver( |
| 264 | Settings.Global.getUriFor(Settings.Global.ZEN_MODE), false, |
| 265 | mSettingsObserver); |
| 266 | |
| 267 | if (ENABLE_LOCK_SCREEN_ALLOW_REMOTE_INPUT) { |
| 268 | mContext.getContentResolver().registerContentObserver( |
| 269 | Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_ALLOW_REMOTE_INPUT), |
| 270 | false, |
| 271 | mSettingsObserver, |
| 272 | UserHandle.USER_ALL); |
| 273 | } |
| 274 | |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 275 | mBroadcastDispatcher.registerReceiver(mAllUsersReceiver, |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 276 | new IntentFilter(ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED), |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 277 | null /* handler */, UserHandle.ALL); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 278 | |
| 279 | IntentFilter filter = new IntentFilter(); |
| 280 | filter.addAction(Intent.ACTION_USER_SWITCHED); |
| 281 | filter.addAction(Intent.ACTION_USER_ADDED); |
| 282 | filter.addAction(Intent.ACTION_USER_UNLOCKED); |
Steve Elliott | b47f1c7 | 2019-12-19 12:39:26 -0500 | [diff] [blame] | 283 | filter.addAction(Intent.ACTION_MANAGED_PROFILE_AVAILABLE); |
| 284 | filter.addAction(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE); |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 285 | mBroadcastDispatcher.registerReceiver(mBaseBroadcastReceiver, filter); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 286 | |
| 287 | IntentFilter internalFilter = new IntentFilter(); |
| 288 | internalFilter.addAction(NOTIFICATION_UNLOCKED_BY_WORK_CHALLENGE_ACTION); |
| 289 | mContext.registerReceiver(mBaseBroadcastReceiver, internalFilter, PERMISSION_SELF, null); |
| 290 | |
| 291 | updateCurrentProfilesCache(); |
| 292 | |
| 293 | mSettingsObserver.onChange(false); // set up |
| 294 | } |
| 295 | |
| 296 | public boolean shouldShowLockscreenNotifications() { |
| 297 | return mShowLockscreenNotifications; |
| 298 | } |
| 299 | |
| 300 | public boolean shouldAllowLockscreenRemoteInput() { |
| 301 | return mAllowLockscreenRemoteInput; |
| 302 | } |
| 303 | |
| 304 | public boolean isCurrentProfile(int userId) { |
Lucas Dupin | 960b7e7f | 2020-01-24 15:47:28 -0800 | [diff] [blame] | 305 | synchronized (mLock) { |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 306 | return userId == UserHandle.USER_ALL || mCurrentProfiles.get(userId) != null; |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | /** |
| 311 | * Returns true if notifications are temporarily disabled for this user for security reasons, |
| 312 | * regardless of the normal settings for that user. |
| 313 | */ |
| 314 | private boolean shouldTemporarilyHideNotifications(int userId) { |
| 315 | if (userId == UserHandle.USER_ALL) { |
| 316 | userId = mCurrentUserId; |
| 317 | } |
Dave Mankoff | e229469 | 2019-08-14 11:53:13 -0400 | [diff] [blame] | 318 | return Dependency.get(KeyguardUpdateMonitor.class).isUserInLockdown(userId); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | /** |
| 322 | * Returns true if we're on a secure lockscreen and the user wants to hide notification data. |
| 323 | * If so, notifications should be hidden. |
| 324 | */ |
| 325 | public boolean shouldHideNotifications(int userId) { |
| 326 | return isLockscreenPublicMode(userId) && !userAllowsNotificationsInPublic(userId) |
| 327 | || (userId != mCurrentUserId && shouldHideNotifications(mCurrentUserId)) |
| 328 | || shouldTemporarilyHideNotifications(userId); |
| 329 | } |
| 330 | |
| 331 | /** |
| 332 | * Returns true if we're on a secure lockscreen and the user wants to hide notifications via |
| 333 | * package-specific override. |
| 334 | */ |
| 335 | public boolean shouldHideNotifications(String key) { |
| 336 | if (getEntryManager() == null) { |
| 337 | Log.wtf(TAG, "mEntryManager was null!", new Throwable()); |
| 338 | return true; |
| 339 | } |
Evan Laird | 181de62 | 2019-10-24 09:53:02 -0400 | [diff] [blame] | 340 | NotificationEntry visibleEntry = getEntryManager().getActiveNotificationUnfiltered(key); |
| 341 | return isLockscreenPublicMode(mCurrentUserId) && visibleEntry != null |
| 342 | && visibleEntry.getRanking().getVisibilityOverride() == VISIBILITY_SECRET; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 343 | } |
| 344 | |
Ned Burns | 8c1b763 | 2019-07-19 14:26:15 -0400 | [diff] [blame] | 345 | public boolean shouldShowOnKeyguard(NotificationEntry entry) { |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 346 | if (getEntryManager() == null) { |
| 347 | Log.wtf(TAG, "mEntryManager was null!", new Throwable()); |
| 348 | return false; |
| 349 | } |
Gus Prevas | dddef39 | 2018-11-02 15:41:43 -0400 | [diff] [blame] | 350 | boolean exceedsPriorityThreshold; |
Julia Reynolds | 5b655c3 | 2019-04-24 14:40:17 -0400 | [diff] [blame] | 351 | if (NotificationUtils.useNewInterruptionModel(mContext) |
| 352 | && hideSilentNotificationsOnLockscreen()) { |
Evan Laird | 25f0275 | 2019-08-14 19:25:06 -0400 | [diff] [blame] | 353 | exceedsPriorityThreshold = entry.getBucket() != BUCKET_SILENT; |
Gus Prevas | dddef39 | 2018-11-02 15:41:43 -0400 | [diff] [blame] | 354 | } else { |
Evan Laird | 181de62 | 2019-10-24 09:53:02 -0400 | [diff] [blame] | 355 | exceedsPriorityThreshold = !entry.getRanking().isAmbient(); |
Gus Prevas | dddef39 | 2018-11-02 15:41:43 -0400 | [diff] [blame] | 356 | } |
| 357 | return mShowLockscreenNotifications && exceedsPriorityThreshold; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 358 | } |
| 359 | |
Julia Reynolds | 5b655c3 | 2019-04-24 14:40:17 -0400 | [diff] [blame] | 360 | private boolean hideSilentNotificationsOnLockscreen() { |
Lucas Dupin | 8968f6a | 2019-08-09 17:41:15 -0700 | [diff] [blame] | 361 | return whitelistIpcs(() -> Settings.Secure.getInt(mContext.getContentResolver(), |
| 362 | Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 1) == 0); |
Julia Reynolds | 5b655c3 | 2019-04-24 14:40:17 -0400 | [diff] [blame] | 363 | } |
| 364 | |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 365 | private void setShowLockscreenNotifications(boolean show) { |
| 366 | mShowLockscreenNotifications = show; |
| 367 | } |
| 368 | |
| 369 | private void setLockscreenAllowRemoteInput(boolean allowLockscreenRemoteInput) { |
| 370 | mAllowLockscreenRemoteInput = allowLockscreenRemoteInput; |
| 371 | } |
| 372 | |
| 373 | protected void updateLockscreenNotificationSetting() { |
| 374 | final boolean show = Settings.Secure.getIntForUser(mContext.getContentResolver(), |
| 375 | Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, |
| 376 | 1, |
| 377 | mCurrentUserId) != 0; |
| 378 | final int dpmFlags = mDevicePolicyManager.getKeyguardDisabledFeatures( |
| 379 | null /* admin */, mCurrentUserId); |
| 380 | final boolean allowedByDpm = (dpmFlags |
| 381 | & DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS) == 0; |
| 382 | |
| 383 | setShowLockscreenNotifications(show && allowedByDpm); |
| 384 | |
| 385 | if (ENABLE_LOCK_SCREEN_ALLOW_REMOTE_INPUT) { |
| 386 | final boolean remoteInput = Settings.Secure.getIntForUser(mContext.getContentResolver(), |
| 387 | Settings.Secure.LOCK_SCREEN_ALLOW_REMOTE_INPUT, |
| 388 | 0, |
| 389 | mCurrentUserId) != 0; |
| 390 | final boolean remoteInputDpm = |
| 391 | (dpmFlags & DevicePolicyManager.KEYGUARD_DISABLE_REMOTE_INPUT) == 0; |
| 392 | |
| 393 | setLockscreenAllowRemoteInput(remoteInput && remoteInputDpm); |
| 394 | } else { |
| 395 | setLockscreenAllowRemoteInput(false); |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | /** |
| 400 | * Has the given user chosen to allow their private (full) notifications to be shown even |
| 401 | * when the lockscreen is in "public" (secure & locked) mode? |
| 402 | */ |
| 403 | public boolean userAllowsPrivateNotificationsInPublic(int userHandle) { |
| 404 | if (userHandle == UserHandle.USER_ALL) { |
| 405 | return true; |
| 406 | } |
| 407 | |
| 408 | if (mUsersAllowingPrivateNotifications.indexOfKey(userHandle) < 0) { |
| 409 | final boolean allowedByUser = 0 != Settings.Secure.getIntForUser( |
| 410 | mContext.getContentResolver(), |
| 411 | Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0, userHandle); |
| 412 | final boolean allowedByDpm = adminAllowsKeyguardFeature(userHandle, |
| 413 | DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS); |
| 414 | final boolean allowed = allowedByUser && allowedByDpm; |
| 415 | mUsersAllowingPrivateNotifications.append(userHandle, allowed); |
| 416 | return allowed; |
| 417 | } |
| 418 | |
| 419 | return mUsersAllowingPrivateNotifications.get(userHandle); |
| 420 | } |
| 421 | |
Lucas Dupin | 960b7e7f | 2020-01-24 15:47:28 -0800 | [diff] [blame] | 422 | /** |
| 423 | * If all managed profiles (work profiles) can show private data in public (secure & locked.) |
| 424 | */ |
| 425 | public boolean allowsManagedPrivateNotificationsInPublic() { |
| 426 | synchronized (mLock) { |
| 427 | for (UserInfo profile : mCurrentManagedProfiles) { |
| 428 | if (!userAllowsPrivateNotificationsInPublic(profile.id)) { |
| 429 | return false; |
| 430 | } |
| 431 | } |
| 432 | } |
| 433 | return true; |
| 434 | } |
| 435 | |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 436 | private boolean adminAllowsKeyguardFeature(int userHandle, int feature) { |
| 437 | if (userHandle == UserHandle.USER_ALL) { |
| 438 | return true; |
| 439 | } |
| 440 | final int dpmFlags = |
| 441 | mDevicePolicyManager.getKeyguardDisabledFeatures(null /* admin */, userHandle); |
| 442 | return (dpmFlags & feature) == 0; |
| 443 | } |
| 444 | |
| 445 | /** |
| 446 | * Save the current "public" (locked and secure) state of the lockscreen. |
| 447 | */ |
| 448 | public void setLockscreenPublicMode(boolean publicMode, int userId) { |
| 449 | mLockscreenPublicMode.put(userId, publicMode); |
| 450 | } |
| 451 | |
| 452 | public boolean isLockscreenPublicMode(int userId) { |
| 453 | if (userId == UserHandle.USER_ALL) { |
| 454 | return mLockscreenPublicMode.get(mCurrentUserId, false); |
| 455 | } |
| 456 | return mLockscreenPublicMode.get(userId, false); |
| 457 | } |
| 458 | |
Selim Cinek | 6f0a62a | 2019-04-09 18:40:12 -0700 | [diff] [blame] | 459 | @Override |
| 460 | public boolean needsSeparateWorkChallenge(int userId) { |
| 461 | return mUsersWithSeperateWorkChallenge.get(userId, false); |
| 462 | } |
| 463 | |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 464 | /** |
| 465 | * Has the given user chosen to allow notifications to be shown even when the lockscreen is in |
| 466 | * "public" (secure & locked) mode? |
| 467 | */ |
Beverly | af16ee0 | 2019-11-25 10:38:56 -0500 | [diff] [blame] | 468 | public boolean userAllowsNotificationsInPublic(int userHandle) { |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 469 | if (isCurrentProfile(userHandle) && userHandle != mCurrentUserId) { |
| 470 | return true; |
| 471 | } |
| 472 | |
| 473 | if (mUsersAllowingNotifications.indexOfKey(userHandle) < 0) { |
| 474 | final boolean allowedByUser = 0 != Settings.Secure.getIntForUser( |
| 475 | mContext.getContentResolver(), |
| 476 | Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0, userHandle); |
| 477 | final boolean allowedByDpm = adminAllowsKeyguardFeature(userHandle, |
| 478 | DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS); |
Zimuzo | b3b9c26 | 2018-10-31 11:54:20 +0000 | [diff] [blame] | 479 | final boolean allowedBySystem = mKeyguardManager.getPrivateNotificationsAllowed(); |
| 480 | final boolean allowed = allowedByUser && allowedByDpm && allowedBySystem; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 481 | mUsersAllowingNotifications.append(userHandle, allowed); |
| 482 | return allowed; |
| 483 | } |
| 484 | |
| 485 | return mUsersAllowingNotifications.get(userHandle); |
| 486 | } |
| 487 | |
| 488 | /** @return true if the entry needs redaction when on the lockscreen. */ |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 489 | public boolean needsRedaction(NotificationEntry ent) { |
Ned Burns | 00b4b2d | 2019-10-17 22:09:27 -0400 | [diff] [blame] | 490 | int userId = ent.getSbn().getUserId(); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 491 | |
| 492 | boolean currentUserWantsRedaction = !userAllowsPrivateNotificationsInPublic(mCurrentUserId); |
| 493 | boolean notiUserWantsRedaction = !userAllowsPrivateNotificationsInPublic(userId); |
| 494 | boolean redactedLockscreen = currentUserWantsRedaction || notiUserWantsRedaction; |
| 495 | |
| 496 | boolean notificationRequestsRedaction = |
Ned Burns | 00b4b2d | 2019-10-17 22:09:27 -0400 | [diff] [blame] | 497 | ent.getSbn().getNotification().visibility == Notification.VISIBILITY_PRIVATE; |
| 498 | boolean userForcesRedaction = packageHasVisibilityOverride(ent.getSbn().getKey()); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 499 | |
| 500 | return userForcesRedaction || notificationRequestsRedaction && redactedLockscreen; |
| 501 | } |
| 502 | |
| 503 | private boolean packageHasVisibilityOverride(String key) { |
| 504 | if (getEntryManager() == null) { |
| 505 | Log.wtf(TAG, "mEntryManager was null!", new Throwable()); |
| 506 | return true; |
| 507 | } |
Evan Laird | 181de62 | 2019-10-24 09:53:02 -0400 | [diff] [blame] | 508 | NotificationEntry entry = getEntryManager().getActiveNotificationUnfiltered(key); |
| 509 | return entry != null |
| 510 | && entry.getRanking().getVisibilityOverride() == Notification.VISIBILITY_PRIVATE; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 511 | } |
| 512 | |
| 513 | private void updateCurrentProfilesCache() { |
Lucas Dupin | 960b7e7f | 2020-01-24 15:47:28 -0800 | [diff] [blame] | 514 | synchronized (mLock) { |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 515 | mCurrentProfiles.clear(); |
Lucas Dupin | 960b7e7f | 2020-01-24 15:47:28 -0800 | [diff] [blame] | 516 | mCurrentManagedProfiles.clear(); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 517 | if (mUserManager != null) { |
| 518 | for (UserInfo user : mUserManager.getProfiles(mCurrentUserId)) { |
| 519 | mCurrentProfiles.put(user.id, user); |
Lucas Dupin | 960b7e7f | 2020-01-24 15:47:28 -0800 | [diff] [blame] | 520 | if (UserManager.USER_TYPE_PROFILE_MANAGED.equals(user.userType)) { |
| 521 | mCurrentManagedProfiles.add(user); |
| 522 | } |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 523 | } |
| 524 | } |
| 525 | } |
Steve Elliott | b47f1c7 | 2019-12-19 12:39:26 -0500 | [diff] [blame] | 526 | mMainHandler.post(() -> { |
| 527 | for (UserChangedListener listener : mListeners) { |
| 528 | listener.onCurrentProfilesChanged(mCurrentProfiles); |
| 529 | } |
| 530 | }); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 531 | } |
| 532 | |
Lucas Dupin | 960b7e7f | 2020-01-24 15:47:28 -0800 | [diff] [blame] | 533 | /** |
| 534 | * If any of the profiles are in public mode. |
| 535 | */ |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 536 | public boolean isAnyProfilePublicMode() { |
Lucas Dupin | 960b7e7f | 2020-01-24 15:47:28 -0800 | [diff] [blame] | 537 | synchronized (mLock) { |
| 538 | for (int i = mCurrentProfiles.size() - 1; i >= 0; i--) { |
| 539 | if (isLockscreenPublicMode(mCurrentProfiles.valueAt(i).id)) { |
| 540 | return true; |
| 541 | } |
| 542 | } |
| 543 | } |
| 544 | return false; |
| 545 | } |
| 546 | |
| 547 | /** |
| 548 | * If any managed/work profiles are in public mode. |
| 549 | */ |
| 550 | public boolean isAnyManagedProfilePublicMode() { |
| 551 | synchronized (mLock) { |
| 552 | for (int i = mCurrentManagedProfiles.size() - 1; i >= 0; i--) { |
| 553 | if (isLockscreenPublicMode(mCurrentManagedProfiles.get(i).id)) { |
| 554 | return true; |
| 555 | } |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 556 | } |
| 557 | } |
| 558 | return false; |
| 559 | } |
| 560 | |
| 561 | /** |
| 562 | * Returns the current user id. This can change if the user is switched. |
| 563 | */ |
| 564 | public int getCurrentUserId() { |
| 565 | return mCurrentUserId; |
| 566 | } |
| 567 | |
| 568 | public SparseArray<UserInfo> getCurrentProfiles() { |
| 569 | return mCurrentProfiles; |
| 570 | } |
| 571 | |
| 572 | @Override |
| 573 | public void onStateChanged(int newState) { |
| 574 | mState = newState; |
| 575 | updatePublicMode(); |
| 576 | } |
| 577 | |
| 578 | public void updatePublicMode() { |
| 579 | //TODO: I think there may be a race condition where mKeyguardViewManager.isShowing() returns |
| 580 | // false when it should be true. Therefore, if we are not on the SHADE, don't even bother |
| 581 | // asking if the keyguard is showing. We still need to check it though because showing the |
| 582 | // camera on the keyguard has a state of SHADE but the keyguard is still showing. |
| 583 | final boolean showingKeyguard = mState != StatusBarState.SHADE |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 584 | || mKeyguardStateController.isShowing(); |
| 585 | final boolean devicePublic = showingKeyguard && mKeyguardStateController.isMethodSecure(); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 586 | |
| 587 | |
| 588 | // Look for public mode users. Users are considered public in either case of: |
| 589 | // - device keyguard is shown in secure mode; |
| 590 | // - profile is locked with a work challenge. |
| 591 | SparseArray<UserInfo> currentProfiles = getCurrentProfiles(); |
Selim Cinek | 6f0a62a | 2019-04-09 18:40:12 -0700 | [diff] [blame] | 592 | mUsersWithSeperateWorkChallenge.clear(); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 593 | for (int i = currentProfiles.size() - 1; i >= 0; i--) { |
| 594 | final int userId = currentProfiles.valueAt(i).id; |
| 595 | boolean isProfilePublic = devicePublic; |
Lucas Dupin | 8968f6a | 2019-08-09 17:41:15 -0700 | [diff] [blame] | 596 | // TODO(b/140058091) |
| 597 | boolean needsSeparateChallenge = whitelistIpcs(() -> |
| 598 | mLockPatternUtils.isSeparateProfileChallengeEnabled(userId)); |
Pavel Grafov | 8538412 | 2019-05-23 15:39:49 +0100 | [diff] [blame] | 599 | if (!devicePublic && userId != getCurrentUserId() |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 600 | && needsSeparateChallenge && mLockPatternUtils.isSecure(userId)) { |
Pavel Grafov | 8538412 | 2019-05-23 15:39:49 +0100 | [diff] [blame] | 601 | // Keyguard.isDeviceLocked is updated asynchronously, assume that all profiles |
| 602 | // with separate challenge are locked when keyguard is visible to avoid race. |
| 603 | isProfilePublic = showingKeyguard || mKeyguardManager.isDeviceLocked(userId); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 604 | } |
| 605 | setLockscreenPublicMode(isProfilePublic, userId); |
Selim Cinek | 6f0a62a | 2019-04-09 18:40:12 -0700 | [diff] [blame] | 606 | mUsersWithSeperateWorkChallenge.put(userId, needsSeparateChallenge); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 607 | } |
Beverly | 85d4c19 | 2019-09-30 11:40:39 -0400 | [diff] [blame] | 608 | getEntryManager().updateNotifications("NotificationLockscreenUserManager.updatePublicMode"); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 609 | } |
| 610 | |
Gus Prevas | a18dc57 | 2019-01-14 16:11:22 -0500 | [diff] [blame] | 611 | @Override |
| 612 | public void addUserChangedListener(UserChangedListener listener) { |
| 613 | mListeners.add(listener); |
| 614 | } |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 615 | |
Steve Elliott | b47f1c7 | 2019-12-19 12:39:26 -0500 | [diff] [blame] | 616 | @Override |
| 617 | public void removeUserChangedListener(UserChangedListener listener) { |
| 618 | mListeners.remove(listener); |
| 619 | } |
| 620 | |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 621 | // public void updatePublicMode() { |
| 622 | // //TODO: I think there may be a race condition where mKeyguardViewManager.isShowing() returns |
| 623 | // // false when it should be true. Therefore, if we are not on the SHADE, don't even bother |
| 624 | // // asking if the keyguard is showing. We still need to check it though because showing the |
| 625 | // // camera on the keyguard has a state of SHADE but the keyguard is still showing. |
| 626 | // final boolean showingKeyguard = mState != StatusBarState.SHADE |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 627 | // || mKeyguardStateController.isShowing(); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 628 | // final boolean devicePublic = showingKeyguard && isSecure(getCurrentUserId()); |
| 629 | // |
| 630 | // |
| 631 | // // Look for public mode users. Users are considered public in either case of: |
| 632 | // // - device keyguard is shown in secure mode; |
| 633 | // // - profile is locked with a work challenge. |
| 634 | // SparseArray<UserInfo> currentProfiles = getCurrentProfiles(); |
| 635 | // for (int i = currentProfiles.size() - 1; i >= 0; i--) { |
| 636 | // final int userId = currentProfiles.valueAt(i).id; |
| 637 | // boolean isProfilePublic = devicePublic; |
| 638 | // if (!devicePublic && userId != getCurrentUserId()) { |
| 639 | // // We can't rely on KeyguardManager#isDeviceLocked() for unified profile challenge |
| 640 | // // due to a race condition where this code could be called before |
| 641 | // // TrustManagerService updates its internal records, resulting in an incorrect |
| 642 | // // state being cached in mLockscreenPublicMode. (b/35951989) |
| 643 | // if (mLockPatternUtils.isSeparateProfileChallengeEnabled(userId) |
| 644 | // && isSecure(userId)) { |
| 645 | // isProfilePublic = mKeyguardManager.isDeviceLocked(userId); |
| 646 | // } |
| 647 | // } |
| 648 | // setLockscreenPublicMode(isProfilePublic, userId); |
| 649 | // } |
| 650 | // } |
| 651 | |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 652 | @Override |
| 653 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 654 | pw.println("NotificationLockscreenUserManager state:"); |
| 655 | pw.print(" mCurrentUserId="); |
| 656 | pw.println(mCurrentUserId); |
| 657 | pw.print(" mShowLockscreenNotifications="); |
| 658 | pw.println(mShowLockscreenNotifications); |
| 659 | pw.print(" mAllowLockscreenRemoteInput="); |
| 660 | pw.println(mAllowLockscreenRemoteInput); |
| 661 | pw.print(" mCurrentProfiles="); |
Lucas Dupin | 960b7e7f | 2020-01-24 15:47:28 -0800 | [diff] [blame] | 662 | synchronized (mLock) { |
| 663 | for (int i = mCurrentProfiles.size() - 1; i >= 0; i--) { |
| 664 | final int userId = mCurrentProfiles.valueAt(i).id; |
| 665 | pw.print("" + userId + " "); |
| 666 | } |
| 667 | } |
| 668 | pw.print(" mCurrentManagedProfiles="); |
| 669 | synchronized (mLock) { |
| 670 | for (UserInfo userInfo : mCurrentManagedProfiles) { |
| 671 | pw.print("" + userInfo.id + " "); |
| 672 | } |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 673 | } |
| 674 | pw.println(); |
| 675 | } |
| 676 | } |