Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a0f134bd authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "notif-backport" into qt-dev

* changes:
  DO NOT MERGE: Fix interaction tracking logic
  DO NOT MERGE: Associate notif cancels with notif posts
  DO NOT MERGE: Allow interrupting notifications to bypass lifetime extension
  DO NOT MERGE: Create a shim for StatusBarManager click methods
parents 250d08c9 0e2acaf0
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import com.android.systemui.shared.system.DevicePolicyManagerWrapper;
import com.android.systemui.shared.system.PackageManagerWrapper;
import com.android.systemui.statusbar.AmbientPulseManager;
import com.android.systemui.statusbar.NavigationBarController;
import com.android.systemui.statusbar.NotificationClickNotifier;
import com.android.systemui.statusbar.NotificationListener;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationMediaManager;
@@ -302,6 +303,7 @@ public class Dependency extends SystemUI {
    @Inject Lazy<ChannelEditorDialogController> mChannelEditorDialogController;
    @Inject Lazy<INotificationManager> mINotificationManager;
    @Inject Lazy<FalsingManager> mFalsingManager;
    @Inject Lazy<NotificationClickNotifier> mClickNotifier;

    @Inject
    public Dependency() {
@@ -479,6 +481,7 @@ public class Dependency extends SystemUI {
        mProviders.put(ChannelEditorDialogController.class, mChannelEditorDialogController::get);
        mProviders.put(INotificationManager.class, mINotificationManager::get);
        mProviders.put(FalsingManager.class, mFalsingManager::get);
        mProviders.put(NotificationClickNotifier.class, mClickNotifier::get);

        // TODO(b/118592525): to support multi-display , we start to add something which is
        //                    per-display, while others may be global. I think it's time to add
+7 −0
Original line number Diff line number Diff line
@@ -70,6 +70,8 @@ import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.statusbar.policy.ZenModeControllerImpl;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerServiceImpl;
import com.android.systemui.util.time.SystemClock;
import com.android.systemui.util.time.SystemClockImpl;
import com.android.systemui.volume.VolumeDialogControllerImpl;

import dagger.Binds;
@@ -241,4 +243,9 @@ public abstract class DependencyBinder {
     */
    @Binds
    public abstract FalsingManager provideFalsingmanager(FalsingManagerProxy falsingManagerImpl);

    /**
     */
    @Binds
    public abstract SystemClock provideSystemClock(SystemClockImpl systemClock);
}
+22 −4
Original line number Diff line number Diff line
@@ -23,8 +23,12 @@ import android.os.Looper;
import android.util.ArraySet;

import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.statusbar.NotificationInteractionTracker;
import com.android.systemui.statusbar.NotificationLifetimeExtender;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.util.time.SystemClock;

import javax.inject.Inject;

/**
 * Extends the lifetime of foreground notification services such that they show for at least
@@ -39,8 +43,15 @@ public class ForegroundServiceLifetimeExtender implements NotificationLifetimeEx
    private NotificationSafeToRemoveCallback mNotificationSafeToRemoveCallback;
    private ArraySet<NotificationEntry> mManagedEntries = new ArraySet<>();
    private Handler mHandler = new Handler(Looper.getMainLooper());
    private final SystemClock mSystemClock;
    private final NotificationInteractionTracker mInteractionTracker;

    public ForegroundServiceLifetimeExtender() {
    @Inject
    public ForegroundServiceLifetimeExtender(
            NotificationInteractionTracker interactionTracker,
            SystemClock systemClock) {
        mSystemClock = systemClock;
        mInteractionTracker = interactionTracker;
    }

    @Override
@@ -55,8 +66,15 @@ public class ForegroundServiceLifetimeExtender implements NotificationLifetimeEx
            return false;
        }

        long currentTime = System.currentTimeMillis();
        return currentTime - entry.notification.getPostTime() < MIN_FGS_TIME_MS;
        // Entry has triggered a HUN or some other interruption, therefore it has been seen and the
        // interrupter might be retaining it anyway.
        if (entry.hasInterrupted()) {
            return false;
        }

        boolean hasInteracted = mInteractionTracker.hasUserInteractedWith(entry.key);
        long aliveTime = mSystemClock.uptimeMillis() - entry.getCreationTime();
        return aliveTime < MIN_FGS_TIME_MS && !hasInteracted;
    }

    @Override
@@ -84,7 +102,7 @@ public class ForegroundServiceLifetimeExtender implements NotificationLifetimeEx
            }
        };
        long delayAmt = MIN_FGS_TIME_MS
                - (System.currentTimeMillis() - entry.notification.getPostTime());
                - (mSystemClock.uptimeMillis() - entry.getCreationTime());
        mHandler.postDelayed(r, delayAmt);
    }
}
+3 −4
Original line number Diff line number Diff line
@@ -44,7 +44,8 @@ public class ForegroundServiceNotificationListener {
    @Inject
    public ForegroundServiceNotificationListener(Context context,
            ForegroundServiceController foregroundServiceController,
            NotificationEntryManager notificationEntryManager) {
            NotificationEntryManager notificationEntryManager,
            ForegroundServiceLifetimeExtender fgsLifetimeExtender) {
        mContext = context;
        mForegroundServiceController = foregroundServiceController;
        notificationEntryManager.addNotificationEntryListener(new NotificationEntryListener() {
@@ -66,9 +67,7 @@ public class ForegroundServiceNotificationListener {
                removeNotification(entry.notification);
            }
        });

        notificationEntryManager.addNotificationLifetimeExtender(
                new ForegroundServiceLifetimeExtender());
        notificationEntryManager.addNotificationLifetimeExtender(fgsLifetimeExtender);
    }

    /**
+4 −2
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.power.EnhancedEstimates;
import com.android.systemui.power.EnhancedEstimatesImpl;
import com.android.systemui.statusbar.KeyguardIndicationController;
import com.android.systemui.statusbar.NotificationClickNotifier;
import com.android.systemui.statusbar.NotificationListener;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationLockscreenUserManagerImpl;
@@ -167,8 +168,9 @@ public class SystemUIFactory {
    @Singleton
    @Provides
    public NotificationLockscreenUserManager provideNotificationLockscreenUserManager(
            Context context) {
        return new NotificationLockscreenUserManagerImpl(context);
            Context context,
            NotificationClickNotifier clickNotifier) {
        return new NotificationLockscreenUserManagerImpl(context, clickNotifier);
    }

    @Singleton
Loading