Merge changes I4a11f027,Ib2c4abf6,Id0c7ef9f,I839d7771 into kraken
* changes: dead code removal Cap the number of notifications that a given package can post. Move the usb mass storage notification & activity into SystemUI.apk. Add some disabled logging and another test case for reapplying the notification views.
This commit is contained in:
@@ -1269,9 +1269,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">
|
||||
|
||||
@@ -18,5 +18,10 @@
|
||||
android:name=".statusbar.PhoneStatusBarService"
|
||||
android:exported="false"
|
||||
/>
|
||||
|
||||
<activity android:name=".usb.UsbStorageActivity"
|
||||
android:excludeFromRecents="true">
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
@@ -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;
|
||||
@@ -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")
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user