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