Close channel dialog when the guts go away

Also don't open the NotificationInfo panel from the keyguard without
authenticating first.

Test: long press on notification from lockscreen
Test: lock the device while the channel editor dialog is open
Bug: 133182818
Change-Id: I6686b77cf54ed5c1b82596217263a53d9664fc64
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInfo.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInfo.java
index 7c6c556..148d83b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInfo.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInfo.java
@@ -118,6 +118,7 @@
     private int mStartingChannelImportance;
     private boolean mWasShownHighPriority;
     private boolean mPressedApply;
+    private boolean mPresentingChannelEditorDialog = false;
 
     /**
      * The last importance level chosen by the user.  Null if the user has not chosen an importance
@@ -447,11 +448,15 @@
 
     private OnClickListener getTurnOffNotificationsClickListener() {
         return ((View view) -> {
-            if (mChannelEditorDialogController != null) {
+            if (!mPresentingChannelEditorDialog && mChannelEditorDialogController != null) {
+                mPresentingChannelEditorDialog = true;
+
                 mChannelEditorDialogController.prepareDialogForApp(mAppName, mPackageName, mAppUid,
                         mUniqueChannelsInRow, mPkgIcon, mOnSettingsClickListener);
-                mChannelEditorDialogController.setOnFinishListener(
-                        () -> closeControls(this, false));
+                mChannelEditorDialogController.setOnFinishListener(() -> {
+                    mPresentingChannelEditorDialog = false;
+                    closeControls(this, false);
+                });
                 mChannelEditorDialogController.show();
             }
         });
@@ -772,6 +777,13 @@
 
     @Override
     public boolean handleCloseControls(boolean save, boolean force) {
+        if (mPresentingChannelEditorDialog && mChannelEditorDialogController != null) {
+            mPresentingChannelEditorDialog = false;
+            // No need for the finish listener because we're closing
+            mChannelEditorDialogController.setOnFinishListener(null);
+            mChannelEditorDialogController.close();
+        }
+
         // Save regardless of the importance so we can lock the importance field if the user wants
         // to keep getting notifications
         if (save) {