diff options
author | Joe Onorato <joeo@android.com> | 2010-05-20 10:21:52 -0700 |
---|---|---|
committer | Joe Onorato <joeo@android.com> | 2010-06-02 14:48:43 -0700 |
commit | a0c56fe93925d20d9c0b830b9664699ce557e78c (patch) | |
tree | b31ff5bb17a888e609a4dbc51de8651252bc7b67 | |
parent | 18e69dfc7235f8a4bfe257f9d1c43539049a22ce (diff) | |
download | frameworks_base-a0c56fe93925d20d9c0b830b9664699ce557e78c.zip frameworks_base-a0c56fe93925d20d9c0b830b9664699ce557e78c.tar.gz frameworks_base-a0c56fe93925d20d9c0b830b9664699ce557e78c.tar.bz2 |
Checkpoint. Doesn't build.
Change-Id: I92e4d539ea71af9e22ced02cbdee7fbd456b7971
-rw-r--r-- | core/java/com/android/internal/statusbar/IStatusBar.aidl | 4 | ||||
-rw-r--r-- | core/java/com/android/internal/statusbar/StatusBarNotification.aidl | 20 | ||||
-rw-r--r-- | core/java/com/android/internal/statusbar/StatusBarNotification.java | 2 | ||||
-rw-r--r-- | core/java/com/android/internal/statusbar/StatusBarNotificationList.java | 13 | ||||
-rw-r--r-- | packages/StatusBarPhone/src/com/android/policy/statusbar/phone/CommandQueue.java | 58 | ||||
-rw-r--r-- | packages/StatusBarPhone/src/com/android/policy/statusbar/phone/NotificationViewList.java | 276 | ||||
-rw-r--r-- | packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java | 63 | ||||
-rw-r--r-- | services/java/com/android/server/status/DisableRecords.java (renamed from packages/StatusBarPhone/src/com/android/policy/statusbar/phone/StatusBarNotification.java) | 12 | ||||
-rw-r--r-- | services/java/com/android/server/status/StatusBarManagerService.java | 3 |
9 files changed, 101 insertions, 350 deletions
diff --git a/core/java/com/android/internal/statusbar/IStatusBar.aidl b/core/java/com/android/internal/statusbar/IStatusBar.aidl index 2127b3b..4501bd7 100644 --- a/core/java/com/android/internal/statusbar/IStatusBar.aidl +++ b/core/java/com/android/internal/statusbar/IStatusBar.aidl @@ -17,12 +17,16 @@ package com.android.internal.statusbar; import com.android.internal.statusbar.StatusBarIcon; +import com.android.internal.statusbar.StatusBarNotification; /** @hide */ 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 disable(int state); void animateExpand(); void animateCollapse(); diff --git a/core/java/com/android/internal/statusbar/StatusBarNotification.aidl b/core/java/com/android/internal/statusbar/StatusBarNotification.aidl new file mode 100644 index 0000000..bd9e89c --- /dev/null +++ b/core/java/com/android/internal/statusbar/StatusBarNotification.aidl @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2010, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.statusbar; + +parcelable StatusBarNotification; + diff --git a/core/java/com/android/internal/statusbar/StatusBarNotification.java b/core/java/com/android/internal/statusbar/StatusBarNotification.java index ba1525e..edb5f52 100644 --- a/core/java/com/android/internal/statusbar/StatusBarNotification.java +++ b/core/java/com/android/internal/statusbar/StatusBarNotification.java @@ -38,7 +38,7 @@ public class StatusBarNotification implements Parcelable { public String pkg; public int id; public String tag; - Notification notification; + public Notification notification; public StatusBarNotification() { } diff --git a/core/java/com/android/internal/statusbar/StatusBarNotificationList.java b/core/java/com/android/internal/statusbar/StatusBarNotificationList.java index 2b70f5f..37f5f63 100644 --- a/core/java/com/android/internal/statusbar/StatusBarNotificationList.java +++ b/core/java/com/android/internal/statusbar/StatusBarNotificationList.java @@ -24,6 +24,9 @@ import android.os.Parcelable; import java.io.PrintWriter; import java.util.ArrayList; +/** + * Contains a list of status bar notifications and IBinder keys in no particular order. + */ public class StatusBarNotificationList implements Parcelable { private class Entry { IBinder key; @@ -116,17 +119,14 @@ public class StatusBarNotificationList implements Parcelable { return mEntries.size(); } - public IBinder add(StatusBarNotification notification) { + public void add(IBinder key, StatusBarNotification notification) { if (notification == null) throw new NullPointerException(); Entry entry = new Entry(); - entry.key = new Binder(); + entry.key = key; entry.notification = notification.clone(); - // TODO: Sort correctly by "when" mEntries.add(entry); - - return entry.key; } public void update(IBinder key, StatusBarNotification notification) { @@ -134,8 +134,7 @@ public class StatusBarNotificationList implements Parcelable { if (index < 0) { throw new IllegalArgumentException("got invalid key: " + key); } - final Entry entry = mEntries.get(index); - entry.notification = notification.clone(); + mEntries.get(index).notification = notification.clone(); } public void remove(IBinder key) { diff --git a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/CommandQueue.java b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/CommandQueue.java index 00ad77c..94b992a 100644 --- a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/CommandQueue.java +++ b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/CommandQueue.java @@ -17,12 +17,15 @@ package com.android.policy.statusbar.phone; import android.os.Handler; +import android.os.IBinder; import android.os.Message; import android.util.Slog; import com.android.internal.statusbar.IStatusBar; import com.android.internal.statusbar.StatusBarIcon; import com.android.internal.statusbar.StatusBarIconList; +import com.android.internal.statusbar.StatusBarNotification; +import com.android.internal.statusbar.StatusBarNotificationList; /** * This class takes the functions from IStatusBar that come in on @@ -41,9 +44,13 @@ class CommandQueue extends IStatusBar.Stub { private static final int OP_SET_ICON = 1; private static final int OP_REMOVE_ICON = 2; - private static final int MSG_DISABLE = 0x00020000; + private static final int MSG_ADD_NOTIFICATION = 0x00020000; + private static final int MSG_UPDATE_NOTIFICATION = 0x00030000; + private static final int MSG_REMOVE_NOTIFICATION = 0x00040000; - private static final int MSG_SET_VISIBILITY = 0x00030000; + private static final int MSG_DISABLE = 0x00050000; + + private static final int MSG_SET_VISIBILITY = 0x00060000; private static final int OP_EXPAND = 1; private static final int OP_COLLAPSE = 2; @@ -51,6 +58,11 @@ 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. */ @@ -59,6 +71,9 @@ 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 disable(int state); public void animateExpand(); public void animateCollapse(); @@ -85,6 +100,30 @@ class CommandQueue extends IStatusBar.Stub { } } + public void addNotification(IBinder key, StatusBarNotification notification) { + synchronized (mList) { + NotificationQueueEntry ne = new NotificationQueueEntry(); + ne.key = key; + ne.notification = notification; + mHandler.obtainMessage(MSG_ADD_NOTIFICATION, 0, 0, ne).sendToTarget(); + } + } + + public void updateNotification(IBinder key, StatusBarNotification notification) { + synchronized (mList) { + NotificationQueueEntry ne = new NotificationQueueEntry(); + ne.key = key; + ne.notification = notification; + mHandler.obtainMessage(MSG_UPDATE_NOTIFICATION, 0, 0, ne).sendToTarget(); + } + } + + public void removeNotification(IBinder key) { + synchronized (mList) { + mHandler.obtainMessage(MSG_REMOVE_NOTIFICATION, 0, 0, key).sendToTarget(); + } + } + public void disable(int state) { synchronized (mList) { mHandler.removeMessages(MSG_DISABLE); @@ -135,6 +174,20 @@ class CommandQueue extends IStatusBar.Stub { } break; } + case MSG_ADD_NOTIFICATION: { + final NotificationQueueEntry ne = (NotificationQueueEntry)msg.obj; + mCallbacks.addNotification(ne.key, ne.notification); + break; + } + case MSG_UPDATE_NOTIFICATION: { + final NotificationQueueEntry ne = (NotificationQueueEntry)msg.obj; + mCallbacks.updateNotification(ne.key, ne.notification); + break; + } + case MSG_REMOVE_NOTIFICATION: { + mCallbacks.removeNotification((IBinder)msg.obj); + break; + } case MSG_DISABLE: mCallbacks.disable(msg.arg1); break; @@ -149,4 +202,3 @@ class CommandQueue extends IStatusBar.Stub { } } - diff --git a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/NotificationViewList.java b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/NotificationViewList.java deleted file mode 100644 index 300d58b..0000000 --- a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/NotificationViewList.java +++ /dev/null @@ -1,276 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.policy.statusbar.phone; - -import android.os.IBinder; -import android.util.Slog; -import android.view.View; -import java.util.ArrayList; - -public class NotificationViewList { - private ArrayList<StatusBarNotification> mOngoing = new ArrayList(); - private ArrayList<StatusBarNotification> mLatest = new ArrayList(); - - public NotificationViewList() { - } - - private static final int indexInList(ArrayList<StatusBarNotification> list, NotificationData n){ - final int N = list.size(); - for (int i=0; i<N; i++) { - StatusBarNotification that = list.get(i); - if (that.data == n) { - return i; - } - } - return -1; - } - - int getIconIndex(NotificationData n) { - final int ongoingSize = mOngoing.size(); - final int latestSize = mLatest.size(); - if (n.ongoingEvent) { - int index = indexInList(mOngoing, n); - if (index >= 0) { - return latestSize + index + 1; - } else { - return -1; - } - } else { - return indexInList(mLatest, n) + 1; - } - } - - void remove(StatusBarNotification notification) { - NotificationData n = notification.data; - int index; - index = indexInList(mOngoing, n); - if (index >= 0) { - mOngoing.remove(index); - return; - } - index = indexInList(mLatest, n); - if (index >= 0) { - mLatest.remove(index); - return; - } - } - - ArrayList<StatusBarNotification> notificationsForPackage(String packageName) { - ArrayList<StatusBarNotification> list = new ArrayList<StatusBarNotification>(); - int N = mOngoing.size(); - for (int i=0; i<N; i++) { - if (matchPackage(mOngoing.get(i), packageName)) { - list.add(mOngoing.get(i)); - } - } - N = mLatest.size(); - for (int i=0; i<N; i++) { - if (matchPackage(mLatest.get(i), packageName)) { - list.add(mLatest.get(i)); - } - } - return list; - } - - private final boolean matchPackage(StatusBarNotification snb, String packageName) { - if (snb.data.contentIntent != null) { - if (snb.data.contentIntent.getTargetPackage().equals(packageName)) { - return true; - } - } else if (snb.data.pkg != null && snb.data.pkg.equals(packageName)) { - return true; - } - return false; - } - - private static final int indexForKey(ArrayList<StatusBarNotification> list, IBinder key) { - final int N = list.size(); - for (int i=0; i<N; i++) { - if (list.get(i).key == key) { - return i; - } - } - return -1; - } - - StatusBarNotification get(IBinder key) { - int index; - index = indexForKey(mOngoing, key); - if (index >= 0) { - return mOngoing.get(index); - } - index = indexForKey(mLatest, key); - if (index >= 0) { - return mLatest.get(index); - } - return null; - } - - // gets the index of the notification's view in its expanded parent view - int getExpandedIndex(StatusBarNotification notification) { - ArrayList<StatusBarNotification> list = notification.data.ongoingEvent ? mOngoing : mLatest; - final IBinder key = notification.key; - int index = 0; - // (the view order is backwards from this list order) - for (int i=list.size()-1; i>=0; i--) { - StatusBarNotification item = list.get(i); - if (item.key == key) { - return index; - } - if (item.view != null) { - index++; - } - } - Slog.e(PhoneStatusBarService.TAG, "Couldn't find notification in NotificationViewList."); - Slog.e(PhoneStatusBarService.TAG, "notification=" + notification); - dump(notification); - return 0; - } - - void clearViews() { - int N = mOngoing.size(); - for (int i=0; i<N; i++) { - mOngoing.get(i).view = null; - } - N = mLatest.size(); - for (int i=0; i<N; i++) { - mLatest.get(i).view = null; - } - } - - int ongoingCount() { - return mOngoing.size(); - } - - int latestCount() { - return mLatest.size(); - } - - StatusBarNotification getOngoing(int index) { - return mOngoing.get(index); - } - - StatusBarNotification getLatest(int index) { - return mLatest.get(index); - } - - int size() { - return mOngoing.size() + mLatest.size(); - } - - void add(StatusBarNotification notification) { - if (PhoneStatusBarService.SPEW) { - Slog.d(PhoneStatusBarService.TAG, "before add NotificationViewList" - + " notification.data.ongoingEvent=" + notification.data.ongoingEvent); - dump(notification); - } - - ArrayList<StatusBarNotification> list = notification.data.ongoingEvent ? mOngoing : mLatest; - long when = notification.data.when; - final int N = list.size(); - int index = N; - for (int i=0; i<N; i++) { - StatusBarNotification that = list.get(i); - if (that.data.when > when) { - index = i; - break; - } - } - list.add(index, notification); - - if (PhoneStatusBarService.SPEW) { - Slog.d(PhoneStatusBarService.TAG, "after add NotificationViewList index=" + index); - dump(notification); - } - } - - void dump(StatusBarNotification notification) { - if (PhoneStatusBarService.SPEW) { - boolean showTime = false; - String s = ""; - for (int i=0; i<mOngoing.size(); i++) { - StatusBarNotification that = mOngoing.get(i); - if (that.key == notification.key) { - s += "["; - } - if (showTime) { - s += that.data.when; - } else { - s += that.data.pkg + "/" + that.data.id + "/" + that.view; - } - if (that.key == notification.key) { - s += "]"; - } - s += " "; - } - Slog.d(PhoneStatusBarService.TAG, "NotificationViewList ongoing: " + s); - - s = ""; - for (int i=0; i<mLatest.size(); i++) { - StatusBarNotification that = mLatest.get(i); - if (that.key == notification.key) { - s += "["; - } - if (showTime) { - s += that.data.when; - } else { - s += that.data.pkg + "/" + that.data.id + "/" + that.view; - } - if (that.key == notification.key) { - s += "]"; - } - s += " "; - } - Slog.d(PhoneStatusBarService.TAG, "NotificationViewList latest: " + s); - } - } - - StatusBarNotification get(View view) { - int N = mOngoing.size(); - for (int i=0; i<N; i++) { - StatusBarNotification notification = mOngoing.get(i); - View v = notification.view; - if (v == view) { - return notification; - } - } - N = mLatest.size(); - for (int i=0; i<N; i++) { - StatusBarNotification notification = mLatest.get(i); - View v = notification.view; - if (v == view) { - return notification; - } - } - return null; - } - - void update(StatusBarNotification notification) { - remove(notification); - add(notification); - } - - boolean hasClearableItems() { - int N = mLatest.size(); - for (int i=0; i<N; i++) { - if (mLatest.get(i).data.clearable) { - return true; - } - } - return false; - } -} diff --git a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java index 1ae3585..c626c45 100644 --- a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java +++ b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java @@ -20,6 +20,7 @@ import com.android.internal.util.CharSequences; import com.android.internal.statusbar.IStatusBar; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.statusbar.StatusBarIcon; +import com.android.internal.statusbar.StatusBarNotification; import android.app.ActivityManagerNative; import android.app.Dialog; @@ -124,7 +125,6 @@ public class PhoneStatusBarService extends StatusBarService { LinearLayout mIcons; IconMerger mNotificationIcons; LinearLayout mStatusIcons; - private UninstallReceiver mUninstallReceiver; // expanded notifications NotificationViewList mNotificationData = new NotificationViewList(); @@ -189,7 +189,6 @@ public class PhoneStatusBarService extends StatusBarService { // First set up our views and stuff. mDisplay = ((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); makeStatusBarView(this); - mUninstallReceiver = new UninstallReceiver(); // Next, call super.onCreate(), which will populate our views. super.onCreate(); @@ -317,6 +316,15 @@ public class PhoneStatusBarService extends StatusBarService { mStatusIcons.removeViewAt(viewIndex); } + public void addNotification(IBinder key, StatusBarNotification notification) { + } + + public void updateNotification(IBinder key, StatusBarNotification notification) { + } + + public void removeNotification(IBinder key) { + } + /** * State is one or more of the DISABLE constants from StatusBarManager. */ @@ -369,12 +377,6 @@ public class PhoneStatusBarService extends StatusBarService { } } - StatusBarNotification getNotification(IBinder key) { - synchronized (mNotificationData) { - return mNotificationData.get(key); - } - } - View.OnFocusChangeListener mFocusChangeListener = new View.OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { // Because 'v' is a ViewGroup, all its children will be (un)selected @@ -990,6 +992,7 @@ public class PhoneStatusBarService extends StatusBarService { + " scroll " + mScrollView.getScrollX() + "," + mScrollView.getScrollY()); pw.println("mNotificationLinearLayout: " + viewInfo(mNotificationLinearLayout)); } + /* synchronized (mNotificationData) { int N = mNotificationData.ongoingCount(); pw.println(" ongoingCount.size=" + N); @@ -1006,6 +1009,7 @@ public class PhoneStatusBarService extends StatusBarService { pw.println(" data=" + n.data); } } + */ if (false) { pw.println("see the logcat for a dump of the views we have created."); @@ -1365,47 +1369,4 @@ public class PhoneStatusBarService extends StatusBarService { vibrate(); } }; - - class UninstallReceiver extends BroadcastReceiver { - public UninstallReceiver() { - IntentFilter filter = new IntentFilter(); - filter.addAction(Intent.ACTION_PACKAGE_REMOVED); - filter.addAction(Intent.ACTION_PACKAGE_RESTARTED); - filter.addDataScheme("package"); - PhoneStatusBarService.this.registerReceiver(this, filter); - IntentFilter sdFilter = new IntentFilter(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE); - PhoneStatusBarService.this.registerReceiver(this, sdFilter); - } - - @Override - public void onReceive(Context context, Intent intent) { - String pkgList[] = null; - if (Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE.equals(intent.getAction())) { - pkgList = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST); - } else { - Uri data = intent.getData(); - if (data != null) { - String pkg = data.getSchemeSpecificPart(); - if (pkg != null) { - pkgList = new String[]{pkg}; - } - } - } - ArrayList<StatusBarNotification> list = null; - if (pkgList != null) { - synchronized (PhoneStatusBarService.this) { - for (String pkg : pkgList) { - list = mNotificationData.notificationsForPackage(pkg); - } - } - } - - if (list != null) { - final int N = list.size(); - for (int i=0; i<N; i++) { - //removeIcon(list.get(i).key); - } - } - } - } } diff --git a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/StatusBarNotification.java b/services/java/com/android/server/status/DisableRecords.java index 97f77da..ade8328 100644 --- a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/StatusBarNotification.java +++ b/services/java/com/android/server/status/DisableRecords.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 The Android Open Source Project + * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,14 +14,4 @@ * limitations under the License. */ -package com.android.policy.statusbar.phone; -import android.os.IBinder; -import android.view.View; - -public class StatusBarNotification { - IBinder key; - NotificationData data; - View view; - View contentView; -} diff --git a/services/java/com/android/server/status/StatusBarManagerService.java b/services/java/com/android/server/status/StatusBarManagerService.java index f4678c3..152f0a3 100644 --- a/services/java/com/android/server/status/StatusBarManagerService.java +++ b/services/java/com/android/server/status/StatusBarManagerService.java @@ -269,7 +269,8 @@ public class StatusBarManagerService extends IStatusBarService.Stub // ================================================================================ public IBinder addNotification(StatusBarNotification notification) { synchronized (mNotifications) { - IBinder key = mNotifications.add(notification); + IBinder key = new Binder(); + mNotifications.add(key, notification); // TODO: tell mBar return key; } |