Make SmartReplyController a Dumpable

Test: dump and inspect
Change-Id: Id3e58ae6559ef1762496f46ff86ccd99886c8aaf
This commit is contained in:
Jeff DeCew
2021-10-26 15:14:17 +00:00
parent b5b6586774
commit bc70d7ba1f
3 changed files with 28 additions and 6 deletions

View File

@@ -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.
*/

View File

@@ -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);
}

View File

@@ -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);