summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorJoe Onorato <joeo@android.com>2010-05-20 10:21:52 -0700
committerJoe Onorato <joeo@android.com>2010-06-02 14:48:43 -0700
commita0c56fe93925d20d9c0b830b9664699ce557e78c (patch)
treeb31ff5bb17a888e609a4dbc51de8651252bc7b67 /packages
parent18e69dfc7235f8a4bfe257f9d1c43539049a22ce (diff)
downloadframeworks_base-a0c56fe93925d20d9c0b830b9664699ce557e78c.zip
frameworks_base-a0c56fe93925d20d9c0b830b9664699ce557e78c.tar.gz
frameworks_base-a0c56fe93925d20d9c0b830b9664699ce557e78c.tar.bz2
Checkpoint. Doesn't build.
Change-Id: I92e4d539ea71af9e22ced02cbdee7fbd456b7971
Diffstat (limited to 'packages')
-rw-r--r--packages/StatusBarPhone/src/com/android/policy/statusbar/phone/CommandQueue.java58
-rw-r--r--packages/StatusBarPhone/src/com/android/policy/statusbar/phone/NotificationViewList.java276
-rw-r--r--packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java63
-rw-r--r--packages/StatusBarPhone/src/com/android/policy/statusbar/phone/StatusBarNotification.java27
4 files changed, 67 insertions, 357 deletions
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/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/StatusBarNotification.java
deleted file mode 100644
index 97f77da..0000000
--- a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/StatusBarNotification.java
+++ /dev/null
@@ -1,27 +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.view.View;
-
-public class StatusBarNotification {
- IBinder key;
- NotificationData data;
- View view;
- View contentView;
-}