summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Onorato <joeo@android.com>2010-06-09 14:47:43 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-06-09 14:47:43 -0700
commit1d46191d88ee9262ea05b868d2db5b44ad85fa43 (patch)
treee51b023ccc1a8d12075665dd06b824584f7afb57
parentfb3a35e586c08c74a8f9a0c332c9e40753c095c5 (diff)
parentb5f9b4f15a5cb060c34f1b8aa16cfee8503af0c7 (diff)
downloadframeworks_base-1d46191d88ee9262ea05b868d2db5b44ad85fa43.zip
frameworks_base-1d46191d88ee9262ea05b868d2db5b44ad85fa43.tar.gz
frameworks_base-1d46191d88ee9262ea05b868d2db5b44ad85fa43.tar.bz2
am b5f9b4f1: am 302759c1: Merge changes I4a11f027,Ib2c4abf6,Id0c7ef9f,I839d7771 into kraken
-rw-r--r--core/res/AndroidManifest.xml3
-rw-r--r--packages/SystemUI/AndroidManifest.xml5
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/PhoneStatusBarService.java17
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java (renamed from services/java/com/android/server/status/StorageNotification.java)9
-rw-r--r--packages/SystemUI/src/com/android/systemui/usb/UsbStorageActivity.java (renamed from services/java/com/android/server/status/UsbStorageActivity.java)2
-rwxr-xr-xservices/java/com/android/server/NotificationManagerService.java22
-rw-r--r--tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java13
9 files changed, 56 insertions, 23 deletions
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 4aff76f..4076891 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -1277,9 +1277,6 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
- <activity android:name="com.android.server.status.UsbStorageActivity"
- android:excludeFromRecents="true">
- </activity>
<activity android:name="com.android.internal.app.ExternalMediaFormatActivity"
android:theme="@style/Theme.Dialog.Alert"
android:excludeFromRecents="true">
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index 3f5b69d..aba5e05 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -18,5 +18,10 @@
android:name=".statusbar.PhoneStatusBarService"
android:exported="false"
/>
+
+ <activity android:name=".usb.UsbStorageActivity"
+ android:excludeFromRecents="true">
+ </activity>
+
</application>
</manifest>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/PhoneStatusBarService.java b/packages/SystemUI/src/com/android/systemui/statusbar/PhoneStatusBarService.java
index e9ae69a..ad59a0c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/PhoneStatusBarService.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/PhoneStatusBarService.java
@@ -85,13 +85,6 @@ public class PhoneStatusBarService extends StatusBarService {
private static final int MSG_ANIMATE = 1000;
private static final int MSG_ANIMATE_REVEAL = 1001;
- public interface NotificationCallbacks {
- void onSetDisabled(int status);
- void onClearAll();
- void onNotificationClick(String pkg, String tag, int id);
- void onPanelRevealed();
- }
-
private class ExpandedDialog extends Dialog {
ExpandedDialog(Context context) {
super(context, com.android.internal.R.style.Theme_Light_NoTitleBar);
@@ -349,6 +342,16 @@ public class PhoneStatusBarService extends StatusBarService {
final RemoteViews contentView = notification.notification.contentView;
+ if (false) {
+ Slog.d(TAG, "old notification: when=" + oldNotification.notification.when
+ + " ongoing=" + oldNotification.isOngoing()
+ + " expanded=" + oldEntry.expanded
+ + " contentView=" + oldContentView);
+ Slog.d(TAG, "new notification: when=" + notification.notification.when
+ + " ongoing=" + oldNotification.isOngoing()
+ + " contentView=" + contentView);
+ }
+
// Can we just reapply the RemoteViews in place? If when didn't change, the order
// didn't change.
if (notification.notification.when == oldNotification.notification.when
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java
index 9ef9d0d..4f39ee4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java
@@ -365,7 +365,7 @@ public class StatusBarPolicy {
// storage
mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
mStorageManager.registerListener(
- new com.android.server.status.StorageNotification(context));
+ new com.android.systemui.usb.StorageNotification(context));
// battery
mService.setIcon("battery", com.android.internal.R.drawable.stat_sys_battery_unknown, 0);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java
index 4d9e695..d200886 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java
@@ -48,12 +48,6 @@ public abstract class StatusBarService extends Service implements CommandQueue.C
CommandQueue mCommandQueue;
IStatusBarService mBarService;
- /* TODO
- H mHandler = new H();
- Object mQueueLock = new Object();
- NotificationCallbacks mNotificationCallbacks;
- */
-
@Override
public void onCreate() {
// Connect in to the status bar manager service
diff --git a/services/java/com/android/server/status/StorageNotification.java b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
index 8da8cd3..f8abc5a 100644
--- a/services/java/com/android/server/status/StorageNotification.java
+++ b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.server.status;
+package com.android.systemui.usb;
import android.app.Activity;
import android.app.Notification;
@@ -80,9 +80,10 @@ public class StorageNotification extends StorageEventListener {
mContext = context;
mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
- mUmsAvailable = mStorageManager.isUsbMassStorageConnected();
+ final boolean connected = mStorageManager.isUsbMassStorageConnected();
Slog.d(TAG, String.format( "Startup with UMS connection %s (media state %s)", mUmsAvailable,
Environment.getExternalStorageState()));
+ onUsbMassStorageConnectionChanged(connected);
}
/*
@@ -122,7 +123,7 @@ public class StorageNotification extends StorageEventListener {
* for stopping UMS.
*/
Intent intent = new Intent();
- intent.setClass(mContext, com.android.server.status.UsbStorageActivity.class);
+ intent.setClass(mContext, com.android.systemui.usb.UsbStorageActivity.class);
PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0);
setUsbStorageNotification(
com.android.internal.R.string.usb_storage_stop_notification_title,
@@ -240,7 +241,7 @@ public class StorageNotification extends StorageEventListener {
if (available) {
Intent intent = new Intent();
- intent.setClass(mContext, com.android.server.status.UsbStorageActivity.class);
+ intent.setClass(mContext, com.android.systemui.usb.UsbStorageActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
final boolean adbOn = 1 == Settings.Secure.getInt(
diff --git a/services/java/com/android/server/status/UsbStorageActivity.java b/packages/SystemUI/src/com/android/systemui/usb/UsbStorageActivity.java
index e8631c5..55d31ec 100644
--- a/services/java/com/android/server/status/UsbStorageActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/usb/UsbStorageActivity.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.server.status;
+package com.android.systemui.usb;
import com.android.internal.R;
import android.app.Activity;
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index ac3b23b..b5c2b1b 100755
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -70,6 +70,8 @@ class NotificationManagerService extends INotificationManager.Stub
private static final String TAG = "NotificationService";
private static final boolean DBG = false;
+ private static final int MAX_PACKAGE_NOTIFICATIONS = 50;
+
// message codes
private static final int MESSAGE_TIMEOUT = 2;
@@ -657,6 +659,26 @@ class NotificationManagerService extends INotificationManager.Stub
{
checkIncomingCall(pkg);
+ // Limit the number of notifications that any given package except the android
+ // package can enqueue. Prevents DOS attacks and deals with leaks.
+ if (!"android".equals(pkg)) {
+ synchronized (mNotificationList) {
+ int count = 0;
+ final int N = mNotificationList.size();
+ for (int i=0; i<N; i++) {
+ final NotificationRecord r = mNotificationList.get(i);
+ if (r.pkg.equals(pkg)) {
+ count++;
+ if (count >= MAX_PACKAGE_NOTIFICATIONS) {
+ Slog.e(TAG, "Package has already posted " + count
+ + " notifications. Not showing more. package=" + pkg);
+ return;
+ }
+ }
+ }
+ }
+ }
+
// This conditional is a dirty hack to limit the logging done on
// behalf of the download manager without affecting other apps.
if (!pkg.equals("com.android.providers.downloads")
diff --git a/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java b/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java
index 3602fec..f96a079 100644
--- a/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java
+++ b/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java
@@ -44,6 +44,7 @@ public class NotificationTestList extends TestActivity
Vibrator mVibrator = new Vibrator();
Handler mHandler = new Handler();
+ long mActivityCreateTime = System.currentTimeMillis();
long mChronometerBase = 0;
@Override
@@ -421,7 +422,7 @@ public class NotificationTestList extends TestActivity
new Test("Persistent #1") {
public void run() {
Notification n = new Notification(R.drawable.icon1, "tick tick tick",
- System.currentTimeMillis());
+ mActivityCreateTime);
n.setLatestEventInfo(NotificationTestList.this, "Persistent #1",
"This is a notification!!!", makeIntent());
mNM.notify(1, n);
@@ -481,6 +482,16 @@ public class NotificationTestList extends TestActivity
}
},
+ new Test("Persistent #1 - different icon") {
+ public void run() {
+ Notification n = new Notification(R.drawable.icon2, null,
+ mActivityCreateTime);
+ n.setLatestEventInfo(NotificationTestList.this, "Persistent #1",
+ "This is the same notification!!!", makeIntent());
+ mNM.notify(1, n);
+ }
+ },
+
new Test("Chronometer Start") {
public void run() {
Notification n = new Notification(R.drawable.icon2, "me me me me",