Fields Summary |
---|
private static final String | TAG |
public static final String | EXTRA_USE_SIDE_CHANNELNotification extras key: if set to true, the posted notification should use
the side channel for delivery instead of using notification manager. |
public static final String | ACTION_BIND_SIDE_CHANNELIntent action to register for on a service to receive side channel
notifications. The listening service must be in the same package as an enabled
{@link android.service.notification.NotificationListenerService}. |
static final int | MAX_SIDE_CHANNEL_SDK_VERSIONMaximum sdk build version which needs support for side channeled notifications.
Currently the only needed use is for side channeling group children before KITKAT_WATCH. |
private static final int | SIDE_CHANNEL_RETRY_BASE_INTERVAL_MSBase time delay for a side channel listener queue retry. |
private static final int | SIDE_CHANNEL_RETRY_MAX_COUNTMaximum retries for a side channel listener before dropping tasks. |
private static final String | SETTING_ENABLED_NOTIFICATION_LISTENERSHidden field Settings.Secure.ENABLED_NOTIFICATION_LISTENERS |
private static final int | SIDE_CHANNEL_BIND_FLAGS |
private static final Object | sEnabledNotificationListenersLockCache of enabled notification listener components |
private static String | sEnabledNotificationListenersGuarded by {@link #sEnabledNotificationListenersLock} |
private static Set | sEnabledNotificationListenerPackagesGuarded by {@link #sEnabledNotificationListenersLock} |
private final android.content.Context | mContext |
private final android.app.NotificationManager | mNotificationManager |
private static final Object | sLockLock for mutable static fields |
private static SideChannelManager | sSideChannelManagerGuarded by {@link #sLock} |
private static final Impl | IMPL |
Methods Summary |
---|
public void | cancel(int id)Cancel a previously shown notification.
if (Build.VERSION.SDK_INT >= 14) {
IMPL = new ImplIceCreamSandwich();
} else if (Build.VERSION.SDK_INT >= 5) {
IMPL = new ImplEclair();
} else {
IMPL = new ImplBase();
}
SIDE_CHANNEL_BIND_FLAGS = IMPL.getSideChannelBindFlags();
cancel(null, id);
|
public void | cancel(java.lang.String tag, int id)Cancel a previously shown notification.
IMPL.cancelNotification(mNotificationManager, tag, id);
if (Build.VERSION.SDK_INT <= MAX_SIDE_CHANNEL_SDK_VERSION) {
pushSideChannelQueue(new CancelTask(mContext.getPackageName(), id, tag));
}
|
public void | cancelAll()Cancel all previously shown notifications.
mNotificationManager.cancelAll();
if (Build.VERSION.SDK_INT <= MAX_SIDE_CHANNEL_SDK_VERSION) {
pushSideChannelQueue(new CancelTask(mContext.getPackageName()));
}
|
public static android.support.v4.app.NotificationManagerCompat | from(android.content.Context context)Get a {@link NotificationManagerCompat} instance for a provided context.
return new NotificationManagerCompat(context);
|
public static java.util.Set | getEnabledListenerPackages(android.content.Context context)Get the set of packages that have an enabled notification listener component within them.
final String enabledNotificationListeners = Settings.Secure.getString(
context.getContentResolver(),
SETTING_ENABLED_NOTIFICATION_LISTENERS);
// Parse the string again if it is different from the last time this method was called.
if (enabledNotificationListeners != null
&& !enabledNotificationListeners.equals(sEnabledNotificationListeners)) {
final String[] components = enabledNotificationListeners.split(":");
Set<String> packageNames = new HashSet<String>(components.length);
for (String component : components) {
ComponentName componentName = ComponentName.unflattenFromString(component);
if (componentName != null) {
packageNames.add(componentName.getPackageName());
}
}
synchronized (sEnabledNotificationListenersLock) {
sEnabledNotificationListenerPackages = packageNames;
sEnabledNotificationListeners = enabledNotificationListeners;
}
}
return sEnabledNotificationListenerPackages;
|
public void | notify(int id, android.app.Notification notification)Post a notification to be shown in the status bar, stream, etc.
notify(null, id, notification);
|
public void | notify(java.lang.String tag, int id, android.app.Notification notification)Post a notification to be shown in the status bar, stream, etc.
if (useSideChannelForNotification(notification)) {
pushSideChannelQueue(new NotifyTask(mContext.getPackageName(), id, tag, notification));
// Cancel this notification in notification manager if it just transitioned to being
// side channelled.
IMPL.cancelNotification(mNotificationManager, tag, id);
} else {
IMPL.postNotification(mNotificationManager, tag, id, notification);
}
|
private void | pushSideChannelQueue(android.support.v4.app.NotificationManagerCompat$Task task)Push a notification task for distribution to notification side channels.
synchronized (sLock) {
if (sSideChannelManager == null) {
sSideChannelManager = new SideChannelManager(mContext.getApplicationContext());
}
}
sSideChannelManager.queueTask(task);
|
private static boolean | useSideChannelForNotification(android.app.Notification notification)Returns true if this notification should use the side channel for delivery.
Bundle extras = NotificationCompat.getExtras(notification);
return extras != null && extras.getBoolean(EXTRA_USE_SIDE_CHANNEL);
|