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

Commit 6b318808 authored by Daniel Sandler's avatar Daniel Sandler Committed by Android (Google) Code Review
Browse files

Remove intruder alert APIs from JB.

Change-Id: I27042d604fbe15879e7b7aaaac860db2d1efa47f
parent 08ce91a1
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -3768,7 +3768,6 @@ package android.app {
    method public android.app.Notification.Builder setDefaults(int);
    method public android.app.Notification.Builder setDeleteIntent(android.app.PendingIntent);
    method public android.app.Notification.Builder setFullScreenIntent(android.app.PendingIntent, boolean);
    method public android.app.Notification.Builder setIntruderActionsShowText(boolean);
    method public android.app.Notification.Builder setLargeIcon(android.graphics.Bitmap);
    method public android.app.Notification.Builder setLights(int, int, int);
    method public android.app.Notification.Builder setNumber(int);
@@ -3784,7 +3783,6 @@ package android.app {
    method public android.app.Notification.Builder setTicker(java.lang.CharSequence);
    method public android.app.Notification.Builder setTicker(java.lang.CharSequence, android.widget.RemoteViews);
    method public android.app.Notification.Builder setUsesChronometer(boolean);
    method public android.app.Notification.Builder setUsesIntruderAlert(boolean);
    method public android.app.Notification.Builder setVibrate(long[]);
    method public android.app.Notification.Builder setWhen(long);
  }
+0 −95
Original line number Diff line number Diff line
@@ -189,12 +189,6 @@ public class Notification implements Parcelable
     */
    public RemoteViews contentView;

    /**
     * The view that will represent this notification in the pop-up "intruder alert" dialog.
     * @hide
     */
    public RemoteViews intruderView;

    /**
     * A large-format version of {@link #contentView}, giving the Notification an
     * opportunity to show more detail. The system UI may choose to show this
@@ -589,9 +583,6 @@ public class Notification implements Parcelable
        }

        actions = parcel.createTypedArray(Action.CREATOR);
        if (parcel.readInt() != 0) {
            intruderView = RemoteViews.CREATOR.createFromParcel(parcel);
        }
        if (parcel.readInt() != 0) {
            bigContentView = RemoteViews.CREATOR.createFromParcel(parcel);
        }
@@ -658,9 +649,6 @@ public class Notification implements Parcelable
        for(int i=0; i<this.actions.length; i++) {
            that.actions[i] = this.actions[i].clone();
        }
        if (this.intruderView != null) {
            that.intruderView = this.intruderView.clone();
        }
        if (this.bigContentView != null) {
            that.bigContentView = this.bigContentView.clone();
        }
@@ -755,13 +743,6 @@ public class Notification implements Parcelable

        parcel.writeTypedArray(actions, 0);

        if (intruderView != null) {
            parcel.writeInt(1);
            intruderView.writeToParcel(parcel, 0);
        } else {
            parcel.writeInt(0);
        }

        if (bigContentView != null) {
            parcel.writeInt(1);
            bigContentView.writeToParcel(parcel, 0);
@@ -942,8 +923,6 @@ public class Notification implements Parcelable
        private Bundle mExtras;
        private int mPriority;
        private ArrayList<Action> mActions = new ArrayList<Action>(3);
        private boolean mCanHasIntruder;
        private boolean mIntruderActionsShowText;
        private boolean mUseChronometer;

        /**
@@ -1349,38 +1328,6 @@ public class Notification implements Parcelable
            return this;
        }

        /**
         * Specify whether this notification should pop up as an
         * "intruder alert" (a small window that shares the screen with the
         * current activity). This sort of notification is (as the name implies)
         * very intrusive, so use it sparingly for notifications that require
         * the user's attention.
         *
         * Notes:
         * <ul>
         * <li>Intruder alerts only show when the screen is on.</li>
         * <li>Intruder alerts take precedence over fullScreenIntents.</li>
         * </ul>
         *
         * @param intrude Whether to pop up an intruder alert (default false).
         */
        public Builder setUsesIntruderAlert(boolean intrude) {
            mCanHasIntruder = intrude;
            return this;
        }

        /**
         * Control text on intruder alert action buttons. By default, action
         * buttons in intruders do not show textual labels.
         * 
         * @param showActionText Whether to show text labels beneath action
         *            icons (default false).
         */
        public Builder setIntruderActionsShowText(boolean showActionText) {
            mIntruderActionsShowText = showActionText;
            return this;
        }

        private void setFlag(int mask, boolean value) {
            if (value) {
                mFlags |= mask;
@@ -1506,45 +1453,6 @@ public class Notification implements Parcelable
            return applyStandardTemplateWithActions(R.layout.notification_template_base);
        }

        private RemoteViews makeIntruderView(boolean showLabels) {
            RemoteViews intruderView = new RemoteViews(mContext.getPackageName(),
                    R.layout.notification_intruder_content);
            if (mLargeIcon != null) {
                intruderView.setImageViewBitmap(R.id.icon, mLargeIcon);
                intruderView.setViewVisibility(R.id.icon, View.VISIBLE);
            } else if (mSmallIcon != 0) {
                intruderView.setImageViewResource(R.id.icon, mSmallIcon);
                intruderView.setViewVisibility(R.id.icon, View.VISIBLE);
            } else {
                intruderView.setViewVisibility(R.id.icon, View.GONE);
            }
            if (mContentTitle != null) {
                intruderView.setTextViewText(R.id.title, mContentTitle);
            }
            if (mContentText != null) {
                intruderView.setTextViewText(R.id.text, mContentText);
            }
            if (mActions.size() > 0) {
                intruderView.setViewVisibility(R.id.actions, View.VISIBLE);
                int N = mActions.size();
                if (N>3) N=3;
                final int[] BUTTONS = { R.id.action0, R.id.action1, R.id.action2 };
                for (int i=0; i<N; i++) {
                    final Action action = mActions.get(i);
                    final int buttonId = BUTTONS[i];

                    intruderView.setViewVisibility(buttonId, View.VISIBLE);
                    intruderView.setTextViewText(buttonId, showLabels ? action.title : null);
                    intruderView.setTextViewCompoundDrawables(buttonId, 0, action.icon, 0, 0);
                    intruderView.setContentDescription(buttonId, action.title);
                    intruderView.setOnClickPendingIntent(buttonId, action.actionIntent);
                }
            } else {
                intruderView.setViewVisibility(R.id.actions, View.GONE);
            }
            return intruderView;
        }

        private RemoteViews generateActionButton(Action action) {
            RemoteViews button = new RemoteViews(mContext.getPackageName(), R.layout.notification_action);
            button.setTextViewCompoundDrawables(R.id.action0, action.icon, 0, 0, 0);
@@ -1579,9 +1487,6 @@ public class Notification implements Parcelable
            n.ledOffMS = mLedOffMs;
            n.defaults = mDefaults;
            n.flags = mFlags;
            if (mCanHasIntruder) {
                n.intruderView = makeIntruderView(mIntruderActionsShowText);
            }
            n.bigContentView = makeBigContentView();
            if (mLedOnMs != 0 && mLedOffMs != 0) {
                n.flags |= FLAG_SHOW_LIGHTS;
+16 −10
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ public class PhoneStatusBar extends BaseStatusBar {
    public static final String ACTION_STATUSBAR_START
            = "com.android.internal.policy.statusbar.START";

    private static final boolean ENABLE_INTRUDERS = true;
    private static final boolean ENABLE_INTRUDERS = false;

    static final int EXPANDED_LEAVE_ALONE = -10000;
    static final int EXPANDED_FULL_OPEN = -10001;
@@ -280,9 +280,11 @@ public class PhoneStatusBar extends BaseStatusBar {
        }
        mNotificationPanel = expanded.findViewById(R.id.notification_panel);

        if (ENABLE_INTRUDERS) {
            mIntruderAlertView = (IntruderAlertView) View.inflate(context, R.layout.intruder_alert, null);
            mIntruderAlertView.setVisibility(View.GONE);
            mIntruderAlertView.setBar(this);
        }

        PhoneStatusBarView sb = (PhoneStatusBarView)View.inflate(context,
                R.layout.status_bar, null);
@@ -520,12 +522,12 @@ public class PhoneStatusBar extends BaseStatusBar {
            }
        } catch (RemoteException ex) {
        }

        /*
         * DISABLED due to missing API
        if (ENABLE_INTRUDERS && (
                   // TODO(dsandler): Only if the screen is on
                notification.notification.intruderView != null)) {
//                   notification.notification.fullScreenIntent != null
//                || (notification.score >= mIntruderInImmersiveMinScore)
//                || (!immersive && (notification.score > mIntruderMinScore)))) {
            Slog.d(TAG, "Presenting high-priority notification");
            // special new transient ticker mode
            // 1. Populate mIntruderAlertView
@@ -554,7 +556,10 @@ public class PhoneStatusBar extends BaseStatusBar {
            if (INTRUDER_ALERT_DECAY_MS > 0) {
                mHandler.sendEmptyMessageDelayed(MSG_HIDE_INTRUDER, INTRUDER_ALERT_DECAY_MS);
            }
        } else if (notification.notification.fullScreenIntent != null) {
        } else 
         */
        
        if (notification.notification.fullScreenIntent != null) {
            // not immersive & a full-screen alert should be shown
            Slog.d(TAG, "Notification has fullScreenIntent; sending fullScreenIntent");
            try {
@@ -675,7 +680,7 @@ public class PhoneStatusBar extends BaseStatusBar {
        updateExpandedViewPos(EXPANDED_LEAVE_ALONE);

        // See if we need to update the intruder.
        if (oldNotification == mCurrentlyIntrudingNotification) {
        if (ENABLE_INTRUDERS && oldNotification == mCurrentlyIntrudingNotification) {
            if (DEBUG) Slog.d(TAG, "updating the current intruder:" + notification);
            // XXX: this is a hack for Alarms. The real implementation will need to *update* 
            // the intruder.
@@ -697,7 +702,7 @@ public class PhoneStatusBar extends BaseStatusBar {
            // Recalculate the position of the sliding windows and the titles.
            updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
            
            if (old == mCurrentlyIntrudingNotification) {
            if (ENABLE_INTRUDERS && old == mCurrentlyIntrudingNotification) {
                mHandler.sendEmptyMessage(MSG_HIDE_INTRUDER);
            }

@@ -2039,6 +2044,7 @@ public class PhoneStatusBar extends BaseStatusBar {
    };

    private void setIntruderAlertVisibility(boolean vis) {
        if (!ENABLE_INTRUDERS) return;
        if (DEBUG) {
            Slog.v(TAG, (vis ? "showing" : "hiding") + " intruder alert window");
        }