Loading packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +89 −5 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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 Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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(); Loading Loading @@ -332,10 +380,21 @@ public abstract class BaseStatusBar extends SystemUI implements } // Set up the initial notification state. 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( Loading Loading @@ -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()); Loading packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java +4 −4 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading @@ -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; Loading @@ -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); Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +2 −2 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -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); Loading packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java +8 −0 Original line number Diff line number Diff line Loading @@ -49,10 +49,18 @@ public class TvStatusBar extends BaseStatusBar { public void addNotification(StatusBarNotification notification) { } @Override public void addNotificationInternal(StatusBarNotification notification) { } @Override public void updateNotification(StatusBarNotification notification) { } @Override protected void removeNotificationInternal(String key) { } @Override public void removeNotification(String key) { } Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +89 −5 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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 Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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(); Loading Loading @@ -332,10 +380,21 @@ public abstract class BaseStatusBar extends SystemUI implements } // Set up the initial notification state. 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( Loading Loading @@ -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()); Loading
packages/SystemUI/src/com/android/systemui/statusbar/InterceptedNotifications.java +4 −4 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading @@ -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; Loading @@ -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); Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +2 −2 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -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); Loading
packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java +8 −0 Original line number Diff line number Diff line Loading @@ -49,10 +49,18 @@ public class TvStatusBar extends BaseStatusBar { public void addNotification(StatusBarNotification notification) { } @Override public void addNotificationInternal(StatusBarNotification notification) { } @Override public void updateNotification(StatusBarNotification notification) { } @Override protected void removeNotificationInternal(String key) { } @Override public void removeNotification(String key) { } Loading