Merge "SysUI: Use SBN keys instead of IBinder keys"
This commit is contained in:
committed by
Android (Google) Code Review
commit
36a9acb7eb
@@ -24,9 +24,9 @@ oneway interface IStatusBar
|
||||
{
|
||||
void setIcon(int index, in StatusBarIcon icon);
|
||||
void removeIcon(int index);
|
||||
void addNotification(IBinder key, in StatusBarNotification notification);
|
||||
void updateNotification(IBinder key, in StatusBarNotification notification);
|
||||
void removeNotification(IBinder key);
|
||||
void addNotification(in StatusBarNotification notification);
|
||||
void updateNotification(in StatusBarNotification notification);
|
||||
void removeNotification(String key);
|
||||
void disable(int state);
|
||||
void animateExpandNotificationsPanel();
|
||||
void animateExpandSettingsPanel();
|
||||
|
||||
@@ -39,8 +39,8 @@ interface IStatusBarService
|
||||
// ---- Methods below are for use by the status bar policy services ----
|
||||
// You need the STATUS_BAR_SERVICE permission
|
||||
void registerStatusBar(IStatusBar callbacks, out StatusBarIconList iconList,
|
||||
out List<IBinder> notificationKeys, out List<StatusBarNotification> notifications,
|
||||
out int[] switches, out List<IBinder> binders);
|
||||
out List<StatusBarNotification> notifications, out int[] switches,
|
||||
out List<IBinder> binders);
|
||||
void onPanelRevealed();
|
||||
void onPanelHidden();
|
||||
void onNotificationClick(String key);
|
||||
|
||||
@@ -315,14 +315,13 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
|
||||
// Connect in to the status bar manager service
|
||||
StatusBarIconList iconList = new StatusBarIconList();
|
||||
ArrayList<IBinder> notificationKeys = new ArrayList<IBinder>();
|
||||
ArrayList<StatusBarNotification> notifications = new ArrayList<StatusBarNotification>();
|
||||
mCommandQueue = new CommandQueue(this, iconList);
|
||||
|
||||
int[] switches = new int[8];
|
||||
ArrayList<IBinder> binders = new ArrayList<IBinder>();
|
||||
try {
|
||||
mBarService.registerStatusBar(mCommandQueue, iconList, notificationKeys, notifications,
|
||||
mBarService.registerStatusBar(mCommandQueue, iconList, notifications,
|
||||
switches, binders);
|
||||
} catch (RemoteException ex) {
|
||||
// If the system process isn't there we're doomed anyway.
|
||||
@@ -348,15 +347,10 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
}
|
||||
}
|
||||
|
||||
// Set up the initial notification state
|
||||
N = notificationKeys.size();
|
||||
if (N == notifications.size()) {
|
||||
for (int i=0; i<N; i++) {
|
||||
addNotification(notificationKeys.get(i), notifications.get(i));
|
||||
}
|
||||
} else {
|
||||
Log.wtf(TAG, "Notification list length mismatch: keys=" + N
|
||||
+ " notifications=" + notifications.size());
|
||||
// Set up the initial notification state.
|
||||
N = notifications.size();
|
||||
for (int i=0; i<N; i++) {
|
||||
addNotification(notifications.get(i));
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
@@ -1050,8 +1044,8 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
*
|
||||
* WARNING: this will call back into us. Don't hold any locks.
|
||||
*/
|
||||
void handleNotificationError(IBinder key, StatusBarNotification n, String message) {
|
||||
removeNotification(key);
|
||||
void handleNotificationError(StatusBarNotification n, String message) {
|
||||
removeNotification(n.getKey());
|
||||
try {
|
||||
mBarService.onNotificationError(n.getPackageName(), n.getTag(), n.getId(), n.getUid(),
|
||||
n.getInitialPid(), message, n.getUserId());
|
||||
@@ -1060,7 +1054,7 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
}
|
||||
}
|
||||
|
||||
protected StatusBarNotification removeNotificationViews(IBinder key) {
|
||||
protected StatusBarNotification removeNotificationViews(String key) {
|
||||
NotificationData.Entry entry = mNotificationData.remove(key);
|
||||
if (entry == null) {
|
||||
Log.w(TAG, "removeNotification for unknown key: " + key);
|
||||
@@ -1075,10 +1069,9 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
return entry.notification;
|
||||
}
|
||||
|
||||
protected NotificationData.Entry createNotificationViews(IBinder key,
|
||||
StatusBarNotification notification) {
|
||||
protected NotificationData.Entry createNotificationViews(StatusBarNotification notification) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "createNotificationViews(key=" + key + ", notification=" + notification);
|
||||
Log.d(TAG, "createNotificationViews(notification=" + notification);
|
||||
}
|
||||
// Construct the icon.
|
||||
final StatusBarIconView iconView = new StatusBarIconView(mContext,
|
||||
@@ -1093,13 +1086,13 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
notification.getNotification().number,
|
||||
notification.getNotification().tickerText);
|
||||
if (!iconView.set(ic)) {
|
||||
handleNotificationError(key, notification, "Couldn't create icon: " + ic);
|
||||
handleNotificationError(notification, "Couldn't create icon: " + ic);
|
||||
return null;
|
||||
}
|
||||
// Construct the expanded view.
|
||||
NotificationData.Entry entry = new NotificationData.Entry(key, notification, iconView);
|
||||
NotificationData.Entry entry = new NotificationData.Entry(notification, iconView);
|
||||
if (!inflateViews(entry, mStackScroller)) {
|
||||
handleNotificationError(key, notification, "Couldn't expand RemoteViews for: "
|
||||
handleNotificationError(notification, "Couldn't expand RemoteViews for: "
|
||||
+ notification);
|
||||
return null;
|
||||
}
|
||||
@@ -1119,8 +1112,8 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
updateRowStates();
|
||||
}
|
||||
|
||||
private void addNotificationViews(IBinder key, StatusBarNotification notification) {
|
||||
addNotificationViews(createNotificationViews(key, notification));
|
||||
private void addNotificationViews(StatusBarNotification notification) {
|
||||
addNotificationViews(createNotificationViews(notification));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1192,7 +1185,7 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
protected abstract void haltTicker();
|
||||
protected abstract void setAreThereNotifications();
|
||||
protected abstract void updateNotificationIcons();
|
||||
protected abstract void tick(IBinder key, StatusBarNotification n, boolean firstTime);
|
||||
protected abstract void tick(StatusBarNotification n, boolean firstTime);
|
||||
protected abstract void updateExpandedViewPos(int expandedPosition);
|
||||
protected abstract boolean shouldDisableNavbarGestures();
|
||||
|
||||
@@ -1200,12 +1193,12 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
return parent != null && parent.indexOfChild(entry.row) == 0;
|
||||
}
|
||||
|
||||
public void updateNotification(IBinder key, StatusBarNotification notification) {
|
||||
if (DEBUG) Log.d(TAG, "updateNotification(" + key + " -> " + notification + ")");
|
||||
public void updateNotification(StatusBarNotification notification) {
|
||||
if (DEBUG) Log.d(TAG, "updateNotification(" + notification + ")");
|
||||
|
||||
final NotificationData.Entry oldEntry = mNotificationData.findByKey(key);
|
||||
final NotificationData.Entry oldEntry = mNotificationData.findByKey(notification.getKey());
|
||||
if (oldEntry == null) {
|
||||
Log.w(TAG, "updateNotification for unknown key: " + key);
|
||||
Log.w(TAG, "updateNotification for unknown key: " + notification.getKey());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1284,7 +1277,7 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
boolean isTopAnyway = isTopNotification(rowParent, oldEntry);
|
||||
if (contentsUnchanged && bigContentsUnchanged && headsUpContentsUnchanged && publicUnchanged
|
||||
&& (orderUnchanged || isTopAnyway)) {
|
||||
if (DEBUG) Log.d(TAG, "reusing notification for key: " + key);
|
||||
if (DEBUG) Log.d(TAG, "reusing notification for key: " + notification.getKey());
|
||||
oldEntry.notification = notification;
|
||||
try {
|
||||
updateNotificationViews(oldEntry, notification);
|
||||
@@ -1308,7 +1301,7 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
notification.getNotification().number,
|
||||
notification.getNotification().tickerText);
|
||||
if (!oldEntry.icon.set(ic)) {
|
||||
handleNotificationError(key, notification, "Couldn't update icon: " + ic);
|
||||
handleNotificationError(notification, "Couldn't update icon: " + ic);
|
||||
return;
|
||||
}
|
||||
updateRowStates();
|
||||
@@ -1316,17 +1309,18 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
catch (RuntimeException e) {
|
||||
// It failed to add cleanly. Log, and remove the view from the panel.
|
||||
Log.w(TAG, "Couldn't reapply views for package " + contentView.getPackage(), e);
|
||||
removeNotificationViews(key);
|
||||
addNotificationViews(key, notification);
|
||||
removeNotificationViews(notification.getKey());
|
||||
addNotificationViews(notification);
|
||||
}
|
||||
} else {
|
||||
if (DEBUG) Log.d(TAG, "not reusing notification for key: " + key);
|
||||
if (DEBUG) Log.d(TAG, "not reusing notification for key: " + notification.getKey());
|
||||
if (DEBUG) Log.d(TAG, "contents was " + (contentsUnchanged ? "unchanged" : "changed"));
|
||||
if (DEBUG) Log.d(TAG, "order was " + (orderUnchanged ? "unchanged" : "changed"));
|
||||
if (DEBUG) Log.d(TAG, "notification is " + (isTopAnyway ? "top" : "not top"));
|
||||
removeNotificationViews(key);
|
||||
addNotificationViews(key, notification); // will also replace the heads up
|
||||
final NotificationData.Entry newEntry = mNotificationData.findByKey(key);
|
||||
removeNotificationViews(notification.getKey());
|
||||
addNotificationViews(notification); // will also replace the heads up
|
||||
final NotificationData.Entry newEntry = mNotificationData.findByKey(
|
||||
notification.getKey());
|
||||
final boolean userChangedExpansion = oldEntry.row.hasUserChangedExpansion();
|
||||
if (userChangedExpansion) {
|
||||
boolean userExpanded = oldEntry.row.isUserExpanded();
|
||||
@@ -1346,7 +1340,7 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
// Restart the ticker if it's still running
|
||||
if (updateTicker && isForCurrentUser) {
|
||||
haltTicker();
|
||||
tick(key, notification, false);
|
||||
tick(notification, false);
|
||||
}
|
||||
|
||||
// Recalculate the position of the sliding windows and the titles.
|
||||
|
||||
@@ -21,7 +21,6 @@ import android.os.IBinder;
|
||||
import android.os.Message;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
|
||||
import com.android.internal.policy.IKeyguardShowCallback;
|
||||
import com.android.internal.statusbar.IStatusBar;
|
||||
import com.android.internal.statusbar.StatusBarIcon;
|
||||
import com.android.internal.statusbar.StatusBarIconList;
|
||||
@@ -73,11 +72,6 @@ public class CommandQueue extends IStatusBar.Stub {
|
||||
private Callbacks mCallbacks;
|
||||
private Handler mHandler = new H();
|
||||
|
||||
private class NotificationQueueEntry {
|
||||
IBinder key;
|
||||
StatusBarNotification notification;
|
||||
}
|
||||
|
||||
/**
|
||||
* These methods are called back on the main thread.
|
||||
*/
|
||||
@@ -86,9 +80,9 @@ public class CommandQueue extends IStatusBar.Stub {
|
||||
public void updateIcon(String slot, int index, int viewIndex,
|
||||
StatusBarIcon old, StatusBarIcon icon);
|
||||
public void removeIcon(String slot, int index, int viewIndex);
|
||||
public void addNotification(IBinder key, StatusBarNotification notification);
|
||||
public void updateNotification(IBinder key, StatusBarNotification notification);
|
||||
public void removeNotification(IBinder key);
|
||||
public void addNotification(StatusBarNotification notification);
|
||||
public void updateNotification(StatusBarNotification notification);
|
||||
public void removeNotification(String key);
|
||||
public void disable(int state);
|
||||
public void animateExpandNotificationsPanel();
|
||||
public void animateCollapsePanels(int flags);
|
||||
@@ -106,7 +100,6 @@ public class CommandQueue extends IStatusBar.Stub {
|
||||
public void showSearchPanel();
|
||||
public void hideSearchPanel();
|
||||
public void setWindowState(int window, int state);
|
||||
|
||||
}
|
||||
|
||||
public CommandQueue(Callbacks callbacks, StatusBarIconList list) {
|
||||
@@ -130,25 +123,21 @@ public class CommandQueue extends IStatusBar.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
public void addNotification(IBinder key, StatusBarNotification notification) {
|
||||
@Override
|
||||
public void addNotification(StatusBarNotification notification) {
|
||||
synchronized (mList) {
|
||||
NotificationQueueEntry ne = new NotificationQueueEntry();
|
||||
ne.key = key;
|
||||
ne.notification = notification;
|
||||
mHandler.obtainMessage(MSG_ADD_NOTIFICATION, 0, 0, ne).sendToTarget();
|
||||
mHandler.obtainMessage(MSG_ADD_NOTIFICATION, 0, 0, notification).sendToTarget();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateNotification(IBinder key, StatusBarNotification notification) {
|
||||
@Override
|
||||
public void updateNotification(StatusBarNotification notification) {
|
||||
synchronized (mList) {
|
||||
NotificationQueueEntry ne = new NotificationQueueEntry();
|
||||
ne.key = key;
|
||||
ne.notification = notification;
|
||||
mHandler.obtainMessage(MSG_UPDATE_NOTIFICATION, 0, 0, ne).sendToTarget();
|
||||
mHandler.obtainMessage(MSG_UPDATE_NOTIFICATION, 0, 0, notification).sendToTarget();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeNotification(IBinder key) {
|
||||
public void removeNotification(String key) {
|
||||
synchronized (mList) {
|
||||
mHandler.obtainMessage(MSG_REMOVE_NOTIFICATION, 0, 0, key).sendToTarget();
|
||||
}
|
||||
@@ -291,17 +280,15 @@ public class CommandQueue extends IStatusBar.Stub {
|
||||
break;
|
||||
}
|
||||
case MSG_ADD_NOTIFICATION: {
|
||||
final NotificationQueueEntry ne = (NotificationQueueEntry)msg.obj;
|
||||
mCallbacks.addNotification(ne.key, ne.notification);
|
||||
mCallbacks.addNotification((StatusBarNotification) msg.obj);
|
||||
break;
|
||||
}
|
||||
case MSG_UPDATE_NOTIFICATION: {
|
||||
final NotificationQueueEntry ne = (NotificationQueueEntry)msg.obj;
|
||||
mCallbacks.updateNotification(ne.key, ne.notification);
|
||||
mCallbacks.updateNotification((StatusBarNotification) msg.obj);
|
||||
break;
|
||||
}
|
||||
case MSG_REMOVE_NOTIFICATION: {
|
||||
mCallbacks.removeNotification((IBinder)msg.obj);
|
||||
mCallbacks.removeNotification((String) msg.obj);
|
||||
break;
|
||||
}
|
||||
case MSG_DISABLE:
|
||||
|
||||
@@ -18,8 +18,6 @@ package com.android.systemui.statusbar;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.content.Context;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.os.Process;
|
||||
import android.provider.Settings;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
@@ -33,13 +31,14 @@ import com.android.systemui.statusbar.phone.PhoneStatusBar;
|
||||
public class InterceptedNotifications {
|
||||
private static final String TAG = "InterceptedNotifications";
|
||||
private static final String EXTRA_INTERCEPT = "android.intercept";
|
||||
private static final String SYNTHETIC_KEY = "InterceptedNotifications.SYNTHETIC_KEY";
|
||||
|
||||
private final Context mContext;
|
||||
private final PhoneStatusBar mBar;
|
||||
private final ArrayMap<IBinder, StatusBarNotification> mIntercepted
|
||||
= new ArrayMap<IBinder, StatusBarNotification>();
|
||||
private final ArrayMap<String, StatusBarNotification> mIntercepted
|
||||
= new ArrayMap<String, StatusBarNotification>();
|
||||
|
||||
private Binder mSynKey;
|
||||
private String mSynKey;
|
||||
|
||||
public InterceptedNotifications(Context context, PhoneStatusBar bar) {
|
||||
mContext = context;
|
||||
@@ -49,36 +48,35 @@ public class InterceptedNotifications {
|
||||
public void releaseIntercepted() {
|
||||
final int n = mIntercepted.size();
|
||||
for (int i = 0; i < n; i++) {
|
||||
final IBinder key = mIntercepted.keyAt(i);
|
||||
final StatusBarNotification sbn = mIntercepted.valueAt(i);
|
||||
sbn.getNotification().extras.putBoolean(EXTRA_INTERCEPT, false);
|
||||
mBar.addNotification(key, sbn);
|
||||
mBar.addNotification(sbn);
|
||||
}
|
||||
mIntercepted.clear();
|
||||
updateSyntheticNotification();
|
||||
}
|
||||
|
||||
public boolean tryIntercept(IBinder key, StatusBarNotification notification) {
|
||||
public boolean tryIntercept(StatusBarNotification notification) {
|
||||
if (!notification.getNotification().extras.getBoolean(EXTRA_INTERCEPT)) return false;
|
||||
if (shouldDisplayIntercepted()) return false;
|
||||
mIntercepted.put(key, notification);
|
||||
mIntercepted.put(notification.getKey(), notification);
|
||||
updateSyntheticNotification();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void remove(IBinder key) {
|
||||
public void remove(String key) {
|
||||
if (mIntercepted.remove(key) != null) {
|
||||
updateSyntheticNotification();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSyntheticEntry(Entry ent) {
|
||||
return mSynKey != null && ent.key.equals(mSynKey);
|
||||
return ent.key.equals(SYNTHETIC_KEY);
|
||||
}
|
||||
|
||||
public void update(IBinder key, StatusBarNotification notification) {
|
||||
if (mIntercepted.containsKey(key)) {
|
||||
mIntercepted.put(key, notification);
|
||||
public void update(StatusBarNotification notification) {
|
||||
if (mIntercepted.containsKey(notification.getKey())) {
|
||||
mIntercepted.put(notification.getKey(), notification);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,10 +106,10 @@ public class InterceptedNotifications {
|
||||
TAG.hashCode(), TAG, Process.myUid(), Process.myPid(), 0, n,
|
||||
mBar.getCurrentUserHandle());
|
||||
if (mSynKey == null) {
|
||||
mSynKey = new Binder();
|
||||
mBar.addNotification(mSynKey, sbn);
|
||||
mSynKey = sbn.getKey();
|
||||
mBar.addNotification(sbn);
|
||||
} else {
|
||||
mBar.updateNotification(mSynKey, sbn);
|
||||
mBar.updateNotification(sbn);
|
||||
}
|
||||
final NotificationData.Entry entry = mBar.mNotificationData.findByKey(mSynKey);
|
||||
entry.row.setOnClickListener(mSynClickListener);
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.systemui.statusbar;
|
||||
|
||||
import android.os.IBinder;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
@@ -29,7 +28,7 @@ import java.util.Comparator;
|
||||
*/
|
||||
public class NotificationData {
|
||||
public static final class Entry {
|
||||
public IBinder key;
|
||||
public String key;
|
||||
public StatusBarNotification notification;
|
||||
public StatusBarIconView icon;
|
||||
public ExpandableNotificationRow row; // the outer expanded view
|
||||
@@ -39,8 +38,8 @@ public class NotificationData {
|
||||
public View expandedBig;
|
||||
private boolean interruption;
|
||||
public Entry() {}
|
||||
public Entry(IBinder key, StatusBarNotification n, StatusBarIconView ic) {
|
||||
this.key = key;
|
||||
public Entry(StatusBarNotification n, StatusBarIconView ic) {
|
||||
this.key = n.getKey();
|
||||
this.notification = n;
|
||||
this.icon = ic;
|
||||
}
|
||||
@@ -63,6 +62,7 @@ public class NotificationData {
|
||||
interruption = true;
|
||||
}
|
||||
}
|
||||
|
||||
private final ArrayList<Entry> mEntries = new ArrayList<Entry>();
|
||||
private final Comparator<Entry> mEntryCmp = new Comparator<Entry>() {
|
||||
// sort first by score, then by when
|
||||
@@ -88,9 +88,9 @@ public class NotificationData {
|
||||
return mEntries.get(i);
|
||||
}
|
||||
|
||||
public Entry findByKey(IBinder key) {
|
||||
public Entry findByKey(String key) {
|
||||
for (Entry e : mEntries) {
|
||||
if (e.key == key) {
|
||||
if (e.key.equals(key)) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public class NotificationData {
|
||||
public int add(Entry entry) {
|
||||
int i;
|
||||
int N = mEntries.size();
|
||||
for (i=0; i<N; i++) {
|
||||
for (i = 0; i < N; i++) {
|
||||
if (mEntryCmp.compare(mEntries.get(i), entry) > 0) {
|
||||
break;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ public class NotificationData {
|
||||
return i;
|
||||
}
|
||||
|
||||
public Entry remove(IBinder key) {
|
||||
public Entry remove(String key) {
|
||||
Entry e = findByKey(key);
|
||||
if (e != null) {
|
||||
mEntries.remove(e);
|
||||
|
||||
@@ -1028,18 +1028,19 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
||||
return new UserHandle(mCurrentUserId);
|
||||
}
|
||||
|
||||
public void addNotification(IBinder key, StatusBarNotification notification) {
|
||||
@Override
|
||||
public void addNotification(StatusBarNotification notification) {
|
||||
if (DEBUG) Log.d(TAG, "addNotification score=" + notification.getScore());
|
||||
Entry shadeEntry = createNotificationViews(key, notification);
|
||||
Entry shadeEntry = createNotificationViews(notification);
|
||||
if (shadeEntry == null) {
|
||||
return;
|
||||
}
|
||||
if (mZenMode != Global.ZEN_MODE_OFF && mIntercepted.tryIntercept(key, notification)) {
|
||||
if (mZenMode != Global.ZEN_MODE_OFF && mIntercepted.tryIntercept(notification)) {
|
||||
return;
|
||||
}
|
||||
if (mUseHeadsUp && shouldInterrupt(notification)) {
|
||||
if (DEBUG) Log.d(TAG, "launching notification in heads up mode");
|
||||
Entry interruptionCandidate = new Entry(key, notification, null);
|
||||
Entry interruptionCandidate = new Entry(notification, null);
|
||||
ViewGroup holder = mHeadsUpNotificationView.getHolder();
|
||||
if (inflateViewsForHeadsUp(interruptionCandidate, holder)) {
|
||||
mInterruptingNotificationTime = System.currentTimeMillis();
|
||||
@@ -1071,7 +1072,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
||||
|
||||
// show the ticker if there isn't already a heads up
|
||||
if (mInterruptingNotificationEntry == null) {
|
||||
tick(null, notification, true);
|
||||
tick(notification, true);
|
||||
}
|
||||
}
|
||||
addNotificationViews(shadeEntry);
|
||||
@@ -1090,12 +1091,13 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNotification(IBinder key, StatusBarNotification notification) {
|
||||
super.updateNotification(key, notification);
|
||||
mIntercepted.update(key, notification);
|
||||
public void updateNotification(StatusBarNotification notification) {
|
||||
super.updateNotification(notification);
|
||||
mIntercepted.update(notification);
|
||||
}
|
||||
|
||||
public void removeNotification(IBinder key) {
|
||||
@Override
|
||||
public void removeNotification(String key) {
|
||||
StatusBarNotification old = removeNotificationViews(key);
|
||||
if (SPEW) Log.d(TAG, "removeNotification key=" + key + " old=" + old);
|
||||
|
||||
@@ -2020,7 +2022,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
||||
public void setHardKeyboardStatus(boolean available, boolean enabled) {}
|
||||
|
||||
@Override
|
||||
protected void tick(IBinder key, StatusBarNotification n, boolean firstTime) {
|
||||
protected void tick(StatusBarNotification n, boolean firstTime) {
|
||||
// no ticking in lights-out mode
|
||||
if (!areLightsOn()) return;
|
||||
|
||||
|
||||
@@ -46,15 +46,15 @@ public class TvStatusBar extends BaseStatusBar {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNotification(IBinder key, StatusBarNotification notification) {
|
||||
public void addNotification(StatusBarNotification notification) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNotification(IBinder key, StatusBarNotification notification) {
|
||||
public void updateNotification(StatusBarNotification notification) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNotification(IBinder key) {
|
||||
public void removeNotification(String key) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -113,7 +113,7 @@ public class TvStatusBar extends BaseStatusBar {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tick(IBinder key, StatusBarNotification n, boolean firstTime) {
|
||||
protected void tick(StatusBarNotification n, boolean firstTime) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -457,7 +457,7 @@ public class NotificationManagerService extends SystemService {
|
||||
{
|
||||
final StatusBarNotification sbn;
|
||||
SingleNotificationStats stats;
|
||||
IBinder statusBarKey;
|
||||
boolean isCanceled;
|
||||
|
||||
// These members are used by NotificationSignalExtractors
|
||||
// to communicate with the ranking module.
|
||||
@@ -472,6 +472,7 @@ public class NotificationManagerService extends SystemService {
|
||||
public Notification getNotification() { return sbn.getNotification(); }
|
||||
public int getFlags() { return sbn.getNotification().flags; }
|
||||
public int getUserId() { return sbn.getUserId(); }
|
||||
public String getKey() { return sbn.getKey(); }
|
||||
|
||||
void dump(PrintWriter pw, String prefix, Context baseContext) {
|
||||
final Notification notification = sbn.getNotification();
|
||||
@@ -1668,7 +1669,7 @@ public class NotificationManagerService extends SystemService {
|
||||
"pkg=" + pkg + " canInterrupt=" + canInterrupt + " intercept=" + intercept);
|
||||
synchronized (mNotificationList) {
|
||||
NotificationRecord old = null;
|
||||
int index = indexOfNotificationLocked(pkg, tag, id, userId);
|
||||
int index = indexOfNotificationLocked(n.getKey());
|
||||
if (index < 0) {
|
||||
mNotificationList.add(r);
|
||||
mUsageStats.registerPostedByApp(r);
|
||||
@@ -1677,12 +1678,8 @@ public class NotificationManagerService extends SystemService {
|
||||
mNotificationList.set(index, r);
|
||||
mUsageStats.registerUpdatedByApp(r, old);
|
||||
// Make sure we don't lose the foreground service state.
|
||||
if (old != null) {
|
||||
notification.flags |=
|
||||
old.getNotification().flags & Notification.FLAG_FOREGROUND_SERVICE;
|
||||
}
|
||||
}
|
||||
if (old != null) {
|
||||
notification.flags |=
|
||||
old.getNotification().flags & Notification.FLAG_FOREGROUND_SERVICE;
|
||||
mNotificationsByKey.remove(old.sbn.getKey());
|
||||
}
|
||||
mNotificationsByKey.put(n.getKey(), r);
|
||||
@@ -1705,18 +1702,17 @@ public class NotificationManagerService extends SystemService {
|
||||
}
|
||||
|
||||
if (notification.icon != 0) {
|
||||
if (old != null && old.statusBarKey != null) {
|
||||
r.statusBarKey = old.statusBarKey;
|
||||
if (old != null && !old.isCanceled) {
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
mStatusBar.updateNotification(r.statusBarKey, n);
|
||||
mStatusBar.updateNotification(n);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(identity);
|
||||
}
|
||||
} else {
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
r.statusBarKey = mStatusBar.addNotification(n);
|
||||
mStatusBar.addNotification(n);
|
||||
if ((n.getNotification().flags & Notification.FLAG_SHOW_LIGHTS) != 0
|
||||
&& canInterrupt) {
|
||||
mAttentionLight.pulse();
|
||||
@@ -1733,10 +1729,10 @@ public class NotificationManagerService extends SystemService {
|
||||
mListeners.notifyPostedLocked(r.sbn, cloneNotificationListLocked());
|
||||
} else {
|
||||
Slog.e(TAG, "Not posting notification with icon==0: " + notification);
|
||||
if (old != null && old.statusBarKey != null) {
|
||||
if (old != null && !old.isCanceled) {
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
mStatusBar.removeNotification(old.statusBarKey);
|
||||
mStatusBar.removeNotification(r.getKey());
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(identity);
|
||||
}
|
||||
@@ -2120,11 +2116,11 @@ public class NotificationManagerService extends SystemService {
|
||||
if (r.getNotification().icon != 0) {
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
mStatusBar.removeNotification(r.statusBarKey);
|
||||
mStatusBar.removeNotification(r.getKey());
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(identity);
|
||||
}
|
||||
r.statusBarKey = null;
|
||||
r.isCanceled = true;
|
||||
mListeners.notifyRemovedLocked(r.sbn, cloneNotificationListLocked());
|
||||
}
|
||||
|
||||
@@ -2392,6 +2388,18 @@ public class NotificationManagerService extends SystemService {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// lock on mNotificationList
|
||||
int indexOfNotificationLocked(String key) {
|
||||
NotificationRecord r = mNotificationsByKey.get(key);
|
||||
if (r == null) {
|
||||
return -1;
|
||||
}
|
||||
int index = Collections.binarySearch(mNotificationList, r, mRankingComparator);
|
||||
// Guarantee to return -1 when not found.
|
||||
return (index >= 0) ? index : -1;
|
||||
}
|
||||
|
||||
|
||||
private void updateNotificationPulse() {
|
||||
synchronized (mNotificationList) {
|
||||
updateLightsLocked();
|
||||
|
||||
@@ -23,7 +23,7 @@ import android.service.notification.StatusBarNotification;
|
||||
|
||||
public interface StatusBarManagerInternal {
|
||||
void setNotificationDelegate(NotificationDelegate delegate);
|
||||
IBinder addNotification(StatusBarNotification notification);
|
||||
void updateNotification(IBinder key, StatusBarNotification notification);
|
||||
void removeNotification(IBinder key);
|
||||
void addNotification(StatusBarNotification notification);
|
||||
void updateNotification(StatusBarNotification notification);
|
||||
void removeNotification(String key);
|
||||
}
|
||||
|
||||
@@ -60,8 +60,8 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
private NotificationDelegate mNotificationDelegate;
|
||||
private volatile IStatusBar mBar;
|
||||
private StatusBarIconList mIcons = new StatusBarIconList();
|
||||
private HashMap<IBinder,StatusBarNotification> mNotifications
|
||||
= new HashMap<IBinder,StatusBarNotification>();
|
||||
private HashMap<String,StatusBarNotification> mNotifications
|
||||
= new HashMap<String,StatusBarNotification>();
|
||||
|
||||
// for disabling the status bar
|
||||
private final ArrayList<DisableRecord> mDisableRecords = new ArrayList<DisableRecord>();
|
||||
@@ -117,30 +117,29 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder addNotification(StatusBarNotification notification) {
|
||||
public void addNotification(StatusBarNotification notification) {
|
||||
synchronized (mNotifications) {
|
||||
IBinder key = new Binder();
|
||||
mNotifications.put(key, notification);
|
||||
mNotifications.put(notification.getKey(), notification);
|
||||
if (mBar != null) {
|
||||
try {
|
||||
mBar.addNotification(key, notification);
|
||||
mBar.addNotification(notification);
|
||||
} catch (RemoteException ex) {
|
||||
}
|
||||
}
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNotification(IBinder key, StatusBarNotification notification) {
|
||||
public void updateNotification(StatusBarNotification notification) {
|
||||
synchronized (mNotifications) {
|
||||
String key = notification.getKey();
|
||||
if (!mNotifications.containsKey(key)) {
|
||||
throw new IllegalArgumentException("updateNotification key not found: " + key);
|
||||
}
|
||||
mNotifications.put(key, notification);
|
||||
mNotifications.put(notification.getKey(), notification);
|
||||
if (mBar != null) {
|
||||
try {
|
||||
mBar.updateNotification(key, notification);
|
||||
mBar.updateNotification(notification);
|
||||
} catch (RemoteException ex) {
|
||||
}
|
||||
}
|
||||
@@ -148,7 +147,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNotification(IBinder key) {
|
||||
public void removeNotification(String key) {
|
||||
synchronized (mNotifications) {
|
||||
final StatusBarNotification n = mNotifications.remove(key);
|
||||
if (n == null) {
|
||||
@@ -512,8 +511,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
// ================================================================================
|
||||
@Override
|
||||
public void registerStatusBar(IStatusBar bar, StatusBarIconList iconList,
|
||||
List<IBinder> notificationKeys, List<StatusBarNotification> notifications,
|
||||
int switches[], List<IBinder> binders) {
|
||||
List<StatusBarNotification> notifications, int switches[], List<IBinder> binders) {
|
||||
enforceStatusBarService();
|
||||
|
||||
Slog.i(TAG, "registerStatusBar bar=" + bar);
|
||||
@@ -522,9 +520,8 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
iconList.copyFrom(mIcons);
|
||||
}
|
||||
synchronized (mNotifications) {
|
||||
for (Map.Entry<IBinder,StatusBarNotification> e: mNotifications.entrySet()) {
|
||||
notificationKeys.add(e.getKey());
|
||||
notifications.add(e.getValue());
|
||||
for (StatusBarNotification sbn : mNotifications.values()) {
|
||||
notifications.add(sbn);
|
||||
}
|
||||
}
|
||||
synchronized (mLock) {
|
||||
@@ -714,7 +711,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
synchronized (mNotifications) {
|
||||
int i=0;
|
||||
pw.println("Notification list:");
|
||||
for (Map.Entry<IBinder,StatusBarNotification> e: mNotifications.entrySet()) {
|
||||
for (Map.Entry<String,StatusBarNotification> e: mNotifications.entrySet()) {
|
||||
pw.printf(" %2d: %s\n", i, e.getValue().toString());
|
||||
i++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user