Ongoing notification for GPS use.

This change improves upon the notification priority API
introduced in change I9e738cc4, allowing privileged clients
to set the priority of a notification when posting it
directly to INotificationManager. StatusBarTest is updated
to test this new feature.

The new LocationController in SystemUI uses this facility to
post a high-priority ongoing notification whenever GPS is in
use (replacing the functionality of the legacy GPS status
bar icon).

Also happens to fix http://b/3325472 (adding a log message
when notifications are dropped because of a missing icon).

Bug: 3412807

Change-Id: I523016ffa53bf979be98ddc4a2deb55a6270c68a
This commit is contained in:
Daniel Sandler
2011-02-03 14:51:35 -05:00
parent 8275c60878
commit e40451a89d
8 changed files with 197 additions and 6 deletions

View File

@ -35,6 +35,10 @@ import android.widget.TextView;
import android.widget.ProgressBar;
import android.os.PowerManager;
// private NM API
import android.app.INotificationManager;
import com.android.internal.statusbar.StatusBarNotification;
public class NotificationTestList extends TestActivity
{
private final static String TAG = "NotificationTestList";
@ -205,6 +209,15 @@ public class NotificationTestList extends TestActivity
}
},
new Test("Null Icon #1 (when=now)") {
public void run() {
Notification n = new Notification(0, null, System.currentTimeMillis());
n.setLatestEventInfo(NotificationTestList.this, "Persistent #1",
"This is the same notification!!!", makeIntent());
mNM.notify(1, n);
}
},
new Test("Bad resource #1 (when=create)") {
public void run() {
Notification n = new Notification(R.drawable.icon2,
@ -752,6 +765,30 @@ public class NotificationTestList extends TestActivity
}
},
new Test("System priority notification") {
public void run() {
Notification n = new Notification.Builder(NotificationTestList.this)
.setSmallIcon(R.drawable.notification1)
.setContentTitle("System priority")
.setContentText("This should appear before all others")
.getNotification();
int[] idOut = new int[1];
try {
INotificationManager directLine = mNM.getService();
directLine.enqueueNotificationWithTagPriority(
getPackageName(),
null,
1,
StatusBarNotification.PRIORITY_SYSTEM,
n,
idOut);
} catch (android.os.RemoteException ex) {
// oh well
}
}
},
new Test("Crash") {
public void run()
{