Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a7b6cbf1 authored by Daniel Sandler's avatar Daniel Sandler Committed by Android (Google) Code Review
Browse files

Merge "API cleanup: NotificationListener" into jb-mr2-dev

parents 5e97c317 e6f7f2e3
Loading
Loading
Loading
Loading
+7 −8
Original line number Original line Diff line number Diff line
@@ -21228,8 +21228,8 @@ package android.service.notification {
  public abstract class NotificationListenerService extends android.app.Service {
  public abstract class NotificationListenerService extends android.app.Service {
    ctor public NotificationListenerService();
    ctor public NotificationListenerService();
    method public final void clearAllNotifications();
    method public final void cancelAllNotifications();
    method public final void clearNotification(java.lang.String, java.lang.String, int);
    method public final void cancelNotification(java.lang.String, java.lang.String, int);
    method public android.service.notification.StatusBarNotification[] getActiveNotifications();
    method public android.service.notification.StatusBarNotification[] getActiveNotifications();
    method public android.os.IBinder onBind(android.content.Intent);
    method public android.os.IBinder onBind(android.content.Intent);
    method public abstract void onNotificationPosted(android.service.notification.StatusBarNotification);
    method public abstract void onNotificationPosted(android.service.notification.StatusBarNotification);
@@ -21242,17 +21242,16 @@ package android.service.notification {
    ctor public StatusBarNotification(android.os.Parcel);
    ctor public StatusBarNotification(android.os.Parcel);
    method public android.service.notification.StatusBarNotification clone();
    method public android.service.notification.StatusBarNotification clone();
    method public int describeContents();
    method public int describeContents();
    method public int getId();
    method public android.app.Notification getNotification();
    method public java.lang.String getPkg();
    method public long getPostTime();
    method public java.lang.String getTag();
    method public int getUserId();
    method public int getUserId();
    method public boolean isClearable();
    method public boolean isClearable();
    method public boolean isOngoing();
    method public boolean isOngoing();
    method public void writeToParcel(android.os.Parcel, int);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator CREATOR;
    field public static final android.os.Parcelable.Creator CREATOR;
    field public final int id;
    field public final android.app.Notification notification;
    field public final java.lang.String pkg;
    field public final long postTime;
    field public final java.lang.String tag;
    field public final android.os.UserHandle user;
  }
  }
}
}
+2 −2
Original line number Original line Diff line number Diff line
@@ -44,8 +44,8 @@ interface INotificationManager
    void registerListener(in INotificationListener listener, in ComponentName component, int userid);
    void registerListener(in INotificationListener listener, in ComponentName component, int userid);
    void unregisterListener(in INotificationListener listener, int userid);
    void unregisterListener(in INotificationListener listener, int userid);


    void clearNotificationFromListener(in INotificationListener token, String pkg, String tag, int id);
    void cancelNotificationFromListener(in INotificationListener token, String pkg, String tag, int id);
    void clearAllNotificationsFromListener(in INotificationListener token);
    void cancelAllNotificationsFromListener(in INotificationListener token);


    StatusBarNotification[] getActiveNotificationsFromListener(in INotificationListener token);
    StatusBarNotification[] getActiveNotificationsFromListener(in INotificationListener token);
}
}
 No newline at end of file
+5 −5
Original line number Original line Diff line number Diff line
@@ -97,9 +97,9 @@ public abstract class NotificationListenerService extends Service {
     * @param id  ID of the notification as specified by the notifying app in
     * @param id  ID of the notification as specified by the notifying app in
     *     {@link android.app.NotificationManager#notify(String, int, android.app.Notification)}.
     *     {@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 {
        try {
            getNotificationInterface().clearNotificationFromListener(mWrapper, pkg, tag, id);
            getNotificationInterface().cancelNotificationFromListener(mWrapper, pkg, tag, id);
        } catch (android.os.RemoteException ex) {
        } catch (android.os.RemoteException ex) {
            Log.v(TAG, "Unable to contact notification manager", 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
     * upon being informed, the notification manager will actually remove all active notifications
     * and you will get multiple {@link #onNotificationRemoved(StatusBarNotification)} callbacks.
     * 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 {
        try {
            getNotificationInterface().clearAllNotificationsFromListener(mWrapper);
            getNotificationInterface().cancelAllNotificationsFromListener(mWrapper);
        } catch (android.os.RemoteException ex) {
        } catch (android.os.RemoteException ex) {
            Log.v(TAG, "Unable to contact notification manager", ex);
            Log.v(TAG, "Unable to contact notification manager", ex);
        }
        }
+67 −24
Original line number Original line Diff line number Diff line
@@ -26,35 +26,21 @@ import android.os.UserHandle;
 * the status bar and any {@link android.service.notification.NotificationListenerService}s.
 * the status bar and any {@link android.service.notification.NotificationListenerService}s.
 */
 */
public class StatusBarNotification implements Parcelable {
public class StatusBarNotification implements Parcelable {
    /** The package of the app that posted the notification. */
    private final String pkg;
    public final String pkg;
    private final int id;
    /** The id supplied to {@link android.app.NotificationManager#notify}. */
    private final String tag;
    public final int id;
    /** The tag supplied to {@link android.app.NotificationManager#notify}, or null if no tag
     * was specified. */
    public final String tag;


    /** The notifying app's calling uid. @hide */
    private final int uid;
    public final int uid;
    private final String basePkg;
    /** The notifying app's base package. @hide */
    private final int initialPid;
    public final String basePkg;
    /** @hide */
    public final int initialPid;
    // TODO: make this field private and move callers to an accessor that
    // TODO: make this field private and move callers to an accessor that
    // ensures sourceUser is applied.
    // ensures sourceUser is applied.


    /** The {@link android.app.Notification} supplied to
    private final Notification notification;
     * {@link android.app.NotificationManager#notify}. */
    private final UserHandle user;
    public final Notification notification;
    private final long postTime;
    /** 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;


    /** @hide */
    private final int score;
    public final int score;


    /** This is temporarily needed for the JB MR1 PDK.
    /** This is temporarily needed for the JB MR1 PDK.
     * @hide */
     * @hide */
@@ -198,4 +184,61 @@ public class StatusBarNotification implements Parcelable {
    public int getUserId() {
    public int getUserId() {
        return this.user.getIdentifier();
        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;
    }
}
}
+352 KiB

File added.

No diff preview for this file type.

Loading