Fixed a bug where the notification became clearable

A notification could become clearable on the lockscreen
when the content was sensitive even though that shouldn't
have happend.
This is now fixed.

Change-Id: I50f31c95dd399bfebfa9e5c46eb99820f31e37ff
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 240d32e..0171128 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -18,7 +18,6 @@
 
 import android.animation.Animator;
 import android.animation.AnimatorListenerAdapter;
-import android.animation.TimeInterpolator;
 import android.app.ActivityManager;
 import android.app.ActivityManagerNative;
 import android.app.Notification;
@@ -76,7 +75,6 @@
 import android.view.WindowManager;
 import android.view.WindowManagerGlobal;
 import android.view.accessibility.AccessibilityManager;
-import android.view.animation.AnimationUtils;
 import android.widget.ImageView;
 import android.widget.RemoteViews;
 import android.widget.TextView;
@@ -86,7 +84,6 @@
 import com.android.internal.logging.MetricsProto.MetricsEvent;
 import com.android.internal.statusbar.IStatusBarService;
 import com.android.internal.statusbar.StatusBarIcon;
-import com.android.internal.util.NotificationColorUtil;
 import com.android.internal.widget.LockPatternUtils;
 import com.android.keyguard.KeyguardUpdateMonitor;
 import com.android.systemui.DejankUtils;
@@ -828,30 +825,25 @@
         }
     }
 
-    protected View updateNotificationVetoButton(View row, StatusBarNotification n) {
+    protected View bindVetoButtonClickListener(View row, StatusBarNotification n) {
         View vetoButton = row.findViewById(R.id.veto);
-        if (n.isClearable()) {
-            final String _pkg = n.getPackageName();
-            final String _tag = n.getTag();
-            final int _id = n.getId();
-            final int _userId = n.getUserId();
-            vetoButton.setOnClickListener(new View.OnClickListener() {
-                    public void onClick(View v) {
-                        // Accessibility feedback
-                        v.announceForAccessibility(
-                                mContext.getString(R.string.accessibility_notification_dismissed));
-                        try {
-                            mBarService.onNotificationClear(_pkg, _tag, _id, _userId);
+        final String _pkg = n.getPackageName();
+        final String _tag = n.getTag();
+        final int _id = n.getId();
+        final int _userId = n.getUserId();
+        vetoButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View v) {
+                // Accessibility feedback
+                v.announceForAccessibility(
+                        mContext.getString(R.string.accessibility_notification_dismissed));
+                try {
+                    mBarService.onNotificationClear(_pkg, _tag, _id, _userId);
 
-                        } catch (RemoteException ex) {
-                            // system process is dead if we're here.
-                        }
-                    }
-                });
-            vetoButton.setVisibility(View.VISIBLE);
-        } else {
-            vetoButton.setVisibility(View.GONE);
-        }
+                } catch (RemoteException ex) {
+                    // system process is dead if we're here.
+                }
+            }
+        });
         vetoButton.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
         return vetoButton;
     }
@@ -1370,7 +1362,7 @@
         }
 
         workAroundBadLayerDrawableOpacity(row);
-        View vetoButton = updateNotificationVetoButton(row, sbn);
+        View vetoButton = bindVetoButtonClickListener(row, sbn);
         vetoButton.setContentDescription(mContext.getString(
                 R.string.accessibility_remove_notification));
 
@@ -2010,7 +2002,7 @@
 
         // Update the veto button accordingly (and as a result, whether this row is
         // swipe-dismissable)
-        updateNotificationVetoButton(entry.row, notification);
+        bindVetoButtonClickListener(entry.row, notification);
 
         if (DEBUG) {
             // Is this for you?
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index 6fae3ab..7f1316f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -28,7 +28,6 @@
 import android.view.MotionEvent;
 import android.view.NotificationHeaderView;
 import android.view.View;
-import android.view.ViewGroup;
 import android.view.ViewStub;
 import android.view.accessibility.AccessibilityEvent;
 import android.widget.Chronometer;
@@ -212,7 +211,8 @@
         mStatusBarNotification = entry.notification;
         mPrivateLayout.onNotificationUpdated(entry);
         mPublicLayout.onNotificationUpdated(entry);
-        updateVetoButton();
+        mShowingPublicInitialized = false;
+        updateClearability();
         if (mIsSummaryWithChildren) {
             recreateNotificationHeader();
         }
@@ -911,7 +911,7 @@
         }
 
         mPrivateLayout.updateExpandButtons(isExpandable());
-        updateVetoButton();
+        updateClearability();
         mShowingPublicInitialized = true;
     }
 
@@ -947,7 +947,7 @@
         }
     }
 
-    private void updateVetoButton() {
+    private void updateClearability() {
         // public versions cannot be dismissed
         mVetoButton.setVisibility(isClearable() && !mShowingPublic ? View.VISIBLE : View.GONE);
     }