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

Commit 6de5ce2b authored by Mady Mellor's avatar Mady Mellor Committed by Android (Google) Code Review
Browse files

Merge "Adds security challenge when changing notification settings from lock screen" into nyc-dev

parents f2a587b4 8e8a69e9
Loading
Loading
Loading
Loading
+33 −13
Original line number Diff line number Diff line
@@ -1047,23 +1047,41 @@ public abstract class BaseStatusBar extends SystemUI implements
        row.findViewById(R.id.done).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // If the user has security enabled, show challenge if the setting is changed.
                if (guts.hasImportanceChanged() && isLockscreenPublicMode() &&
                        (mState == StatusBarState.KEYGUARD
                        || mState == StatusBarState.SHADE_LOCKED)) {
                    OnDismissAction dismissAction = new OnDismissAction() {
                        @Override
                        public boolean onDismiss() {
                            saveImportanceCloseControls(sbn, row, guts, v);
                            return true;
                        }
                    };
                    onLockedNotificationImportanceChange(dismissAction);
                } else {
                    saveImportanceCloseControls(sbn, row, guts, v);
                }
            }
        });
        guts.bindImportance(pmUser, sbn, row, mNotificationData.getImportance(sbn.getKey()));
    }

    private void saveImportanceCloseControls(StatusBarNotification sbn,
            ExpandableNotificationRow row, NotificationGuts guts, View done) {
        guts.saveImportance(sbn);

        int[] rowLocation = new int[2];
        int[] doneLocation = new int[2];
        row.getLocationOnScreen(rowLocation);
                v.getLocationOnScreen(doneLocation);
        done.getLocationOnScreen(doneLocation);

                final int centerX = v.getWidth() / 2;
                final int centerY = v.getHeight() / 2;
        final int centerX = done.getWidth() / 2;
        final int centerY = done.getHeight() / 2;
        final int x = doneLocation[0] - rowLocation[0] + centerX;
        final int y = doneLocation[1] - rowLocation[1] + centerY;
        dismissPopups(x, y);
    }
        });

        guts.bindImportance(pmUser, sbn, row, mNotificationData.getImportance(sbn.getKey()));
    }

    protected SwipeHelper.LongPressListener getNotificationLongClicker() {
        return new SwipeHelper.LongPressListener() {
@@ -1450,6 +1468,8 @@ public abstract class BaseStatusBar extends SystemUI implements
        }
    }

    protected void onLockedNotificationImportanceChange(OnDismissAction dismissAction) {}

    protected void onLockedRemoteInput(ExpandableNotificationRow row, View clickedView) {}

    @Override
+22 −15
Original line number Diff line number Diff line
@@ -130,30 +130,23 @@ public class NotificationGuts extends LinearLayout implements TunerService.Tunab
            importanceSlider.setVisibility(View.VISIBLE);
            importanceButtons.setVisibility(View.GONE);
        } else {
            int userImportance = NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED;
            mStartingImportance = NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED;
            try {
                userImportance =
                mStartingImportance =
                        mINotificationManager.getImportance(sbn.getPackageName(), sbn.getUid());
            } catch (RemoteException e) {}
            bindToggles(importanceButtons, userImportance, systemApp);
            bindToggles(importanceButtons, mStartingImportance, systemApp);
            importanceButtons.setVisibility(View.VISIBLE);
            importanceSlider.setVisibility(View.GONE);
        }
    }

    void saveImportance(final StatusBarNotification sbn) {
        int progress;
        if (mSeekBar!= null && mSeekBar.isShown()) {
            progress = mSeekBar.getProgress();
        } else {
            if (mBlock.isChecked()) {
                progress = NotificationListenerService.Ranking.IMPORTANCE_NONE;
            } else if (mSilent.isChecked()) {
                progress = NotificationListenerService.Ranking.IMPORTANCE_LOW;
            } else {
                progress = NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED;
            }
    public boolean hasImportanceChanged() {
        return mStartingImportance != getSelectedImportance();
    }

    void saveImportance(final StatusBarNotification sbn) {
        int progress = getSelectedImportance();
        MetricsLogger.action(mContext, MetricsEvent.ACTION_SAVE_IMPORTANCE,
                progress - mStartingImportance);
        try {
@@ -163,6 +156,20 @@ public class NotificationGuts extends LinearLayout implements TunerService.Tunab
        }
    }

    private int getSelectedImportance() {
        if (mSeekBar!= null && mSeekBar.isShown()) {
            return mSeekBar.getProgress();
        } else {
            if (mBlock.isChecked()) {
                return NotificationListenerService.Ranking.IMPORTANCE_NONE;
            } else if (mSilent.isChecked()) {
                return NotificationListenerService.Ranking.IMPORTANCE_LOW;
            } else {
                return NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED;
            }
        }
    }

    private void bindToggles(final View importanceButtons, final int importance,
            final boolean systemApp) {
        mBlock = (RadioButton) importanceButtons.findViewById(R.id.block_importance);
+6 −0
Original line number Diff line number Diff line
@@ -4196,6 +4196,12 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        }
    }

    @Override
    public void onLockedNotificationImportanceChange(OnDismissAction dismissAction) {
        mLeaveOpenOnKeyguardHide = true;
        dismissKeyguardThenExecute(dismissAction, true /* afterKeyguardGone */);
    }

    @Override
    protected void onLockedRemoteInput(ExpandableNotificationRow row, View clicked) {
        mLeaveOpenOnKeyguardHide = true;