diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 8102fae28aaf6..c459da9fb9a3d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -1047,24 +1047,42 @@ public abstract class BaseStatusBar extends SystemUI implements row.findViewById(R.id.done).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - guts.saveImportance(sbn); - - int[] rowLocation = new int[2]; - int[] doneLocation = new int[2]; - row.getLocationOnScreen(rowLocation); - v.getLocationOnScreen(doneLocation); - - final int centerX = v.getWidth() / 2; - final int centerY = v.getHeight() / 2; - final int x = doneLocation[0] - rowLocation[0] + centerX; - final int y = doneLocation[1] - rowLocation[1] + centerY; - dismissPopups(x, y); + // 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); + done.getLocationOnScreen(doneLocation); + + 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); + } + protected SwipeHelper.LongPressListener getNotificationLongClicker() { return new SwipeHelper.LongPressListener() { @Override @@ -1450,6 +1468,8 @@ public abstract class BaseStatusBar extends SystemUI implements } } + protected void onLockedNotificationImportanceChange(OnDismissAction dismissAction) {} + protected void onLockedRemoteInput(ExpandableNotificationRow row, View clickedView) {} @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java index 45a24a0b38224..3e0542f97e480 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java @@ -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); } } + public boolean hasImportanceChanged() { + return mStartingImportance != getSelectedImportance(); + } + 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; - } - } + 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); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 32a6f161cfdf9..bf58592c7ca9b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -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;