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

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

New NotificationListenerService.

This is the best and only way for apps to listen for
notifications: create a NotificationListenerService, wait
for the NoMan to bind to you (as a result of the user
checking a box somewhere in Settings and agreeing to a
scary dialog box), and you'll start receiving notification
posted and dismissed callbacks. Your service, while enabled,
will also be able to clear one or all notifications.

Use this power wisely.

This change moves StatusBarNotification out of
com.android.internal into android.service.notification.
[Internal customers, including System UI and early users of
the system-only listener binder API, will need to be
updated.]

Bug: 8199624
Change-Id: I1be46f823d4b3ddc901109ec1e085cd6deb740c2
parent bab9687e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -69,7 +69,6 @@ LOCAL_SRC_FILES += \
	core/java/android/app/IAlarmManager.aidl \
	core/java/android/app/IBackupAgent.aidl \
	core/java/android/app/IInstrumentationWatcher.aidl \
	core/java/android/app/INotificationListener.aidl \
	core/java/android/app/INotificationManager.aidl \
	core/java/android/app/IProcessObserver.aidl \
	core/java/android/app/ISearchManager.aidl \
@@ -148,6 +147,7 @@ LOCAL_SRC_FILES += \
	core/java/android/os/IUpdateLock.aidl \
	core/java/android/os/IUserManager.aidl \
	core/java/android/os/IVibratorService.aidl \
	core/java/android/service/notification/INotificationListener.aidl \
	core/java/android/service/dreams/IDreamManager.aidl \
	core/java/android/service/dreams/IDreamService.aidl \
	core/java/android/service/wallpaper/IWallpaperConnection.aidl \
+1 −0
Original line number Diff line number Diff line
@@ -159,6 +159,7 @@ $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framew
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/com/android/internal/view/IInputMethodCallback.*)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/com/android/internal/view/IInputMethodSession.*)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/com/android/internal/view/IInputMethodCallback.*)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates)
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
+33 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ package android {
    field public static final java.lang.String BIND_APPWIDGET = "android.permission.BIND_APPWIDGET";
    field public static final java.lang.String BIND_DEVICE_ADMIN = "android.permission.BIND_DEVICE_ADMIN";
    field public static final java.lang.String BIND_INPUT_METHOD = "android.permission.BIND_INPUT_METHOD";
    field public static final java.lang.String BIND_NOTIFICATION_LISTENER_SERVICE = "android.permission.BIND_NOTIFICATION_LISTENER_SERVICE";
    field public static final java.lang.String BIND_REMOTEVIEWS = "android.permission.BIND_REMOTEVIEWS";
    field public static final java.lang.String BIND_TEXT_SERVICE = "android.permission.BIND_TEXT_SERVICE";
    field public static final java.lang.String BIND_VPN_SERVICE = "android.permission.BIND_VPN_SERVICE";
@@ -20839,6 +20840,38 @@ package android.service.dreams {
}
package android.service.notification {
  public abstract class NotificationListenerService extends android.app.Service {
    ctor public NotificationListenerService();
    method public final void clearAllNotifications();
    method public final void clearNotification(java.lang.String, java.lang.String, int);
    method public android.os.IBinder onBind(android.content.Intent);
    method public abstract void onNotificationPosted(android.service.notification.StatusBarNotification);
    method public abstract void onNotificationRemoved(android.service.notification.StatusBarNotification);
    field public static final java.lang.String SERVICE_INTERFACE = "android.service.notification.NotificationListenerService";
  }
  public class StatusBarNotification implements android.os.Parcelable {
    ctor public StatusBarNotification(java.lang.String, java.lang.String, int, java.lang.String, int, int, int, android.app.Notification, android.os.UserHandle, long);
    ctor public StatusBarNotification(android.os.Parcel);
    method public android.service.notification.StatusBarNotification clone();
    method public int describeContents();
    method public int getUserId();
    method public boolean isClearable();
    method public boolean isOngoing();
    method public void writeToParcel(android.os.Parcel, int);
    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;
  }
}
package android.service.textservice {
  public abstract class SpellCheckerService extends android.app.Service {
+7 −5
Original line number Diff line number Diff line
@@ -17,12 +17,12 @@

package android.app;

import android.app.INotificationListener;
import android.app.ITransientNotification;
import android.service.notification.StatusBarNotification;
import android.app.Notification;
import android.content.ComponentName;
import android.content.Intent;

import com.android.internal.statusbar.StatusBarNotification;
import android.service.notification.INotificationListener;

/** {@hide} */
interface INotificationManager
@@ -41,7 +41,9 @@ interface INotificationManager
    StatusBarNotification[] getActiveNotifications(String callingPkg);
    StatusBarNotification[] getHistoricalNotifications(String callingPkg, int count);

    void registerListener(in INotificationListener listener, String pkg, int userid);
    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);
}
 No newline at end of file
+16 −0
Original line number Diff line number Diff line
@@ -655,6 +655,22 @@ public final class Settings {
    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    public static final String ACTION_DREAM_SETTINGS = "android.settings.DREAM_SETTINGS";

    /**
     * Activity Action: Show Notification listener settings.
     * <p>
     * In some cases, a matching Activity may not exist, so ensure you
     * safeguard against this.
     * <p>
     * Input: Nothing.
     * <p>
     * Output: Nothing.
     * @see android.service.notification.NotificationListenerService
     * @hide
     */
    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    public static final String ACTION_NOTIFICATION_LISTENER_SETTINGS
            = "android.settings.NOTIFICATION_LISTENER_SETTINGS";

    // End of Intent actions for Settings

    /**
Loading