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

Commit a7072094 authored by Jeff DeCew's avatar Jeff DeCew Committed by Automerger Merge Worker
Browse files

Make SmartReplyController a Dumpable am: 69c191b6

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16167378

Change-Id: I76b4535c03e86aa314706b515b9ec25a5d3b6e67
parents 3c5b4f39 69c191b6
Loading
Loading
Loading
Loading
+21 −3
Original line number Diff line number Diff line
@@ -19,35 +19,44 @@ import android.app.Notification;
import android.os.RemoteException;
import android.util.ArraySet;

import androidx.annotation.NonNull;

import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.statusbar.NotificationVisibility;
import com.android.systemui.Dumpable;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.statusbar.dagger.StatusBarModule;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.logging.NotificationLogger;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.Set;

/**
 * Handles when smart replies are added to a notification
 * and clicked upon.
 */
public class SmartReplyController {
public class SmartReplyController implements Dumpable {
    private final IStatusBarService mBarService;
    private final NotificationEntryManager mEntryManager;
    private final NotificationClickNotifier mClickNotifier;
    private Set<String> mSendingKeys = new ArraySet<>();
    private final Set<String> mSendingKeys = new ArraySet<>();
    private Callback mCallback;

    /**
     * Injected constructor. See {@link StatusBarModule}.
     */
    public SmartReplyController(NotificationEntryManager entryManager,
    public SmartReplyController(
            DumpManager dumpManager,
            NotificationEntryManager entryManager,
            IStatusBarService statusBarService,
            NotificationClickNotifier clickNotifier) {
        mBarService = statusBarService;
        mEntryManager = entryManager;
        mClickNotifier = clickNotifier;
        dumpManager.registerDumpable(this);
    }

    public void setCallback(Callback callback) {
@@ -75,6 +84,7 @@ public class SmartReplyController {
    public void smartActionClicked(
            NotificationEntry entry, int actionIndex, Notification.Action action,
            boolean generatedByAssistant) {
        // TODO(b/204183781): get this from the current pipeline
        final int count = mEntryManager.getActiveNotificationsCount();
        final int rank = entry.getRanking().getRank();
        NotificationVisibility.NotificationLocation location =
@@ -112,6 +122,14 @@ public class SmartReplyController {
        }
    }

    @Override
    public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) {
        pw.println("mSendingKeys: " + mSendingKeys.size());
        for (String key : mSendingKeys) {
            pw.println(" * " + key);
        }
    }

    /**
     * Callback for any class that needs to do something in response to a smart reply being sent.
     */
+2 −1
Original line number Diff line number Diff line
@@ -166,10 +166,11 @@ public interface StatusBarDependenciesModule {
    @SysUISingleton
    @Provides
    static SmartReplyController provideSmartReplyController(
            DumpManager dumpManager,
            NotificationEntryManager entryManager,
            IStatusBarService statusBarService,
            NotificationClickNotifier clickNotifier) {
        return new SmartReplyController(entryManager, statusBarService, clickNotifier);
        return new SmartReplyController(dumpManager, entryManager, statusBarService, clickNotifier);
    }


+5 −2
Original line number Diff line number Diff line
@@ -86,8 +86,11 @@ public class SmartReplyControllerTest extends SysuiTestCase {
        mDependency.injectTestDependency(NotificationEntryManager.class,
                mNotificationEntryManager);

        mSmartReplyController = new SmartReplyController(mNotificationEntryManager,
                mIStatusBarService, mClickNotifier);
        mSmartReplyController = new SmartReplyController(
                mock(DumpManager.class),
                mNotificationEntryManager,
                mIStatusBarService,
                mClickNotifier);
        mDependency.injectTestDependency(SmartReplyController.class,
                mSmartReplyController);