Loading core/java/android/app/Notification.java +8 −5 Original line number Diff line number Diff line Loading @@ -1331,11 +1331,14 @@ public class Notification implements Parcelable public Notification(Context context, int icon, CharSequence tickerText, long when, CharSequence contentTitle, CharSequence contentText, Intent contentIntent) { this.when = when; this.icon = icon; this.tickerText = tickerText; setLatestEventInfo(context, contentTitle, contentText, PendingIntent.getActivity(context, 0, contentIntent, 0)); new Builder(context) .setWhen(when) .setSmallIcon(icon) .setTicker(tickerText) .setContentTitle(contentTitle) .setContentText(contentText) .setContentIntent(PendingIntent.getActivity(context, 0, contentIntent, 0)) .buildInto(this); } /** Loading core/tests/notificationtests/src/android/app/NotificationStressTest.java +9 −4 Original line number Diff line number Diff line Loading @@ -77,15 +77,20 @@ public class NotificationStressTest extends InstrumentationTestCase { } private void sendNotification(int id, CharSequence text) { // Create "typical" notification with random icon Notification notification = new Notification(ICONS[mRandom.nextInt(ICONS.length)], text, System.currentTimeMillis()); // Fill in arbitrary content Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com")); PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, intent, 0); CharSequence title = text + " " + id; CharSequence subtitle = String.valueOf(System.currentTimeMillis()); notification.setLatestEventInfo(mContext, title, subtitle, pendingIntent); // Create "typical" notification with random icon Notification notification = new Notification.Builder(mContext) .setSmallIcon(ICONS[mRandom.nextInt(ICONS.length)]) .setTicker(text) .setWhen(System.currentTimeMillis()) .setContentTitle(title) .setContentText(subtitle) .setContentIntent(pendingIntent) .build(); mNotificationManager.notify(id, notification); SystemClock.sleep(10); } Loading location/java/com/android/internal/location/GpsNetInitiatedHandler.java +16 −14 Original line number Diff line number Diff line Loading @@ -172,7 +172,7 @@ public class GpsNetInitiatedHandler { * <p> * This is lazily created, so use {@link #setNINotification()}. */ private Notification mNiNotification; private Notification.Builder mNiNotificationBuilder; public GpsNetInitiatedHandler(Context context, INetInitiatedListener netInitiatedListener, Loading Loading @@ -367,29 +367,31 @@ public class GpsNetInitiatedHandler { ", message: " + message); // Construct Notification if (mNiNotification == null) { mNiNotification = new Notification(); mNiNotification.icon = com.android.internal.R.drawable.stat_sys_gps_on; /* Change notification icon here */ mNiNotification.when = 0; if (mNiNotificationBuilder == null) { mNiNotificationBuilder = new Notification.Builder(mContext) .setSmallIcon(com.android.internal.R.drawable.stat_sys_gps_on) .setWhen(0) .setOngoing(true) .setAutoCancel(true) .setColor(mContext.getColor( com.android.internal.R.color.system_notification_accent_color)); } if (mPlaySounds) { mNiNotification.defaults |= Notification.DEFAULT_SOUND; mNiNotificationBuilder.setDefaults(Notification.DEFAULT_SOUND); } else { mNiNotification.defaults &= ~Notification.DEFAULT_SOUND; mNiNotificationBuilder.setDefaults(0); } mNiNotification.flags = Notification.FLAG_ONGOING_EVENT | Notification.FLAG_AUTO_CANCEL; mNiNotification.tickerText = getNotifTicker(notif, mContext); // if not to popup dialog immediately, pending intent will open the dialog Intent intent = !mPopupImmediately ? getDlgIntent(notif) : new Intent(); PendingIntent pi = PendingIntent.getBroadcast(mContext, 0, intent, 0); mNiNotification.color = mContext.getColor( com.android.internal.R.color.system_notification_accent_color); mNiNotification.setLatestEventInfo(mContext, title, message, pi); mNiNotificationBuilder.setTicker(getNotifTicker(notif, mContext)) .setContentTitle(title) .setContentText(message) .setContentIntent(pi); notificationManager.notifyAsUser(null, notif.notificationId, mNiNotification, notificationManager.notifyAsUser(null, notif.notificationId, mNiNotificationBuilder.build(), UserHandle.ALL); } Loading services/core/java/com/android/server/ConnectivityService.java +11 −9 Original line number Diff line number Diff line Loading @@ -3289,7 +3289,6 @@ public class ConnectivityService extends IConnectivityManager.Stub CharSequence title; CharSequence details; int icon; Notification notification = new Notification(); if (notifyType == NotificationType.NO_INTERNET && networkType == ConnectivityManager.TYPE_WIFI) { title = r.getString(R.string.wifi_no_internet, 0); Loading Loading @@ -3324,14 +3323,17 @@ public class ConnectivityService extends IConnectivityManager.Stub return; } notification.when = 0; notification.icon = icon; notification.flags = Notification.FLAG_AUTO_CANCEL; notification.tickerText = title; notification.color = mContext.getColor( com.android.internal.R.color.system_notification_accent_color); notification.setLatestEventInfo(mContext, title, details, notification.contentIntent); notification.contentIntent = intent; Notification notification = new Notification.Builder(mContext) .setWhen(0) .setSmallIcon(icon) .setAutoCancel(true) .setTicker(title) .setColor(mContext.getColor( com.android.internal.R.color.system_notification_accent_color)) .setContentTitle(title) .setContentText(details) .setContentIntent(intent) .build(); try { notificationManager.notify(NOTIFICATION_ID, id, notification); Loading services/core/java/com/android/server/InputMethodManagerService.java +15 −19 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ import android.graphics.drawable.Drawable; import android.inputmethodservice.InputMethodService; import android.net.Uri; import android.os.Binder; import android.os.Bundle; import android.os.Environment; import android.os.Handler; import android.os.IBinder; Loading Loading @@ -212,7 +213,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub private NotificationManager mNotificationManager; private KeyguardManager mKeyguardManager; private StatusBarManagerService mStatusBar; private Notification mImeSwitcherNotification; private Notification.Builder mImeSwitcherNotification; private PendingIntent mImeSwitchPendingIntent; private boolean mShowOngoingImeSwitcherForPhones; private boolean mNotificationShown; Loading Loading @@ -798,18 +799,15 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mHasFeature = context.getPackageManager().hasSystemFeature( PackageManager.FEATURE_INPUT_METHODS); mImeSwitcherNotification = new Notification(); mImeSwitcherNotification.icon = com.android.internal.R.drawable.ic_notification_ime_default; mImeSwitcherNotification.when = 0; mImeSwitcherNotification.flags = Notification.FLAG_ONGOING_EVENT; mImeSwitcherNotification.tickerText = null; mImeSwitcherNotification.defaults = 0; // please be quiet mImeSwitcherNotification.sound = null; mImeSwitcherNotification.vibrate = null; // Tag this notification specially so SystemUI knows it's important mImeSwitcherNotification.extras.putBoolean(Notification.EXTRA_ALLOW_DURING_SETUP, true); mImeSwitcherNotification.category = Notification.CATEGORY_SYSTEM; Bundle extras = new Bundle(); extras.putBoolean(Notification.EXTRA_ALLOW_DURING_SETUP, true); mImeSwitcherNotification = new Notification.Builder(mContext) .setSmallIcon(com.android.internal.R.drawable.ic_notification_ime_default) .setWhen(0) .setOngoing(true) .addExtras(extras) .setCategory(Notification.CATEGORY_SYSTEM) .setColor(com.android.internal.R.color.system_notification_accent_color); Intent intent = new Intent(Settings.ACTION_SHOW_INPUT_METHOD_PICKER); mImeSwitchPendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0); Loading Loading @@ -1766,11 +1764,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub com.android.internal.R.string.select_input_method); final CharSequence summary = InputMethodUtils.getImeAndSubtypeDisplayName( mContext, imi, mCurrentSubtype); mImeSwitcherNotification.color = mContext.getColor( com.android.internal.R.color.system_notification_accent_color); mImeSwitcherNotification.setLatestEventInfo( mContext, title, summary, mImeSwitchPendingIntent); mImeSwitcherNotification.setContentTitle(title) .setContentText(summary) .setContentIntent(mImeSwitchPendingIntent); if ((mNotificationManager != null) && !mWindowManagerService.hasNavigationBar()) { if (DEBUG) { Loading @@ -1778,7 +1774,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } mNotificationManager.notifyAsUser(null, com.android.internal.R.string.select_input_method, mImeSwitcherNotification, UserHandle.ALL); mImeSwitcherNotification.build(), UserHandle.ALL); mNotificationShown = true; } } else { Loading Loading
core/java/android/app/Notification.java +8 −5 Original line number Diff line number Diff line Loading @@ -1331,11 +1331,14 @@ public class Notification implements Parcelable public Notification(Context context, int icon, CharSequence tickerText, long when, CharSequence contentTitle, CharSequence contentText, Intent contentIntent) { this.when = when; this.icon = icon; this.tickerText = tickerText; setLatestEventInfo(context, contentTitle, contentText, PendingIntent.getActivity(context, 0, contentIntent, 0)); new Builder(context) .setWhen(when) .setSmallIcon(icon) .setTicker(tickerText) .setContentTitle(contentTitle) .setContentText(contentText) .setContentIntent(PendingIntent.getActivity(context, 0, contentIntent, 0)) .buildInto(this); } /** Loading
core/tests/notificationtests/src/android/app/NotificationStressTest.java +9 −4 Original line number Diff line number Diff line Loading @@ -77,15 +77,20 @@ public class NotificationStressTest extends InstrumentationTestCase { } private void sendNotification(int id, CharSequence text) { // Create "typical" notification with random icon Notification notification = new Notification(ICONS[mRandom.nextInt(ICONS.length)], text, System.currentTimeMillis()); // Fill in arbitrary content Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com")); PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, intent, 0); CharSequence title = text + " " + id; CharSequence subtitle = String.valueOf(System.currentTimeMillis()); notification.setLatestEventInfo(mContext, title, subtitle, pendingIntent); // Create "typical" notification with random icon Notification notification = new Notification.Builder(mContext) .setSmallIcon(ICONS[mRandom.nextInt(ICONS.length)]) .setTicker(text) .setWhen(System.currentTimeMillis()) .setContentTitle(title) .setContentText(subtitle) .setContentIntent(pendingIntent) .build(); mNotificationManager.notify(id, notification); SystemClock.sleep(10); } Loading
location/java/com/android/internal/location/GpsNetInitiatedHandler.java +16 −14 Original line number Diff line number Diff line Loading @@ -172,7 +172,7 @@ public class GpsNetInitiatedHandler { * <p> * This is lazily created, so use {@link #setNINotification()}. */ private Notification mNiNotification; private Notification.Builder mNiNotificationBuilder; public GpsNetInitiatedHandler(Context context, INetInitiatedListener netInitiatedListener, Loading Loading @@ -367,29 +367,31 @@ public class GpsNetInitiatedHandler { ", message: " + message); // Construct Notification if (mNiNotification == null) { mNiNotification = new Notification(); mNiNotification.icon = com.android.internal.R.drawable.stat_sys_gps_on; /* Change notification icon here */ mNiNotification.when = 0; if (mNiNotificationBuilder == null) { mNiNotificationBuilder = new Notification.Builder(mContext) .setSmallIcon(com.android.internal.R.drawable.stat_sys_gps_on) .setWhen(0) .setOngoing(true) .setAutoCancel(true) .setColor(mContext.getColor( com.android.internal.R.color.system_notification_accent_color)); } if (mPlaySounds) { mNiNotification.defaults |= Notification.DEFAULT_SOUND; mNiNotificationBuilder.setDefaults(Notification.DEFAULT_SOUND); } else { mNiNotification.defaults &= ~Notification.DEFAULT_SOUND; mNiNotificationBuilder.setDefaults(0); } mNiNotification.flags = Notification.FLAG_ONGOING_EVENT | Notification.FLAG_AUTO_CANCEL; mNiNotification.tickerText = getNotifTicker(notif, mContext); // if not to popup dialog immediately, pending intent will open the dialog Intent intent = !mPopupImmediately ? getDlgIntent(notif) : new Intent(); PendingIntent pi = PendingIntent.getBroadcast(mContext, 0, intent, 0); mNiNotification.color = mContext.getColor( com.android.internal.R.color.system_notification_accent_color); mNiNotification.setLatestEventInfo(mContext, title, message, pi); mNiNotificationBuilder.setTicker(getNotifTicker(notif, mContext)) .setContentTitle(title) .setContentText(message) .setContentIntent(pi); notificationManager.notifyAsUser(null, notif.notificationId, mNiNotification, notificationManager.notifyAsUser(null, notif.notificationId, mNiNotificationBuilder.build(), UserHandle.ALL); } Loading
services/core/java/com/android/server/ConnectivityService.java +11 −9 Original line number Diff line number Diff line Loading @@ -3289,7 +3289,6 @@ public class ConnectivityService extends IConnectivityManager.Stub CharSequence title; CharSequence details; int icon; Notification notification = new Notification(); if (notifyType == NotificationType.NO_INTERNET && networkType == ConnectivityManager.TYPE_WIFI) { title = r.getString(R.string.wifi_no_internet, 0); Loading Loading @@ -3324,14 +3323,17 @@ public class ConnectivityService extends IConnectivityManager.Stub return; } notification.when = 0; notification.icon = icon; notification.flags = Notification.FLAG_AUTO_CANCEL; notification.tickerText = title; notification.color = mContext.getColor( com.android.internal.R.color.system_notification_accent_color); notification.setLatestEventInfo(mContext, title, details, notification.contentIntent); notification.contentIntent = intent; Notification notification = new Notification.Builder(mContext) .setWhen(0) .setSmallIcon(icon) .setAutoCancel(true) .setTicker(title) .setColor(mContext.getColor( com.android.internal.R.color.system_notification_accent_color)) .setContentTitle(title) .setContentText(details) .setContentIntent(intent) .build(); try { notificationManager.notify(NOTIFICATION_ID, id, notification); Loading
services/core/java/com/android/server/InputMethodManagerService.java +15 −19 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ import android.graphics.drawable.Drawable; import android.inputmethodservice.InputMethodService; import android.net.Uri; import android.os.Binder; import android.os.Bundle; import android.os.Environment; import android.os.Handler; import android.os.IBinder; Loading Loading @@ -212,7 +213,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub private NotificationManager mNotificationManager; private KeyguardManager mKeyguardManager; private StatusBarManagerService mStatusBar; private Notification mImeSwitcherNotification; private Notification.Builder mImeSwitcherNotification; private PendingIntent mImeSwitchPendingIntent; private boolean mShowOngoingImeSwitcherForPhones; private boolean mNotificationShown; Loading Loading @@ -798,18 +799,15 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mHasFeature = context.getPackageManager().hasSystemFeature( PackageManager.FEATURE_INPUT_METHODS); mImeSwitcherNotification = new Notification(); mImeSwitcherNotification.icon = com.android.internal.R.drawable.ic_notification_ime_default; mImeSwitcherNotification.when = 0; mImeSwitcherNotification.flags = Notification.FLAG_ONGOING_EVENT; mImeSwitcherNotification.tickerText = null; mImeSwitcherNotification.defaults = 0; // please be quiet mImeSwitcherNotification.sound = null; mImeSwitcherNotification.vibrate = null; // Tag this notification specially so SystemUI knows it's important mImeSwitcherNotification.extras.putBoolean(Notification.EXTRA_ALLOW_DURING_SETUP, true); mImeSwitcherNotification.category = Notification.CATEGORY_SYSTEM; Bundle extras = new Bundle(); extras.putBoolean(Notification.EXTRA_ALLOW_DURING_SETUP, true); mImeSwitcherNotification = new Notification.Builder(mContext) .setSmallIcon(com.android.internal.R.drawable.ic_notification_ime_default) .setWhen(0) .setOngoing(true) .addExtras(extras) .setCategory(Notification.CATEGORY_SYSTEM) .setColor(com.android.internal.R.color.system_notification_accent_color); Intent intent = new Intent(Settings.ACTION_SHOW_INPUT_METHOD_PICKER); mImeSwitchPendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0); Loading Loading @@ -1766,11 +1764,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub com.android.internal.R.string.select_input_method); final CharSequence summary = InputMethodUtils.getImeAndSubtypeDisplayName( mContext, imi, mCurrentSubtype); mImeSwitcherNotification.color = mContext.getColor( com.android.internal.R.color.system_notification_accent_color); mImeSwitcherNotification.setLatestEventInfo( mContext, title, summary, mImeSwitchPendingIntent); mImeSwitcherNotification.setContentTitle(title) .setContentText(summary) .setContentIntent(mImeSwitchPendingIntent); if ((mNotificationManager != null) && !mWindowManagerService.hasNavigationBar()) { if (DEBUG) { Loading @@ -1778,7 +1774,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } mNotificationManager.notifyAsUser(null, com.android.internal.R.string.select_input_method, mImeSwitcherNotification, UserHandle.ALL); mImeSwitcherNotification.build(), UserHandle.ALL); mNotificationShown = true; } } else { Loading