From aaba60b281713d45a0f232580302c7b54a7207df Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Sun, 23 May 2010 15:18:41 -0400 Subject: [PATCH] Notifications don't crash when you click them, and pass through events to NotificationManagerService Change-Id: Iae4a636d3c6d5c617440b11eb5b8bc77838ad584 --- .../internal/statusbar/IStatusBarService.aidl | 2 ++ .../statusbar/phone/PhoneStatusBarService.java | 17 ++++++++++++----- .../server/status/StatusBarManagerService.java | 10 +++++++++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl index 0a5b90e48e278..f713bf98e3c28 100644 --- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl +++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl @@ -33,4 +33,6 @@ interface IStatusBarService // ---- Methods below are for use by the status bar policy services ---- void registerStatusBar(IStatusBar callbacks, out StatusBarIconList state); void visibilityChanged(boolean visible); + void onNotificationClick(String pkg, String tag, int id); + void onClearAllNotifications(); } 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 37b365594cc1d..97b38b684def2 100644 --- a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java +++ b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java @@ -103,7 +103,7 @@ public class PhoneStatusBarService extends StatusBarService { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_BACK: if (!down) { - //TODO PhoneStatusBarService.this.collapse(); + animateCollapse(); } return true; } @@ -119,7 +119,6 @@ public class PhoneStatusBarService extends StatusBarService { int mPixelFormat; H mHandler = new H(); Object mQueueLock = new Object(); - NotificationCallbacks mNotificationCallbacks; // icons String[] mRightIconSlots; @@ -925,12 +924,16 @@ public class PhoneStatusBarService extends StatusBarService { new Rect(pos[0], pos[1], pos[0]+v.getWidth(), pos[1]+v.getHeight())); try { mIntent.send(PhoneStatusBarService.this, 0, overlay); - mNotificationCallbacks.onNotificationClick(mPkg, mTag, mId); } catch (PendingIntent.CanceledException e) { // the stack trace isn't very helpful here. Just log the exception message. Slog.w(TAG, "Sending contentIntent failed: " + e); } - //collapse(); + try { + mBarService.onNotificationClick(mPkg, mTag, mId); + } catch (RemoteException ex) { + // system process is dead if we're here. + } + animateCollapse(); } } @@ -1314,7 +1317,11 @@ public class PhoneStatusBarService extends StatusBarService { private View.OnClickListener mClearButtonListener = new View.OnClickListener() { public void onClick(View v) { - mNotificationCallbacks.onClearAll(); + try { + mBarService.onClearAllNotifications(); + } catch (RemoteException ex) { + // system process is dead if we're here. + } animateCollapse(); } }; diff --git a/services/java/com/android/server/status/StatusBarManagerService.java b/services/java/com/android/server/status/StatusBarManagerService.java index 22b3810ae5a6e..26a41f321144f 100644 --- a/services/java/com/android/server/status/StatusBarManagerService.java +++ b/services/java/com/android/server/status/StatusBarManagerService.java @@ -255,7 +255,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub mBar = bar; iconList.copyFrom(mIcons); } - + /** * The status bar service should call this when the user changes whether * the status bar is visible or not. @@ -264,6 +264,14 @@ public class StatusBarManagerService extends IStatusBarService.Stub Slog.d(TAG, "visibilityChanged visible=" + visible); } + public void onNotificationClick(String pkg, String tag, int id) { + mNotificationCallbacks.onNotificationClick(pkg, tag, id); + } + + public void onClearAllNotifications() { + mNotificationCallbacks.onClearAll(); + } + // ================================================================================ // Callbacks for NotificationManagerService. // ================================================================================