summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Onorato <joeo@android.com>2010-06-09 14:44:58 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-06-09 14:44:58 -0700
commitae706c10c08209cdca79725ac7d25eec50777ada (patch)
tree82135b537aafe8a44b59c7b799afd4170be748dc
parent302759c1ba33767478cd7ae19c2481b2ead49203 (diff)
parent0faeb078cf2bf689eaa69e7041013c5152281b4f (diff)
downloadframeworks_base-ae706c10c08209cdca79725ac7d25eec50777ada.zip
frameworks_base-ae706c10c08209cdca79725ac7d25eec50777ada.tar.gz
frameworks_base-ae706c10c08209cdca79725ac7d25eec50777ada.tar.bz2
Merge changes Ia5884ef4,Ie495a41d,I3f7066c2,If5faf446,I6ae0740f,I57b2d296,Iea78a637 into kraken
* changes: Add a test item the turns on a bunch of extra icons. Move the status bar icon list, hopefully for the last time. Call into the notification manager when the panel is revealed. Move status_bar_latest_event and LatestItemView into SystemUI.apk. Start the status bar service based on a configuration option, instead of trampolining through a braodcast receiver. Require the STATUS_BAR_SERVICE permission for something to be the status bar. Handle errors inflating notifications (and their icons).
-rw-r--r--core/java/com/android/internal/statusbar/IStatusBarService.aidl4
-rw-r--r--core/res/AndroidManifest.xml7
-rw-r--r--core/res/res/drawable/status_bar_item_background.xml2
-rw-r--r--core/res/res/values/arrays.xml24
-rw-r--r--core/res/res/values/config.xml30
-rw-r--r--core/res/res/values/strings.xml5
-rw-r--r--packages/SystemUI/AndroidManifest.xml9
-rw-r--r--packages/SystemUI/res/drawable-hdpi/status_bar_item_background_focus.9.pngbin1657 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/status_bar_item_background_normal.9.pngbin197 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/status_bar_item_background_pressed.9.pngbin1531 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/status_bar_item_background_focus.9.pngbin11006 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/status_bar_item_background_normal.9.pngbin186 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/status_bar_item_background_pressed.9.pngbin11006 -> 0 bytes
-rw-r--r--packages/SystemUI/res/layout/status_bar_latest_event.xml (renamed from core/res/res/layout/status_bar_latest_event.xml)8
-rw-r--r--packages/SystemUI/res/values/arrays.xml28
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/PhoneStatusBarService.java66
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java57
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStarter.java38
-rwxr-xr-xpolicy/com/android/internal/policy/impl/PhoneWindowManager.java8
-rw-r--r--services/java/com/android/server/InputMethodManagerService.java2
-rwxr-xr-xservices/java/com/android/server/NotificationManagerService.java8
-rw-r--r--services/java/com/android/server/StatusBarManagerService.java (renamed from services/java/com/android/server/status/StatusBarManagerService.java)65
-rw-r--r--services/java/com/android/server/SystemServer.java1
-rw-r--r--services/java/com/android/server/status/LatestItemView.java34
-rwxr-xr-xservices/java/com/android/server/status/package.html5
-rw-r--r--tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java50
-rw-r--r--tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java17
27 files changed, 229 insertions, 239 deletions
diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
index 1f25b37..045c24f 100644
--- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl
+++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
@@ -32,9 +32,11 @@ interface IStatusBarService
void removeIcon(String slot);
// ---- Methods below are for use by the status bar policy services ----
+ // You need the STATUS_BAR_SERVICE permission
void registerStatusBar(IStatusBar callbacks, out StatusBarIconList iconList,
out List<IBinder> notificationKeys, out List<StatusBarNotification> notifications);
- void visibilityChanged(boolean visible);
+ void onPanelRevealed();
void onNotificationClick(String pkg, String tag, int id);
+ void onNotificationError(String pkg, String tag, int id, String message);
void onClearAllNotifications();
}
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 2ddb6b9..aff9453 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -908,6 +908,13 @@
android:description="@string/permdesc_statusBar"
android:protectionLevel="signatureOrSystem" />
+ <!-- Allows an application to be the status bar. Currently used only by SystemUI.apk
+ @hide -->
+ <permission android:name="android.permission.STATUS_BAR_SERVICE"
+ android:label="@string/permlab_statusBarService"
+ android:description="@string/permdesc_statusBarService"
+ android:protectionLevel="signature" />
+
<!-- Allows an application to force a BACK operation on whatever is the
top activity. -->
<permission android:name="android.permission.FORCE_BACK"
diff --git a/core/res/res/drawable/status_bar_item_background.xml b/core/res/res/drawable/status_bar_item_background.xml
index 088389b..425a502 100644
--- a/core/res/res/drawable/status_bar_item_background.xml
+++ b/core/res/res/drawable/status_bar_item_background.xml
@@ -16,7 +16,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
- android:drawable="@drawable/status_bar_item_background_pressed" />
+ android:drawable="@drawable/status_bar_item_background_pressed" />
<item android:state_focused="true" android:state_pressed="false"
android:drawable="@drawable/status_bar_item_background_focus" />
<item android:drawable="@drawable/status_bar_item_background_normal" />
diff --git a/core/res/res/values/arrays.xml b/core/res/res/values/arrays.xml
index 0493756..aeee8af 100644
--- a/core/res/res/values/arrays.xml
+++ b/core/res/res/values/arrays.xml
@@ -117,28 +117,4 @@
<item>3</item>
</integer-array>
- <!-- Do not translate. Defines the slots for the right-hand side icons. That is to say, the
- icons in the status bar that are not notifications. -->
- <string-array name="status_bar_icon_order">
- <item><xliff:g id="id">ime</xliff:g></item>
- <item><xliff:g id="id">sync_failing</xliff:g></item>
- <item><xliff:g id="id">sync_active</xliff:g></item>
- <item><xliff:g id="id">gps</xliff:g></item>
- <item><xliff:g id="id">bluetooth</xliff:g></item>
- <item><xliff:g id="id">tty</xliff:g></item>
- <item><xliff:g id="id">speakerphone</xliff:g></item>
- <item><xliff:g id="id">mute</xliff:g></item>
- <item><xliff:g id="id">volume</xliff:g></item>
- <item><xliff:g id="id">tty</xliff:g></item>
- <item><xliff:g id="id">wifi</xliff:g></item>
- <item><xliff:g id="id">cdma_eri</xliff:g></item>
- <item><xliff:g id="id">data_connection</xliff:g></item>
- <item><xliff:g id="id">phone_evdo_signal</xliff:g></item>
- <item><xliff:g id="id">phone_signal</xliff:g></item>
- <item><xliff:g id="id">battery</xliff:g></item>
- <item><xliff:g id="id">alarm_clock</xliff:g></item>
- <item><xliff:g id="id">secure</xliff:g></item>
- <item><xliff:g id="id">clock</xliff:g></item>
- </string-array>
-
</resources>
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 1946388..cffcd1d 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -19,7 +19,35 @@
<!-- These resources are around just to allow their values to be customized
for different hardware and product builds. -->
-<resources>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- Component to be used as the status bar service. Must implement the IStatusBar
+ interface. This name is in the ComponentName flattened format (package/class) -->
+ <string name="config_statusBarComponent">com.android.systemui/com.android.systemui.statusbar.PhoneStatusBarService</string>
+
+ <!-- Do not translate. Defines the slots for the right-hand side icons. That is to say, the
+ icons in the status bar that are not notifications. -->
+ <string-array name="config_statusBarIcons">
+ <item><xliff:g id="id">ime</xliff:g></item>
+ <item><xliff:g id="id">sync_failing</xliff:g></item>
+ <item><xliff:g id="id">sync_active</xliff:g></item>
+ <item><xliff:g id="id">gps</xliff:g></item>
+ <item><xliff:g id="id">bluetooth</xliff:g></item>
+ <item><xliff:g id="id">tty</xliff:g></item>
+ <item><xliff:g id="id">speakerphone</xliff:g></item>
+ <item><xliff:g id="id">mute</xliff:g></item>
+ <item><xliff:g id="id">volume</xliff:g></item>
+ <item><xliff:g id="id">tty</xliff:g></item>
+ <item><xliff:g id="id">wifi</xliff:g></item>
+ <item><xliff:g id="id">cdma_eri</xliff:g></item>
+ <item><xliff:g id="id">data_connection</xliff:g></item>
+ <item><xliff:g id="id">phone_evdo_signal</xliff:g></item>
+ <item><xliff:g id="id">phone_signal</xliff:g></item>
+ <item><xliff:g id="id">battery</xliff:g></item>
+ <item><xliff:g id="id">alarm_clock</xliff:g></item>
+ <item><xliff:g id="id">secure</xliff:g></item>
+ <item><xliff:g id="id">clock</xliff:g></item>
+ </string-array>
+
<!-- Flag indicating whether the surface flinger has limited
alpha compositing functionality in hardware. If set, the window
manager will disable alpha trasformation in animations where not
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index e7f892a..fc1db18 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -393,6 +393,11 @@
the status bar or add and remove system icons.</string>
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permlab_statusBarService">status bar</string>
+ <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permdesc_statusBarService">Allows the application to be the status bar.</string>
+
+ <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permlab_expandStatusBar">expand/collapse status bar</string>
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permdesc_expandStatusBar">Allows application to
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index aba5e05..74d87ba 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -2,18 +2,13 @@
package="com.android.systemui"
android:sharedUserId="android.uid.system">
+ <uses-permission android:name="android.permission.STATUS_BAR_SERVICE" />
+
<application
android:allowClearUserData="false"
android:label="@string/app_label"
android:icon="@drawable/ic_launcher_settings">
- <receiver
- android:name=".statusbar.StatusBarStarter"
- >
- <intent-filter>
- <action android:name="com.android.internal.policy.statusbar.START" />
- </intent-filter>
- </receiver>
<service
android:name=".statusbar.PhoneStatusBarService"
android:exported="false"
diff --git a/packages/SystemUI/res/drawable-hdpi/status_bar_item_background_focus.9.png b/packages/SystemUI/res/drawable-hdpi/status_bar_item_background_focus.9.png
deleted file mode 100644
index 0876bc6..0000000
--- a/packages/SystemUI/res/drawable-hdpi/status_bar_item_background_focus.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/status_bar_item_background_normal.9.png b/packages/SystemUI/res/drawable-hdpi/status_bar_item_background_normal.9.png
deleted file mode 100644
index c01c018..0000000
--- a/packages/SystemUI/res/drawable-hdpi/status_bar_item_background_normal.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/status_bar_item_background_pressed.9.png b/packages/SystemUI/res/drawable-hdpi/status_bar_item_background_pressed.9.png
deleted file mode 100644
index 343e4ca..0000000
--- a/packages/SystemUI/res/drawable-hdpi/status_bar_item_background_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/status_bar_item_background_focus.9.png b/packages/SystemUI/res/drawable-mdpi/status_bar_item_background_focus.9.png
deleted file mode 100644
index c3e2415..0000000
--- a/packages/SystemUI/res/drawable-mdpi/status_bar_item_background_focus.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/status_bar_item_background_normal.9.png b/packages/SystemUI/res/drawable-mdpi/status_bar_item_background_normal.9.png
deleted file mode 100644
index b8e399d..0000000
--- a/packages/SystemUI/res/drawable-mdpi/status_bar_item_background_normal.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/status_bar_item_background_pressed.9.png b/packages/SystemUI/res/drawable-mdpi/status_bar_item_background_pressed.9.png
deleted file mode 100644
index 02b4e9a..0000000
--- a/packages/SystemUI/res/drawable-mdpi/status_bar_item_background_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/layout/status_bar_latest_event.xml b/packages/SystemUI/res/layout/status_bar_latest_event.xml
index 59cc90d..88d9739 100644
--- a/core/res/res/layout/status_bar_latest_event.xml
+++ b/packages/SystemUI/res/layout/status_bar_latest_event.xml
@@ -4,20 +4,20 @@
android:orientation="vertical"
>
- <com.android.server.status.LatestItemView android:id="@+id/content"
+ <com.android.systemui.statusbar.LatestItemView android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="64sp"
- android:background="@drawable/status_bar_item_background"
+ android:background="@android:drawable/status_bar_item_background"
android:focusable="true"
android:clickable="true"
android:paddingRight="6sp"
>
- </com.android.server.status.LatestItemView>
+ </com.android.systemui.statusbar.LatestItemView>
<View
android:layout_width="match_parent"
android:layout_height="1sp"
- android:background="@drawable/divider_horizontal_bright"
+ android:background="@android:drawable/divider_horizontal_bright"
/>
</LinearLayout>
diff --git a/packages/SystemUI/res/values/arrays.xml b/packages/SystemUI/res/values/arrays.xml
deleted file mode 100644
index dbb0e0f..0000000
--- a/packages/SystemUI/res/values/arrays.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/* //device/apps/common/assets/res/any/colors.xml
-**
-** Copyright 2006, 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.
-*/
--->
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-
- <!-- Do not translate. Defines the slots for the right-hand side icons. That is to say, the
- icons in the status bar that are not notifications. -->
- <string-array name="status_bar_icon_order">
- <item><xliff:g id="id">TODO: Remove; not used.</xliff:g></item>
- </string-array>
-
-</resources>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/PhoneStatusBarService.java b/packages/SystemUI/src/com/android/systemui/statusbar/PhoneStatusBarService.java
index ad59a0c..a7e5e31 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/PhoneStatusBarService.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/PhoneStatusBarService.java
@@ -116,7 +116,6 @@ public class PhoneStatusBarService extends StatusBarService {
Object mQueueLock = new Object();
// icons
- String[] mRightIconSlots;
LinearLayout mIcons;
IconMerger mNotificationIcons;
LinearLayout mStatusIcons;
@@ -153,6 +152,7 @@ public class PhoneStatusBarService extends StatusBarService {
TrackingView mTrackingView;
WindowManager.LayoutParams mTrackingParams;
int mTrackingPosition; // the position of the top of the tracking view.
+ private boolean mPanelSlightlyVisible;
// ticker
private Ticker mTicker;
@@ -201,7 +201,6 @@ public class PhoneStatusBarService extends StatusBarService {
// ================================================================================
private void makeStatusBarView(Context context) {
Resources res = context.getResources();
- mRightIconSlots = res.getStringArray(R.array.status_bar_icon_order);
mHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
mIconWidth = mHeight;
@@ -373,6 +372,14 @@ public class PhoneStatusBarService extends StatusBarService {
oldEntry.content.setOnClickListener(new Launcher(contentIntent,
notification.pkg, notification.tag, notification.id));
}
+ // Update the icon.
+ final StatusBarIcon ic = new StatusBarIcon(notification.pkg,
+ notification.notification.icon, notification.notification.iconLevel,
+ notification.notification.number);
+ if (!oldEntry.icon.set(ic)) {
+ handleNotificationError(key, notification, "Couldn't update icon: " + ic);
+ return;
+ }
}
catch (RuntimeException e) {
// It failed to add cleanly. Log, and remove the view from the panel.
@@ -380,9 +387,6 @@ public class PhoneStatusBarService extends StatusBarService {
removeNotificationViews(key);
addNotificationViews(key, notification);
}
- // Update the icon.
- oldEntry.icon.set(new StatusBarIcon(notification.pkg, notification.notification.icon,
- notification.notification.iconLevel, notification.notification.number));
} else {
Slog.d(TAG, "not reusing notification");
removeNotificationViews(key);
@@ -429,11 +433,10 @@ public class PhoneStatusBarService extends StatusBarService {
// create the row view
LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- View row = inflater.inflate(com.android.internal.R.layout.status_bar_latest_event,
- parent, false);
+ View row = inflater.inflate(R.layout.status_bar_latest_event, parent, false);
// bind the click event to the content area
- ViewGroup content = (ViewGroup)row.findViewById(com.android.internal.R.id.content);
+ ViewGroup content = (ViewGroup)row.findViewById(R.id.content);
content.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
content.setOnFocusChangeListener(mFocusChangeListener);
PendingIntent contentIntent = n.contentIntent;
@@ -451,8 +454,9 @@ public class PhoneStatusBarService extends StatusBarService {
exception = e;
}
if (expanded == null) {
- Slog.e(TAG, "couldn't inflate view for package " + notification.pkg, exception);
- row.setVisibility(View.GONE);
+ String ident = notification.pkg + "/0x" + Integer.toHexString(notification.id);
+ Slog.e(TAG, "couldn't inflate view for notification " + ident);
+ return null;
} else {
content.addView(expanded);
row.setDrawingCacheEnabled(true);
@@ -474,14 +478,23 @@ public class PhoneStatusBarService extends StatusBarService {
}
// Construct the expanded view.
final View[] views = makeNotificationView(notification, parent);
+ if (views == null) {
+ handleNotificationError(key, notification, "Couldn't expand RemoteViews for: "
+ + notification);
+ return;
+ }
final View row = views[0];
final View content = views[1];
final View expanded = views[2];
// Construct the icon.
- StatusBarIconView iconView = new StatusBarIconView(this,
+ final StatusBarIconView iconView = new StatusBarIconView(this,
notification.pkg + "/0x" + Integer.toHexString(notification.id));
- iconView.set(new StatusBarIcon(notification.pkg, notification.notification.icon,
- notification.notification.iconLevel, notification.notification.number));
+ final StatusBarIcon ic = new StatusBarIcon(notification.pkg, notification.notification.icon,
+ notification.notification.iconLevel, notification.notification.number);
+ if (!iconView.set(ic)) {
+ handleNotificationError(key, notification, "Coulding create icon: " + ic);
+ return;
+ }
// Add the expanded view.
final int viewIndex = list.add(key, notification, row, content, expanded, iconView);
parent.addView(row, viewIndex);
@@ -967,6 +980,21 @@ public class PhoneStatusBarService extends StatusBarService {
}
}
+ /**
+ * Cancel this notification and tell the StatusBarManagerService / NotificationManagerService
+ * about the failure.
+ *
+ * WARNING: this will call back into us. Don't hold any locks.
+ */
+ void handleNotificationError(IBinder key, StatusBarNotification n, String message) {
+ removeNotification(key);
+ try {
+ mBarService.onNotificationError(n.pkg, n.tag, n.id, message);
+ } catch (RemoteException ex) {
+ // The end is nigh.
+ }
+ }
+
private class MyTicker extends Ticker {
MyTicker(Context context, StatusBarView sb) {
super(context, sb);
@@ -1268,8 +1296,15 @@ public class PhoneStatusBarService extends StatusBarService {
// because the window itself extends below the content view.
mExpandedParams.y = -disph;
}
- visibilityChanged(visible);
mExpandedDialog.getWindow().setAttributes(mExpandedParams);
+
+ // As long as this isn't just a repositioning that's not supposed to affect
+ // the user's perception of what's showing, call to say that the visibility
+ // has changed. (Otherwise, someone else will call to do that).
+ if (expandedPosition != EXPANDED_LEAVE_ALONE) {
+ Slog.d(TAG, "updateExpandedViewPos visibilityChanged(" + visible + ")");
+ visibilityChanged(visible);
+ }
}
if (SPEW) {
@@ -1299,12 +1334,11 @@ public class PhoneStatusBarService extends StatusBarService {
* turned off. If any other notifications happen, the lights will turn back on. Steve says
* this is what he wants. (see bug 1131461)
*/
- private boolean mPanelSlightlyVisible;
void visibilityChanged(boolean visible) {
if (mPanelSlightlyVisible != visible) {
mPanelSlightlyVisible = visible;
try {
- mBarService.visibilityChanged(visible);
+ mBarService.onPanelRevealed();
} catch (RemoteException ex) {
// Won't fail unless the world has ended.
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
index 5eb0d68..bc1e798 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
@@ -32,7 +32,6 @@ public class StatusBarIconView extends AnimatedImageView {
private StatusBarIcon mIcon;
@ViewDebug.ExportedProperty private String mSlot;
- @ViewDebug.ExportedProperty private boolean mError;
public StatusBarIconView(Context context, String slot) {
super(context);
@@ -52,39 +51,33 @@ public class StatusBarIconView extends AnimatedImageView {
return a.equals(b);
}
- public void set(StatusBarIcon icon) {
- error: {
- final boolean iconEquals = !mError
- && mIcon != null
- && streq(mIcon.iconPackage, icon.iconPackage)
- && mIcon.iconId == icon.iconId;
- final boolean levelEquals = !mError
- && iconEquals
- && mIcon.iconLevel == icon.iconLevel;
- final boolean visibilityEquals = !mError
- && mIcon != null
- && mIcon.visible == icon.visible;
- mError = false;
- if (!iconEquals) {
- Drawable drawable = getIcon(icon);
- if (drawable == null) {
- mError = true;
- Slog.w(PhoneStatusBarService.TAG, "No icon ID for slot " + mSlot);
- break error;
- }
- setImageDrawable(drawable);
- }
- if (!levelEquals) {
- setImageLevel(icon.iconLevel);
- }
- if (!visibilityEquals) {
- setVisibility(icon.visible ? VISIBLE : GONE);
+ /**
+ * Returns whether the set succeeded.
+ */
+ public boolean set(StatusBarIcon icon) {
+ final boolean iconEquals = mIcon != null
+ && streq(mIcon.iconPackage, icon.iconPackage)
+ && mIcon.iconId == icon.iconId;
+ final boolean levelEquals = iconEquals
+ && mIcon.iconLevel == icon.iconLevel;
+ final boolean visibilityEquals = mIcon != null
+ && mIcon.visible == icon.visible;
+ if (!iconEquals) {
+ Drawable drawable = getIcon(icon);
+ if (drawable == null) {
+ Slog.w(PhoneStatusBarService.TAG, "No icon for slot " + mSlot);
+ return false;
}
- mIcon = icon.clone();
+ setImageDrawable(drawable);
+ }
+ if (!levelEquals) {
+ setImageLevel(icon.iconLevel);
}
- if (mError) {
- setVisibility(GONE);
+ if (!visibilityEquals) {
+ setVisibility(icon.visible ? VISIBLE : GONE);
}
+ mIcon = icon.clone();
+ return true;
}
private Drawable getIcon(StatusBarIcon icon) {
@@ -106,7 +99,7 @@ public class StatusBarIconView extends AnimatedImageView {
try {
r = context.getPackageManager().getResourcesForApplication(icon.iconPackage);
} catch (PackageManager.NameNotFoundException ex) {
- Slog.e(PhoneStatusBarService.TAG, "Icon package not found: "+icon.iconPackage, ex);
+ Slog.e(PhoneStatusBarService.TAG, "Icon package not found: " + icon.iconPackage);
return null;
}
} else {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStarter.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStarter.java
deleted file mode 100644
index 2b9dfb0..0000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStarter.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.systemui.statusbar;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.BroadcastReceiver;
-import android.util.Log;
-
-/**
- * Receive a broadcast from the StatusBarManagerService at boot time, and
- * kick off the StatusBarService.
- */
-public class StatusBarStarter extends BroadcastReceiver {
- private static final String TAG = "StatusBarStarter";
-
- @Override
- public void onReceive(Context context, Intent intent) {
- Log.d(TAG, "StatusBarStarter onReceive intent=" + intent);
- context.startService(new Intent(context, PhoneStatusBarService.class));
- }
-}
-
-
diff --git a/policy/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/com/android/internal/policy/impl/PhoneWindowManager.java
index 73a57ee..d152bc4 100755
--- a/policy/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -957,12 +957,20 @@ public class PhoneWindowManager implements WindowManagerPolicy {
public int prepareAddWindowLw(WindowState win, WindowManager.LayoutParams attrs) {
switch (attrs.type) {
case TYPE_STATUS_BAR:
+ mContext.enforceCallingOrSelfPermission(
+ android.Manifest.permission.STATUS_BAR_SERVICE,
+ "PhoneWindowManager");
+ // TODO: Need to handle the race condition of the status bar proc
+ // dying and coming back before the removeWindowLw cleanup has happened.
if (mStatusBar != null) {
return WindowManagerImpl.ADD_MULTIPLE_SINGLETON;
}
mStatusBar = win;
break;
case TYPE_STATUS_BAR_PANEL:
+ mContext.enforceCallingOrSelfPermission(
+ android.Manifest.permission.STATUS_BAR_SERVICE,
+ "PhoneWindowManager");
mStatusBarPanels.add(win);
break;
case TYPE_KEYGUARD:
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index a1f26f2..4d35bec 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -26,7 +26,7 @@ import com.android.internal.view.IInputMethodManager;
import com.android.internal.view.IInputMethodSession;
import com.android.internal.view.InputBindResult;
-import com.android.server.status.StatusBarManagerService;
+import com.android.server.StatusBarManagerService;
import org.xmlpull.v1.XmlPullParserException;
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index b5c2b1b..6f44e8e 100755
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -17,7 +17,7 @@
package com.android.server;
import com.android.internal.statusbar.StatusBarNotification;
-import com.android.server.status.StatusBarManagerService;
+import com.android.server.StatusBarManagerService;
import android.app.ActivityManagerNative;
import android.app.IActivityManager;
@@ -303,6 +303,12 @@ class NotificationManagerService extends INotificationManager.Stub
updateLightsLocked();
}
}
+
+ public void onNotificationError(String pkg, String tag, int id, String message) {
+ Slog.d(TAG, "onNotification error pkg=" + pkg + " tag=" + tag + " id=" + id);
+ cancelNotification(pkg, tag, id, 0, 0);
+ // TODO: Tell the activity manager.
+ }
};
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
diff --git a/services/java/com/android/server/status/StatusBarManagerService.java b/services/java/com/android/server/StatusBarManagerService.java
index 0af1ebb..1a16387 100644
--- a/services/java/com/android/server/status/StatusBarManagerService.java
+++ b/services/java/com/android/server/StatusBarManagerService.java
@@ -14,11 +14,12 @@
* limitations under the License.
*/
-package com.android.server.status;
+package com.android.server;
import android.app.PendingIntent;
import android.app.StatusBarManager;
import android.content.BroadcastReceiver;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -55,9 +56,6 @@ public class StatusBarManagerService extends IStatusBarService.Stub
static final String TAG = "StatusBarManagerService";
static final boolean SPEW = true;
- public static final String ACTION_STATUSBAR_START
- = "com.android.internal.policy.statusbar.START";
-
final Context mContext;
Handler mHandler = new Handler();
NotificationCallbacks mNotificationCallbacks;
@@ -87,6 +85,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub
void onClearAll();
void onNotificationClick(String pkg, String tag, int id);
void onPanelRevealed();
+ void onNotificationError(String pkg, String tag, int id, String message);
}
/**
@@ -96,7 +95,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub
mContext = context;
final Resources res = context.getResources();
- mIcons.defineSlots(res.getStringArray(com.android.internal.R.array.status_bar_icon_order));
+ mIcons.defineSlots(res.getStringArray(com.android.internal.R.array.config_statusBarIcons));
}
public void setNotificationCallbacks(NotificationCallbacks listener) {
@@ -111,9 +110,12 @@ public class StatusBarManagerService extends IStatusBarService.Stub
}
public void systemReady2() {
- // Start the status bar app
- Intent intent = new Intent(ACTION_STATUSBAR_START);
- mContext.sendBroadcast(intent /** permission **/);
+ ComponentName cn = ComponentName.unflattenFromString(
+ mContext.getString(com.android.internal.R.string.config_statusBarComponent));
+ Intent intent = new Intent();
+ intent.setComponent(cn);
+ Slog.i(TAG, "Starting service: " + cn);
+ mContext.startService(intent);
}
// ================================================================================
@@ -248,12 +250,19 @@ public class StatusBarManagerService extends IStatusBarService.Stub
"StatusBarManagerService");
}
+ private void enforceStatusBarService() {
+ mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR_SERVICE,
+ "StatusBarManagerService");
+ }
+
// ================================================================================
// Callbacks from the status bar service.
// ================================================================================
public void registerStatusBar(IStatusBar bar, StatusBarIconList iconList,
List<IBinder> notificationKeys, List<StatusBarNotification> notifications) {
+ enforceStatusBarService();
+
Slog.i(TAG, "registerStatusBar bar=" + bar);
mBar = bar;
synchronized (mIcons) {
@@ -268,18 +277,32 @@ public class StatusBarManagerService extends IStatusBarService.Stub
}
/**
- * The status bar service should call this when the user changes whether
- * the status bar is visible or not.
+ * The status bar service should call this each time the user brings the panel from
+ * invisible to visible in order to clear the notification light.
*/
- public void visibilityChanged(boolean visible) {
- //Slog.d(TAG, "visibilityChanged visible=" + visible);
+ public void onPanelRevealed() {
+ enforceStatusBarService();
+
+ // tell the notification manager to turn off the lights.
+ mNotificationCallbacks.onPanelRevealed();
}
public void onNotificationClick(String pkg, String tag, int id) {
+ enforceStatusBarService();
+
mNotificationCallbacks.onNotificationClick(pkg, tag, id);
}
+ public void onNotificationError(String pkg, String tag, int id, String message) {
+ enforceStatusBarService();
+
+ // WARNING: this will call back into us to do the remove. Don't hold any locks.
+ mNotificationCallbacks.onNotificationError(pkg, tag, id, message);
+ }
+
public void onClearAllNotifications() {
+ enforceStatusBarService();
+
mNotificationCallbacks.onClearAll();
}
@@ -423,24 +446,6 @@ public class StatusBarManagerService extends IStatusBarService.Stub
}
}
- /**
- * The LEDs are turned o)ff when the notification panel is shown, even just a little bit.
- * This was added last-minute and is inconsistent with the way the rest of the notifications
- * are handled, because the notification isn't really cancelled. The lights are just
- * turned off. If any other notifications happen, the lights will turn back on. Steve says
- * this is what he wants. (see bug 1131461)
- */
- private boolean mPanelSlightlyVisible;
- void panelSlightlyVisible(boolean visible) {
- if (mPanelSlightlyVisible != visible) {
- mPanelSlightlyVisible = visible;
- if (visible) {
- // tell the notification manager to turn off the lights.
- mNotificationCallbacks.onPanelRevealed();
- }
- }
- }
-
private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 4307cdc..b91bf73 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -17,7 +17,6 @@
package com.android.server;
import com.android.server.am.ActivityManagerService;
-import com.android.server.status.StatusBarManagerService;
import com.android.internal.os.BinderInternal;
import com.android.internal.os.SamplingProfilerIntegration;
diff --git a/services/java/com/android/server/status/LatestItemView.java b/services/java/com/android/server/status/LatestItemView.java
deleted file mode 100644
index fe8d164..0000000
--- a/services/java/com/android/server/status/LatestItemView.java
+++ /dev/null
@@ -1,34 +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.server.status;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.util.Slog;
-import android.view.MotionEvent;
-import android.widget.FrameLayout;
-
-public class LatestItemView extends FrameLayout {
-
- public LatestItemView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public boolean dispatchTouchEvent(MotionEvent ev) {
- return onTouchEvent(ev);
- }
-}
diff --git a/services/java/com/android/server/status/package.html b/services/java/com/android/server/status/package.html
deleted file mode 100755
index c9f96a6..0000000
--- a/services/java/com/android/server/status/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<body>
-
-{@hide}
-
-</body>
diff --git a/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java b/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java
index f96a079..4d071e3 100644
--- a/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java
+++ b/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java
@@ -123,29 +123,49 @@ public class NotificationTestList extends TestActivity
}
},
- new Test("Bad Icon") {
+ new Test("Bad Icon #1 (when=create)") {
public void run() {
- mNM.notify(1, new Notification(NotificationTestList.this,
- R.layout.chrono_notification, /* not a drawable! */
- null, System.currentTimeMillis()-(1000*60*60*24),
- "(453) 123-2328",
- "", null));
+ Notification n = new Notification(R.layout.chrono_notification /* not an icon */,
+ null, mActivityCreateTime);
+ n.setLatestEventInfo(NotificationTestList.this, "Persistent #1",
+ "This is the same notification!!!", makeIntent());
+ mNM.notify(1, n);
}
},
- new Test("Bad resource #2") {
- public void run()
- {
- Notification n = new Notification(NotificationTestList.this,
- R.drawable.ic_statusbar_missedcall,
- null, System.currentTimeMillis()-(1000*60*60*24),
- "(453) 123-2328",
- "", null);
+ new Test("Bad Icon #1 (when=now)") {
+ public void run() {
+ Notification n = new Notification(R.layout.chrono_notification /* not an icon */,
+ 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,
+ null, mActivityCreateTime);
+ n.setLatestEventInfo(NotificationTestList.this, "Persistent #1",
+ "This is the same notification!!!", makeIntent());
n.contentView.setInt(1 /*bogus*/, "bogus method", 666);
- mNM.notify(2, n);
+ mNM.notify(1, n);
}
},
+ new Test("Bad resource #1 (when=now)") {
+ public void run() {
+ Notification n = new Notification(R.drawable.icon2,
+ null, System.currentTimeMillis());
+ n.setLatestEventInfo(NotificationTestList.this, "Persistent #1",
+ "This is the same notification!!!", makeIntent());
+ n.contentView.setInt(1 /*bogus*/, "bogus method", 666);
+ mNM.notify(1, n);
+ }
+ },
+
+
new Test("Bad resource #3") {
public void run()
{
diff --git a/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java b/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java
index 3532e30..cb94e52 100644
--- a/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java
+++ b/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java
@@ -157,5 +157,22 @@ public class StatusBarTest extends TestActivity
}, 3000);
}
},
+ new Test("More icons") {
+ public void run() {
+ for (String slot: new String[] {
+ "sync_failing",
+ "gps",
+ "bluetooth",
+ "tty",
+ "speakerphone",
+ "mute",
+ "wifi",
+ "alarm_clock",
+ "secure",
+ }) {
+ mStatusBarManager.setIconVisibility(slot, true);
+ }
+ }
+ },
};
}