Make "security required" notification ongoing

* While investigating the referenced bug, it was discovered that
  canceling the "security required" notification (with "X", rather
  than the "cancel" option in the dialog) causes the notification
  to be unavailable until a reboot
* This puts the account needing a security update in the position
  of being unsyncable, and might explain the referenced bug (we
  have no confirmation of that step; on the other hand, the tester
  can't now reproduce the problem, so an unusual action like this
  is to be expected)
* The fix consists of making this particular notification "ongoing",
  which prevents the user from dismissing it; arguably, this should
  always have been the case anyway...
* Consider this fix for backport into LTE and MR2 branches

Bug: 5072343
Change-Id: Ia7419236cf9389380d1e079b1a9a6f425015c487
This commit is contained in:
Marc Blank 2011-07-28 13:55:10 -07:00
parent f64fd6fe71
commit d9b2a8f237
1 changed files with 16 additions and 4 deletions

View File

@ -133,6 +133,17 @@ public class NotificationController {
return sInstance;
}
/**
* Return whether or not a notification, based on the passed-in id, needs to be "ongoing"
* @param notificationId the notification id to check
* @return whether or not the notification must be "ongoing"
*/
private boolean needsOngoingNotification(int notificationId) {
// "Security needed" must be ongoing so that the user doesn't close it; otherwise, sync will
// be prevented until a reboot. Consider also doing this for password expired.
return notificationId == NOTIFICATION_ID_SECURITY_NEEDED;
}
/**
* Returns a {@link Notification} for an event with the given account. The account contains
* specific rules on ring tone usage and these will be used to modify the notification
@ -152,7 +163,7 @@ public class NotificationController {
*/
private Notification createAccountNotification(Account account, String ticker,
CharSequence title, String contentText, Intent intent, Bitmap largeIcon,
Integer number, boolean enableAudio) {
Integer number, boolean enableAudio, boolean ongoing) {
// Pending Intent
PendingIntent pending = null;
if (intent != null) {
@ -169,7 +180,8 @@ public class NotificationController {
.setNumber(number == null ? 0 : number)
.setSmallIcon(R.drawable.stat_notify_email_generic)
.setWhen(mClock.getTime())
.setTicker(ticker);
.setTicker(ticker)
.setOngoing(ongoing);
if (enableAudio) {
setupSoundAndVibration(builder, account);
@ -192,7 +204,7 @@ public class NotificationController {
private void showAccountNotification(Account account, String ticker, String title,
String contentText, Intent intent, int notificationId) {
Notification notification = createAccountNotification(account, ticker, title, contentText,
intent, null, null, true);
intent, null, null, true, needsOngoingNotification(notificationId));
mNotificationManager.notify(notificationId, notification);
}
@ -431,7 +443,7 @@ public class NotificationController {
boolean enableAudio = (now - mLastMessageNotifyTime) > MIN_SOUND_INTERVAL_MS;
Notification notification = createAccountNotification(
account, title.toString(), title, text,
intent, largeIcon, number, enableAudio);
intent, largeIcon, number, enableAudio, false);
mLastMessageNotifyTime = now;
return notification;
}