Remove bubble permission view

Bug: 131630936
Test: manual
Change-Id: I4023b3a32770fe42d67dd907d6c7a570d41583ee
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
index 67f3274..39867c3 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
@@ -22,8 +22,6 @@
 import static android.util.StatsLogInternal.BUBBLE_DEVELOPER_ERROR_REPORTED__ERROR__DOCUMENT_LAUNCH_NOT_ALWAYS;
 import static android.view.Display.INVALID_DISPLAY;
 
-import android.animation.LayoutTransition;
-import android.animation.ObjectAnimator;
 import android.annotation.Nullable;
 import android.app.ActivityOptions;
 import android.app.ActivityView;
@@ -41,9 +39,7 @@
 import android.graphics.Insets;
 import android.graphics.Point;
 import android.graphics.drawable.Drawable;
-import android.graphics.drawable.GradientDrawable;
 import android.graphics.drawable.ShapeDrawable;
-import android.os.RemoteException;
 import android.os.ServiceManager;
 import android.os.UserHandle;
 import android.provider.Settings;
@@ -54,13 +50,9 @@
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.WindowInsets;
-import android.widget.FrameLayout;
-import android.widget.ImageView;
 import android.widget.LinearLayout;
-import android.widget.TextView;
 
 import com.android.systemui.Dependency;
-import com.android.systemui.Interpolators;
 import com.android.systemui.R;
 import com.android.systemui.recents.TriangleShape;
 import com.android.systemui.statusbar.AlphaOptimizedButton;
@@ -80,10 +72,6 @@
 
     private AlphaOptimizedButton mSettingsIcon;
 
-    // Permission view
-    private View mPermissionView;
-    private TextView mPermissionPrompt;
-
     // Views for expanded state
     private ExpandableNotificationRow mNotifRow;
     private ActivityView mActivityView;
@@ -97,7 +85,6 @@
     private int mMinHeight;
     private int mSettingsIconHeight;
     private int mBubbleHeight;
-    private int mPermissionHeight;
     private int mPointerWidth;
     private int mPointerHeight;
 
@@ -194,36 +181,11 @@
         triangleDrawable.setTint(bgColor);
         mPointerView.setBackground(triangleDrawable);
 
-        FrameLayout permissionOrSettings = findViewById(R.id.permission_or_settings);
-
-        LayoutTransition transition = new LayoutTransition();
-        transition.setDuration(200);
-
-        ObjectAnimator appearAnimator = ObjectAnimator.ofFloat(null, View.ALPHA, 0f, 1f);
-        transition.setAnimator(LayoutTransition.APPEARING, appearAnimator);
-        transition.setInterpolator(LayoutTransition.APPEARING, Interpolators.ALPHA_IN);
-
-        ObjectAnimator disappearAnimator = ObjectAnimator.ofFloat(null, View.ALPHA, 1f, 0f);
-        transition.setAnimator(LayoutTransition.DISAPPEARING, disappearAnimator);
-        transition.setInterpolator(LayoutTransition.DISAPPEARING, Interpolators.ALPHA_OUT);
-
-        transition.setAnimateParentHierarchy(false);
-        permissionOrSettings.setLayoutTransition(transition);
-        permissionOrSettings.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
-
         mSettingsIconHeight = getContext().getResources().getDimensionPixelSize(
                 R.dimen.bubble_expanded_header_height);
         mSettingsIcon = findViewById(R.id.settings_button);
         mSettingsIcon.setOnClickListener(this);
 
-        mPermissionHeight = getContext().getResources().getDimensionPixelSize(
-                R.dimen.bubble_permission_height);
-        mPermissionView = findViewById(R.id.permission_layout);
-        mPermissionPrompt = mPermissionView.findViewById(R.id.prompt);
-
-        findViewById(R.id.no_bubbles_button).setOnClickListener(this);
-        findViewById(R.id.yes_bubbles_button).setOnClickListener(this);
-
         mActivityView = new ActivityView(mContext, null /* attrs */, 0 /* defStyle */,
                 true /* singleTaskInstance */);
         addView(mActivityView);
@@ -273,23 +235,6 @@
     }
 
     /**
-     * Creates a background with corners rounded based on how the view is configured to display
-     */
-    private Drawable createPermissionBackground(int bgColor) {
-        TypedArray ta2 = getContext().obtainStyledAttributes(
-                new int[] {android.R.attr.dialogCornerRadius});
-        final float cr = ta2.getDimension(0, 0f);
-        ta2.recycle();
-
-        float[] radii = new float[] {cr, cr, cr, cr, 0, 0, 0, 0};
-        GradientDrawable chromeBackground = new GradientDrawable();
-        chromeBackground.setShape(GradientDrawable.RECTANGLE);
-        chromeBackground.setCornerRadii(radii);
-        chromeBackground.setColor(bgColor);
-        return chromeBackground;
-    }
-
-    /**
      * Sets the listener to notify when a bubble has been blocked.
      */
     public void setOnBlockedListener(OnBubbleBlockedListener listener) {
@@ -323,7 +268,7 @@
             mAppIcon = mPm.getDefaultActivityIcon();
         }
         updateTheme();
-        togglePermissionOrSettings();
+        showSettingsIcon();
         updateExpandedView();
     }
 
@@ -370,10 +315,6 @@
         int foregroundColor = ta.getColor(1, Color.BLACK /* default */);
         ta.recycle();
 
-        // Update permission prompt color.
-        mPermissionView.setBackground(createPermissionBackground(backgroundColor));
-        mPermissionPrompt.setTextColor(foregroundColor);
-
         // Update triangle color.
         ShapeDrawable triangleDrawable = new ShapeDrawable(
                 TriangleShape.create(mPointerWidth, mPointerHeight, false /* pointUp */));
@@ -381,22 +322,6 @@
         mPointerView.setBackground(triangleDrawable);
     }
 
-    void togglePermissionOrSettings() {
-        boolean hasUserApprovedBubblesForPackage = false;
-        try {
-            hasUserApprovedBubblesForPackage =
-                    mNotificationManagerService.hasUserApprovedBubblesForPackage(
-                            mEntry.notification.getPackageName(), mEntry.notification.getUid());
-        } catch (RemoteException e) {
-            Log.w(TAG, e);
-        }
-        if (hasUserApprovedBubblesForPackage) {
-            showSettingsIcon();
-        } else {
-            showPermissionView();
-        }
-    }
-
     private void updateExpandedView() {
         mBubbleIntent = getBubbleIntent(mEntry);
         if (mBubbleIntent != null) {
@@ -427,11 +352,8 @@
      * @return total height that the expanded view occupies.
      */
     int getExpandedSize() {
-        int chromeHeight = mPermissionView.getVisibility() != View.VISIBLE
-                ? mSettingsIconHeight
-                : mPermissionHeight;
         return mBubbleHeight + mPointerView.getHeight() + mPointerMargin
-                + chromeHeight;
+                + mSettingsIconHeight;
     }
 
     void updateHeight() {
@@ -455,11 +377,8 @@
                 }
                 desiredHeight = desiredPx > 0 ? desiredPx : mMinHeight;
             }
-            int chromeHeight = mPermissionView.getVisibility() != View.VISIBLE
-                    ? mSettingsIconHeight
-                    : mPermissionHeight;
-            int max = mStackView.getMaxExpandedHeight() - chromeHeight - mPointerView.getHeight()
-                    - mPointerMargin;
+            int max = mStackView.getMaxExpandedHeight() - mSettingsIconHeight
+                    - mPointerView.getHeight() - mPointerMargin;
             float height = Math.min(desiredHeight, max);
             height = Math.max(height, mMinHeight);
             LayoutParams lp = (LayoutParams) mActivityView.getLayoutParams();
@@ -492,30 +411,6 @@
                 logBubbleClickEvent(mEntry,
                         StatsLog.BUBBLE_UICHANGED__ACTION__HEADER_GO_TO_SETTINGS);
             });
-        } else if (id == R.id.no_bubbles_button) {
-            setBubblesAllowed(false);
-        } else if (id == R.id.yes_bubbles_button) {
-            setBubblesAllowed(true);
-        }
-    }
-
-    private void setBubblesAllowed(boolean allowed) {
-        try {
-            mNotificationManagerService.setBubblesAllowed(
-                    mEntry.notification.getPackageName(),
-                    mEntry.notification.getUid(),
-                    allowed);
-            if (allowed) {
-                showSettingsIcon();
-            } else if (mOnBubbleBlockedListener != null) {
-                mOnBubbleBlockedListener.onBubbleBlocked(mEntry);
-            }
-            mStackView.onExpandedHeightChanged();
-            logBubbleClickEvent(mEntry,
-                    allowed ? StatsLog.BUBBLE_UICHANGED__ACTION__PERMISSION_OPT_IN :
-                            StatsLog.BUBBLE_UICHANGED__ACTION__PERMISSION_OPT_OUT);
-        } catch (RemoteException e) {
-            Log.w(TAG, e);
         }
     }
 
@@ -526,23 +421,9 @@
 
     void showSettingsIcon() {
         updateSettingsContentDescription();
-
-        mPermissionView.setVisibility(GONE);
         mSettingsIcon.setVisibility(VISIBLE);
     }
 
-    void showPermissionView() {
-        ((ImageView) mPermissionView.findViewById(R.id.pkgicon)).setImageDrawable(mAppIcon);
-        ((TextView) mPermissionView.findViewById(R.id.pkgname)).setText(mAppName);
-        mPermissionPrompt.setText(
-                getResources().getString(R.string.bubbles_prompt, mAppName));
-        logBubbleClickEvent(mEntry,
-                StatsLog.BUBBLE_UICHANGED__ACTION__PERMISSION_DIALOG_SHOWN);
-
-        mSettingsIcon.setVisibility(GONE);
-        mPermissionView.setVisibility(VISIBLE);
-    }
-
     /**
      * Update appearance of the expanded view being displayed.
      */