diff options
author | Daniel Sandler <dsandler@android.com> | 2013-04-25 15:44:16 -0400 |
---|---|---|
committer | Daniel Sandler <dsandler@android.com> | 2013-04-25 15:51:08 -0400 |
commit | e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0 (patch) | |
tree | 74beebf24f5a077a2441c7342b1f005864ca1920 /core/java | |
parent | 25cf8cee6f304a286d321204e448b18ce733a60c (diff) | |
download | frameworks_base-e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0.zip frameworks_base-e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0.tar.gz frameworks_base-e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0.tar.bz2 |
API cleanup: NotificationListener
- Wrap all public member variables in getters and make
slots private
- Rename clear* methods to cancel* to be more consistent
with existing public Notification API
Bug: 8656860
Change-Id: I84f7e71fbb627f859352a93089c6a531b44dac95
Diffstat (limited to 'core/java')
3 files changed, 74 insertions, 31 deletions
diff --git a/core/java/android/app/INotificationManager.aidl b/core/java/android/app/INotificationManager.aidl index 6cfb56e..9f933ca 100644 --- a/core/java/android/app/INotificationManager.aidl +++ b/core/java/android/app/INotificationManager.aidl @@ -44,8 +44,8 @@ interface INotificationManager void registerListener(in INotificationListener listener, in ComponentName component, int userid); void unregisterListener(in INotificationListener listener, int userid); - void clearNotificationFromListener(in INotificationListener token, String pkg, String tag, int id); - void clearAllNotificationsFromListener(in INotificationListener token); + void cancelNotificationFromListener(in INotificationListener token, String pkg, String tag, int id); + void cancelAllNotificationsFromListener(in INotificationListener token); StatusBarNotification[] getActiveNotificationsFromListener(in INotificationListener token); }
\ No newline at end of file diff --git a/core/java/android/service/notification/NotificationListenerService.java b/core/java/android/service/notification/NotificationListenerService.java index 6a5864c..5031d3c 100644 --- a/core/java/android/service/notification/NotificationListenerService.java +++ b/core/java/android/service/notification/NotificationListenerService.java @@ -97,9 +97,9 @@ public abstract class NotificationListenerService extends Service { * @param id ID of the notification as specified by the notifying app in * {@link android.app.NotificationManager#notify(String, int, android.app.Notification)}. */ - public final void clearNotification(String pkg, String tag, int id) { + public final void cancelNotification(String pkg, String tag, int id) { try { - getNotificationInterface().clearNotificationFromListener(mWrapper, pkg, tag, id); + getNotificationInterface().cancelNotificationFromListener(mWrapper, pkg, tag, id); } catch (android.os.RemoteException ex) { Log.v(TAG, "Unable to contact notification manager", ex); } @@ -114,11 +114,11 @@ public abstract class NotificationListenerService extends Service { * upon being informed, the notification manager will actually remove all active notifications * and you will get multiple {@link #onNotificationRemoved(StatusBarNotification)} callbacks. * - * {@see #clearNotification(String, String, int)} + * {@see #cancelNotification(String, String, int)} */ - public final void clearAllNotifications() { + public final void cancelAllNotifications() { try { - getNotificationInterface().clearAllNotificationsFromListener(mWrapper); + getNotificationInterface().cancelAllNotificationsFromListener(mWrapper); } catch (android.os.RemoteException ex) { Log.v(TAG, "Unable to contact notification manager", ex); } diff --git a/core/java/android/service/notification/StatusBarNotification.java b/core/java/android/service/notification/StatusBarNotification.java index 006518c..5ed6d38 100644 --- a/core/java/android/service/notification/StatusBarNotification.java +++ b/core/java/android/service/notification/StatusBarNotification.java @@ -26,35 +26,21 @@ import android.os.UserHandle; * the status bar and any {@link android.service.notification.NotificationListenerService}s. */ public class StatusBarNotification implements Parcelable { - /** The package of the app that posted the notification. */ - public final String pkg; - /** The id supplied to {@link android.app.NotificationManager#notify}. */ - public final int id; - /** The tag supplied to {@link android.app.NotificationManager#notify}, or null if no tag - * was specified. */ - public final String tag; + private final String pkg; + private final int id; + private final String tag; - /** The notifying app's calling uid. @hide */ - public final int uid; - /** The notifying app's base package. @hide */ - public final String basePkg; - /** @hide */ - public final int initialPid; + private final int uid; + private final String basePkg; + private final int initialPid; // TODO: make this field private and move callers to an accessor that // ensures sourceUser is applied. - /** The {@link android.app.Notification} supplied to - * {@link android.app.NotificationManager#notify}. */ - public final Notification notification; - /** The {@link android.os.UserHandle} for whom this notification is intended. */ - public final UserHandle user; - /** The time (in {@link System#currentTimeMillis} time) the notification was posted, - * which may be different than {@link android.app.Notification#when}. - */ - public final long postTime; + private final Notification notification; + private final UserHandle user; + private final long postTime; - /** @hide */ - public final int score; + private final int score; /** This is temporarily needed for the JB MR1 PDK. * @hide */ @@ -198,4 +184,61 @@ public class StatusBarNotification implements Parcelable { public int getUserId() { return this.user.getIdentifier(); } + + /** The package of the app that posted the notification. */ + public String getPkg() { + return pkg; + } + + /** The id supplied to {@link android.app.NotificationManager#notify}. */ + public int getId() { + return id; + } + + /** The tag supplied to {@link android.app.NotificationManager#notify}, or null if no tag + * was specified. */ + public String getTag() { + return tag; + } + + /** The notifying app's calling uid. @hide */ + public int getUid() { + return uid; + } + + /** The notifying app's base package. @hide */ + public String getBasePkg() { + return basePkg; + } + + /** @hide */ + public int getInitialPid() { + return initialPid; + } + + /** The {@link android.app.Notification} supplied to + * {@link android.app.NotificationManager#notify}. */ + public Notification getNotification() { + return notification; + } + + /** + * The {@link android.os.UserHandle} for whom this notification is intended. + * @hide + */ + public UserHandle getUser() { + return user; + } + + /** The time (in {@link System#currentTimeMillis} time) the notification was posted, + * which may be different than {@link android.app.Notification#when}. + */ + public long getPostTime() { + return postTime; + } + + /** @hide */ + public int getScore() { + return score; + } } |