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

Commit 6a9124a0 authored by Steve Elliott's avatar Steve Elliott
Browse files

Add sensitive content redaction to notif pipeline

This incorporates two behaviors originally handled by the
NotificationViewHierarchyManager:

1. A change in DynamicPrivacy would trigger
   NotificationViewHierarchyManager#updateNotificationViews

2. The aformentioned #updateNotificationViews method was responsible
   for setting the redaction state on each NotificationEntry

A new Coordinator is introduced to the NotifPipeline to handle both of
these behaviors. (1) is handled by attaching a new Invalidator that
will request a notif list rebuild when dynamic privacy changes. (2) is
handled by processing each ListEntry in an OnPreRenderListListener,
and setting the redaction state on each NotificationEntry.

Test: manual - turn on setting to hide sensitive notification content
               on the lockscreen, lock phone, turn screen back on,
               observe notifications on lock screen
Fixes: 200025730
Change-Id: I57b4d68f440ea50f13f6da4676144400f875ea8c
parent e093dca3
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.systemui.flags;

import android.content.Context;
import android.util.FeatureFlagUtils;
import android.util.Log;
import android.widget.Toast;

import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.R;
@@ -86,6 +88,22 @@ public class FeatureFlags {
        }
    }

    public void assertLegacyPipelineEnabled() {
        if (isNewNotifPipelineRenderingEnabled()) {
            throw new IllegalStateException("Old pipeline code running w/ new pipeline enabled");
        }
    }

    public boolean checkLegacyPipelineEnabled() {
        if (!isNewNotifPipelineRenderingEnabled()) {
            return true;
        }
        Log.d("NotifPipeline", "Old pipeline code running w/ new pipeline enabled",
                new Exception());
        Toast.makeText(mContext, "Old pipeline code running!", Toast.LENGTH_SHORT).show();
        return false;
    }

    public boolean isNewNotifPipelineEnabled() {
        return isEnabled(Flags.NEW_NOTIFICATION_PIPELINE);
    }
+15 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.view.ViewGroup;

import com.android.systemui.R;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.dagger.StatusBarModule;
import com.android.systemui.statusbar.notification.AssistantFeedbackController;
@@ -72,6 +73,7 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle

    // Dependencies:
    private final DynamicChildBindController mDynamicChildBindController;
    private final FeatureFlags mFeatureFlags;
    protected final NotificationLockscreenUserManager mLockscreenUserManager;
    protected final NotificationGroupManagerLegacy mGroupManager;
    protected final VisualStabilityManager mVisualStabilityManager;
@@ -107,6 +109,7 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle
    public NotificationViewHierarchyManager(
            Context context,
            @Main Handler mainHandler,
            FeatureFlags featureFlags,
            NotificationLockscreenUserManager notificationLockscreenUserManager,
            NotificationGroupManagerLegacy groupManager,
            VisualStabilityManager visualStabilityManager,
@@ -121,6 +124,7 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle
            AssistantFeedbackController assistantFeedbackController) {
        mContext = context;
        mHandler = mainHandler;
        mFeatureFlags = featureFlags;
        mLockscreenUserManager = notificationLockscreenUserManager;
        mBypassController = bypassController;
        mGroupManager = groupManager;
@@ -151,6 +155,10 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle
    //TODO: Rewrite this to focus on Entries, or some other data object instead of views
    public void updateNotificationViews() {
        Assert.isMainThread();
        if (!mFeatureFlags.checkLegacyPipelineEnabled()) {
            return;
        }

        beginUpdate();

        List<NotificationEntry> activeNotifications = mEntryManager.getVisibleNotifications();
@@ -425,6 +433,10 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle
     */
    public void updateRowStates() {
        Assert.isMainThread();
        if (!mFeatureFlags.checkLegacyPipelineEnabled()) {
            return;
        }

        beginUpdate();
        updateRowStatesInternal();
        endUpdate();
@@ -510,6 +522,9 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle

    @Override
    public void onDynamicPrivacyChanged() {
        if (!mFeatureFlags.checkLegacyPipelineEnabled()) {
            return;
        }
        if (mPerformingUpdate) {
            Log.w(TAG, "onDynamicPrivacyChanged made a re-entrant call");
        }
+2 −0
Original line number Diff line number Diff line
@@ -184,6 +184,7 @@ public interface StatusBarDependenciesModule {
    static NotificationViewHierarchyManager provideNotificationViewHierarchyManager(
            Context context,
            @Main Handler mainHandler,
            FeatureFlags featureFlags,
            NotificationLockscreenUserManager notificationLockscreenUserManager,
            NotificationGroupManagerLegacy groupManager,
            VisualStabilityManager visualStabilityManager,
@@ -199,6 +200,7 @@ public interface StatusBarDependenciesModule {
        return new NotificationViewHierarchyManager(
                context,
                mainHandler,
                featureFlags,
                notificationLockscreenUserManager,
                groupManager,
                visualStabilityManager,
+6 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import com.android.systemui.statusbar.notification.collection.listbuilder.OnBefo
import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeRenderListListener;
import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeSortListener;
import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeTransformGroupsListener;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.Invalidator;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifComparator;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifPromoter;
@@ -216,6 +217,11 @@ public class NotifPipeline implements CommonNotifCollection {
        mShadeListBuilder.addOnBeforeRenderListListener(listener);
    }

    /** Registers an invalidator that can be used to invalidate the entire notif list. */
    public void addPreRenderInvalidator(Invalidator invalidator) {
        mShadeListBuilder.addPreRenderInvalidator(invalidator);
    }

    /**
     * Returns a read-only view in to the current shade list, i.e. the list of notifications that
     * are currently present in the shade. If this method is called during pipeline execution it
+16 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import com.android.systemui.statusbar.notification.collection.listbuilder.OnBefo
import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeTransformGroupsListener;
import com.android.systemui.statusbar.notification.collection.listbuilder.PipelineState;
import com.android.systemui.statusbar.notification.collection.listbuilder.ShadeListBuilderLogger;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.Invalidator;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifComparator;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifPromoter;
@@ -174,6 +175,13 @@ public class ShadeListBuilder implements Dumpable {
        mOnBeforeRenderListListeners.add(listener);
    }

    void addPreRenderInvalidator(Invalidator invalidator) {
        Assert.isMainThread();

        mPipelineState.requireState(STATE_IDLE);
        invalidator.setInvalidationListener(this::onPreRenderInvalidated);
    }

    void addPreGroupFilter(NotifFilter filter) {
        Assert.isMainThread();
        mPipelineState.requireState(STATE_IDLE);
@@ -256,6 +264,14 @@ public class ShadeListBuilder implements Dumpable {
                }
            };

    private void onPreRenderInvalidated(Invalidator invalidator) {
        Assert.isMainThread();

        mLogger.logPreRenderInvalidated(invalidator.getName(), mPipelineState.getState());

        rebuildListIfBefore(STATE_FINALIZING);
    }

    private void onPreGroupFilterInvalidated(NotifFilter filter) {
        Assert.isMainThread();

Loading