summaryrefslogtreecommitdiff
path: root/src/com/android/email/NotificationController.java
diff options
context:
space:
mode:
authorAndy Stadler <stadler@google.com>2010-12-01 12:58:36 -0800
committerAndy Stadler <stadler@google.com>2010-12-01 12:58:36 -0800
commit1ca111c19c83d54ad23bd8615d9c648e09ec3366 (patch)
tree7724ca5860fe8ee50e06f34a47cf8e3c11ab969e /src/com/android/email/NotificationController.java
parentd1ee5b8fa5fe92df1ded5953a9e3f001b38a1ac7 (diff)
Add password expiration plumbing
* Set aggregated expiration values with DPM * Fix min/max logic when aggregating, and fix unit test * Add expiration tests when checking if policies are active * Add expire-password to uses-policies set * Handle password refresh (clear notifications and sec. holds) * Handle password expiration (warning and/or wipe synced data) * Unit tests for provider-level methods * Refactor common security notification logic * Placeholder notification strings (need final) Bug: 3197935 Change-Id: Idf1975edd81dd7f55729156dc6b1002b7d09841f
Diffstat (limited to 'src/com/android/email/NotificationController.java')
-rw-r--r--src/com/android/email/NotificationController.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/com/android/email/NotificationController.java b/src/com/android/email/NotificationController.java
index 0a120a367..965f7a4dc 100644
--- a/src/com/android/email/NotificationController.java
+++ b/src/com/android/email/NotificationController.java
@@ -44,6 +44,8 @@ public class NotificationController {
public static final int NOTIFICATION_ID_SECURITY_NEEDED = 1;
public static final int NOTIFICATION_ID_EXCHANGE_CALENDAR_ADDED = 2;
public static final int NOTIFICATION_ID_ATTACHMENT_WARNING = 3;
+ public static final int NOTIFICATION_ID_PASSWORD_EXPIRING = 4;
+ public static final int NOTIFICATION_ID_PASSWORD_EXPIRED = 5;
private static final int NOTIFICATION_ID_BASE_NEW_MESSAGES = 0x10000000;
private static final int NOTIFICATION_ID_BASE_LOGIN_WARNING = 0x20000000;
@@ -70,6 +72,60 @@ public class NotificationController {
}
/**
+ * Generic notifier for any account. Uses notification rules from account.
+ *
+ * @param account The account for which the notification is posted
+ * @param ticker String for ticker
+ * @param contentTitle String for notification content title
+ * @param contentText String for notification content text
+ * @param intent The intent to launch from the notification
+ * @param notificationId The notification id
+ */
+ public void postAccountNotification(Account account, String ticker, String contentTitle,
+ String contentText, Intent intent, int notificationId) {
+
+ // Pending Intent
+ PendingIntent pending =
+ PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+
+ // Ringtone & Vibration
+ String ringtoneString = account.getRingtone();
+ Uri ringTone = (ringtoneString == null) ? null : Uri.parse(ringtoneString);
+ boolean vibrate = 0 != (account.mFlags & Account.FLAGS_VIBRATE_ALWAYS);
+ boolean vibrateWhenSilent = 0 != (account.mFlags & Account.FLAGS_VIBRATE_WHEN_SILENT);
+
+ // Use the account's notification rules for sound & vibrate (but always notify)
+ boolean nowSilent =
+ mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE;
+
+ int defaults = Notification.DEFAULT_LIGHTS;
+ if (vibrate || (vibrateWhenSilent && nowSilent)) {
+ defaults |= Notification.DEFAULT_VIBRATE;
+ }
+
+ // Notification
+ Notification.Builder nb = new Notification.Builder(mContext);
+ nb.setSmallIcon(R.drawable.stat_notify_email_generic);
+ nb.setTicker(ticker);
+ nb.setContentTitle(contentTitle);
+ nb.setContentText(contentText);
+ nb.setContentIntent(pending);
+ nb.setSound(ringTone);
+ nb.setDefaults(defaults);
+ Notification notification = nb.getNotification();
+
+ mNotificationManager.notify(notificationId, notification);
+ }
+
+ /**
+ * Generic notification canceler.
+ * @param notificationId The notification id
+ */
+ public void cancelNotification(int notificationId) {
+ mNotificationManager.cancel(notificationId);
+ }
+
+ /**
* @return the "new message" notification ID for an account. It just assumes
* accountID won't be too huge. Any other smarter/cleaner way?
*/