PhoneStatusBar.java revision 99a9655b9333c3bff6e462b12baa56a5fcd4cb20
1/* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.systemui.statusbar.phone; 18 19import android.animation.ObjectAnimator; 20import android.app.ActivityManager; 21import android.app.ActivityManagerNative; 22import android.app.Dialog; 23import android.app.KeyguardManager; 24import android.app.Notification; 25import android.app.PendingIntent; 26import android.app.StatusBarManager; 27import android.content.BroadcastReceiver; 28import android.content.Context; 29import android.content.Intent; 30import android.content.IntentFilter; 31import android.content.pm.ApplicationInfo; 32import android.content.pm.PackageManager.NameNotFoundException; 33import android.content.res.Resources; 34import android.content.res.Configuration; 35import android.inputmethodservice.InputMethodService; 36import android.graphics.PixelFormat; 37import android.graphics.Rect; 38import android.graphics.drawable.Drawable; 39import android.os.Build; 40import android.os.IBinder; 41import android.os.RemoteException; 42import android.os.Handler; 43import android.os.Message; 44import android.os.ServiceManager; 45import android.os.SystemClock; 46import android.provider.Settings; 47import android.text.TextUtils; 48import android.util.DisplayMetrics; 49import android.util.Slog; 50import android.util.Log; 51import android.view.Display; 52import android.view.Gravity; 53import android.view.IWindowManager; 54import android.view.KeyEvent; 55import android.view.LayoutInflater; 56import android.view.MotionEvent; 57import android.view.VelocityTracker; 58import android.view.View; 59import android.view.ViewGroup; 60import android.view.ViewGroup.LayoutParams; 61import android.view.Window; 62import android.view.WindowManager; 63import android.view.WindowManagerImpl; 64import android.view.animation.Animation; 65import android.view.animation.AnimationUtils; 66import android.widget.ImageView; 67import android.widget.LinearLayout; 68import android.widget.RemoteViews; 69import android.widget.ScrollView; 70import android.widget.TextView; 71 72import java.io.FileDescriptor; 73import java.io.PrintWriter; 74import java.util.ArrayList; 75 76import com.android.internal.statusbar.StatusBarIcon; 77import com.android.internal.statusbar.StatusBarNotification; 78 79import com.android.systemui.R; 80import com.android.systemui.recent.RecentTasksLoader; 81import com.android.systemui.recent.RecentsPanelView; 82import com.android.systemui.recent.TaskDescription; 83import com.android.systemui.statusbar.NotificationData; 84import com.android.systemui.statusbar.StatusBar; 85import com.android.systemui.statusbar.StatusBarIconView; 86import com.android.systemui.statusbar.SignalClusterView; 87import com.android.systemui.statusbar.policy.DateView; 88import com.android.systemui.statusbar.policy.BatteryController; 89import com.android.systemui.statusbar.policy.LocationController; 90import com.android.systemui.statusbar.policy.NetworkController; 91import com.android.systemui.statusbar.policy.NotificationRowLayout; 92 93public class PhoneStatusBar extends StatusBar { 94 static final String TAG = "PhoneStatusBar"; 95 public static final boolean DEBUG = false; 96 public static final boolean SPEW = false; 97 public static final boolean DUMPTRUCK = true; // extra dumpsys info 98 99 // additional instrumentation for testing purposes; intended to be left on during development 100 public static final boolean CHATTY = DEBUG; 101 102 public static final String ACTION_STATUSBAR_START 103 = "com.android.internal.policy.statusbar.START"; 104 105 static final int EXPANDED_LEAVE_ALONE = -10000; 106 static final int EXPANDED_FULL_OPEN = -10001; 107 108 private static final int MSG_ANIMATE = 100; 109 private static final int MSG_ANIMATE_REVEAL = 101; 110 private static final int MSG_OPEN_NOTIFICATION_PANEL = 1000; 111 private static final int MSG_CLOSE_NOTIFICATION_PANEL = 1001; 112 private static final int MSG_SHOW_INTRUDER = 1002; 113 private static final int MSG_HIDE_INTRUDER = 1003; 114 private static final int MSG_OPEN_RECENTS_PANEL = 1020; 115 private static final int MSG_CLOSE_RECENTS_PANEL = 1021; 116 117 // will likely move to a resource or other tunable param at some point 118 private static final int INTRUDER_ALERT_DECAY_MS = 10000; 119 120 private static final boolean CLOSE_PANEL_WHEN_EMPTIED = true; 121 122 // fling gesture tuning parameters, scaled to display density 123 private float mSelfExpandVelocityPx; // classic value: 2000px/s 124 private float mSelfCollapseVelocityPx; // classic value: 2000px/s (will be negated to collapse "up") 125 private float mFlingExpandMinVelocityPx; // classic value: 200px/s 126 private float mFlingCollapseMinVelocityPx; // classic value: 200px/s 127 private float mCollapseMinDisplayFraction; // classic value: 0.08 (25px/min(320px,480px) on G1) 128 private float mExpandMinDisplayFraction; // classic value: 0.5 (drag open halfway to expand) 129 private float mFlingGestureMaxXVelocityPx; // classic value: 150px/s 130 131 private float mExpandAccelPx; // classic value: 2000px/s/s 132 private float mCollapseAccelPx; // classic value: 2000px/s/s (will be negated to collapse "up") 133 134 PhoneStatusBarPolicy mIconPolicy; 135 136 // These are no longer handled by the policy, because we need custom strategies for them 137 BatteryController mBatteryController; 138 LocationController mLocationController; 139 NetworkController mNetworkController; 140 141 int mNaturalBarHeight = -1; 142 int mIconSize = -1; 143 int mIconHPadding = -1; 144 Display mDisplay; 145 146 IWindowManager mWindowManager; 147 148 PhoneStatusBarView mStatusBarView; 149 int mPixelFormat; 150 H mHandler = new H(); 151 Object mQueueLock = new Object(); 152 153 // icons 154 LinearLayout mIcons; 155 IconMerger mNotificationIcons; 156 View mMoreIcon; 157 LinearLayout mStatusIcons; 158 159 // expanded notifications 160 Dialog mExpandedDialog; 161 ExpandedView mExpandedView; 162 WindowManager.LayoutParams mExpandedParams; 163 ScrollView mScrollView; 164 View mExpandedContents; 165 // top bar 166 TextView mNoNotificationsTitle; 167 View mClearButton; 168 View mSettingsButton; 169 170 // drag bar 171 CloseDragHandle mCloseView; 172 173 // all notifications 174 NotificationData mNotificationData = new NotificationData(); 175 NotificationRowLayout mPile; 176 177 // position 178 int[] mPositionTmp = new int[2]; 179 boolean mExpanded; 180 boolean mExpandedVisible; 181 182 // the date view 183 DateView mDateView; 184 185 // for immersive activities 186 private View mIntruderAlertView; 187 188 // on-screen navigation buttons 189 private NavigationBarView mNavigationBarView = null; 190 191 // the tracker view 192 TrackingView mTrackingView; 193 WindowManager.LayoutParams mTrackingParams; 194 int mTrackingPosition; // the position of the top of the tracking view. 195 private boolean mPanelSlightlyVisible; 196 197 // ticker 198 private Ticker mTicker; 199 private View mTickerView; 200 private boolean mTicking; 201 202 // Recent apps 203 private RecentsPanelView mRecentsPanel; 204 private RecentTasksLoader mRecentTasksLoader; 205 206 // Tracking finger for opening/closing. 207 int mEdgeBorder; // corresponds to R.dimen.status_bar_edge_ignore 208 boolean mTracking; 209 VelocityTracker mVelocityTracker; 210 211 static final int ANIM_FRAME_DURATION = (1000/60); 212 213 boolean mAnimating; 214 long mCurAnimationTime; 215 float mAnimY; 216 float mAnimVel; 217 float mAnimAccel; 218 long mAnimLastTime; 219 boolean mAnimatingReveal = false; 220 int mViewDelta; 221 int[] mAbsPos = new int[2]; 222 Runnable mPostCollapseCleanup = null; 223 224 225 // for disabling the status bar 226 int mDisabled = 0; 227 228 // tracking calls to View.setSystemUiVisibility() 229 int mSystemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE; 230 231 DisplayMetrics mDisplayMetrics = new DisplayMetrics(); 232 233 private int mNavigationIconHints = 0; 234 235 private class ExpandedDialog extends Dialog { 236 ExpandedDialog(Context context) { 237 super(context, com.android.internal.R.style.Theme_Translucent_NoTitleBar); 238 } 239 240 @Override 241 public boolean dispatchKeyEvent(KeyEvent event) { 242 boolean down = event.getAction() == KeyEvent.ACTION_DOWN; 243 switch (event.getKeyCode()) { 244 case KeyEvent.KEYCODE_BACK: 245 if (!down) { 246 animateCollapse(); 247 } 248 return true; 249 } 250 return super.dispatchKeyEvent(event); 251 } 252 } 253 254 @Override 255 public void start() { 256 mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)) 257 .getDefaultDisplay(); 258 259 mWindowManager = IWindowManager.Stub.asInterface( 260 ServiceManager.getService(Context.WINDOW_SERVICE)); 261 262 super.start(); // calls makeStatusBarView() 263 264 addNavigationBar(); 265 266 //addIntruderView(); 267 268 // Lastly, call to the icon policy to install/update all the icons. 269 mIconPolicy = new PhoneStatusBarPolicy(mContext); 270 } 271 272 // ================================================================================ 273 // Constructing the view 274 // ================================================================================ 275 protected View makeStatusBarView() { 276 final Context context = mContext; 277 278 Resources res = context.getResources(); 279 280 updateDisplaySize(); // populates mDisplayMetrics 281 loadDimens(); 282 283 mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size); 284 285 ExpandedView expanded = (ExpandedView)View.inflate(context, 286 R.layout.status_bar_expanded, null); 287 if (DEBUG) { 288 expanded.setBackgroundColor(0x6000FF80); 289 } 290 expanded.mService = this; 291 292 mIntruderAlertView = View.inflate(context, R.layout.intruder_alert, null); 293 mIntruderAlertView.setVisibility(View.GONE); 294 mIntruderAlertView.setClickable(true); 295 296 PhoneStatusBarView sb = (PhoneStatusBarView)View.inflate(context, 297 R.layout.status_bar, null); 298 sb.mService = this; 299 mStatusBarView = sb; 300 301 try { 302 boolean showNav = mWindowManager.hasNavigationBar(); 303 if (showNav) { 304 mNavigationBarView = 305 (NavigationBarView) View.inflate(context, R.layout.navigation_bar, null); 306 307 mNavigationBarView.setDisabledFlags(mDisabled); 308 } 309 } catch (RemoteException ex) { 310 // no window manager? good luck with that 311 } 312 313 // figure out which pixel-format to use for the status bar. 314 mPixelFormat = PixelFormat.OPAQUE; 315 mStatusIcons = (LinearLayout)sb.findViewById(R.id.statusIcons); 316 mNotificationIcons = (IconMerger)sb.findViewById(R.id.notificationIcons); 317 mMoreIcon = sb.findViewById(R.id.moreIcon); 318 mNotificationIcons.setOverflowIndicator(mMoreIcon); 319 mIcons = (LinearLayout)sb.findViewById(R.id.icons); 320 mTickerView = sb.findViewById(R.id.ticker); 321 322 mExpandedDialog = new ExpandedDialog(context); 323 mExpandedView = expanded; 324 mPile = (NotificationRowLayout)expanded.findViewById(R.id.latestItems); 325 mExpandedContents = mPile; // was: expanded.findViewById(R.id.notificationLinearLayout); 326 mNoNotificationsTitle = (TextView)expanded.findViewById(R.id.noNotificationsTitle); 327 mNoNotificationsTitle.setVisibility(View.GONE); // disabling for now 328 329 mClearButton = expanded.findViewById(R.id.clear_all_button); 330 mClearButton.setOnClickListener(mClearButtonListener); 331 mClearButton.setAlpha(0f); 332 mClearButton.setEnabled(false); 333 mDateView = (DateView)expanded.findViewById(R.id.date); 334 mSettingsButton = expanded.findViewById(R.id.settings_button); 335 mSettingsButton.setOnClickListener(mSettingsButtonListener); 336 mScrollView = (ScrollView)expanded.findViewById(R.id.scroll); 337 338 mTicker = new MyTicker(context, sb); 339 340 TickerView tickerView = (TickerView)sb.findViewById(R.id.tickerText); 341 tickerView.mTicker = mTicker; 342 343 mTrackingView = (TrackingView)View.inflate(context, R.layout.status_bar_tracking, null); 344 mTrackingView.mService = this; 345 mCloseView = (CloseDragHandle)mTrackingView.findViewById(R.id.close); 346 mCloseView.mService = this; 347 348 mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore); 349 350 // set the inital view visibility 351 setAreThereNotifications(); 352 353 // Other icons 354 mLocationController = new LocationController(mContext); // will post a notification 355 mBatteryController = new BatteryController(mContext); 356 mBatteryController.addIconView((ImageView)sb.findViewById(R.id.battery)); 357 mNetworkController = new NetworkController(mContext); 358 final SignalClusterView signalCluster = 359 (SignalClusterView)sb.findViewById(R.id.signal_cluster); 360 mNetworkController.addSignalCluster(signalCluster); 361 signalCluster.setNetworkController(mNetworkController); 362// final ImageView wimaxRSSI = 363// (ImageView)sb.findViewById(R.id.wimax_signal); 364// if (wimaxRSSI != null) { 365// mNetworkController.addWimaxIconView(wimaxRSSI); 366// } 367 // Recents Panel 368 mRecentTasksLoader = new RecentTasksLoader(context); 369 updateRecentsPanel(); 370 371 // receive broadcasts 372 IntentFilter filter = new IntentFilter(); 373 filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); 374 filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); 375 filter.addAction(Intent.ACTION_SCREEN_OFF); 376 context.registerReceiver(mBroadcastReceiver, filter); 377 378 return sb; 379 } 380 381 protected WindowManager.LayoutParams getRecentsLayoutParams(LayoutParams layoutParams) { 382 boolean opaque = false; 383 WindowManager.LayoutParams lp = new WindowManager.LayoutParams( 384 layoutParams.width, 385 layoutParams.height, 386 WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, 387 WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 388 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM 389 | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, 390 (opaque ? PixelFormat.OPAQUE : PixelFormat.TRANSLUCENT)); 391 if (ActivityManager.isHighEndGfx(mDisplay)) { 392 lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; 393 } 394 lp.gravity = Gravity.BOTTOM | Gravity.LEFT; 395 lp.setTitle("RecentsPanel"); 396 lp.windowAnimations = com.android.internal.R.style.Animation_RecentApplications; 397 lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED 398 | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; 399 return lp; 400 } 401 402 protected void updateRecentsPanel() { 403 // Recents Panel 404 boolean visible = false; 405 ArrayList<TaskDescription> recentTasksList = null; 406 boolean firstScreenful = false; 407 if (mRecentsPanel != null) { 408 visible = mRecentsPanel.isShowing(); 409 WindowManagerImpl.getDefault().removeView(mRecentsPanel); 410 if (visible) { 411 recentTasksList = mRecentsPanel.getRecentTasksList(); 412 firstScreenful = mRecentsPanel.getFirstScreenful(); 413 } 414 } 415 416 // Provide RecentsPanelView with a temporary parent to allow layout params to work. 417 LinearLayout tmpRoot = new LinearLayout(mContext); 418 mRecentsPanel = (RecentsPanelView) LayoutInflater.from(mContext).inflate( 419 R.layout.status_bar_recent_panel, tmpRoot, false); 420 mRecentsPanel.setRecentTasksLoader(mRecentTasksLoader); 421 mRecentTasksLoader.setRecentsPanel(mRecentsPanel); 422 mRecentsPanel.setOnTouchListener(new TouchOutsideListener(MSG_CLOSE_RECENTS_PANEL, 423 mRecentsPanel)); 424 mRecentsPanel.setVisibility(View.GONE); 425 WindowManager.LayoutParams lp = getRecentsLayoutParams(mRecentsPanel.getLayoutParams()); 426 427 WindowManagerImpl.getDefault().addView(mRecentsPanel, lp); 428 mRecentsPanel.setBar(this); 429 if (visible) { 430 mRecentsPanel.show(true, false, recentTasksList, firstScreenful); 431 } 432 433 } 434 435 protected int getStatusBarGravity() { 436 return Gravity.TOP | Gravity.FILL_HORIZONTAL; 437 } 438 439 public int getStatusBarHeight() { 440 final Resources res = mContext.getResources(); 441 return res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); 442 } 443 444 private View.OnClickListener mRecentsClickListener = new View.OnClickListener() { 445 public void onClick(View v) { 446 toggleRecentApps(); 447 } 448 }; 449 450 private void prepareNavigationBarView() { 451 mNavigationBarView.reorient(); 452 453 mNavigationBarView.getRecentsButton().setOnClickListener(mRecentsClickListener); 454 mNavigationBarView.getRecentsButton().setOnTouchListener(mRecentsPanel); 455 } 456 457 // For small-screen devices (read: phones) that lack hardware navigation buttons 458 private void addNavigationBar() { 459 if (mNavigationBarView == null) return; 460 461 prepareNavigationBarView(); 462 463 WindowManagerImpl.getDefault().addView( 464 mNavigationBarView, getNavigationBarLayoutParams()); 465 } 466 467 private void repositionNavigationBar() { 468 if (mNavigationBarView == null) return; 469 470 prepareNavigationBarView(); 471 472 WindowManagerImpl.getDefault().updateViewLayout( 473 mNavigationBarView, getNavigationBarLayoutParams()); 474 } 475 476 private WindowManager.LayoutParams getNavigationBarLayoutParams() { 477 WindowManager.LayoutParams lp = new WindowManager.LayoutParams( 478 LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 479 WindowManager.LayoutParams.TYPE_NAVIGATION_BAR, 480 0 481 | WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING 482 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE 483 | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL 484 | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH 485 | WindowManager.LayoutParams.FLAG_SLIPPERY, 486 PixelFormat.OPAQUE); 487 // this will allow the navbar to run in an overlay on devices that support this 488 if (ActivityManager.isHighEndGfx(mDisplay)) { 489 lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; 490 } 491 492 lp.setTitle("NavigationBar"); 493 lp.windowAnimations = 0; 494 495 return lp; 496 } 497 498 private void addIntruderView() { 499 final int height = getStatusBarHeight(); 500 501 WindowManager.LayoutParams lp = new WindowManager.LayoutParams( 502 ViewGroup.LayoutParams.MATCH_PARENT, 503 ViewGroup.LayoutParams.WRAP_CONTENT, 504 WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL, 505 WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 506 | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS 507 | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL 508 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE 509 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM 510 | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, 511 PixelFormat.TRANSLUCENT); 512 lp.gravity = Gravity.TOP | Gravity.FILL_HORIZONTAL; 513 lp.y += height * 1.5; // FIXME 514 lp.setTitle("IntruderAlert"); 515 lp.packageName = mContext.getPackageName(); 516 lp.windowAnimations = R.style.Animation_StatusBar_IntruderAlert; 517 518 WindowManagerImpl.getDefault().addView(mIntruderAlertView, lp); 519 } 520 521 public void addIcon(String slot, int index, int viewIndex, StatusBarIcon icon) { 522 if (SPEW) Slog.d(TAG, "addIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex 523 + " icon=" + icon); 524 StatusBarIconView view = new StatusBarIconView(mContext, slot, null); 525 view.set(icon); 526 mStatusIcons.addView(view, viewIndex, new LinearLayout.LayoutParams(mIconSize, mIconSize)); 527 } 528 529 public void updateIcon(String slot, int index, int viewIndex, 530 StatusBarIcon old, StatusBarIcon icon) { 531 if (SPEW) Slog.d(TAG, "updateIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex 532 + " old=" + old + " icon=" + icon); 533 StatusBarIconView view = (StatusBarIconView)mStatusIcons.getChildAt(viewIndex); 534 view.set(icon); 535 } 536 537 public void removeIcon(String slot, int index, int viewIndex) { 538 if (SPEW) Slog.d(TAG, "removeIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex); 539 mStatusIcons.removeViewAt(viewIndex); 540 } 541 542 public void addNotification(IBinder key, StatusBarNotification notification) { 543 StatusBarIconView iconView = addNotificationViews(key, notification); 544 if (iconView == null) return; 545 546 boolean immersive = false; 547 try { 548 immersive = ActivityManagerNative.getDefault().isTopActivityImmersive(); 549 if (DEBUG) { 550 Slog.d(TAG, "Top activity is " + (immersive?"immersive":"not immersive")); 551 } 552 } catch (RemoteException ex) { 553 } 554 if (immersive) { 555 if ((notification.notification.flags & Notification.FLAG_HIGH_PRIORITY) != 0) { 556 Slog.d(TAG, "Presenting high-priority notification in immersive activity"); 557 // special new transient ticker mode 558 // 1. Populate mIntruderAlertView 559 560 ImageView alertIcon = (ImageView) mIntruderAlertView.findViewById(R.id.alertIcon); 561 TextView alertText = (TextView) mIntruderAlertView.findViewById(R.id.alertText); 562 alertIcon.setImageDrawable(StatusBarIconView.getIcon( 563 alertIcon.getContext(), 564 iconView.getStatusBarIcon())); 565 alertText.setText(notification.notification.tickerText); 566 567 View button = mIntruderAlertView.findViewById(R.id.intruder_alert_content); 568 button.setOnClickListener( 569 new NotificationClicker(notification.notification.contentIntent, 570 notification.pkg, notification.tag, notification.id)); 571 572 // 2. Animate mIntruderAlertView in 573 mHandler.sendEmptyMessage(MSG_SHOW_INTRUDER); 574 575 // 3. Set alarm to age the notification off (TODO) 576 mHandler.removeMessages(MSG_HIDE_INTRUDER); 577 mHandler.sendEmptyMessageDelayed(MSG_HIDE_INTRUDER, INTRUDER_ALERT_DECAY_MS); 578 } 579 } else if (notification.notification.fullScreenIntent != null) { 580 // not immersive & a full-screen alert should be shown 581 Slog.d(TAG, "Notification has fullScreenIntent; sending fullScreenIntent"); 582 try { 583 notification.notification.fullScreenIntent.send(); 584 } catch (PendingIntent.CanceledException e) { 585 } 586 } else { 587 // usual case: status bar visible & not immersive 588 589 // show the ticker 590 tick(notification); 591 } 592 593 // Recalculate the position of the sliding windows and the titles. 594 setAreThereNotifications(); 595 updateExpandedViewPos(EXPANDED_LEAVE_ALONE); 596 } 597 598 public void updateNotification(IBinder key, StatusBarNotification notification) { 599 if (DEBUG) Slog.d(TAG, "updateNotification(" + key + " -> " + notification + ")"); 600 601 final NotificationData.Entry oldEntry = mNotificationData.findByKey(key); 602 if (oldEntry == null) { 603 Slog.w(TAG, "updateNotification for unknown key: " + key); 604 return; 605 } 606 607 final StatusBarNotification oldNotification = oldEntry.notification; 608 final RemoteViews oldContentView = oldNotification.notification.contentView; 609 610 final RemoteViews contentView = notification.notification.contentView; 611 612 613 if (DEBUG) { 614 Slog.d(TAG, "old notification: when=" + oldNotification.notification.when 615 + " ongoing=" + oldNotification.isOngoing() 616 + " expanded=" + oldEntry.expanded 617 + " contentView=" + oldContentView 618 + " rowParent=" + oldEntry.row.getParent()); 619 Slog.d(TAG, "new notification: when=" + notification.notification.when 620 + " ongoing=" + oldNotification.isOngoing() 621 + " contentView=" + contentView); 622 } 623 624 625 // Can we just reapply the RemoteViews in place? If when didn't change, the order 626 // didn't change. 627 boolean contentsUnchanged = oldEntry.expanded != null 628 && contentView != null && oldContentView != null 629 && contentView.getPackage() != null 630 && oldContentView.getPackage() != null 631 && oldContentView.getPackage().equals(contentView.getPackage()) 632 && oldContentView.getLayoutId() == contentView.getLayoutId(); 633 ViewGroup rowParent = (ViewGroup) oldEntry.row.getParent(); 634 boolean orderUnchanged = notification.notification.when==oldNotification.notification.when 635 && notification.priority == oldNotification.priority; 636 // priority now encompasses isOngoing() 637 638 boolean updateTicker = notification.notification.tickerText != null 639 && !TextUtils.equals(notification.notification.tickerText, 640 oldEntry.notification.notification.tickerText); 641 boolean isFirstAnyway = rowParent.indexOfChild(oldEntry.row) == 0; 642 if (contentsUnchanged && (orderUnchanged || isFirstAnyway)) { 643 if (DEBUG) Slog.d(TAG, "reusing notification for key: " + key); 644 oldEntry.notification = notification; 645 try { 646 // Reapply the RemoteViews 647 contentView.reapply(mContext, oldEntry.content); 648 // update the contentIntent 649 final PendingIntent contentIntent = notification.notification.contentIntent; 650 if (contentIntent != null) { 651 final View.OnClickListener listener = new NotificationClicker(contentIntent, 652 notification.pkg, notification.tag, notification.id); 653 oldEntry.largeIcon.setOnClickListener(listener); 654 oldEntry.content.setOnClickListener(listener); 655 } else { 656 oldEntry.largeIcon.setOnClickListener(null); 657 oldEntry.content.setOnClickListener(null); 658 } 659 // Update the icon. 660 final StatusBarIcon ic = new StatusBarIcon(notification.pkg, 661 notification.notification.icon, notification.notification.iconLevel, 662 notification.notification.number, 663 notification.notification.tickerText); 664 if (!oldEntry.icon.set(ic)) { 665 handleNotificationError(key, notification, "Couldn't update icon: " + ic); 666 return; 667 } 668 // Update the large icon 669 if (notification.notification.largeIcon != null) { 670 oldEntry.largeIcon.setImageBitmap(notification.notification.largeIcon); 671 } else { 672 oldEntry.largeIcon.getLayoutParams().width = 0; 673 oldEntry.largeIcon.setVisibility(View.INVISIBLE); 674 } 675 } 676 catch (RuntimeException e) { 677 // It failed to add cleanly. Log, and remove the view from the panel. 678 Slog.w(TAG, "Couldn't reapply views for package " + contentView.getPackage(), e); 679 removeNotificationViews(key); 680 addNotificationViews(key, notification); 681 } 682 } else { 683 if (SPEW) Slog.d(TAG, "not reusing notification"); 684 removeNotificationViews(key); 685 addNotificationViews(key, notification); 686 } 687 688 // Update the veto button accordingly (and as a result, whether this row is 689 // swipe-dismissable) 690 updateNotificationVetoButton(oldEntry.row, notification); 691 692 // Restart the ticker if it's still running 693 if (updateTicker) { 694 mTicker.halt(); 695 tick(notification); 696 } 697 698 // Recalculate the position of the sliding windows and the titles. 699 setAreThereNotifications(); 700 updateExpandedViewPos(EXPANDED_LEAVE_ALONE); 701 } 702 703 public void removeNotification(IBinder key) { 704 if (SPEW) Slog.d(TAG, "removeNotification key=" + key); 705 StatusBarNotification old = removeNotificationViews(key); 706 707 if (old != null) { 708 // Cancel the ticker if it's still running 709 mTicker.removeEntry(old); 710 711 // Recalculate the position of the sliding windows and the titles. 712 updateExpandedViewPos(EXPANDED_LEAVE_ALONE); 713 714 if (CLOSE_PANEL_WHEN_EMPTIED && mNotificationData.size() == 0 && !mAnimating) { 715 animateCollapse(); 716 } 717 } 718 719 setAreThereNotifications(); 720 } 721 722 @Override 723 protected void onConfigurationChanged(Configuration newConfig) { 724 updateRecentsPanel(); 725 } 726 727 728 View[] makeNotificationView(StatusBarNotification notification, ViewGroup parent) { 729 Notification n = notification.notification; 730 RemoteViews remoteViews = n.contentView; 731 if (remoteViews == null) { 732 return null; 733 } 734 735 // create the row view 736 LayoutInflater inflater = (LayoutInflater)mContext.getSystemService( 737 Context.LAYOUT_INFLATER_SERVICE); 738 View row = inflater.inflate(R.layout.status_bar_notification_row, parent, false); 739 740 // wire up the veto button 741 View vetoButton = updateNotificationVetoButton(row, notification); 742 vetoButton.setContentDescription(mContext.getString( 743 R.string.accessibility_remove_notification)); 744 745 // the large icon 746 ImageView largeIcon = (ImageView)row.findViewById(R.id.large_icon); 747 if (notification.notification.largeIcon != null) { 748 largeIcon.setImageBitmap(notification.notification.largeIcon); 749 } else { 750 largeIcon.getLayoutParams().width = 0; 751 largeIcon.setVisibility(View.INVISIBLE); 752 } 753 754 // bind the click event to the content area 755 ViewGroup content = (ViewGroup)row.findViewById(R.id.content); 756 content.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); 757 content.setOnFocusChangeListener(mFocusChangeListener); 758 PendingIntent contentIntent = n.contentIntent; 759 if (contentIntent != null) { 760 final View.OnClickListener listener = new NotificationClicker(contentIntent, 761 notification.pkg, notification.tag, notification.id); 762 largeIcon.setOnClickListener(listener); 763 content.setOnClickListener(listener); 764 } else { 765 largeIcon.setOnClickListener(null); 766 content.setOnClickListener(null); 767 } 768 769 View expanded = null; 770 Exception exception = null; 771 try { 772 expanded = remoteViews.apply(mContext, content); 773 } 774 catch (RuntimeException e) { 775 exception = e; 776 } 777 if (expanded == null) { 778 String ident = notification.pkg + "/0x" + Integer.toHexString(notification.id); 779 Slog.e(TAG, "couldn't inflate view for notification " + ident, exception); 780 return null; 781 } else { 782 content.addView(expanded); 783 row.setDrawingCacheEnabled(true); 784 } 785 786 applyLegacyRowBackground(notification, content); 787 788 return new View[] { row, content, expanded }; 789 } 790 791 StatusBarIconView addNotificationViews(IBinder key, StatusBarNotification notification) { 792 if (DEBUG) { 793 Slog.d(TAG, "addNotificationViews(key=" + key + ", notification=" + notification); 794 } 795 // Construct the icon. 796 final StatusBarIconView iconView = new StatusBarIconView(mContext, 797 notification.pkg + "/0x" + Integer.toHexString(notification.id), 798 notification.notification); 799 iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); 800 801 final StatusBarIcon ic = new StatusBarIcon(notification.pkg, 802 notification.notification.icon, 803 notification.notification.iconLevel, 804 notification.notification.number, 805 notification.notification.tickerText); 806 if (!iconView.set(ic)) { 807 handleNotificationError(key, notification, "Couldn't create icon: " + ic); 808 return null; 809 } 810 // Construct the expanded view. 811 NotificationData.Entry entry = new NotificationData.Entry(key, notification, iconView); 812 if (!inflateViews(entry, mPile)) { 813 handleNotificationError(key, notification, "Couldn't expand RemoteViews for: " 814 + notification); 815 return null; 816 } 817 818 // Add the expanded view and icon. 819 int pos = mNotificationData.add(entry); 820 if (DEBUG) { 821 Slog.d(TAG, "addNotificationViews: added at " + pos); 822 } 823 updateNotificationIcons(); 824 825 return iconView; 826 } 827 828 private void loadNotificationShade() { 829 int N = mNotificationData.size(); 830 831 ArrayList<View> toShow = new ArrayList<View>(); 832 833 for (int i=0; i<N; i++) { 834 View row = mNotificationData.get(N-i-1).row; 835 toShow.add(row); 836 } 837 838 ArrayList<View> toRemove = new ArrayList<View>(); 839 for (int i=0; i<mPile.getChildCount(); i++) { 840 View child = mPile.getChildAt(i); 841 if (!toShow.contains(child)) { 842 toRemove.add(child); 843 } 844 } 845 846 for (View remove : toRemove) { 847 mPile.removeView(remove); 848 } 849 850 for (int i=0; i<toShow.size(); i++) { 851 View v = toShow.get(i); 852 if (v.getParent() == null) { 853 mPile.addView(v, 0); // the notification shade has newest at the top 854 } 855 } 856 } 857 858 private void reloadAllNotificationIcons() { 859 if (mNotificationIcons == null) return; 860 mNotificationIcons.removeAllViews(); 861 updateNotificationIcons(); 862 } 863 864 private void updateNotificationIcons() { 865 loadNotificationShade(); 866 867 final LinearLayout.LayoutParams params 868 = new LinearLayout.LayoutParams(mIconSize + 2*mIconHPadding, mNaturalBarHeight); 869 870 int N = mNotificationData.size(); 871 872 if (DEBUG) { 873 Slog.d(TAG, "refreshing icons: " + N + " notifications, mNotificationIcons=" + mNotificationIcons); 874 } 875 876 ArrayList<View> toShow = new ArrayList<View>(); 877 878 for (int i=0; i<N; i++) { 879 toShow.add(mNotificationData.get(N-i-1).icon); 880 } 881 882 ArrayList<View> toRemove = new ArrayList<View>(); 883 for (int i=0; i<mNotificationIcons.getChildCount(); i++) { 884 View child = mNotificationIcons.getChildAt(i); 885 if (!toShow.contains(child)) { 886 toRemove.add(child); 887 } 888 } 889 890 for (View remove : toRemove) { 891 mNotificationIcons.removeView(remove); 892 } 893 894 for (int i=0; i<toShow.size(); i++) { 895 View v = toShow.get(i); 896 if (v.getParent() == null) { 897 mNotificationIcons.addView(v, i, params); 898 } 899 } 900 } 901 902 private boolean inflateViews(NotificationData.Entry entry, ViewGroup parent) { 903 StatusBarNotification sbn = entry.notification; 904 RemoteViews remoteViews = sbn.notification.contentView; 905 if (remoteViews == null) { 906 return false; 907 } 908 909 // create the row view 910 LayoutInflater inflater = (LayoutInflater)mContext.getSystemService( 911 Context.LAYOUT_INFLATER_SERVICE); 912 View row = inflater.inflate(R.layout.status_bar_notification_row, parent, false); 913 View vetoButton = updateNotificationVetoButton(row, sbn); 914 vetoButton.setContentDescription(mContext.getString( 915 R.string.accessibility_remove_notification)); 916 917 // the large icon 918 ImageView largeIcon = (ImageView)row.findViewById(R.id.large_icon); 919 if (sbn.notification.largeIcon != null) { 920 largeIcon.setImageBitmap(sbn.notification.largeIcon); 921 largeIcon.setContentDescription(sbn.notification.tickerText); 922 } else { 923 largeIcon.getLayoutParams().width = 0; 924 largeIcon.setVisibility(View.INVISIBLE); 925 } 926 largeIcon.setContentDescription(sbn.notification.tickerText); 927 928 // bind the click event to the content area 929 ViewGroup content = (ViewGroup)row.findViewById(R.id.content); 930 // XXX: update to allow controls within notification views 931 content.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); 932// content.setOnFocusChangeListener(mFocusChangeListener); 933 PendingIntent contentIntent = sbn.notification.contentIntent; 934 if (contentIntent != null) { 935 final View.OnClickListener listener = new NotificationClicker(contentIntent, 936 sbn.pkg, sbn.tag, sbn.id); 937 largeIcon.setOnClickListener(listener); 938 content.setOnClickListener(listener); 939 } else { 940 largeIcon.setOnClickListener(null); 941 content.setOnClickListener(null); 942 } 943 944 View expanded = null; 945 Exception exception = null; 946 try { 947 expanded = remoteViews.apply(mContext, content); 948 } 949 catch (RuntimeException e) { 950 exception = e; 951 } 952 if (expanded == null) { 953 final String ident = sbn.pkg + "/0x" + Integer.toHexString(sbn.id); 954 Slog.e(TAG, "couldn't inflate view for notification " + ident, exception); 955 return false; 956 } else { 957 content.addView(expanded); 958 row.setDrawingCacheEnabled(true); 959 } 960 961 applyLegacyRowBackground(sbn, content); 962 963 entry.row = row; 964 entry.content = content; 965 entry.expanded = expanded; 966 entry.largeIcon = largeIcon; 967 968 return true; 969 } 970 971 void applyLegacyRowBackground(StatusBarNotification sbn, View content) { 972 if (sbn.notification.contentView.getLayoutId() != 973 com.android.internal.R.layout.status_bar_latest_event_content) { 974 int version = 0; 975 try { 976 ApplicationInfo info = mContext.getPackageManager().getApplicationInfo(sbn.pkg, 0); 977 version = info.targetSdkVersion; 978 } catch (NameNotFoundException ex) { 979 Slog.e(TAG, "Failed looking up ApplicationInfo for " + sbn.pkg, ex); 980 } 981 if (version > 0 && version < Build.VERSION_CODES.GINGERBREAD) { 982 content.setBackgroundResource(R.drawable.notification_row_legacy_bg); 983 } else { 984 content.setBackgroundResource(R.drawable.notification_row_bg); 985 } 986 } 987 } 988 989 StatusBarNotification removeNotificationViews(IBinder key) { 990 NotificationData.Entry entry = mNotificationData.remove(key); 991 if (entry == null) { 992 Slog.w(TAG, "removeNotification for unknown key: " + key); 993 return null; 994 } 995 // Remove the expanded view. 996 ViewGroup rowParent = (ViewGroup)entry.row.getParent(); 997 if (rowParent != null) rowParent.removeView(entry.row); 998 updateNotificationIcons(); 999 1000 return entry.notification; 1001 } 1002 1003 private void setAreThereNotifications() { 1004 final boolean any = mNotificationData.size() > 0; 1005 1006 final boolean clearable = any && mNotificationData.hasClearableItems(); 1007 1008 if (DEBUG) { 1009 Slog.d(TAG, "setAreThereNotifications: N=" + mNotificationData.size() 1010 + " any=" + any + " clearable=" + clearable); 1011 } 1012 1013 if (mClearButton.isShown()) { 1014 if (clearable != (mClearButton.getAlpha() == 1.0f)) { 1015 ObjectAnimator.ofFloat(mClearButton, "alpha", 1016 clearable ? 1.0f : 0.0f) 1017 .setDuration(250) 1018 .start(); 1019 } 1020 } else { 1021 mClearButton.setAlpha(clearable ? 1.0f : 0.0f); 1022 } 1023 mClearButton.setEnabled(clearable); 1024 1025 /* 1026 if (mNoNotificationsTitle.isShown()) { 1027 if (any != (mNoNotificationsTitle.getAlpha() == 0.0f)) { 1028 ObjectAnimator a = ObjectAnimator.ofFloat(mNoNotificationsTitle, "alpha", 1029 (any ? 0.0f : 0.75f)); 1030 a.setDuration(any ? 0 : 500); 1031 a.setStartDelay(any ? 250 : 1000); 1032 a.start(); 1033 } 1034 } else { 1035 mNoNotificationsTitle.setAlpha(any ? 0.0f : 0.75f); 1036 } 1037 */ 1038 } 1039 1040 public void showClock(boolean show) { 1041 View clock = mStatusBarView.findViewById(R.id.clock); 1042 if (clock != null) { 1043 clock.setVisibility(show ? View.VISIBLE : View.GONE); 1044 } 1045 } 1046 1047 /** 1048 * State is one or more of the DISABLE constants from StatusBarManager. 1049 */ 1050 public void disable(int state) { 1051 final int old = mDisabled; 1052 final int diff = state ^ old; 1053 mDisabled = state; 1054 1055 if (DEBUG) { 1056 Slog.d(TAG, String.format("disable: 0x%08x -> 0x%08x (diff: 0x%08x)", 1057 old, state, diff)); 1058 } 1059 1060 StringBuilder flagdbg = new StringBuilder(); 1061 flagdbg.append("disable: < "); 1062 flagdbg.append(((state & StatusBarManager.DISABLE_EXPAND) != 0) ? "EXPAND" : "expand"); 1063 flagdbg.append(((diff & StatusBarManager.DISABLE_EXPAND) != 0) ? "* " : " "); 1064 flagdbg.append(((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) ? "ICONS" : "icons"); 1065 flagdbg.append(((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) ? "* " : " "); 1066 flagdbg.append(((state & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) ? "ALERTS" : "alerts"); 1067 flagdbg.append(((diff & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) ? "* " : " "); 1068 flagdbg.append(((state & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) ? "TICKER" : "ticker"); 1069 flagdbg.append(((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) ? "* " : " "); 1070 flagdbg.append(((state & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) ? "SYSTEM_INFO" : "system_info"); 1071 flagdbg.append(((diff & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) ? "* " : " "); 1072 flagdbg.append(((state & StatusBarManager.DISABLE_BACK) != 0) ? "BACK" : "back"); 1073 flagdbg.append(((diff & StatusBarManager.DISABLE_BACK) != 0) ? "* " : " "); 1074 flagdbg.append(((state & StatusBarManager.DISABLE_HOME) != 0) ? "HOME" : "home"); 1075 flagdbg.append(((diff & StatusBarManager.DISABLE_HOME) != 0) ? "* " : " "); 1076 flagdbg.append(((state & StatusBarManager.DISABLE_RECENT) != 0) ? "RECENT" : "recent"); 1077 flagdbg.append(((diff & StatusBarManager.DISABLE_RECENT) != 0) ? "* " : " "); 1078 flagdbg.append(((state & StatusBarManager.DISABLE_CLOCK) != 0) ? "CLOCK" : "clock"); 1079 flagdbg.append(((diff & StatusBarManager.DISABLE_CLOCK) != 0) ? "* " : " "); 1080 flagdbg.append(">"); 1081 Slog.d(TAG, flagdbg.toString()); 1082 1083 if ((diff & StatusBarManager.DISABLE_CLOCK) != 0) { 1084 boolean show = (state & StatusBarManager.DISABLE_CLOCK) == 0; 1085 showClock(show); 1086 } 1087 if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) { 1088 if ((state & StatusBarManager.DISABLE_EXPAND) != 0) { 1089 animateCollapse(); 1090 } 1091 } 1092 1093 if ((diff & (StatusBarManager.DISABLE_HOME 1094 | StatusBarManager.DISABLE_RECENT 1095 | StatusBarManager.DISABLE_BACK)) != 0) { 1096 // the nav bar will take care of these 1097 if (mNavigationBarView != null) mNavigationBarView.setDisabledFlags(state); 1098 1099 if ((state & StatusBarManager.DISABLE_RECENT) != 0) { 1100 // close recents if it's visible 1101 mHandler.removeMessages(MSG_CLOSE_RECENTS_PANEL); 1102 mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL); 1103 } 1104 } 1105 1106 if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { 1107 if ((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { 1108 if (mTicking) { 1109 mTicker.halt(); 1110 } else { 1111 setNotificationIconVisibility(false, com.android.internal.R.anim.fade_out); 1112 } 1113 } else { 1114 if (!mExpandedVisible) { 1115 setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in); 1116 } 1117 } 1118 } else if ((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { 1119 if (mTicking && (state & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { 1120 mTicker.halt(); 1121 } 1122 } 1123 } 1124 1125 /** 1126 * All changes to the status bar and notifications funnel through here and are batched. 1127 */ 1128 private class H extends Handler { 1129 public void handleMessage(Message m) { 1130 switch (m.what) { 1131 case MSG_ANIMATE: 1132 doAnimation(); 1133 break; 1134 case MSG_ANIMATE_REVEAL: 1135 doRevealAnimation(); 1136 break; 1137 case MSG_OPEN_NOTIFICATION_PANEL: 1138 animateExpand(); 1139 break; 1140 case MSG_CLOSE_NOTIFICATION_PANEL: 1141 animateCollapse(); 1142 break; 1143 case MSG_SHOW_INTRUDER: 1144 setIntruderAlertVisibility(true); 1145 break; 1146 case MSG_HIDE_INTRUDER: 1147 setIntruderAlertVisibility(false); 1148 break; 1149 case MSG_OPEN_RECENTS_PANEL: 1150 if (DEBUG) Slog.d(TAG, "opening recents panel"); 1151 if (mRecentsPanel != null) { 1152 mRecentsPanel.show(true, true); 1153 } 1154 break; 1155 case MSG_CLOSE_RECENTS_PANEL: 1156 if (DEBUG) Slog.d(TAG, "closing recents panel"); 1157 if (mRecentsPanel != null && mRecentsPanel.isShowing()) { 1158 mRecentsPanel.show(false, true); 1159 } 1160 break; 1161 } 1162 } 1163 } 1164 1165 View.OnFocusChangeListener mFocusChangeListener = new View.OnFocusChangeListener() { 1166 public void onFocusChange(View v, boolean hasFocus) { 1167 // Because 'v' is a ViewGroup, all its children will be (un)selected 1168 // too, which allows marqueeing to work. 1169 v.setSelected(hasFocus); 1170 } 1171 }; 1172 1173 private void makeExpandedVisible() { 1174 if (SPEW) Slog.d(TAG, "Make expanded visible: expanded visible=" + mExpandedVisible); 1175 if (mExpandedVisible) { 1176 return; 1177 } 1178 mExpandedVisible = true; 1179 visibilityChanged(true); 1180 1181 updateExpandedViewPos(EXPANDED_LEAVE_ALONE); 1182 mExpandedParams.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; 1183 mExpandedParams.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; 1184 if (DEBUG) { 1185 Slog.d(TAG, "makeExpandedVisible: expanded params = " + mExpandedParams); 1186 } 1187 mExpandedDialog.getWindow().setAttributes(mExpandedParams); 1188 mExpandedView.requestFocus(View.FOCUS_FORWARD); 1189 mTrackingView.setVisibility(View.VISIBLE); 1190 } 1191 1192 public void animateExpand() { 1193 if (SPEW) Slog.d(TAG, "Animate expand: expanded=" + mExpanded); 1194 if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) { 1195 return ; 1196 } 1197 if (mExpanded) { 1198 return; 1199 } 1200 1201 prepareTracking(0, true); 1202 performFling(0, mSelfExpandVelocityPx, true); 1203 } 1204 1205 public void animateCollapse() { 1206 animateCollapse(false); 1207 } 1208 1209 public void animateCollapse(boolean excludeRecents) { 1210 animateCollapse(excludeRecents, 1.0f); 1211 } 1212 1213 public void animateCollapse(boolean excludeRecents, float velocityMultiplier) { 1214 if (SPEW) { 1215 Slog.d(TAG, "animateCollapse(): mExpanded=" + mExpanded 1216 + " mExpandedVisible=" + mExpandedVisible 1217 + " mExpanded=" + mExpanded 1218 + " mAnimating=" + mAnimating 1219 + " mAnimY=" + mAnimY 1220 + " mAnimVel=" + mAnimVel); 1221 } 1222 1223 if (!excludeRecents) { 1224 mHandler.removeMessages(MSG_CLOSE_RECENTS_PANEL); 1225 mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL); 1226 } 1227 1228 if (!mExpandedVisible) { 1229 return; 1230 } 1231 1232 int y; 1233 if (mAnimating) { 1234 y = (int)mAnimY; 1235 } else { 1236 y = mDisplayMetrics.heightPixels-1; 1237 } 1238 // Let the fling think that we're open so it goes in the right direction 1239 // and doesn't try to re-open the windowshade. 1240 mExpanded = true; 1241 prepareTracking(y, false); 1242 performFling(y, -mSelfCollapseVelocityPx*velocityMultiplier, true); 1243 } 1244 1245 void performExpand() { 1246 if (SPEW) Slog.d(TAG, "performExpand: mExpanded=" + mExpanded); 1247 if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) { 1248 return ; 1249 } 1250 if (mExpanded) { 1251 return; 1252 } 1253 1254 mExpanded = true; 1255 makeExpandedVisible(); 1256 updateExpandedViewPos(EXPANDED_FULL_OPEN); 1257 1258 if (false) postStartTracing(); 1259 } 1260 1261 void performCollapse() { 1262 if (SPEW) Slog.d(TAG, "performCollapse: mExpanded=" + mExpanded 1263 + " mExpandedVisible=" + mExpandedVisible); 1264 1265 if (!mExpandedVisible) { 1266 return; 1267 } 1268 mExpandedVisible = false; 1269 visibilityChanged(false); 1270 mExpandedParams.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; 1271 mExpandedParams.flags &= ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; 1272 mExpandedDialog.getWindow().setAttributes(mExpandedParams); 1273 mTrackingView.setVisibility(View.GONE); 1274 1275 if ((mDisabled & StatusBarManager.DISABLE_NOTIFICATION_ICONS) == 0) { 1276 setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in); 1277 } 1278 1279 if (!mExpanded) { 1280 return; 1281 } 1282 mExpanded = false; 1283 if (mPostCollapseCleanup != null) { 1284 mPostCollapseCleanup.run(); 1285 mPostCollapseCleanup = null; 1286 } 1287 } 1288 1289 void doAnimation() { 1290 if (mAnimating) { 1291 if (SPEW) Slog.d(TAG, "doAnimation"); 1292 if (SPEW) Slog.d(TAG, "doAnimation before mAnimY=" + mAnimY); 1293 incrementAnim(); 1294 if (SPEW) Slog.d(TAG, "doAnimation after mAnimY=" + mAnimY); 1295 if (mAnimY >= mDisplayMetrics.heightPixels-1) { 1296 if (SPEW) Slog.d(TAG, "Animation completed to expanded state."); 1297 mAnimating = false; 1298 updateExpandedViewPos(EXPANDED_FULL_OPEN); 1299 performExpand(); 1300 } 1301 else if (mAnimY < mStatusBarView.getHeight()) { 1302 if (SPEW) Slog.d(TAG, "Animation completed to collapsed state."); 1303 mAnimating = false; 1304 updateExpandedViewPos(0); 1305 performCollapse(); 1306 } 1307 else { 1308 updateExpandedViewPos((int)mAnimY); 1309 mCurAnimationTime += ANIM_FRAME_DURATION; 1310 mHandler.sendMessageAtTime(mHandler.obtainMessage(MSG_ANIMATE), mCurAnimationTime); 1311 } 1312 } 1313 } 1314 1315 void stopTracking() { 1316 mTracking = false; 1317 mVelocityTracker.recycle(); 1318 mVelocityTracker = null; 1319 } 1320 1321 void incrementAnim() { 1322 long now = SystemClock.uptimeMillis(); 1323 float t = ((float)(now - mAnimLastTime)) / 1000; // ms -> s 1324 final float y = mAnimY; 1325 final float v = mAnimVel; // px/s 1326 final float a = mAnimAccel; // px/s/s 1327 mAnimY = y + (v*t) + (0.5f*a*t*t); // px 1328 mAnimVel = v + (a*t); // px/s 1329 mAnimLastTime = now; // ms 1330 //Slog.d(TAG, "y=" + y + " v=" + v + " a=" + a + " t=" + t + " mAnimY=" + mAnimY 1331 // + " mAnimAccel=" + mAnimAccel); 1332 } 1333 1334 void doRevealAnimation() { 1335 final int h = mCloseView.getHeight() + mStatusBarView.getHeight(); 1336 if (mAnimatingReveal && mAnimating && mAnimY < h) { 1337 incrementAnim(); 1338 if (mAnimY >= h) { 1339 mAnimY = h; 1340 updateExpandedViewPos((int)mAnimY); 1341 } else { 1342 updateExpandedViewPos((int)mAnimY); 1343 mCurAnimationTime += ANIM_FRAME_DURATION; 1344 mHandler.sendMessageAtTime(mHandler.obtainMessage(MSG_ANIMATE_REVEAL), 1345 mCurAnimationTime); 1346 } 1347 } 1348 } 1349 1350 void prepareTracking(int y, boolean opening) { 1351 if (CHATTY) { 1352 Slog.d(TAG, "panel: beginning to track the user's touch, y=" + y + " opening=" + opening); 1353 } 1354 1355 // there are some race conditions that cause this to be inaccurate; let's recalculate it any 1356 // time we're about to drag the panel 1357 updateExpandedSize(); 1358 1359 mTracking = true; 1360 mVelocityTracker = VelocityTracker.obtain(); 1361 if (opening) { 1362 mAnimAccel = mExpandAccelPx; 1363 mAnimVel = mFlingExpandMinVelocityPx; 1364 mAnimY = mStatusBarView.getHeight(); 1365 updateExpandedViewPos((int)mAnimY); 1366 mAnimating = true; 1367 mAnimatingReveal = true; 1368 mHandler.removeMessages(MSG_ANIMATE); 1369 mHandler.removeMessages(MSG_ANIMATE_REVEAL); 1370 long now = SystemClock.uptimeMillis(); 1371 mAnimLastTime = now; 1372 mCurAnimationTime = now + ANIM_FRAME_DURATION; 1373 mAnimating = true; 1374 mHandler.sendMessageAtTime(mHandler.obtainMessage(MSG_ANIMATE_REVEAL), 1375 mCurAnimationTime); 1376 makeExpandedVisible(); 1377 } else { 1378 // it's open, close it? 1379 if (mAnimating) { 1380 mAnimating = false; 1381 mHandler.removeMessages(MSG_ANIMATE); 1382 } 1383 updateExpandedViewPos(y + mViewDelta); 1384 } 1385 } 1386 1387 void performFling(int y, float vel, boolean always) { 1388 if (CHATTY) { 1389 Slog.d(TAG, "panel: will fling, y=" + y + " vel=" + vel); 1390 } 1391 1392 mAnimatingReveal = false; 1393 1394 mAnimY = y; 1395 mAnimVel = vel; 1396 1397 //Slog.d(TAG, "starting with mAnimY=" + mAnimY + " mAnimVel=" + mAnimVel); 1398 1399 if (mExpanded) { 1400 if (!always && ( 1401 vel > mFlingCollapseMinVelocityPx 1402 || (y > (mDisplayMetrics.heightPixels*(1f-mCollapseMinDisplayFraction)) && 1403 vel > -mFlingExpandMinVelocityPx))) { 1404 // We are expanded, but they didn't move sufficiently to cause 1405 // us to retract. Animate back to the expanded position. 1406 mAnimAccel = mExpandAccelPx; 1407 if (vel < 0) { 1408 mAnimVel = 0; 1409 } 1410 } 1411 else { 1412 // We are expanded and are now going to animate away. 1413 mAnimAccel = -mCollapseAccelPx; 1414 if (vel > 0) { 1415 mAnimVel = 0; 1416 } 1417 } 1418 } else { 1419 if (always || ( 1420 vel > mFlingExpandMinVelocityPx 1421 || (y > (mDisplayMetrics.heightPixels*(1f-mExpandMinDisplayFraction)) && 1422 vel > -mFlingCollapseMinVelocityPx))) { 1423 // We are collapsed, and they moved enough to allow us to 1424 // expand. Animate in the notifications. 1425 mAnimAccel = mExpandAccelPx; 1426 if (vel < 0) { 1427 mAnimVel = 0; 1428 } 1429 } 1430 else { 1431 // We are collapsed, but they didn't move sufficiently to cause 1432 // us to retract. Animate back to the collapsed position. 1433 mAnimAccel = -mCollapseAccelPx; 1434 if (vel > 0) { 1435 mAnimVel = 0; 1436 } 1437 } 1438 } 1439 //Slog.d(TAG, "mAnimY=" + mAnimY + " mAnimVel=" + mAnimVel 1440 // + " mAnimAccel=" + mAnimAccel); 1441 1442 long now = SystemClock.uptimeMillis(); 1443 mAnimLastTime = now; 1444 mCurAnimationTime = now + ANIM_FRAME_DURATION; 1445 mAnimating = true; 1446 mHandler.removeMessages(MSG_ANIMATE); 1447 mHandler.removeMessages(MSG_ANIMATE_REVEAL); 1448 mHandler.sendMessageAtTime(mHandler.obtainMessage(MSG_ANIMATE), mCurAnimationTime); 1449 stopTracking(); 1450 } 1451 1452 boolean interceptTouchEvent(MotionEvent event) { 1453 if (SPEW) { 1454 Slog.d(TAG, "Touch: rawY=" + event.getRawY() + " event=" + event + " mDisabled=" 1455 + mDisabled); 1456 } else if (CHATTY) { 1457 if (event.getAction() != MotionEvent.ACTION_MOVE) { 1458 Slog.d(TAG, String.format( 1459 "panel: %s at (%f, %f) mDisabled=0x%08x", 1460 MotionEvent.actionToString(event.getAction()), 1461 event.getRawX(), event.getRawY(), mDisabled)); 1462 } 1463 } 1464 1465 if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) { 1466 return false; 1467 } 1468 1469 final int action = event.getAction(); 1470 final int statusBarSize = mStatusBarView.getHeight(); 1471 final int hitSize = statusBarSize*2; 1472 final int y = (int)event.getRawY(); 1473 if (action == MotionEvent.ACTION_DOWN) { 1474 if (!mExpanded) { 1475 mViewDelta = statusBarSize - y; 1476 } else { 1477 mTrackingView.getLocationOnScreen(mAbsPos); 1478 mViewDelta = mAbsPos[1] + mTrackingView.getHeight() - y; 1479 } 1480 if ((!mExpanded && y < hitSize) || 1481 (mExpanded && y > (mDisplayMetrics.heightPixels-hitSize))) { 1482 1483 // We drop events at the edge of the screen to make the windowshade come 1484 // down by accident less, especially when pushing open a device with a keyboard 1485 // that rotates (like g1 and droid) 1486 int x = (int)event.getRawX(); 1487 final int edgeBorder = mEdgeBorder; 1488 if (x >= edgeBorder && x < mDisplayMetrics.widthPixels - edgeBorder) { 1489 prepareTracking(y, !mExpanded);// opening if we're not already fully visible 1490 trackMovement(event); 1491 } 1492 } 1493 } else if (mTracking) { 1494 trackMovement(event); 1495 final int minY = statusBarSize + mCloseView.getHeight(); 1496 if (action == MotionEvent.ACTION_MOVE) { 1497 if (mAnimatingReveal && y < minY) { 1498 // nothing 1499 } else { 1500 mAnimatingReveal = false; 1501 updateExpandedViewPos(y + mViewDelta); 1502 } 1503 } else if (action == MotionEvent.ACTION_UP 1504 || action == MotionEvent.ACTION_CANCEL) { 1505 mVelocityTracker.computeCurrentVelocity(1000); 1506 1507 float yVel = mVelocityTracker.getYVelocity(); 1508 boolean negative = yVel < 0; 1509 1510 float xVel = mVelocityTracker.getXVelocity(); 1511 if (xVel < 0) { 1512 xVel = -xVel; 1513 } 1514 if (xVel > mFlingGestureMaxXVelocityPx) { 1515 xVel = mFlingGestureMaxXVelocityPx; // limit how much we care about the x axis 1516 } 1517 1518 float vel = (float)Math.hypot(yVel, xVel); 1519 if (negative) { 1520 vel = -vel; 1521 } 1522 1523 if (CHATTY) { 1524 Slog.d(TAG, String.format("gesture: vraw=(%f,%f) vnorm=(%f,%f) vlinear=%f", 1525 mVelocityTracker.getXVelocity(), 1526 mVelocityTracker.getYVelocity(), 1527 xVel, yVel, 1528 vel)); 1529 } 1530 1531 performFling(y + mViewDelta, vel, false); 1532 } 1533 1534 } 1535 return false; 1536 } 1537 1538 private void trackMovement(MotionEvent event) { 1539 // Add movement to velocity tracker using raw screen X and Y coordinates instead 1540 // of window coordinates because the window frame may be moving at the same time. 1541 float deltaX = event.getRawX() - event.getX(); 1542 float deltaY = event.getRawY() - event.getY(); 1543 event.offsetLocation(deltaX, deltaY); 1544 mVelocityTracker.addMovement(event); 1545 event.offsetLocation(-deltaX, -deltaY); 1546 } 1547 1548 @Override // CommandQueue 1549 public void setNavigationIconHints(int hints) { 1550 if (hints == mNavigationIconHints) return; 1551 1552 mNavigationIconHints = hints; 1553 1554 if (mNavigationBarView != null) { 1555 mNavigationBarView.setNavigationIconHints(hints); 1556 } 1557 } 1558 1559 @Override // CommandQueue 1560 public void setSystemUiVisibility(int vis) { 1561 final int old = mSystemUiVisibility; 1562 final int diff = vis ^ old; 1563 1564 if (diff != 0) { 1565 mSystemUiVisibility = vis; 1566 1567 if (0 != (diff & View.SYSTEM_UI_FLAG_LOW_PROFILE)) { 1568 final boolean lightsOut = (0 != (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE)); 1569 if (lightsOut) { 1570 animateCollapse(); 1571 } 1572 if (mNavigationBarView != null) { 1573 mNavigationBarView.setLowProfile(lightsOut); 1574 } 1575 } 1576 1577 notifyUiVisibilityChanged(); 1578 } 1579 } 1580 1581 public void setLightsOn(boolean on) { 1582 Log.v(TAG, "setLightsOn(" + on + ")"); 1583 if (on) { 1584 setSystemUiVisibility(mSystemUiVisibility & ~View.SYSTEM_UI_FLAG_LOW_PROFILE); 1585 } else { 1586 setSystemUiVisibility(mSystemUiVisibility | View.SYSTEM_UI_FLAG_LOW_PROFILE); 1587 } 1588 } 1589 1590 private void notifyUiVisibilityChanged() { 1591 try { 1592 mWindowManager.statusBarVisibilityChanged(mSystemUiVisibility); 1593 } catch (RemoteException ex) { 1594 } 1595 } 1596 1597 public void topAppWindowChanged(boolean showMenu) { 1598 if (DEBUG) { 1599 Slog.d(TAG, (showMenu?"showing":"hiding") + " the MENU button"); 1600 } 1601 if (mNavigationBarView != null) { 1602 mNavigationBarView.setMenuVisibility(showMenu); 1603 } 1604 1605 // See above re: lights-out policy for legacy apps. 1606 if (showMenu) setLightsOn(true); 1607 } 1608 1609 @Override 1610 public void setImeWindowStatus(IBinder token, int vis, int backDisposition) { 1611 boolean altBack = (backDisposition == InputMethodService.BACK_DISPOSITION_WILL_DISMISS) 1612 || ((vis & InputMethodService.IME_VISIBLE) != 0); 1613 1614 mCommandQueue.setNavigationIconHints( 1615 altBack ? (mNavigationIconHints | StatusBarManager.NAVIGATION_HINT_BACK_ALT) 1616 : (mNavigationIconHints & ~StatusBarManager.NAVIGATION_HINT_BACK_ALT)); 1617 } 1618 1619 @Override 1620 public void setHardKeyboardStatus(boolean available, boolean enabled) { } 1621 1622 public NotificationClicker makeClicker(PendingIntent intent, String pkg, String tag, int id) { 1623 return new NotificationClicker(intent, pkg, tag, id); 1624 } 1625 1626 private class NotificationClicker implements View.OnClickListener { 1627 private PendingIntent mIntent; 1628 private String mPkg; 1629 private String mTag; 1630 private int mId; 1631 1632 NotificationClicker(PendingIntent intent, String pkg, String tag, int id) { 1633 mIntent = intent; 1634 mPkg = pkg; 1635 mTag = tag; 1636 mId = id; 1637 } 1638 1639 public void onClick(View v) { 1640 try { 1641 // The intent we are sending is for the application, which 1642 // won't have permission to immediately start an activity after 1643 // the user switches to home. We know it is safe to do at this 1644 // point, so make sure new activity switches are now allowed. 1645 ActivityManagerNative.getDefault().resumeAppSwitches(); 1646 // Also, notifications can be launched from the lock screen, 1647 // so dismiss the lock screen when the activity starts. 1648 ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity(); 1649 } catch (RemoteException e) { 1650 } 1651 1652 if (mIntent != null) { 1653 int[] pos = new int[2]; 1654 v.getLocationOnScreen(pos); 1655 Intent overlay = new Intent(); 1656 overlay.setSourceBounds( 1657 new Rect(pos[0], pos[1], pos[0]+v.getWidth(), pos[1]+v.getHeight())); 1658 try { 1659 mIntent.send(mContext, 0, overlay); 1660 } catch (PendingIntent.CanceledException e) { 1661 // the stack trace isn't very helpful here. Just log the exception message. 1662 Slog.w(TAG, "Sending contentIntent failed: " + e); 1663 } 1664 1665 KeyguardManager kgm = 1666 (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE); 1667 if (kgm != null) kgm.exitKeyguardSecurely(null); 1668 } 1669 1670 try { 1671 mBarService.onNotificationClick(mPkg, mTag, mId); 1672 } catch (RemoteException ex) { 1673 // system process is dead if we're here. 1674 } 1675 1676 // close the shade if it was open 1677 animateCollapse(); 1678 1679 // If this click was on the intruder alert, hide that instead 1680 mHandler.sendEmptyMessage(MSG_HIDE_INTRUDER); 1681 } 1682 } 1683 1684 private void tick(StatusBarNotification n) { 1685 // Show the ticker if one is requested. Also don't do this 1686 // until status bar window is attached to the window manager, 1687 // because... well, what's the point otherwise? And trying to 1688 // run a ticker without being attached will crash! 1689 if (n.notification.tickerText != null && mStatusBarView.getWindowToken() != null) { 1690 if (0 == (mDisabled & (StatusBarManager.DISABLE_NOTIFICATION_ICONS 1691 | StatusBarManager.DISABLE_NOTIFICATION_TICKER))) { 1692 mTicker.addEntry(n); 1693 } 1694 } 1695 } 1696 1697 /** 1698 * Cancel this notification and tell the StatusBarManagerService / NotificationManagerService 1699 * about the failure. 1700 * 1701 * WARNING: this will call back into us. Don't hold any locks. 1702 */ 1703 void handleNotificationError(IBinder key, StatusBarNotification n, String message) { 1704 removeNotification(key); 1705 try { 1706 mBarService.onNotificationError(n.pkg, n.tag, n.id, n.uid, n.initialPid, message); 1707 } catch (RemoteException ex) { 1708 // The end is nigh. 1709 } 1710 } 1711 1712 private class MyTicker extends Ticker { 1713 MyTicker(Context context, View sb) { 1714 super(context, sb); 1715 } 1716 1717 @Override 1718 public void tickerStarting() { 1719 mTicking = true; 1720 mIcons.setVisibility(View.GONE); 1721 mTickerView.setVisibility(View.VISIBLE); 1722 mTickerView.startAnimation(loadAnim(com.android.internal.R.anim.push_up_in, null)); 1723 mIcons.startAnimation(loadAnim(com.android.internal.R.anim.push_up_out, null)); 1724 } 1725 1726 @Override 1727 public void tickerDone() { 1728 mIcons.setVisibility(View.VISIBLE); 1729 mTickerView.setVisibility(View.GONE); 1730 mIcons.startAnimation(loadAnim(com.android.internal.R.anim.push_down_in, null)); 1731 mTickerView.startAnimation(loadAnim(com.android.internal.R.anim.push_down_out, 1732 mTickingDoneListener)); 1733 } 1734 1735 public void tickerHalting() { 1736 mIcons.setVisibility(View.VISIBLE); 1737 mTickerView.setVisibility(View.GONE); 1738 mIcons.startAnimation(loadAnim(com.android.internal.R.anim.fade_in, null)); 1739 mTickerView.startAnimation(loadAnim(com.android.internal.R.anim.fade_out, 1740 mTickingDoneListener)); 1741 } 1742 } 1743 1744 Animation.AnimationListener mTickingDoneListener = new Animation.AnimationListener() {; 1745 public void onAnimationEnd(Animation animation) { 1746 mTicking = false; 1747 } 1748 public void onAnimationRepeat(Animation animation) { 1749 } 1750 public void onAnimationStart(Animation animation) { 1751 } 1752 }; 1753 1754 private Animation loadAnim(int id, Animation.AnimationListener listener) { 1755 Animation anim = AnimationUtils.loadAnimation(mContext, id); 1756 if (listener != null) { 1757 anim.setAnimationListener(listener); 1758 } 1759 return anim; 1760 } 1761 1762 public static String viewInfo(View v) { 1763 return "[(" + v.getLeft() + "," + v.getTop() + ")(" + v.getRight() + "," + v.getBottom() 1764 + ") " + v.getWidth() + "x" + v.getHeight() + "]"; 1765 } 1766 1767 public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { 1768 synchronized (mQueueLock) { 1769 pw.println("Current Status Bar state:"); 1770 pw.println(" mExpanded=" + mExpanded 1771 + ", mExpandedVisible=" + mExpandedVisible); 1772 pw.println(" mTicking=" + mTicking); 1773 pw.println(" mTracking=" + mTracking); 1774 pw.println(" mAnimating=" + mAnimating 1775 + ", mAnimY=" + mAnimY + ", mAnimVel=" + mAnimVel 1776 + ", mAnimAccel=" + mAnimAccel); 1777 pw.println(" mCurAnimationTime=" + mCurAnimationTime 1778 + " mAnimLastTime=" + mAnimLastTime); 1779 pw.println(" mAnimatingReveal=" + mAnimatingReveal 1780 + " mViewDelta=" + mViewDelta); 1781 pw.println(" mDisplayMetrics=" + mDisplayMetrics); 1782 pw.println(" mExpandedParams: " + mExpandedParams); 1783 pw.println(" mExpandedView: " + viewInfo(mExpandedView)); 1784 pw.println(" mExpandedDialog: " + mExpandedDialog); 1785 pw.println(" mTrackingParams: " + mTrackingParams); 1786 pw.println(" mTrackingView: " + viewInfo(mTrackingView)); 1787 pw.println(" mPile: " + viewInfo(mPile)); 1788 pw.println(" mNoNotificationsTitle: " + viewInfo(mNoNotificationsTitle)); 1789 pw.println(" mCloseView: " + viewInfo(mCloseView)); 1790 pw.println(" mTickerView: " + viewInfo(mTickerView)); 1791 pw.println(" mScrollView: " + viewInfo(mScrollView) 1792 + " scroll " + mScrollView.getScrollX() + "," + mScrollView.getScrollY()); 1793 } 1794 1795 pw.print(" mNavigationBarView="); 1796 if (mNavigationBarView == null) { 1797 pw.println("null"); 1798 } else { 1799 mNavigationBarView.dump(fd, pw, args); 1800 } 1801 1802 if (DUMPTRUCK) { 1803 synchronized (mNotificationData) { 1804 int N = mNotificationData.size(); 1805 pw.println(" notification icons: " + N); 1806 for (int i=0; i<N; i++) { 1807 NotificationData.Entry e = mNotificationData.get(i); 1808 pw.println(" [" + i + "] key=" + e.key + " icon=" + e.icon); 1809 StatusBarNotification n = e.notification; 1810 pw.println(" pkg=" + n.pkg + " id=" + n.id + " priority=" + n.priority); 1811 pw.println(" notification=" + n.notification); 1812 pw.println(" tickerText=\"" + n.notification.tickerText + "\""); 1813 } 1814 } 1815 1816 int N = mStatusIcons.getChildCount(); 1817 pw.println(" system icons: " + N); 1818 for (int i=0; i<N; i++) { 1819 StatusBarIconView ic = (StatusBarIconView) mStatusIcons.getChildAt(i); 1820 pw.println(" [" + i + "] icon=" + ic); 1821 } 1822 1823 if (false) { 1824 pw.println("see the logcat for a dump of the views we have created."); 1825 // must happen on ui thread 1826 mHandler.post(new Runnable() { 1827 public void run() { 1828 mStatusBarView.getLocationOnScreen(mAbsPos); 1829 Slog.d(TAG, "mStatusBarView: ----- (" + mAbsPos[0] + "," + mAbsPos[1] 1830 + ") " + mStatusBarView.getWidth() + "x" 1831 + mStatusBarView.getHeight()); 1832 mStatusBarView.debug(); 1833 1834 mExpandedView.getLocationOnScreen(mAbsPos); 1835 Slog.d(TAG, "mExpandedView: ----- (" + mAbsPos[0] + "," + mAbsPos[1] 1836 + ") " + mExpandedView.getWidth() + "x" 1837 + mExpandedView.getHeight()); 1838 mExpandedView.debug(); 1839 1840 mTrackingView.getLocationOnScreen(mAbsPos); 1841 Slog.d(TAG, "mTrackingView: ----- (" + mAbsPos[0] + "," + mAbsPos[1] 1842 + ") " + mTrackingView.getWidth() + "x" 1843 + mTrackingView.getHeight()); 1844 mTrackingView.debug(); 1845 } 1846 }); 1847 } 1848 } 1849 1850 mNetworkController.dump(fd, pw, args); 1851 } 1852 1853 void onBarViewAttached() { 1854 // The status bar has just been attached to the view hierarchy; it's possible that the 1855 // screen has rotated in-between when we set up the window and now, so let's double-check 1856 // the display metrics just in case. 1857 updateDisplaySize(); 1858 1859 WindowManager.LayoutParams lp; 1860 int pixelFormat; 1861 Drawable bg; 1862 1863 /// ---------- Tracking View -------------- 1864 bg = mTrackingView.getBackground(); 1865 if (bg != null) { 1866 pixelFormat = bg.getOpacity(); 1867 } 1868 1869 lp = new WindowManager.LayoutParams( 1870 ViewGroup.LayoutParams.MATCH_PARENT, 1871 ViewGroup.LayoutParams.MATCH_PARENT, 1872 WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL, 1873 0 1874 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 1875 | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS 1876 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, 1877 PixelFormat.TRANSLUCENT); 1878 if (ActivityManager.isHighEndGfx(mDisplay)) { 1879 lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; 1880 } 1881// lp.token = mStatusBarView.getWindowToken(); 1882 lp.gravity = Gravity.TOP | Gravity.FILL_HORIZONTAL; 1883 lp.setTitle("TrackingView"); 1884 lp.y = mTrackingPosition; 1885 mTrackingParams = lp; 1886 1887 WindowManagerImpl.getDefault().addView(mTrackingView, lp); 1888 } 1889 1890 void onTrackingViewAttached() { 1891 WindowManager.LayoutParams lp; 1892 int pixelFormat; 1893 1894 /// ---------- Expanded View -------------- 1895 pixelFormat = PixelFormat.TRANSLUCENT; 1896 1897 lp = mExpandedDialog.getWindow().getAttributes(); 1898 lp.x = 0; 1899 mTrackingPosition = lp.y = mDisplayMetrics.heightPixels; // sufficiently large negative 1900 lp.type = WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL; 1901 lp.flags = 0 1902 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 1903 | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS 1904 | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL 1905 | WindowManager.LayoutParams.FLAG_DITHER 1906 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; 1907 if (ActivityManager.isHighEndGfx(mDisplay)) { 1908 lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; 1909 } 1910 lp.format = pixelFormat; 1911 lp.gravity = Gravity.TOP | Gravity.FILL_HORIZONTAL; 1912 lp.setTitle("StatusBarExpanded"); 1913 mExpandedParams = lp; 1914 updateExpandedSize(); 1915 mExpandedDialog.getWindow().setFormat(pixelFormat); 1916 1917 mExpandedDialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); 1918 mExpandedDialog.setContentView(mExpandedView, 1919 new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1920 ViewGroup.LayoutParams.MATCH_PARENT)); 1921 mExpandedDialog.getWindow().setBackgroundDrawable(null); 1922 mExpandedDialog.show(); 1923 } 1924 1925 void setNotificationIconVisibility(boolean visible, int anim) { 1926 int old = mNotificationIcons.getVisibility(); 1927 int v = visible ? View.VISIBLE : View.INVISIBLE; 1928 if (old != v) { 1929 mNotificationIcons.setVisibility(v); 1930 mNotificationIcons.startAnimation(loadAnim(anim, null)); 1931 } 1932 } 1933 1934 void updateExpandedInvisiblePosition() { 1935 if (mTrackingView != null) { 1936 mTrackingPosition = -mDisplayMetrics.heightPixels; 1937 if (mTrackingParams != null) { 1938 mTrackingParams.y = mTrackingPosition; 1939 WindowManagerImpl.getDefault().updateViewLayout(mTrackingView, mTrackingParams); 1940 } 1941 } 1942 if (mExpandedParams != null) { 1943 mExpandedParams.y = -mDisplayMetrics.heightPixels; 1944 mExpandedDialog.getWindow().setAttributes(mExpandedParams); 1945 } 1946 } 1947 1948 void updateExpandedViewPos(int expandedPosition) { 1949 if (SPEW) { 1950 Slog.d(TAG, "updateExpandedViewPos before expandedPosition=" + expandedPosition 1951 + " mTrackingParams.y=" + ((mTrackingParams == null) ? "?" : mTrackingParams.y) 1952 + " mTrackingPosition=" + mTrackingPosition); 1953 } 1954 1955 int h = mStatusBarView.getHeight(); 1956 int disph = mDisplayMetrics.heightPixels; 1957 1958 // If the expanded view is not visible, make sure they're still off screen. 1959 // Maybe the view was resized. 1960 if (!mExpandedVisible) { 1961 updateExpandedInvisiblePosition(); 1962 return; 1963 } 1964 1965 // tracking view... 1966 int pos; 1967 if (expandedPosition == EXPANDED_FULL_OPEN) { 1968 pos = h; 1969 } 1970 else if (expandedPosition == EXPANDED_LEAVE_ALONE) { 1971 pos = mTrackingPosition; 1972 } 1973 else { 1974 if (expandedPosition <= disph) { 1975 pos = expandedPosition; 1976 } else { 1977 pos = disph; 1978 } 1979 pos -= disph-h; 1980 } 1981 mTrackingPosition = mTrackingParams.y = pos; 1982 mTrackingParams.height = disph-h; 1983 WindowManagerImpl.getDefault().updateViewLayout(mTrackingView, mTrackingParams); 1984 1985 if (mExpandedParams != null) { 1986 if (mCloseView.getWindowVisibility() == View.VISIBLE) { 1987 mCloseView.getLocationInWindow(mPositionTmp); 1988 final int closePos = mPositionTmp[1]; 1989 1990 mExpandedContents.getLocationInWindow(mPositionTmp); 1991 final int contentsBottom = mPositionTmp[1] + mExpandedContents.getHeight(); 1992 1993 mExpandedParams.y = pos + mTrackingView.getHeight() 1994 - (mTrackingParams.height-closePos) - contentsBottom; 1995 1996 if (SPEW) { 1997 Slog.d(PhoneStatusBar.TAG, 1998 "pos=" + pos + 1999 " trackingHeight=" + mTrackingView.getHeight() + 2000 " (trackingParams.height - closePos)=" + 2001 (mTrackingParams.height - closePos) + 2002 " contentsBottom=" + contentsBottom); 2003 } 2004 2005 } else { 2006 // If the tracking view is not yet visible, then we can't have 2007 // a good value of the close view location. We need to wait for 2008 // it to be visible to do a layout. 2009 mExpandedParams.y = -mDisplayMetrics.heightPixels; 2010 } 2011 int max = h; 2012 if (mExpandedParams.y > max) { 2013 mExpandedParams.y = max; 2014 } 2015 int min = mTrackingPosition; 2016 if (mExpandedParams.y < min) { 2017 mExpandedParams.y = min; 2018 } 2019 2020 boolean visible = (mTrackingPosition + mTrackingView.getHeight()) > h; 2021 if (!visible) { 2022 // if the contents aren't visible, move the expanded view way off screen 2023 // because the window itself extends below the content view. 2024 mExpandedParams.y = -disph; 2025 } 2026 mExpandedDialog.getWindow().setAttributes(mExpandedParams); 2027 2028 // As long as this isn't just a repositioning that's not supposed to affect 2029 // the user's perception of what's showing, call to say that the visibility 2030 // has changed. (Otherwise, someone else will call to do that). 2031 if (expandedPosition != EXPANDED_LEAVE_ALONE) { 2032 if (SPEW) Slog.d(TAG, "updateExpandedViewPos visibilityChanged(" + visible + ")"); 2033 visibilityChanged(visible); 2034 } 2035 } 2036 2037 if (SPEW) { 2038 Slog.d(TAG, "updateExpandedViewPos after expandedPosition=" + expandedPosition 2039 + " mTrackingParams.y=" + mTrackingParams.y 2040 + " mTrackingPosition=" + mTrackingPosition 2041 + " mExpandedParams.y=" + mExpandedParams.y 2042 + " mExpandedParams.height=" + mExpandedParams.height); 2043 } 2044 } 2045 2046 int getExpandedHeight(int disph) { 2047 if (DEBUG) { 2048 Slog.d(TAG, "getExpandedHeight(" + disph + "): sbView=" 2049 + mStatusBarView.getHeight() + " closeView=" + mCloseView.getHeight()); 2050 } 2051 return disph - mStatusBarView.getHeight() - mCloseView.getHeight(); 2052 } 2053 2054 void updateDisplaySize() { 2055 mDisplay.getMetrics(mDisplayMetrics); 2056 if (DEBUG) { 2057 Slog.d(TAG, "updateDisplaySize: " + mDisplayMetrics); 2058 } 2059 updateExpandedSize(); 2060 } 2061 2062 void updateExpandedSize() { 2063 if (DEBUG) { 2064 Slog.d(TAG, "updateExpandedSize()"); 2065 } 2066 if (mExpandedDialog != null && mExpandedParams != null && mDisplayMetrics != null) { 2067 mExpandedParams.width = mDisplayMetrics.widthPixels; 2068 mExpandedParams.height = getExpandedHeight(mDisplayMetrics.heightPixels); 2069 if (!mExpandedVisible) { 2070 updateExpandedInvisiblePosition(); 2071 } else { 2072 mExpandedDialog.getWindow().setAttributes(mExpandedParams); 2073 } 2074 if (DEBUG) { 2075 Slog.d(TAG, "updateExpandedSize: height=" + mExpandedParams.height + " " + 2076 (mExpandedVisible ? "VISIBLE":"INVISIBLE")); 2077 } 2078 } 2079 } 2080 2081 public void toggleRecentApps() { 2082 int msg = (mRecentsPanel.getVisibility() == View.VISIBLE) 2083 ? MSG_CLOSE_RECENTS_PANEL : MSG_OPEN_RECENTS_PANEL; 2084 mHandler.removeMessages(msg); 2085 mHandler.sendEmptyMessage(msg); 2086 } 2087 2088 /** 2089 * The LEDs are turned o)ff when the notification panel is shown, even just a little bit. 2090 * This was added last-minute and is inconsistent with the way the rest of the notifications 2091 * are handled, because the notification isn't really cancelled. The lights are just 2092 * turned off. If any other notifications happen, the lights will turn back on. Steve says 2093 * this is what he wants. (see bug 1131461) 2094 */ 2095 void visibilityChanged(boolean visible) { 2096 if (mPanelSlightlyVisible != visible) { 2097 mPanelSlightlyVisible = visible; 2098 try { 2099 mBarService.onPanelRevealed(); 2100 } catch (RemoteException ex) { 2101 // Won't fail unless the world has ended. 2102 } 2103 } 2104 } 2105 2106 void performDisableActions(int net) { 2107 int old = mDisabled; 2108 int diff = net ^ old; 2109 mDisabled = net; 2110 2111 // act accordingly 2112 if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) { 2113 if ((net & StatusBarManager.DISABLE_EXPAND) != 0) { 2114 Slog.d(TAG, "DISABLE_EXPAND: yes"); 2115 animateCollapse(); 2116 } 2117 } 2118 if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { 2119 if ((net & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { 2120 Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: yes"); 2121 if (mTicking) { 2122 mNotificationIcons.setVisibility(View.INVISIBLE); 2123 mTicker.halt(); 2124 } else { 2125 setNotificationIconVisibility(false, com.android.internal.R.anim.fade_out); 2126 } 2127 } else { 2128 Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: no"); 2129 if (!mExpandedVisible) { 2130 setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in); 2131 } 2132 } 2133 } else if ((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { 2134 if (mTicking && (net & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { 2135 mTicker.halt(); 2136 } 2137 } 2138 } 2139 2140 private View.OnClickListener mClearButtonListener = new View.OnClickListener() { 2141 final int mini(int a, int b) { 2142 return (b>a?a:b); 2143 } 2144 public void onClick(View v) { 2145 synchronized (mNotificationData) { 2146 // animate-swipe all dismissable notifications, then animate the shade closed 2147 int numChildren = mPile.getChildCount(); 2148 2149 int scrollTop = mScrollView.getScrollY(); 2150 int scrollBottom = scrollTop + mScrollView.getHeight(); 2151 final ArrayList<View> snapshot = new ArrayList<View>(numChildren); 2152 for (int i=0; i<numChildren; i++) { 2153 final View child = mPile.getChildAt(i); 2154 if (mPile.canChildBeDismissed(child) && child.getBottom() > scrollTop && 2155 child.getTop() < scrollBottom) { 2156 snapshot.add(child); 2157 } 2158 } 2159 final int N = snapshot.size(); 2160 new Thread(new Runnable() { 2161 @Override 2162 public void run() { 2163 // Decrease the delay for every row we animate to give the sense of 2164 // accelerating the swipes 2165 final int ROW_DELAY_DECREMENT = 10; 2166 int currentDelay = 140; 2167 int totalDelay = 0; 2168 2169 // Set the shade-animating state to avoid doing other work during 2170 // all of these animations. In particular, avoid layout and 2171 // redrawing when collapsing the shade. 2172 mPile.setViewRemoval(false); 2173 2174 mPostCollapseCleanup = new Runnable() { 2175 public void run() { 2176 try { 2177 mPile.setViewRemoval(true); 2178 mBarService.onClearAllNotifications(); 2179 } catch (Exception ex) { } 2180 } 2181 }; 2182 2183 View sampleView = snapshot.get(0); 2184 int width = sampleView.getWidth(); 2185 final int velocity = (int)(width * 8); // 1000/8 = 125 ms duration 2186 for (View v : snapshot) { 2187 final View _v = v; 2188 mHandler.postDelayed(new Runnable() { 2189 @Override 2190 public void run() { 2191 mPile.dismissRowAnimated(_v, velocity); 2192 } 2193 }, totalDelay); 2194 currentDelay = Math.max(50, currentDelay - ROW_DELAY_DECREMENT); 2195 totalDelay += currentDelay; 2196 } 2197 // Delay the collapse animation until after all swipe animations have 2198 // finished. Provide some buffer because there may be some extra delay 2199 // before actually starting each swipe animation. Ideally, we'd 2200 // synchronize the end of those animations with the start of the collaps 2201 // exactly. 2202 mHandler.postDelayed(new Runnable() { 2203 public void run() { 2204 animateCollapse(false); 2205 } 2206 }, totalDelay + 225); 2207 } 2208 }).start(); 2209 } 2210 } 2211 }; 2212 2213 private View.OnClickListener mSettingsButtonListener = new View.OnClickListener() { 2214 public void onClick(View v) { 2215 try { 2216 // Dismiss the lock screen when Settings starts. 2217 ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity(); 2218 } catch (RemoteException e) { 2219 } 2220 v.getContext().startActivity(new Intent(Settings.ACTION_SETTINGS) 2221 .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); 2222 animateCollapse(); 2223 } 2224 }; 2225 2226 private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { 2227 public void onReceive(Context context, Intent intent) { 2228 String action = intent.getAction(); 2229 if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action) 2230 || Intent.ACTION_SCREEN_OFF.equals(action)) { 2231 boolean excludeRecents = false; 2232 if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) { 2233 String reason = intent.getStringExtra("reason"); 2234 if (reason != null) { 2235 excludeRecents = reason.equals("recentapps"); 2236 } 2237 } 2238 animateCollapse(excludeRecents); 2239 } 2240 else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) { 2241 repositionNavigationBar(); 2242 updateResources(); 2243 } 2244 } 2245 }; 2246 2247 private void setIntruderAlertVisibility(boolean vis) { 2248 mIntruderAlertView.setVisibility(vis ? View.VISIBLE : View.GONE); 2249 } 2250 2251 /** 2252 * Reload some of our resources when the configuration changes. 2253 * 2254 * We don't reload everything when the configuration changes -- we probably 2255 * should, but getting that smooth is tough. Someday we'll fix that. In the 2256 * meantime, just update the things that we know change. 2257 */ 2258 void updateResources() { 2259 final Context context = mContext; 2260 final Resources res = context.getResources(); 2261 2262 if (mClearButton instanceof TextView) { 2263 ((TextView)mClearButton).setText(context.getText(R.string.status_bar_clear_all_button)); 2264 } 2265 mNoNotificationsTitle.setText(context.getText(R.string.status_bar_no_notifications_title)); 2266 2267 loadDimens(); 2268 } 2269 2270 protected void loadDimens() { 2271 final Resources res = mContext.getResources(); 2272 2273 mNaturalBarHeight = res.getDimensionPixelSize( 2274 com.android.internal.R.dimen.status_bar_height); 2275 2276 int newIconSize = res.getDimensionPixelSize( 2277 com.android.internal.R.dimen.status_bar_icon_size); 2278 int newIconHPadding = res.getDimensionPixelSize( 2279 R.dimen.status_bar_icon_padding); 2280 2281 if (newIconHPadding != mIconHPadding || newIconSize != mIconSize) { 2282// Slog.d(TAG, "size=" + newIconSize + " padding=" + newIconHPadding); 2283 mIconHPadding = newIconHPadding; 2284 mIconSize = newIconSize; 2285 //reloadAllNotificationIcons(); // reload the tray 2286 } 2287 2288 mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore); 2289 2290 mSelfExpandVelocityPx = res.getDimension(R.dimen.self_expand_velocity); 2291 mSelfCollapseVelocityPx = res.getDimension(R.dimen.self_collapse_velocity); 2292 mFlingExpandMinVelocityPx = res.getDimension(R.dimen.fling_expand_min_velocity); 2293 mFlingCollapseMinVelocityPx = res.getDimension(R.dimen.fling_collapse_min_velocity); 2294 2295 mCollapseMinDisplayFraction = res.getFraction(R.dimen.collapse_min_display_fraction, 1, 1); 2296 mExpandMinDisplayFraction = res.getFraction(R.dimen.expand_min_display_fraction, 1, 1); 2297 2298 mExpandAccelPx = res.getDimension(R.dimen.expand_accel); 2299 mCollapseAccelPx = res.getDimension(R.dimen.collapse_accel); 2300 2301 mFlingGestureMaxXVelocityPx = res.getDimension(R.dimen.fling_gesture_max_x_velocity); 2302 2303 if (false) Slog.v(TAG, "updateResources"); 2304 } 2305 2306 // 2307 // tracing 2308 // 2309 2310 void postStartTracing() { 2311 mHandler.postDelayed(mStartTracing, 3000); 2312 } 2313 2314 void vibrate() { 2315 android.os.Vibrator vib = (android.os.Vibrator)mContext.getSystemService( 2316 Context.VIBRATOR_SERVICE); 2317 vib.vibrate(250); 2318 } 2319 2320 Runnable mStartTracing = new Runnable() { 2321 public void run() { 2322 vibrate(); 2323 SystemClock.sleep(250); 2324 Slog.d(TAG, "startTracing"); 2325 android.os.Debug.startMethodTracing("/data/statusbar-traces/trace"); 2326 mHandler.postDelayed(mStopTracing, 10000); 2327 } 2328 }; 2329 2330 Runnable mStopTracing = new Runnable() { 2331 public void run() { 2332 android.os.Debug.stopMethodTracing(); 2333 Slog.d(TAG, "stopTracing"); 2334 vibrate(); 2335 } 2336 }; 2337 2338 public class TouchOutsideListener implements View.OnTouchListener { 2339 private int mMsg; 2340 private RecentsPanelView mPanel; 2341 2342 public TouchOutsideListener(int msg, RecentsPanelView panel) { 2343 mMsg = msg; 2344 mPanel = panel; 2345 } 2346 2347 public boolean onTouch(View v, MotionEvent ev) { 2348 final int action = ev.getAction(); 2349 if (action == MotionEvent.ACTION_OUTSIDE 2350 || (action == MotionEvent.ACTION_DOWN 2351 && !mPanel.isInContentArea((int)ev.getX(), (int)ev.getY()))) { 2352 mHandler.removeMessages(mMsg); 2353 mHandler.sendEmptyMessage(mMsg); 2354 return true; 2355 } 2356 return false; 2357 } 2358 } 2359} 2360 2361