diff options
Diffstat (limited to 'services/java/com/android/server/status/StatusBarService.java')
-rw-r--r-- | services/java/com/android/server/status/StatusBarService.java | 96 |
1 files changed, 62 insertions, 34 deletions
diff --git a/services/java/com/android/server/status/StatusBarService.java b/services/java/com/android/server/status/StatusBarService.java index b44168a..8d73904 100644 --- a/services/java/com/android/server/status/StatusBarService.java +++ b/services/java/com/android/server/status/StatusBarService.java @@ -126,7 +126,7 @@ public class StatusBarService extends IStatusBar.Stub public interface NotificationCallbacks { void onSetDisabled(int status); void onClearAll(); - void onNotificationClick(String pkg, int id); + void onNotificationClick(String pkg, String tag, int id); void onPanelRevealed(); } @@ -140,7 +140,7 @@ public class StatusBarService extends IStatusBar.Stub boolean down = event.getAction() == KeyEvent.ACTION_DOWN; switch (event.getKeyCode()) { case KeyEvent.KEYCODE_BACK: - if (down) { + if (!down) { StatusBarService.this.deactivate(); } return true; @@ -322,6 +322,7 @@ public class StatusBarService extends IStatusBar.Stub IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); + filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Telephony.Intents.SPN_STRINGS_UPDATED_ACTION); context.registerReceiver(mBroadcastReceiver, filter); } @@ -691,6 +692,7 @@ public class StatusBarService extends IStatusBar.Stub mTicker.addEntry(n, StatusBarIcon.getIcon(mContext, data), n.tickerText); } } + updateExpandedViewPos(EXPANDED_LEAVE_ALONE); } // icon @@ -832,7 +834,7 @@ public class StatusBarService extends IStatusBar.Stub content.setOnFocusChangeListener(mFocusChangeListener); PendingIntent contentIntent = n.contentIntent; if (contentIntent != null) { - content.setOnClickListener(new Launcher(contentIntent, n.pkg, n.id)); + content.setOnClickListener(new Launcher(contentIntent, n.pkg, n.tag, n.id)); } View child = null; @@ -895,7 +897,7 @@ public class StatusBarService extends IStatusBar.Stub com.android.internal.R.id.content); PendingIntent contentIntent = n.contentIntent; if (contentIntent != null) { - content.setOnClickListener(new Launcher(contentIntent, n.pkg, n.id)); + content.setOnClickListener(new Launcher(contentIntent, n.pkg, n.tag, n.id)); } } catch (RuntimeException e) { @@ -949,7 +951,9 @@ public class StatusBarService extends IStatusBar.Stub panelSlightlyVisible(true); updateExpandedViewPos(EXPANDED_LEAVE_ALONE); - mExpandedDialog.show(); + mExpandedParams.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; + mExpandedParams.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; + mExpandedDialog.getWindow().setAttributes(mExpandedParams); mExpandedView.requestFocus(View.FOCUS_FORWARD); mTrackingView.setVisibility(View.VISIBLE); @@ -972,15 +976,24 @@ public class StatusBarService extends IStatusBar.Stub } void animateCollapse() { - if (SPEW) Log.d(TAG, "Animate collapse: expanded=" + mExpanded - + " expanded visible=" + mExpandedVisible); + if (SPEW) { + Log.d(TAG, "animateCollapse(): mExpanded=" + mExpanded + + " mExpandedVisible=" + mExpandedVisible + + " mAnimating=" + mAnimating + + " mAnimVel=" + mAnimVel); + } if (!mExpandedVisible) { return; } - prepareTracking(mDisplay.getHeight()-1); - performFling(mDisplay.getHeight()-1, -2000.0f, true); + if (mAnimating) { + return; + } + + int y = mDisplay.getHeight()-1; + prepareTracking(y); + performFling(y, -2000.0f, true); } void performExpand() { @@ -1017,7 +1030,9 @@ public class StatusBarService extends IStatusBar.Stub } mExpandedVisible = false; panelSlightlyVisible(false); - mExpandedDialog.hide(); + mExpandedParams.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; + mExpandedParams.flags &= ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; + mExpandedDialog.getWindow().setAttributes(mExpandedParams); mTrackingView.setVisibility(View.GONE); if ((mDisabled & StatusBarManager.DISABLE_NOTIFICATION_ICONS) == 0) { @@ -1046,6 +1061,7 @@ public class StatusBarService extends IStatusBar.Stub else if (mAnimY < mStatusBarView.getHeight()) { if (SPEW) Log.d(TAG, "Animation completed to collapsed state."); mAnimating = false; + updateExpandedViewPos(0); performCollapse(); } else { @@ -1095,7 +1111,7 @@ public class StatusBarService extends IStatusBar.Stub mTracking = true; mVelocityTracker = VelocityTracker.obtain(); boolean opening = !mExpanded; - if (!mExpanded) { + if (opening) { mAnimAccel = 2000.0f; mAnimVel = 200; mAnimY = mStatusBarView.getHeight(); @@ -1110,16 +1126,13 @@ public class StatusBarService extends IStatusBar.Stub mAnimating = true; mHandler.sendMessageAtTime(mHandler.obtainMessage(MSG_ANIMATE_REVEAL), mCurAnimationTime); + makeExpandedVisible(); } else { // it's open, close it? if (mAnimating) { mAnimating = false; mHandler.removeMessages(MSG_ANIMATE); } - } - if (opening) { - makeExpandedVisible(); - } else { updateExpandedViewPos(y + mViewDelta); } } @@ -1247,11 +1260,13 @@ public class StatusBarService extends IStatusBar.Stub private class Launcher implements View.OnClickListener { private PendingIntent mIntent; private String mPkg; + private String mTag; private int mId; - Launcher(PendingIntent intent, String pkg, int id) { + Launcher(PendingIntent intent, String pkg, String tag, int id) { mIntent = intent; mPkg = pkg; + mTag = tag; mId = id; } @@ -1266,7 +1281,7 @@ public class StatusBarService extends IStatusBar.Stub } try { mIntent.send(); - mNotificationCallbacks.onNotificationClick(mPkg, mId); + mNotificationCallbacks.onNotificationClick(mPkg, mTag, mId); } catch (PendingIntent.CanceledException e) { // the stack trace isn't very helpful here. Just log the exception message. Log.w(TAG, "Sending contentIntent failed: " + e); @@ -1489,24 +1504,28 @@ public class StatusBarService extends IStatusBar.Stub /// ---------- Expanded View -------------- pixelFormat = PixelFormat.TRANSLUCENT; - if (false) { - bg = mExpandedView.getBackground(); - if (bg != null) { - pixelFormat = bg.getOpacity(); + bg = mExpandedView.getBackground(); + if (bg != null) { + pixelFormat = bg.getOpacity(); + if (pixelFormat != PixelFormat.TRANSLUCENT) { + // we want good-looking gradients, so we force a 8-bits per + // pixel format. + pixelFormat = PixelFormat.RGBX_8888; } } + final int disph = mDisplay.getHeight(); lp = mExpandedDialog.getWindow().getAttributes(); lp.width = ViewGroup.LayoutParams.FILL_PARENT; lp.height = ViewGroup.LayoutParams.WRAP_CONTENT; lp.x = 0; - lp.y = 0; + mTrackingPosition = lp.y = -disph; // sufficiently large negative lp.type = WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL; lp.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL - | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM - | WindowManager.LayoutParams.FLAG_DITHER; + | WindowManager.LayoutParams.FLAG_DITHER + | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; lp.format = pixelFormat; lp.gravity = Gravity.TOP | Gravity.FILL_HORIZONTAL; lp.setTitle("StatusBarExpanded"); @@ -1519,7 +1538,6 @@ public class StatusBarService extends IStatusBar.Stub new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); mExpandedDialog.show(); - mExpandedDialog.hide(); FrameLayout hack = (FrameLayout)mExpandedView.getParent(); hack.setForeground(null); } @@ -1541,20 +1559,29 @@ public class StatusBarService extends IStatusBar.Stub void updateExpandedViewPos(int expandedPosition) { if (SPEW) { - Log.d(TAG, "updateExpandedViewPos before pos=" + expandedPosition + Log.d(TAG, "updateExpandedViewPos before expandedPosition=" + expandedPosition + " mTrackingParams.y=" + mTrackingParams.y + " mTrackingPosition=" + mTrackingPosition); } - // If the expanded view is not visible, there is no reason to do - // any work. + int h = mStatusBarView.getHeight(); + int disph = mDisplay.getHeight(); + + // If the expanded view is not visible, make sure they're still off screen. + // Maybe the view was resized. if (!mExpandedVisible) { + if (mTrackingView != null) { + mTrackingPosition = mTrackingParams.y = -disph; + WindowManagerImpl.getDefault().updateViewLayout(mTrackingView, mTrackingParams); + } + if (mExpandedParams != null) { + mExpandedParams.y = -disph; + mExpandedDialog.getWindow().setAttributes(mExpandedParams); + } return; } - + // tracking view... - int h = mStatusBarView.getHeight(); - int disph = mDisplay.getHeight(); int pos; if (expandedPosition == EXPANDED_FULL_OPEN) { pos = h; @@ -1665,14 +1692,15 @@ public class StatusBarService extends IStatusBar.Stub private View.OnClickListener mClearButtonListener = new View.OnClickListener() { public void onClick(View v) { mNotificationCallbacks.onClearAll(); - performCollapse(); + addPendingOp(OP_EXPAND, null, false); } }; private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { String action = intent.getAction(); - if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) { + if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action) + || Intent.ACTION_SCREEN_OFF.equals(action)) { deactivate(); } else if (Telephony.Intents.SPN_STRINGS_UPDATED_ACTION.equals(action)) { @@ -1726,7 +1754,7 @@ public class StatusBarService extends IStatusBar.Stub mOngoingTitle.setText(mContext.getText(R.string.status_bar_ongoing_events_title)); mLatestTitle.setText(mContext.getText(R.string.status_bar_latest_events_title)); mNoNotificationsTitle.setText(mContext.getText(R.string.status_bar_no_notifications_title)); - Log.d(TAG, "updateResources"); + if (false) Log.v(TAG, "updateResources"); } // |