summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java94
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java8
4 files changed, 103 insertions, 11 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 0495f46..b244ae1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -22,6 +22,7 @@ import android.app.Notification;
import android.app.PendingIntent;
import android.app.TaskStackBuilder;
import android.content.BroadcastReceiver;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -46,6 +47,7 @@ import android.os.UserManager;
import android.provider.Settings;
import android.service.dreams.DreamService;
import android.service.dreams.IDreamManager;
+import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.text.TextUtils;
import android.util.Log;
@@ -79,6 +81,7 @@ import com.android.systemui.statusbar.phone.KeyguardTouchDelegate;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Locale;
public abstract class BaseStatusBar extends SystemUI implements
@@ -86,6 +89,7 @@ public abstract class BaseStatusBar extends SystemUI implements
public static final String TAG = "StatusBar";
public static final boolean DEBUG = false;
public static final boolean MULTIUSER_DEBUG = false;
+ private static final boolean USE_NOTIFICATION_LISTENER = false;
protected static final int MSG_SHOW_RECENT_APPS = 1019;
protected static final int MSG_HIDE_RECENT_APPS = 1020;
@@ -158,6 +162,7 @@ public abstract class BaseStatusBar extends SystemUI implements
protected WindowManager mWindowManager;
protected IWindowManager mWindowManagerService;
+
protected abstract void refreshLayout(int layoutDirection);
protected Display mDisplay;
@@ -253,6 +258,49 @@ public abstract class BaseStatusBar extends SystemUI implements
}
};
+ private final NotificationListenerService mNotificationListener =
+ new NotificationListenerService() {
+ @Override
+ public void onListenerConnected() {
+ if (DEBUG) Log.d(TAG, "onListenerConnected");
+ final StatusBarNotification[] notifications = getActiveNotifications();
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ for (StatusBarNotification sbn : notifications) {
+ addNotificationInternal(sbn);
+ }
+ }
+ });
+ }
+
+ @Override
+ public void onNotificationPosted(final StatusBarNotification sbn) {
+ if (DEBUG) Log.d(TAG, "onNotificationPosted: " + sbn);
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ if (mNotificationData.findByKey(sbn.getKey()) != null) {
+ updateNotificationInternal(sbn);
+ } else {
+ addNotificationInternal(sbn);
+ }
+ }
+ });
+ }
+
+ @Override
+ public void onNotificationRemoved(final StatusBarNotification sbn) {
+ if (DEBUG) Log.d(TAG, "onNotificationRemoved: " + sbn);
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ removeNotificationInternal(sbn.getKey());
+ }
+ });
+ }
+ };
+
private void updateCurrentProfilesCache() {
synchronized (mCurrentProfiles) {
mCurrentProfiles.clear();
@@ -332,11 +380,22 @@ public abstract class BaseStatusBar extends SystemUI implements
}
// Set up the initial notification state.
- N = notifications.size();
- for (int i=0; i<N; i++) {
- addNotification(notifications.get(i));
+ if (USE_NOTIFICATION_LISTENER) {
+ try {
+ mNotificationListener.registerAsSystemService(
+ new ComponentName(mContext.getPackageName(), getClass().getCanonicalName()),
+ UserHandle.USER_ALL);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Unable to register notification listener", e);
+ }
+ } else {
+ N = notifications.size();
+ for (int i=0; i<N; i++) {
+ addNotification(notifications.get(i));
+ }
}
+
if (DEBUG) {
Log.d(TAG, String.format(
"init: icons=%d disabled=0x%08x lights=0x%08x menu=0x%08x imeButton=0x%08x",
@@ -1161,7 +1220,32 @@ public abstract class BaseStatusBar extends SystemUI implements
return parent != null && parent.indexOfChild(entry.row) == 0;
}
+
+ @Override
+ public void addNotification(StatusBarNotification notification) {
+ if (!USE_NOTIFICATION_LISTENER) {
+ addNotificationInternal(notification);
+ }
+ }
+
+ public abstract void addNotificationInternal(StatusBarNotification notification);
+
+ @Override
+ public void removeNotification(String key) {
+ if (!USE_NOTIFICATION_LISTENER) {
+ removeNotificationInternal(key);
+ }
+ }
+
+ protected abstract void removeNotificationInternal(String key);
+
public void updateNotification(StatusBarNotification notification) {
+ if (!USE_NOTIFICATION_LISTENER) {
+ updateNotificationInternal(notification);
+ }
+ }
+
+ public void updateNotificationInternal(StatusBarNotification notification) {
if (DEBUG) Log.d(TAG, "updateNotification(" + notification + ")");
final NotificationData.Entry oldEntry = mNotificationData.findByKey(notification.getKey());
@@ -1237,11 +1321,11 @@ public abstract class BaseStatusBar extends SystemUI implements
boolean orderUnchanged =
notification.getNotification().when == oldNotification.getNotification().when
&& notification.getScore() == oldNotification.getScore();
- // score now encompasses/supersedes isOngoing()
+ // score now encompasses/supersedes isOngoing()
boolean updateTicker = notification.getNotification().tickerText != null
&& !TextUtils.equals(notification.getNotification().tickerText,
- oldEntry.notification.getNotification().tickerText);
+ oldEntry.notification.getNotification().tickerText);
boolean isTopAnyway = isTopNotification(rowParent, oldEntry);
if (contentsUnchanged && bigContentsUnchanged && headsUpContentsUnchanged && publicUnchanged
&& (orderUnchanged || isTopAnyway)) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java b/packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java
index bd511f2..0555879 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java
@@ -50,7 +50,7 @@ public class InterceptedNotifications {
for (int i = 0; i < n; i++) {
final StatusBarNotification sbn = mIntercepted.valueAt(i);
sbn.getNotification().extras.putBoolean(EXTRA_INTERCEPT, false);
- mBar.addNotification(sbn);
+ mBar.addNotificationInternal(sbn);
}
mIntercepted.clear();
updateSyntheticNotification();
@@ -88,7 +88,7 @@ public class InterceptedNotifications {
private void updateSyntheticNotification() {
if (mIntercepted.isEmpty()) {
if (mSynKey != null) {
- mBar.removeNotification(mSynKey);
+ mBar.removeNotificationInternal(mSynKey);
mSynKey = null;
}
return;
@@ -107,9 +107,9 @@ public class InterceptedNotifications {
mBar.getCurrentUserHandle());
if (mSynKey == null) {
mSynKey = sbn.getKey();
- mBar.addNotification(sbn);
+ mBar.addNotificationInternal(sbn);
} else {
- mBar.updateNotification(sbn);
+ mBar.updateNotificationInternal(sbn);
}
final NotificationData.Entry entry = mBar.mNotificationData.findByKey(mSynKey);
entry.row.setOnClickListener(mSynClickListener);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 8735d36..35ffb9c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -1028,7 +1028,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
}
@Override
- public void addNotification(StatusBarNotification notification) {
+ public void addNotificationInternal(StatusBarNotification notification) {
if (DEBUG) Log.d(TAG, "addNotification score=" + notification.getScore());
Entry shadeEntry = createNotificationViews(notification);
if (shadeEntry == null) {
@@ -1096,7 +1096,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
}
@Override
- public void removeNotification(String key) {
+ public void removeNotificationInternal(String key) {
StatusBarNotification old = removeNotificationViews(key);
if (SPEW) Log.d(TAG, "removeNotification key=" + key + " old=" + old);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java
index 846d248..25147b4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java
@@ -50,10 +50,18 @@ public class TvStatusBar extends BaseStatusBar {
}
@Override
+ public void addNotificationInternal(StatusBarNotification notification) {
+ }
+
+ @Override
public void updateNotification(StatusBarNotification notification) {
}
@Override
+ protected void removeNotificationInternal(String key) {
+ }
+
+ @Override
public void removeNotification(String key) {
}