Merge "Adds security challenge when changing notification settings from lock screen" into nyc-dev
This commit is contained in:
@@ -1047,24 +1047,42 @@ public abstract class BaseStatusBar extends SystemUI implements
|
|||||||
row.findViewById(R.id.done).setOnClickListener(new View.OnClickListener() {
|
row.findViewById(R.id.done).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
guts.saveImportance(sbn);
|
// If the user has security enabled, show challenge if the setting is changed.
|
||||||
|
if (guts.hasImportanceChanged() && isLockscreenPublicMode() &&
|
||||||
int[] rowLocation = new int[2];
|
(mState == StatusBarState.KEYGUARD
|
||||||
int[] doneLocation = new int[2];
|
|| mState == StatusBarState.SHADE_LOCKED)) {
|
||||||
row.getLocationOnScreen(rowLocation);
|
OnDismissAction dismissAction = new OnDismissAction() {
|
||||||
v.getLocationOnScreen(doneLocation);
|
@Override
|
||||||
|
public boolean onDismiss() {
|
||||||
final int centerX = v.getWidth() / 2;
|
saveImportanceCloseControls(sbn, row, guts, v);
|
||||||
final int centerY = v.getHeight() / 2;
|
return true;
|
||||||
final int x = doneLocation[0] - rowLocation[0] + centerX;
|
}
|
||||||
final int y = doneLocation[1] - rowLocation[1] + centerY;
|
};
|
||||||
dismissPopups(x, y);
|
onLockedNotificationImportanceChange(dismissAction);
|
||||||
|
} else {
|
||||||
|
saveImportanceCloseControls(sbn, row, guts, v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
guts.bindImportance(pmUser, sbn, row, mNotificationData.getImportance(sbn.getKey()));
|
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() {
|
protected SwipeHelper.LongPressListener getNotificationLongClicker() {
|
||||||
return new SwipeHelper.LongPressListener() {
|
return new SwipeHelper.LongPressListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -1450,6 +1468,8 @@ public abstract class BaseStatusBar extends SystemUI implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void onLockedNotificationImportanceChange(OnDismissAction dismissAction) {}
|
||||||
|
|
||||||
protected void onLockedRemoteInput(ExpandableNotificationRow row, View clickedView) {}
|
protected void onLockedRemoteInput(ExpandableNotificationRow row, View clickedView) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -130,30 +130,23 @@ public class NotificationGuts extends LinearLayout implements TunerService.Tunab
|
|||||||
importanceSlider.setVisibility(View.VISIBLE);
|
importanceSlider.setVisibility(View.VISIBLE);
|
||||||
importanceButtons.setVisibility(View.GONE);
|
importanceButtons.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
int userImportance = NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED;
|
mStartingImportance = NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED;
|
||||||
try {
|
try {
|
||||||
userImportance =
|
mStartingImportance =
|
||||||
mINotificationManager.getImportance(sbn.getPackageName(), sbn.getUid());
|
mINotificationManager.getImportance(sbn.getPackageName(), sbn.getUid());
|
||||||
} catch (RemoteException e) {}
|
} catch (RemoteException e) {}
|
||||||
bindToggles(importanceButtons, userImportance, systemApp);
|
bindToggles(importanceButtons, mStartingImportance, systemApp);
|
||||||
importanceButtons.setVisibility(View.VISIBLE);
|
importanceButtons.setVisibility(View.VISIBLE);
|
||||||
importanceSlider.setVisibility(View.GONE);
|
importanceSlider.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasImportanceChanged() {
|
||||||
|
return mStartingImportance != getSelectedImportance();
|
||||||
|
}
|
||||||
|
|
||||||
void saveImportance(final StatusBarNotification sbn) {
|
void saveImportance(final StatusBarNotification sbn) {
|
||||||
int progress;
|
int progress = getSelectedImportance();
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MetricsLogger.action(mContext, MetricsEvent.ACTION_SAVE_IMPORTANCE,
|
MetricsLogger.action(mContext, MetricsEvent.ACTION_SAVE_IMPORTANCE,
|
||||||
progress - mStartingImportance);
|
progress - mStartingImportance);
|
||||||
try {
|
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,
|
private void bindToggles(final View importanceButtons, final int importance,
|
||||||
final boolean systemApp) {
|
final boolean systemApp) {
|
||||||
mBlock = (RadioButton) importanceButtons.findViewById(R.id.block_importance);
|
mBlock = (RadioButton) importanceButtons.findViewById(R.id.block_importance);
|
||||||
|
|||||||
@@ -4196,6 +4196,12 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLockedNotificationImportanceChange(OnDismissAction dismissAction) {
|
||||||
|
mLeaveOpenOnKeyguardHide = true;
|
||||||
|
dismissKeyguardThenExecute(dismissAction, true /* afterKeyguardGone */);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onLockedRemoteInput(ExpandableNotificationRow row, View clicked) {
|
protected void onLockedRemoteInput(ExpandableNotificationRow row, View clicked) {
|
||||||
mLeaveOpenOnKeyguardHide = true;
|
mLeaveOpenOnKeyguardHide = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user