Loading packages/SystemUI/src/com/android/systemui/statusbar/HeadsUpStatusBarView.java +13 −14 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import com.android.keyguard.AlphaOptimizedLinearLayout; import com.android.systemui.R; import com.android.systemui.plugins.DarkIconDispatcher; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.NotificationEntry.OnSensitivityChangedListener; import java.util.ArrayList; Loading @@ -49,6 +48,7 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout { private TextView mTextView; private NotificationEntry mShowingEntry; private Runnable mOnDrawingRectChangedListener; private boolean mRedactSensitiveContent; public HeadsUpStatusBarView(Context context) { this(context, null); Loading Loading @@ -111,29 +111,28 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout { } public void setEntry(NotificationEntry entry) { if (mShowingEntry != null) { mShowingEntry.removeOnSensitivityChangedListener(mOnSensitivityChangedListener); } mShowingEntry = entry; if (mShowingEntry != null) { CharSequence text = entry.headsUpStatusBarText; if (entry.isSensitive()) { if (mRedactSensitiveContent && entry.hasSensitiveContents()) { text = entry.headsUpStatusBarTextPublic; } mTextView.setText(text); mShowingEntry.addOnSensitivityChangedListener(mOnSensitivityChangedListener); } } private final OnSensitivityChangedListener mOnSensitivityChangedListener = entry -> { if (entry != mShowingEntry) { throw new IllegalStateException("Got a sensitivity change for " + entry + " but mShowingEntry is " + mShowingEntry); public void setRedactSensitiveContent(boolean redactSensitiveContent) { if (mRedactSensitiveContent == redactSensitiveContent) { return; } mRedactSensitiveContent = redactSensitiveContent; if (mShowingEntry != null && mShowingEntry.hasSensitiveContents()) { mTextView.setText( mRedactSensitiveContent ? mShowingEntry.headsUpStatusBarTextPublic : mShowingEntry.headsUpStatusBarText); } } // Update the text setEntry(entry); }; @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { Loading packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt +16 −9 Original line number Diff line number Diff line Loading @@ -386,7 +386,7 @@ class LockscreenShadeTransitionController @Inject constructor( } if (view is ExpandableNotificationRow) { // Only drag down on sensitive views, otherwise the ExpandHelper will take this return view.entry.isSensitive return lockScreenUserManager.notifNeedsRedactionInPublic(view.entry) } } return false Loading Loading @@ -552,7 +552,8 @@ class LockscreenShadeTransitionController @Inject constructor( logger.logShadeDisabledOnGoToLockedShade() return } var userId: Int = lockScreenUserManager.getCurrentUserId() val currentUser = lockScreenUserManager.currentUserId var userId: Int = currentUser var entry: NotificationEntry? = null if (expandView is ExpandableNotificationRow) { entry = expandView.entry Loading @@ -562,12 +563,18 @@ class LockscreenShadeTransitionController @Inject constructor( entry.setGroupExpansionChanging(true) userId = entry.sbn.userId } var fullShadeNeedsBouncer = (!lockScreenUserManager.userAllowsPrivateNotificationsInPublic( lockScreenUserManager.getCurrentUserId()) || !lockScreenUserManager.shouldShowLockscreenNotifications() || falsingCollector.shouldEnforceBouncer()) if (keyguardBypassController.bypassEnabled) { fullShadeNeedsBouncer = false val fullShadeNeedsBouncer = when { // No bouncer necessary if we're bypassing keyguardBypassController.bypassEnabled -> false // Redacted notificationss are present, bouncer should be shown before un-redacting in // the full shade lockScreenUserManager.sensitiveNotifsNeedRedactionInPublic(currentUser) -> true // Notifications are hidden in public, bouncer should be shown before showing them in // the full shade !lockScreenUserManager.shouldShowLockscreenNotifications() -> true // Bouncer is being enforced, so we need to show it falsingCollector.shouldEnforceBouncer() -> true else -> false } if (lockScreenUserManager.isLockscreenPublicMode(userId) && fullShadeNeedsBouncer) { statusBarStateController.setLeaveOpenOnKeyguardHide(true) Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManager.java +9 −4 Original line number Diff line number Diff line Loading @@ -71,17 +71,22 @@ public interface NotificationLockscreenUserManager { boolean shouldHideNotifications(String key); boolean shouldShowOnKeyguard(NotificationEntry entry); void addOnNeedsRedactionInPublicChangedListener(Runnable listener); void removeOnNeedsRedactionInPublicChangedListener(Runnable listener); boolean isAnyProfilePublicMode(); void updatePublicMode(); boolean needsRedaction(NotificationEntry entry); /** Does this notification require redaction if it is displayed when the device is public? */ boolean notifNeedsRedactionInPublic(NotificationEntry entry); /** * Has the given user chosen to allow their private (full) notifications to be shown even * when the lockscreen is in "public" (secure & locked) mode? * Do all sensitive notifications belonging to the given user require redaction when they are * displayed in public? */ boolean userAllowsPrivateNotificationsInPublic(int currentUserId); boolean sensitiveNotifsNeedRedactionInPublic(int userId); /** * Has the given user chosen to allow notifications to be shown even when the lockscreen is in Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java +80 −63 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import static com.android.systemui.statusbar.notification.stack.NotificationPrio import android.app.ActivityManager; import android.app.KeyguardManager; import android.app.Notification; import android.app.NotificationManager; import android.app.admin.DevicePolicyManager; import android.content.BroadcastReceiver; Loading @@ -45,7 +44,6 @@ import android.util.SparseBooleanArray; import com.android.internal.statusbar.NotificationVisibility; import com.android.internal.widget.LockPatternUtils; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.systemui.Dependency; import com.android.systemui.Dumpable; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.dagger.SysUISingleton; Loading @@ -60,6 +58,7 @@ import com.android.systemui.statusbar.notification.collection.notifcollection.Co import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider; import com.android.systemui.statusbar.policy.DeviceProvisionedController; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.util.ListenerSet; import com.android.systemui.util.settings.SecureSettings; import java.io.PrintWriter; Loading @@ -85,13 +84,12 @@ public class NotificationLockscreenUserManagerImpl implements private final DeviceProvisionedController mDeviceProvisionedController; private final KeyguardStateController mKeyguardStateController; private final SecureSettings mSecureSettings; private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; private final Lazy<OverviewProxyService> mOverviewProxyService; private final Object mLock = new Object(); // Lazy private NotificationEntryManager mEntryManager; private final Lazy<NotificationVisibilityProvider> mVisibilityProviderLazy; private final Lazy<CommonNotifCollection> mCommonNotifCollectionLazy; private final Lazy<NotificationEntryManager> mEntryManagerLazy; private final DevicePolicyManager mDevicePolicyManager; private final SparseBooleanArray mLockscreenPublicMode = new SparseBooleanArray(); private final SparseBooleanArray mUsersWithSeparateWorkChallenge = new SparseBooleanArray(); Loading @@ -103,13 +101,14 @@ public class NotificationLockscreenUserManagerImpl implements private final List<UserChangedListener> mListeners = new ArrayList<>(); private final BroadcastDispatcher mBroadcastDispatcher; private final NotificationClickNotifier mClickNotifier; private boolean mShowLockscreenNotifications; private boolean mAllowLockscreenRemoteInput; private LockPatternUtils mLockPatternUtils; protected KeyguardManager mKeyguardManager; private int mState = StatusBarState.SHADE; private List<KeyguardNotificationSuppressor> mKeyguardSuppressors = new ArrayList<>(); private final LockPatternUtils mLockPatternUtils; private final List<KeyguardNotificationSuppressor> mKeyguardSuppressors = new ArrayList<>(); protected final Context mContext; private final Handler mMainHandler; protected final SparseArray<UserInfo> mCurrentProfiles = new SparseArray<>(); protected final SparseArray<UserInfo> mCurrentManagedProfiles = new SparseArray<>(); private final ListenerSet<Runnable> mOnSensitiveContentRedactionChangeListeners = new ListenerSet<>(); protected final BroadcastReceiver mAllUsersReceiver = new BroadcastReceiver() { @Override Loading @@ -120,7 +119,11 @@ public class NotificationLockscreenUserManagerImpl implements isCurrentProfile(getSendingUserId())) { mUsersAllowingPrivateNotifications.clear(); updateLockscreenNotificationSetting(); getEntryManager().updateNotifications("ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED"); for (Runnable listener : mOnSensitiveContentRedactionChangeListeners) { listener.run(); } mEntryManagerLazy.get() .updateNotifications("ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED"); } } }; Loading @@ -142,7 +145,7 @@ public class NotificationLockscreenUserManagerImpl implements // The filtering needs to happen before the update call below in order to // make sure // the presenter has the updated notifications from the new user getEntryManager().reapplyFilterAndSort("user switched"); mEntryManagerLazy.get().reapplyFilterAndSort("user switched"); mPresenter.onUserSwitched(mCurrentUserId); for (UserChangedListener listener : mListeners) { Loading @@ -156,7 +159,7 @@ public class NotificationLockscreenUserManagerImpl implements break; case Intent.ACTION_USER_UNLOCKED: // Start the overview connection to the launcher service Dependency.get(OverviewProxyService.class).startConnectionToCurrentUser(); mOverviewProxyService.get().startConnectionToCurrentUser(); break; case NOTIFICATION_UNLOCKED_BY_WORK_CHALLENGE_ACTION: final IntentSender intentSender = intent.getParcelableExtra( Loading @@ -179,28 +182,26 @@ public class NotificationLockscreenUserManagerImpl implements } }; protected final Context mContext; private final Handler mMainHandler; protected final SparseArray<UserInfo> mCurrentProfiles = new SparseArray<>(); protected final SparseArray<UserInfo> mCurrentManagedProfiles = new SparseArray<>(); protected int mCurrentUserId = 0; // Late-init protected NotificationPresenter mPresenter; protected ContentObserver mLockscreenSettingsObserver; protected ContentObserver mSettingsObserver; private boolean mHideSilentNotificationsOnLockscreen; protected KeyguardManager mKeyguardManager; private NotificationEntryManager getEntryManager() { if (mEntryManager == null) { mEntryManager = Dependency.get(NotificationEntryManager.class); } return mEntryManager; } protected int mCurrentUserId = 0; private int mState = StatusBarState.SHADE; private boolean mHideSilentNotificationsOnLockscreen; private boolean mShowLockscreenNotifications; private boolean mAllowLockscreenRemoteInput; @Inject public NotificationLockscreenUserManagerImpl(Context context, public NotificationLockscreenUserManagerImpl( Context context, BroadcastDispatcher broadcastDispatcher, DevicePolicyManager devicePolicyManager, KeyguardUpdateMonitor keyguardUpdateMonitor, Lazy<NotificationEntryManager> notificationEntryManagerLazy, Lazy<OverviewProxyService> overviewProxyServiceLazy, UserManager userManager, Lazy<NotificationVisibilityProvider> visibilityProviderLazy, Lazy<CommonNotifCollection> commonNotifCollectionLazy, Loading @@ -216,9 +217,11 @@ public class NotificationLockscreenUserManagerImpl implements mMainHandler = mainHandler; mDevicePolicyManager = devicePolicyManager; mUserManager = userManager; mOverviewProxyService = overviewProxyServiceLazy; mCurrentUserId = ActivityManager.getCurrentUser(); mVisibilityProviderLazy = visibilityProviderLazy; mCommonNotifCollectionLazy = commonNotifCollectionLazy; mEntryManagerLazy = notificationEntryManagerLazy; mClickNotifier = clickNotifier; statusBarStateController.addCallback(this); mLockPatternUtils = new LockPatternUtils(context); Loading @@ -227,10 +230,12 @@ public class NotificationLockscreenUserManagerImpl implements mDeviceProvisionedController = deviceProvisionedController; mSecureSettings = secureSettings; mKeyguardStateController = keyguardStateController; mKeyguardUpdateMonitor = keyguardUpdateMonitor; dumpManager.registerDumpable(this); } @Override public void setUpWithPresenter(NotificationPresenter presenter) { mPresenter = presenter; Loading @@ -243,7 +248,10 @@ public class NotificationLockscreenUserManagerImpl implements mUsersAllowingNotifications.clear(); // ... and refresh all the notifications updateLockscreenNotificationSetting(); getEntryManager().updateNotifications("LOCK_SCREEN_SHOW_NOTIFICATIONS," for (Runnable listener : mOnSensitiveContentRedactionChangeListeners) { listener.run(); } mEntryManagerLazy.get().updateNotifications("LOCK_SCREEN_SHOW_NOTIFICATIONS," + " or LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS change"); } }; Loading @@ -253,7 +261,7 @@ public class NotificationLockscreenUserManagerImpl implements public void onChange(boolean selfChange) { updateLockscreenNotificationSetting(); if (mDeviceProvisionedController.isDeviceProvisioned()) { getEntryManager().updateNotifications("LOCK_SCREEN_ALLOW_REMOTE_INPUT" mEntryManagerLazy.get().updateNotifications("LOCK_SCREEN_ALLOW_REMOTE_INPUT" + " or ZEN_MODE change"); } } Loading Loading @@ -312,14 +320,17 @@ public class NotificationLockscreenUserManagerImpl implements mSettingsObserver.onChange(false); // set up } @Override public boolean shouldShowLockscreenNotifications() { return mShowLockscreenNotifications; } @Override public boolean shouldAllowLockscreenRemoteInput() { return mAllowLockscreenRemoteInput; } @Override public boolean isCurrentProfile(int userId) { synchronized (mLock) { return userId == UserHandle.USER_ALL || mCurrentProfiles.get(userId) != null; Loading @@ -334,7 +345,7 @@ public class NotificationLockscreenUserManagerImpl implements if (userId == UserHandle.USER_ALL) { userId = mCurrentUserId; } boolean inLockdown = Dependency.get(KeyguardUpdateMonitor.class).isUserInLockdown(userId); boolean inLockdown = mKeyguardUpdateMonitor.isUserInLockdown(userId); mUsersInLockdownLatestResult.put(userId, inLockdown); return inLockdown; } Loading @@ -343,6 +354,7 @@ public class NotificationLockscreenUserManagerImpl implements * Returns true if we're on a secure lockscreen and the user wants to hide notification data. * If so, notifications should be hidden. */ @Override public boolean shouldHideNotifications(int userId) { boolean hide = isLockscreenPublicMode(userId) && !userAllowsNotificationsInPublic(userId) || (userId != mCurrentUserId && shouldHideNotifications(mCurrentUserId)) Loading @@ -355,6 +367,7 @@ public class NotificationLockscreenUserManagerImpl implements * Returns true if we're on a secure lockscreen and the user wants to hide notifications via * package-specific override. */ @Override public boolean shouldHideNotifications(String key) { if (mCommonNotifCollectionLazy.get() == null) { Log.wtf(TAG, "mCommonNotifCollectionLazy was null!", new Throwable()); Loading @@ -365,6 +378,7 @@ public class NotificationLockscreenUserManagerImpl implements && visibleEntry.getRanking().getLockscreenVisibilityOverride() == VISIBILITY_SECRET; } @Override public boolean shouldShowOnKeyguard(NotificationEntry entry) { if (mCommonNotifCollectionLazy.get() == null) { Log.wtf(TAG, "mCommonNotifCollectionLazy was null!", new Throwable()); Loading @@ -387,14 +401,6 @@ public class NotificationLockscreenUserManagerImpl implements return mShowLockscreenNotifications && exceedsPriorityThreshold; } private void setShowLockscreenNotifications(boolean show) { mShowLockscreenNotifications = show; } private void setLockscreenAllowRemoteInput(boolean allowLockscreenRemoteInput) { mAllowLockscreenRemoteInput = allowLockscreenRemoteInput; } protected void updateLockscreenNotificationSetting() { final boolean show = mSecureSettings.getIntForUser( Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, Loading @@ -408,7 +414,7 @@ public class NotificationLockscreenUserManagerImpl implements mHideSilentNotificationsOnLockscreen = mSecureSettings.getIntForUser( Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 1, mCurrentUserId) == 0; setShowLockscreenNotifications(show && allowedByDpm); mShowLockscreenNotifications = show && allowedByDpm; if (ENABLE_LOCK_SCREEN_ALLOW_REMOTE_INPUT) { final boolean remoteInput = mSecureSettings.getIntForUser( Loading @@ -418,9 +424,9 @@ public class NotificationLockscreenUserManagerImpl implements final boolean remoteInputDpm = (dpmFlags & DevicePolicyManager.KEYGUARD_DISABLE_REMOTE_INPUT) == 0; setLockscreenAllowRemoteInput(remoteInput && remoteInputDpm); mAllowLockscreenRemoteInput = remoteInput && remoteInputDpm; } else { setLockscreenAllowRemoteInput(false); mAllowLockscreenRemoteInput = false; } } Loading @@ -428,7 +434,7 @@ public class NotificationLockscreenUserManagerImpl implements * Has the given user chosen to allow their private (full) notifications to be shown even * when the lockscreen is in "public" (secure & locked) mode? */ public boolean userAllowsPrivateNotificationsInPublic(int userHandle) { protected boolean userAllowsPrivateNotificationsInPublic(int userHandle) { if (userHandle == UserHandle.USER_ALL) { return true; } Loading Loading @@ -473,10 +479,12 @@ public class NotificationLockscreenUserManagerImpl implements /** * Save the current "public" (locked and secure) state of the lockscreen. */ @Override public void setLockscreenPublicMode(boolean publicMode, int userId) { mLockscreenPublicMode.put(userId, publicMode); } @Override public boolean isLockscreenPublicMode(int userId) { if (userId == UserHandle.USER_ALL) { return mLockscreenPublicMode.get(mCurrentUserId, false); Loading @@ -493,6 +501,7 @@ public class NotificationLockscreenUserManagerImpl implements * Has the given user chosen to allow notifications to be shown even when the lockscreen is in * "public" (secure & locked) mode? */ @Override public boolean userAllowsNotificationsInPublic(int userHandle) { if (isCurrentProfile(userHandle) && userHandle != mCurrentUserId) { return true; Loading @@ -513,36 +522,37 @@ public class NotificationLockscreenUserManagerImpl implements } /** @return true if the entry needs redaction when on the lockscreen. */ public boolean needsRedaction(NotificationEntry ent) { @Override public boolean notifNeedsRedactionInPublic(NotificationEntry ent) { int userId = ent.getSbn().getUserId(); return ent.hasSensitiveContents() && sensitiveNotifsNeedRedactionInPublic(userId); } @Override public boolean sensitiveNotifsNeedRedactionInPublic(int userId) { boolean isCurrentUserRedactingNotifs = !userAllowsPrivateNotificationsInPublic(mCurrentUserId); if (userId == mCurrentUserId) { return isCurrentUserRedactingNotifs; } boolean isNotifForManagedProfile = mCurrentManagedProfiles.contains(userId); boolean isNotifUserRedacted = !userAllowsPrivateNotificationsInPublic(userId); // redact notifications if the current user is redacting notifications; however if the // notification is associated with a managed profile, we rely on the managed profile // setting to determine whether to redact it boolean isNotifRedacted = (!isNotifForManagedProfile && isCurrentUserRedactingNotifs) || isNotifUserRedacted; boolean notificationRequestsRedaction = ent.getSbn().getNotification().visibility == Notification.VISIBILITY_PRIVATE; boolean userForcesRedaction = packageHasVisibilityOverride(ent.getSbn().getKey()); return userForcesRedaction || notificationRequestsRedaction && isNotifRedacted; return (!isNotifForManagedProfile && isCurrentUserRedactingNotifs) || isNotifUserRedacted; } private boolean packageHasVisibilityOverride(String key) { if (mCommonNotifCollectionLazy.get() == null) { Log.wtf(TAG, "mEntryManager was null!", new Throwable()); return true; @Override public void addOnNeedsRedactionInPublicChangedListener(Runnable listener) { mOnSensitiveContentRedactionChangeListeners.addIfAbsent(listener); } NotificationEntry entry = mCommonNotifCollectionLazy.get().getEntry(key); return entry != null && entry.getRanking().getLockscreenVisibilityOverride() == Notification.VISIBILITY_PRIVATE; @Override public void removeOnNeedsRedactionInPublicChangedListener(Runnable listener) { mOnSensitiveContentRedactionChangeListeners.remove(listener); } private void updateCurrentProfilesCache() { Loading @@ -562,12 +572,16 @@ public class NotificationLockscreenUserManagerImpl implements for (UserChangedListener listener : mListeners) { listener.onCurrentProfilesChanged(mCurrentProfiles); } for (Runnable listener : mOnSensitiveContentRedactionChangeListeners) { listener.run(); } }); } /** * If any of the profiles are in public mode. */ @Override public boolean isAnyProfilePublicMode() { synchronized (mLock) { for (int i = mCurrentProfiles.size() - 1; i >= 0; i--) { Loading Loading @@ -596,10 +610,12 @@ public class NotificationLockscreenUserManagerImpl implements /** * Returns the current user id. This can change if the user is switched. */ @Override public int getCurrentUserId() { return mCurrentUserId; } @Override public SparseArray<UserInfo> getCurrentProfiles() { return mCurrentProfiles; } Loading Loading @@ -640,7 +656,8 @@ public class NotificationLockscreenUserManagerImpl implements setLockscreenPublicMode(isProfilePublic, userId); mUsersWithSeparateWorkChallenge.put(userId, needsSeparateChallenge); } getEntryManager().updateNotifications("NotificationLockscreenUserManager.updatePublicMode"); mEntryManagerLazy.get() .updateNotifications("NotificationLockscreenUserManager.updatePublicMode"); } @Override Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java +20 −8 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
packages/SystemUI/src/com/android/systemui/statusbar/HeadsUpStatusBarView.java +13 −14 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import com.android.keyguard.AlphaOptimizedLinearLayout; import com.android.systemui.R; import com.android.systemui.plugins.DarkIconDispatcher; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.NotificationEntry.OnSensitivityChangedListener; import java.util.ArrayList; Loading @@ -49,6 +48,7 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout { private TextView mTextView; private NotificationEntry mShowingEntry; private Runnable mOnDrawingRectChangedListener; private boolean mRedactSensitiveContent; public HeadsUpStatusBarView(Context context) { this(context, null); Loading Loading @@ -111,29 +111,28 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout { } public void setEntry(NotificationEntry entry) { if (mShowingEntry != null) { mShowingEntry.removeOnSensitivityChangedListener(mOnSensitivityChangedListener); } mShowingEntry = entry; if (mShowingEntry != null) { CharSequence text = entry.headsUpStatusBarText; if (entry.isSensitive()) { if (mRedactSensitiveContent && entry.hasSensitiveContents()) { text = entry.headsUpStatusBarTextPublic; } mTextView.setText(text); mShowingEntry.addOnSensitivityChangedListener(mOnSensitivityChangedListener); } } private final OnSensitivityChangedListener mOnSensitivityChangedListener = entry -> { if (entry != mShowingEntry) { throw new IllegalStateException("Got a sensitivity change for " + entry + " but mShowingEntry is " + mShowingEntry); public void setRedactSensitiveContent(boolean redactSensitiveContent) { if (mRedactSensitiveContent == redactSensitiveContent) { return; } mRedactSensitiveContent = redactSensitiveContent; if (mShowingEntry != null && mShowingEntry.hasSensitiveContents()) { mTextView.setText( mRedactSensitiveContent ? mShowingEntry.headsUpStatusBarTextPublic : mShowingEntry.headsUpStatusBarText); } } // Update the text setEntry(entry); }; @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { Loading
packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt +16 −9 Original line number Diff line number Diff line Loading @@ -386,7 +386,7 @@ class LockscreenShadeTransitionController @Inject constructor( } if (view is ExpandableNotificationRow) { // Only drag down on sensitive views, otherwise the ExpandHelper will take this return view.entry.isSensitive return lockScreenUserManager.notifNeedsRedactionInPublic(view.entry) } } return false Loading Loading @@ -552,7 +552,8 @@ class LockscreenShadeTransitionController @Inject constructor( logger.logShadeDisabledOnGoToLockedShade() return } var userId: Int = lockScreenUserManager.getCurrentUserId() val currentUser = lockScreenUserManager.currentUserId var userId: Int = currentUser var entry: NotificationEntry? = null if (expandView is ExpandableNotificationRow) { entry = expandView.entry Loading @@ -562,12 +563,18 @@ class LockscreenShadeTransitionController @Inject constructor( entry.setGroupExpansionChanging(true) userId = entry.sbn.userId } var fullShadeNeedsBouncer = (!lockScreenUserManager.userAllowsPrivateNotificationsInPublic( lockScreenUserManager.getCurrentUserId()) || !lockScreenUserManager.shouldShowLockscreenNotifications() || falsingCollector.shouldEnforceBouncer()) if (keyguardBypassController.bypassEnabled) { fullShadeNeedsBouncer = false val fullShadeNeedsBouncer = when { // No bouncer necessary if we're bypassing keyguardBypassController.bypassEnabled -> false // Redacted notificationss are present, bouncer should be shown before un-redacting in // the full shade lockScreenUserManager.sensitiveNotifsNeedRedactionInPublic(currentUser) -> true // Notifications are hidden in public, bouncer should be shown before showing them in // the full shade !lockScreenUserManager.shouldShowLockscreenNotifications() -> true // Bouncer is being enforced, so we need to show it falsingCollector.shouldEnforceBouncer() -> true else -> false } if (lockScreenUserManager.isLockscreenPublicMode(userId) && fullShadeNeedsBouncer) { statusBarStateController.setLeaveOpenOnKeyguardHide(true) Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManager.java +9 −4 Original line number Diff line number Diff line Loading @@ -71,17 +71,22 @@ public interface NotificationLockscreenUserManager { boolean shouldHideNotifications(String key); boolean shouldShowOnKeyguard(NotificationEntry entry); void addOnNeedsRedactionInPublicChangedListener(Runnable listener); void removeOnNeedsRedactionInPublicChangedListener(Runnable listener); boolean isAnyProfilePublicMode(); void updatePublicMode(); boolean needsRedaction(NotificationEntry entry); /** Does this notification require redaction if it is displayed when the device is public? */ boolean notifNeedsRedactionInPublic(NotificationEntry entry); /** * Has the given user chosen to allow their private (full) notifications to be shown even * when the lockscreen is in "public" (secure & locked) mode? * Do all sensitive notifications belonging to the given user require redaction when they are * displayed in public? */ boolean userAllowsPrivateNotificationsInPublic(int currentUserId); boolean sensitiveNotifsNeedRedactionInPublic(int userId); /** * Has the given user chosen to allow notifications to be shown even when the lockscreen is in Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java +80 −63 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import static com.android.systemui.statusbar.notification.stack.NotificationPrio import android.app.ActivityManager; import android.app.KeyguardManager; import android.app.Notification; import android.app.NotificationManager; import android.app.admin.DevicePolicyManager; import android.content.BroadcastReceiver; Loading @@ -45,7 +44,6 @@ import android.util.SparseBooleanArray; import com.android.internal.statusbar.NotificationVisibility; import com.android.internal.widget.LockPatternUtils; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.systemui.Dependency; import com.android.systemui.Dumpable; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.dagger.SysUISingleton; Loading @@ -60,6 +58,7 @@ import com.android.systemui.statusbar.notification.collection.notifcollection.Co import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider; import com.android.systemui.statusbar.policy.DeviceProvisionedController; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.util.ListenerSet; import com.android.systemui.util.settings.SecureSettings; import java.io.PrintWriter; Loading @@ -85,13 +84,12 @@ public class NotificationLockscreenUserManagerImpl implements private final DeviceProvisionedController mDeviceProvisionedController; private final KeyguardStateController mKeyguardStateController; private final SecureSettings mSecureSettings; private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; private final Lazy<OverviewProxyService> mOverviewProxyService; private final Object mLock = new Object(); // Lazy private NotificationEntryManager mEntryManager; private final Lazy<NotificationVisibilityProvider> mVisibilityProviderLazy; private final Lazy<CommonNotifCollection> mCommonNotifCollectionLazy; private final Lazy<NotificationEntryManager> mEntryManagerLazy; private final DevicePolicyManager mDevicePolicyManager; private final SparseBooleanArray mLockscreenPublicMode = new SparseBooleanArray(); private final SparseBooleanArray mUsersWithSeparateWorkChallenge = new SparseBooleanArray(); Loading @@ -103,13 +101,14 @@ public class NotificationLockscreenUserManagerImpl implements private final List<UserChangedListener> mListeners = new ArrayList<>(); private final BroadcastDispatcher mBroadcastDispatcher; private final NotificationClickNotifier mClickNotifier; private boolean mShowLockscreenNotifications; private boolean mAllowLockscreenRemoteInput; private LockPatternUtils mLockPatternUtils; protected KeyguardManager mKeyguardManager; private int mState = StatusBarState.SHADE; private List<KeyguardNotificationSuppressor> mKeyguardSuppressors = new ArrayList<>(); private final LockPatternUtils mLockPatternUtils; private final List<KeyguardNotificationSuppressor> mKeyguardSuppressors = new ArrayList<>(); protected final Context mContext; private final Handler mMainHandler; protected final SparseArray<UserInfo> mCurrentProfiles = new SparseArray<>(); protected final SparseArray<UserInfo> mCurrentManagedProfiles = new SparseArray<>(); private final ListenerSet<Runnable> mOnSensitiveContentRedactionChangeListeners = new ListenerSet<>(); protected final BroadcastReceiver mAllUsersReceiver = new BroadcastReceiver() { @Override Loading @@ -120,7 +119,11 @@ public class NotificationLockscreenUserManagerImpl implements isCurrentProfile(getSendingUserId())) { mUsersAllowingPrivateNotifications.clear(); updateLockscreenNotificationSetting(); getEntryManager().updateNotifications("ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED"); for (Runnable listener : mOnSensitiveContentRedactionChangeListeners) { listener.run(); } mEntryManagerLazy.get() .updateNotifications("ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED"); } } }; Loading @@ -142,7 +145,7 @@ public class NotificationLockscreenUserManagerImpl implements // The filtering needs to happen before the update call below in order to // make sure // the presenter has the updated notifications from the new user getEntryManager().reapplyFilterAndSort("user switched"); mEntryManagerLazy.get().reapplyFilterAndSort("user switched"); mPresenter.onUserSwitched(mCurrentUserId); for (UserChangedListener listener : mListeners) { Loading @@ -156,7 +159,7 @@ public class NotificationLockscreenUserManagerImpl implements break; case Intent.ACTION_USER_UNLOCKED: // Start the overview connection to the launcher service Dependency.get(OverviewProxyService.class).startConnectionToCurrentUser(); mOverviewProxyService.get().startConnectionToCurrentUser(); break; case NOTIFICATION_UNLOCKED_BY_WORK_CHALLENGE_ACTION: final IntentSender intentSender = intent.getParcelableExtra( Loading @@ -179,28 +182,26 @@ public class NotificationLockscreenUserManagerImpl implements } }; protected final Context mContext; private final Handler mMainHandler; protected final SparseArray<UserInfo> mCurrentProfiles = new SparseArray<>(); protected final SparseArray<UserInfo> mCurrentManagedProfiles = new SparseArray<>(); protected int mCurrentUserId = 0; // Late-init protected NotificationPresenter mPresenter; protected ContentObserver mLockscreenSettingsObserver; protected ContentObserver mSettingsObserver; private boolean mHideSilentNotificationsOnLockscreen; protected KeyguardManager mKeyguardManager; private NotificationEntryManager getEntryManager() { if (mEntryManager == null) { mEntryManager = Dependency.get(NotificationEntryManager.class); } return mEntryManager; } protected int mCurrentUserId = 0; private int mState = StatusBarState.SHADE; private boolean mHideSilentNotificationsOnLockscreen; private boolean mShowLockscreenNotifications; private boolean mAllowLockscreenRemoteInput; @Inject public NotificationLockscreenUserManagerImpl(Context context, public NotificationLockscreenUserManagerImpl( Context context, BroadcastDispatcher broadcastDispatcher, DevicePolicyManager devicePolicyManager, KeyguardUpdateMonitor keyguardUpdateMonitor, Lazy<NotificationEntryManager> notificationEntryManagerLazy, Lazy<OverviewProxyService> overviewProxyServiceLazy, UserManager userManager, Lazy<NotificationVisibilityProvider> visibilityProviderLazy, Lazy<CommonNotifCollection> commonNotifCollectionLazy, Loading @@ -216,9 +217,11 @@ public class NotificationLockscreenUserManagerImpl implements mMainHandler = mainHandler; mDevicePolicyManager = devicePolicyManager; mUserManager = userManager; mOverviewProxyService = overviewProxyServiceLazy; mCurrentUserId = ActivityManager.getCurrentUser(); mVisibilityProviderLazy = visibilityProviderLazy; mCommonNotifCollectionLazy = commonNotifCollectionLazy; mEntryManagerLazy = notificationEntryManagerLazy; mClickNotifier = clickNotifier; statusBarStateController.addCallback(this); mLockPatternUtils = new LockPatternUtils(context); Loading @@ -227,10 +230,12 @@ public class NotificationLockscreenUserManagerImpl implements mDeviceProvisionedController = deviceProvisionedController; mSecureSettings = secureSettings; mKeyguardStateController = keyguardStateController; mKeyguardUpdateMonitor = keyguardUpdateMonitor; dumpManager.registerDumpable(this); } @Override public void setUpWithPresenter(NotificationPresenter presenter) { mPresenter = presenter; Loading @@ -243,7 +248,10 @@ public class NotificationLockscreenUserManagerImpl implements mUsersAllowingNotifications.clear(); // ... and refresh all the notifications updateLockscreenNotificationSetting(); getEntryManager().updateNotifications("LOCK_SCREEN_SHOW_NOTIFICATIONS," for (Runnable listener : mOnSensitiveContentRedactionChangeListeners) { listener.run(); } mEntryManagerLazy.get().updateNotifications("LOCK_SCREEN_SHOW_NOTIFICATIONS," + " or LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS change"); } }; Loading @@ -253,7 +261,7 @@ public class NotificationLockscreenUserManagerImpl implements public void onChange(boolean selfChange) { updateLockscreenNotificationSetting(); if (mDeviceProvisionedController.isDeviceProvisioned()) { getEntryManager().updateNotifications("LOCK_SCREEN_ALLOW_REMOTE_INPUT" mEntryManagerLazy.get().updateNotifications("LOCK_SCREEN_ALLOW_REMOTE_INPUT" + " or ZEN_MODE change"); } } Loading Loading @@ -312,14 +320,17 @@ public class NotificationLockscreenUserManagerImpl implements mSettingsObserver.onChange(false); // set up } @Override public boolean shouldShowLockscreenNotifications() { return mShowLockscreenNotifications; } @Override public boolean shouldAllowLockscreenRemoteInput() { return mAllowLockscreenRemoteInput; } @Override public boolean isCurrentProfile(int userId) { synchronized (mLock) { return userId == UserHandle.USER_ALL || mCurrentProfiles.get(userId) != null; Loading @@ -334,7 +345,7 @@ public class NotificationLockscreenUserManagerImpl implements if (userId == UserHandle.USER_ALL) { userId = mCurrentUserId; } boolean inLockdown = Dependency.get(KeyguardUpdateMonitor.class).isUserInLockdown(userId); boolean inLockdown = mKeyguardUpdateMonitor.isUserInLockdown(userId); mUsersInLockdownLatestResult.put(userId, inLockdown); return inLockdown; } Loading @@ -343,6 +354,7 @@ public class NotificationLockscreenUserManagerImpl implements * Returns true if we're on a secure lockscreen and the user wants to hide notification data. * If so, notifications should be hidden. */ @Override public boolean shouldHideNotifications(int userId) { boolean hide = isLockscreenPublicMode(userId) && !userAllowsNotificationsInPublic(userId) || (userId != mCurrentUserId && shouldHideNotifications(mCurrentUserId)) Loading @@ -355,6 +367,7 @@ public class NotificationLockscreenUserManagerImpl implements * Returns true if we're on a secure lockscreen and the user wants to hide notifications via * package-specific override. */ @Override public boolean shouldHideNotifications(String key) { if (mCommonNotifCollectionLazy.get() == null) { Log.wtf(TAG, "mCommonNotifCollectionLazy was null!", new Throwable()); Loading @@ -365,6 +378,7 @@ public class NotificationLockscreenUserManagerImpl implements && visibleEntry.getRanking().getLockscreenVisibilityOverride() == VISIBILITY_SECRET; } @Override public boolean shouldShowOnKeyguard(NotificationEntry entry) { if (mCommonNotifCollectionLazy.get() == null) { Log.wtf(TAG, "mCommonNotifCollectionLazy was null!", new Throwable()); Loading @@ -387,14 +401,6 @@ public class NotificationLockscreenUserManagerImpl implements return mShowLockscreenNotifications && exceedsPriorityThreshold; } private void setShowLockscreenNotifications(boolean show) { mShowLockscreenNotifications = show; } private void setLockscreenAllowRemoteInput(boolean allowLockscreenRemoteInput) { mAllowLockscreenRemoteInput = allowLockscreenRemoteInput; } protected void updateLockscreenNotificationSetting() { final boolean show = mSecureSettings.getIntForUser( Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, Loading @@ -408,7 +414,7 @@ public class NotificationLockscreenUserManagerImpl implements mHideSilentNotificationsOnLockscreen = mSecureSettings.getIntForUser( Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 1, mCurrentUserId) == 0; setShowLockscreenNotifications(show && allowedByDpm); mShowLockscreenNotifications = show && allowedByDpm; if (ENABLE_LOCK_SCREEN_ALLOW_REMOTE_INPUT) { final boolean remoteInput = mSecureSettings.getIntForUser( Loading @@ -418,9 +424,9 @@ public class NotificationLockscreenUserManagerImpl implements final boolean remoteInputDpm = (dpmFlags & DevicePolicyManager.KEYGUARD_DISABLE_REMOTE_INPUT) == 0; setLockscreenAllowRemoteInput(remoteInput && remoteInputDpm); mAllowLockscreenRemoteInput = remoteInput && remoteInputDpm; } else { setLockscreenAllowRemoteInput(false); mAllowLockscreenRemoteInput = false; } } Loading @@ -428,7 +434,7 @@ public class NotificationLockscreenUserManagerImpl implements * Has the given user chosen to allow their private (full) notifications to be shown even * when the lockscreen is in "public" (secure & locked) mode? */ public boolean userAllowsPrivateNotificationsInPublic(int userHandle) { protected boolean userAllowsPrivateNotificationsInPublic(int userHandle) { if (userHandle == UserHandle.USER_ALL) { return true; } Loading Loading @@ -473,10 +479,12 @@ public class NotificationLockscreenUserManagerImpl implements /** * Save the current "public" (locked and secure) state of the lockscreen. */ @Override public void setLockscreenPublicMode(boolean publicMode, int userId) { mLockscreenPublicMode.put(userId, publicMode); } @Override public boolean isLockscreenPublicMode(int userId) { if (userId == UserHandle.USER_ALL) { return mLockscreenPublicMode.get(mCurrentUserId, false); Loading @@ -493,6 +501,7 @@ public class NotificationLockscreenUserManagerImpl implements * Has the given user chosen to allow notifications to be shown even when the lockscreen is in * "public" (secure & locked) mode? */ @Override public boolean userAllowsNotificationsInPublic(int userHandle) { if (isCurrentProfile(userHandle) && userHandle != mCurrentUserId) { return true; Loading @@ -513,36 +522,37 @@ public class NotificationLockscreenUserManagerImpl implements } /** @return true if the entry needs redaction when on the lockscreen. */ public boolean needsRedaction(NotificationEntry ent) { @Override public boolean notifNeedsRedactionInPublic(NotificationEntry ent) { int userId = ent.getSbn().getUserId(); return ent.hasSensitiveContents() && sensitiveNotifsNeedRedactionInPublic(userId); } @Override public boolean sensitiveNotifsNeedRedactionInPublic(int userId) { boolean isCurrentUserRedactingNotifs = !userAllowsPrivateNotificationsInPublic(mCurrentUserId); if (userId == mCurrentUserId) { return isCurrentUserRedactingNotifs; } boolean isNotifForManagedProfile = mCurrentManagedProfiles.contains(userId); boolean isNotifUserRedacted = !userAllowsPrivateNotificationsInPublic(userId); // redact notifications if the current user is redacting notifications; however if the // notification is associated with a managed profile, we rely on the managed profile // setting to determine whether to redact it boolean isNotifRedacted = (!isNotifForManagedProfile && isCurrentUserRedactingNotifs) || isNotifUserRedacted; boolean notificationRequestsRedaction = ent.getSbn().getNotification().visibility == Notification.VISIBILITY_PRIVATE; boolean userForcesRedaction = packageHasVisibilityOverride(ent.getSbn().getKey()); return userForcesRedaction || notificationRequestsRedaction && isNotifRedacted; return (!isNotifForManagedProfile && isCurrentUserRedactingNotifs) || isNotifUserRedacted; } private boolean packageHasVisibilityOverride(String key) { if (mCommonNotifCollectionLazy.get() == null) { Log.wtf(TAG, "mEntryManager was null!", new Throwable()); return true; @Override public void addOnNeedsRedactionInPublicChangedListener(Runnable listener) { mOnSensitiveContentRedactionChangeListeners.addIfAbsent(listener); } NotificationEntry entry = mCommonNotifCollectionLazy.get().getEntry(key); return entry != null && entry.getRanking().getLockscreenVisibilityOverride() == Notification.VISIBILITY_PRIVATE; @Override public void removeOnNeedsRedactionInPublicChangedListener(Runnable listener) { mOnSensitiveContentRedactionChangeListeners.remove(listener); } private void updateCurrentProfilesCache() { Loading @@ -562,12 +572,16 @@ public class NotificationLockscreenUserManagerImpl implements for (UserChangedListener listener : mListeners) { listener.onCurrentProfilesChanged(mCurrentProfiles); } for (Runnable listener : mOnSensitiveContentRedactionChangeListeners) { listener.run(); } }); } /** * If any of the profiles are in public mode. */ @Override public boolean isAnyProfilePublicMode() { synchronized (mLock) { for (int i = mCurrentProfiles.size() - 1; i >= 0; i--) { Loading Loading @@ -596,10 +610,12 @@ public class NotificationLockscreenUserManagerImpl implements /** * Returns the current user id. This can change if the user is switched. */ @Override public int getCurrentUserId() { return mCurrentUserId; } @Override public SparseArray<UserInfo> getCurrentProfiles() { return mCurrentProfiles; } Loading Loading @@ -640,7 +656,8 @@ public class NotificationLockscreenUserManagerImpl implements setLockscreenPublicMode(isProfilePublic, userId); mUsersWithSeparateWorkChallenge.put(userId, needsSeparateChallenge); } getEntryManager().updateNotifications("NotificationLockscreenUserManager.updatePublicMode"); mEntryManagerLazy.get() .updateNotifications("NotificationLockscreenUserManager.updatePublicMode"); } @Override Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java +20 −8 File changed.Preview size limit exceeded, changes collapsed. Show changes