diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java index f22acb78f3021..0fd9272c7da78 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java @@ -638,22 +638,6 @@ public final class NotificationEntry extends ListEntry { if (row != null) row.setHeadsUpAnimatingAway(animatingAway); } - /** - * Set that this notification was automatically heads upped. This happens for example when - * the user bypasses the lockscreen and media is playing. - */ - public void setAutoHeadsUp(boolean autoHeadsUp) { - mAutoHeadsUp = autoHeadsUp; - } - - /** - * @return if this notification was automatically heads upped. This happens for example when - * * the user bypasses the lockscreen and media is playing. - */ - public boolean isAutoHeadsUp() { - return mAutoHeadsUp; - } - public boolean mustStayOnScreen() { return row != null && row.mustStayOnScreen(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/HeadsUpCoordinator.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/HeadsUpCoordinator.kt index b84b382330737..0bf21af7026b5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/HeadsUpCoordinator.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/HeadsUpCoordinator.kt @@ -100,7 +100,7 @@ class HeadsUpCoordinator @Inject constructor( if (wasHeadsUp) { if (shouldHeadsUp) { mHeadsUpManager.updateNotification(entry.key, hunAgain) - } else if (!mHeadsUpManager.isEntryAutoHeadsUpped(entry.key)) { + } else { // We don't want this to be interrupting anymore, let's remove it mHeadsUpManager.removeNotification( entry.key, false /* removeImmediately */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/BypassHeadsUpNotifier.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/BypassHeadsUpNotifier.kt deleted file mode 100644 index b61a5408626bb..0000000000000 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/BypassHeadsUpNotifier.kt +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (C) 2019 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -package com.android.systemui.statusbar.notification.interruption - -import android.content.Context -import android.media.MediaMetadata -import android.provider.Settings -import com.android.keyguard.KeyguardUpdateMonitor -import com.android.systemui.dagger.SysUISingleton -import com.android.systemui.plugins.statusbar.StatusBarStateController -import com.android.systemui.statusbar.NotificationLockscreenUserManager -import com.android.systemui.statusbar.NotificationMediaManager -import com.android.systemui.statusbar.StatusBarState -import com.android.systemui.statusbar.notification.collection.NotificationEntry -import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection -import com.android.systemui.statusbar.phone.HeadsUpManagerPhone -import com.android.systemui.statusbar.phone.KeyguardBypassController -import com.android.systemui.tuner.TunerService -import javax.inject.Inject - -/** - * A class that automatically creates heads up for important notification when bypassing the - * lockscreen - */ -@SysUISingleton -class BypassHeadsUpNotifier @Inject constructor( - private val context: Context, - private val bypassController: KeyguardBypassController, - private val statusBarStateController: StatusBarStateController, - private val headsUpManager: HeadsUpManagerPhone, - private val notificationLockscreenUserManager: NotificationLockscreenUserManager, - private val mediaManager: NotificationMediaManager, - private val commonNotifCollection: CommonNotifCollection, - tunerService: TunerService -) : StatusBarStateController.StateListener, NotificationMediaManager.MediaListener { - - private var currentMediaEntry: NotificationEntry? = null - private var enabled = true - - var fullyAwake = false - set(value) { - field = value - if (value) { - updateAutoHeadsUp(currentMediaEntry) - } - } - - init { - statusBarStateController.addCallback(this) - tunerService.addTunable( - TunerService.Tunable { _, _ -> - enabled = Settings.Secure.getIntForUser( - context.contentResolver, - Settings.Secure.SHOW_MEDIA_WHEN_BYPASSING, - 0 /* default */, - KeyguardUpdateMonitor.getCurrentUser()) != 0 - }, Settings.Secure.SHOW_MEDIA_WHEN_BYPASSING) - } - - fun setUp() { - mediaManager.addCallback(this) - } - - override fun onPrimaryMetadataOrStateChanged(metadata: MediaMetadata?, state: Int) { - val previous = currentMediaEntry - val mediaNotificationKey = mediaManager.mediaNotificationKey - currentMediaEntry = - if (mediaNotificationKey != null && NotificationMediaManager.isPlayingState(state)) - commonNotifCollection.getEntry(mediaNotificationKey) - else null - updateAutoHeadsUp(previous) - updateAutoHeadsUp(currentMediaEntry) - } - - private fun updateAutoHeadsUp(entry: NotificationEntry?) { - entry?.let { - val autoHeadsUp = it == currentMediaEntry && canAutoHeadsUp(it) - it.isAutoHeadsUp = autoHeadsUp - if (autoHeadsUp) { - headsUpManager.showNotification(it) - } - } - } - - /** - * @return {@code true} if this entry be autoHeadsUpped right now. - */ - private fun canAutoHeadsUp(entry: NotificationEntry): Boolean { - if (!isAutoHeadsUpAllowed()) { - return false - } - if (entry.isSensitive) { - // filter sensitive notifications - return false - } - if (!notificationLockscreenUserManager.shouldShowOnKeyguard(entry)) { - // filter notifications invisible on Keyguard - return false - } - if (commonNotifCollection.getEntry(entry.key) != null) { - // filter notifications not the active list currently - return false - } - return true - } - - override fun onStatePostChange() { - updateAutoHeadsUp(currentMediaEntry) - } - - /** - * @return {@code true} if autoHeadsUp is possible right now. - */ - private fun isAutoHeadsUpAllowed(): Boolean { - if (!enabled) { - return false - } - if (!bypassController.bypassEnabled) { - return false - } - if (statusBarStateController.state != StatusBarState.KEYGUARD) { - return false - } - if (!fullyAwake) { - return false - } - return true - } -} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/HeadsUpController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/HeadsUpController.java index b1c69e44da126..74fb3f7f9f66a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/HeadsUpController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/HeadsUpController.java @@ -124,7 +124,7 @@ public class HeadsUpController { if (wasHeadsUp) { if (shouldHeadsUp) { mHeadsUpManager.updateNotification(entry.getKey(), hunAgain); - } else if (!mHeadsUpManager.isEntryAutoHeadsUpped(entry.getKey())) { + } else { // We don't want this to be interrupting anymore, let's remove it mHeadsUpManager.removeNotification(entry.getKey(), false /* removeImmediately */); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java index 2824ab85152f8..77cff344558f0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java @@ -60,16 +60,14 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, private final KeyguardBypassController mBypassController; private final GroupMembershipManager mGroupMembershipManager; private final List mHeadsUpPhoneListeners = new ArrayList<>(); - private final int mAutoHeadsUpNotificationDecay; // TODO (b/162832756): remove visual stability manager when migrating to new pipeline private VisualStabilityManager mVisualStabilityManager; private boolean mReleaseOnExpandFinish; private boolean mTrackingHeadsUp; - private HashSet mSwipedOutKeys = new HashSet<>(); - private HashSet mEntriesToRemoveAfterExpand = new HashSet<>(); - private HashSet mKeysToRemoveWhenLeavingKeyguard = new HashSet<>(); - private ArraySet mEntriesToRemoveWhenReorderingAllowed + private final HashSet mSwipedOutKeys = new HashSet<>(); + private final HashSet mEntriesToRemoveAfterExpand = new HashSet<>(); + private final ArraySet mEntriesToRemoveWhenReorderingAllowed = new ArraySet<>(); private boolean mIsExpanded; private boolean mHeadsUpGoingAway; @@ -110,8 +108,6 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, super(context, logger); Resources resources = mContext.getResources(); mExtensionTime = resources.getInteger(R.integer.ambient_notification_extension_time); - mAutoHeadsUpNotificationDecay = resources.getInteger( - R.integer.auto_heads_up_notification_decay); statusBarStateController.addCallback(mStatusBarStateListener); mBypassController = bypassController; mGroupMembershipManager = groupMembershipManager; @@ -234,15 +230,6 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, } } - @Override - public boolean isEntryAutoHeadsUpped(String key) { - HeadsUpEntryPhone headsUpEntryPhone = getHeadsUpEntryPhone(key); - if (headsUpEntryPhone == null) { - return false; - } - return headsUpEntryPhone.isAutoHeadsUp(); - } - /** * Set that we are exiting the headsUp pinned mode, but some notifications might still be * animating out. This is used to keep the touchable regions in a reasonable state. @@ -375,7 +362,6 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, @Override protected void onAlertEntryRemoved(AlertEntry alertEntry) { - mKeysToRemoveWhenLeavingKeyguard.remove(alertEntry.mEntry.getKey()); super.onAlertEntryRemoved(alertEntry); mEntryPool.release((HeadsUpEntryPhone) alertEntry); } @@ -437,11 +423,6 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, */ private boolean extended; - /** - * Was this entry received while on keyguard - */ - private boolean mIsAutoHeadsUp; - @Override public boolean isSticky() { @@ -459,8 +440,6 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, false /* persistent */); } else if (mTrackingHeadsUp) { mEntriesToRemoveAfterExpand.add(entry); - } else if (mIsAutoHeadsUp && mStatusBarState == StatusBarState.KEYGUARD) { - mKeysToRemoveWhenLeavingKeyguard.add(entry.getKey()); } else { removeAlertEntry(entry.getKey()); } @@ -471,7 +450,6 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, @Override public void updateEntry(boolean updatePostTime) { - mIsAutoHeadsUp = mEntry.isAutoHeadsUp(); super.updateEntry(updatePostTime); if (mEntriesToRemoveAfterExpand.contains(mEntry)) { @@ -480,7 +458,6 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, if (mEntriesToRemoveWhenReorderingAllowed.contains(mEntry)) { mEntriesToRemoveWhenReorderingAllowed.remove(mEntry); } - mKeysToRemoveWhenLeavingKeyguard.remove(mEntry.getKey()); } @Override @@ -515,7 +492,6 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, super.reset(); mMenuShownPinned = false; extended = false; - mIsAutoHeadsUp = false; } private void extendPulse() { @@ -525,34 +501,9 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, } } - @Override - public int compareTo(AlertEntry alertEntry) { - HeadsUpEntryPhone headsUpEntry = (HeadsUpEntryPhone) alertEntry; - boolean autoShown = isAutoHeadsUp(); - boolean otherAutoShown = headsUpEntry.isAutoHeadsUp(); - if (autoShown && !otherAutoShown) { - return 1; - } else if (!autoShown && otherAutoShown) { - return -1; - } - return super.compareTo(alertEntry); - } - @Override protected long calculateFinishTime() { - return mPostTime + getDecayDuration() + (extended ? mExtensionTime : 0); - } - - private int getDecayDuration() { - if (isAutoHeadsUp()) { - return getRecommendedHeadsUpTimeoutMs(mAutoHeadsUpNotificationDecay); - } else { - return getRecommendedHeadsUpTimeoutMs(mAutoDismissNotificationDecay); - } - } - - private boolean isAutoHeadsUp() { - return mIsAutoHeadsUp; + return super.calculateFinishTime() + (extended ? mExtensionTime : 0); } } @@ -577,13 +528,6 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, boolean wasKeyguard = mStatusBarState == StatusBarState.KEYGUARD; boolean isKeyguard = newState == StatusBarState.KEYGUARD; mStatusBarState = newState; - if (wasKeyguard && !isKeyguard && mKeysToRemoveWhenLeavingKeyguard.size() != 0) { - String[] keys = mKeysToRemoveWhenLeavingKeyguard.toArray(new String[0]); - for (String key : keys) { - removeAlertEntry(key); - } - mKeysToRemoveWhenLeavingKeyguard.clear(); - } if (wasKeyguard && !isKeyguard && mBypassController.getBypassEnabled()) { ArrayList keysToRemove = new ArrayList<>(); for (AlertEntry entry : mAlertEntries.values()) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index ae4a19e2b2127..455ffdc873402 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -211,7 +211,6 @@ import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator import com.android.systemui.statusbar.notification.collection.legacy.VisualStabilityManager; import com.android.systemui.statusbar.notification.collection.render.NotifShadeEventSource; import com.android.systemui.statusbar.notification.init.NotificationsController; -import com.android.systemui.statusbar.notification.interruption.BypassHeadsUpNotifier; import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProvider; import com.android.systemui.statusbar.notification.logging.NotificationLogger; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; @@ -482,7 +481,6 @@ public class StatusBar extends CoreStartable implements private final HeadsUpManagerPhone mHeadsUpManager; private final StatusBarTouchableRegionManager mStatusBarTouchableRegionManager; private final DynamicPrivacyController mDynamicPrivacyController; - private final BypassHeadsUpNotifier mBypassHeadsUpNotifier; private final FalsingCollector mFalsingCollector; private final FalsingManager mFalsingManager; private final BroadcastDispatcher mBroadcastDispatcher; @@ -703,7 +701,6 @@ public class StatusBar extends CoreStartable implements KeyguardStateController keyguardStateController, HeadsUpManagerPhone headsUpManagerPhone, DynamicPrivacyController dynamicPrivacyController, - BypassHeadsUpNotifier bypassHeadsUpNotifier, FalsingManager falsingManager, FalsingCollector falsingCollector, BroadcastDispatcher broadcastDispatcher, @@ -800,7 +797,6 @@ public class StatusBar extends CoreStartable implements mKeyguardIndicationController = keyguardIndicationController; mStatusBarTouchableRegionManager = statusBarTouchableRegionManager; mDynamicPrivacyController = dynamicPrivacyController; - mBypassHeadsUpNotifier = bypassHeadsUpNotifier; mFalsingCollector = falsingCollector; mFalsingManager = falsingManager; mBroadcastDispatcher = broadcastDispatcher; @@ -917,7 +913,6 @@ public class StatusBar extends CoreStartable implements mScreenLifecycle.addObserver(mScreenObserver); mWakefulnessLifecycle.addObserver(mWakefulnessObserver); mUiModeManager = mContext.getSystemService(UiModeManager.class); - mBypassHeadsUpNotifier.setUp(); if (mBubblesOptional.isPresent()) { mBubblesOptional.get().setExpandListener(mBubbleExpandListener); } @@ -3581,7 +3576,6 @@ public class StatusBar extends CoreStartable implements maybeEscalateHeadsUp(); dismissVolumeDialog(); mWakeUpCoordinator.setFullyAwake(false); - mBypassHeadsUpNotifier.setFullyAwake(false); mKeyguardBypassController.onStartedGoingToSleep(); // The unlocked screen off and fold to aod animations might use our LightRevealScrim - @@ -3623,7 +3617,6 @@ public class StatusBar extends CoreStartable implements @Override public void onFinishedWakingUp() { mWakeUpCoordinator.setFullyAwake(true); - mBypassHeadsUpNotifier.setFullyAwake(true); mWakeUpCoordinator.setWakingUp(false); if (mLaunchCameraWhenFinishedWaking) { mNotificationPanelViewController.launchCamera( diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java index 977fe9c2d2012..f5364b9363b9b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java @@ -71,7 +71,6 @@ import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator import com.android.systemui.statusbar.notification.collection.legacy.VisualStabilityManager; import com.android.systemui.statusbar.notification.collection.render.NotifShadeEventSource; import com.android.systemui.statusbar.notification.init.NotificationsController; -import com.android.systemui.statusbar.notification.interruption.BypassHeadsUpNotifier; import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProvider; import com.android.systemui.statusbar.notification.logging.NotificationLogger; import com.android.systemui.statusbar.notification.row.NotificationGutsManager; @@ -152,7 +151,6 @@ public interface StatusBarPhoneModule { KeyguardStateController keyguardStateController, HeadsUpManagerPhone headsUpManagerPhone, DynamicPrivacyController dynamicPrivacyController, - BypassHeadsUpNotifier bypassHeadsUpNotifier, FalsingManager falsingManager, FalsingCollector falsingCollector, BroadcastDispatcher broadcastDispatcher, @@ -250,7 +248,6 @@ public interface StatusBarPhoneModule { keyguardStateController, headsUpManagerPhone, dynamicPrivacyController, - bypassHeadsUpNotifier, falsingManager, falsingCollector, broadcastDispatcher, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java index 9587261e75bf2..c83bfce21aa1e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java @@ -378,10 +378,6 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { public void onDensityOrFontScaleChanged() { } - public boolean isEntryAutoHeadsUpped(String key) { - return false; - } - /** * Determines if the notification is for a critical call that must display on top of an active * input notification. diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java index 77065b2d4380d..f4f5bfa4daa6d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java @@ -129,7 +129,6 @@ import com.android.systemui.statusbar.notification.collection.legacy.VisualStabi import com.android.systemui.statusbar.notification.collection.render.NotifShadeEventSource; import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider; import com.android.systemui.statusbar.notification.init.NotificationsController; -import com.android.systemui.statusbar.notification.interruption.BypassHeadsUpNotifier; import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProviderImpl; import com.android.systemui.statusbar.notification.logging.NotificationLogger; import com.android.systemui.statusbar.notification.logging.NotificationPanelLoggerFake; @@ -226,7 +225,6 @@ public class StatusBarTest extends SysuiTestCase { @Mock private NotificationMediaManager mNotificationMediaManager; @Mock private NavigationBarController mNavigationBarController; @Mock private AccessibilityFloatingMenuController mAccessibilityFloatingMenuController; - @Mock private BypassHeadsUpNotifier mBypassHeadsUpNotifier; @Mock private SysuiColorExtractor mColorExtractor; @Mock private ColorExtractor.GradientColors mGradientColors; @Mock private PulseExpansionHandler mPulseExpansionHandler; @@ -394,7 +392,6 @@ public class StatusBarTest extends SysuiTestCase { mKeyguardStateController, mHeadsUpManager, mDynamicPrivacyController, - mBypassHeadsUpNotifier, new FalsingManagerFake(), new FalsingCollectorFake(), mBroadcastDispatcher,