TabletStatusBar.java revision 2932645d9967f63aa716035e40e02af1e6e5aa19
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.tablet; 18 19import java.io.FileDescriptor; 20import java.io.PrintWriter; 21import java.util.ArrayList; 22 23import android.animation.LayoutTransition; 24import android.animation.ObjectAnimator; 25import android.app.ActivityManagerNative; 26import android.app.PendingIntent; 27import android.app.Notification; 28import android.app.StatusBarManager; 29import android.content.Context; 30import android.content.Intent; 31import android.content.SharedPreferences; 32import android.content.res.Configuration; 33import android.content.res.Resources; 34import android.inputmethodservice.InputMethodService; 35import android.graphics.PixelFormat; 36import android.graphics.Rect; 37import android.graphics.drawable.LayerDrawable; 38import android.os.Handler; 39import android.os.IBinder; 40import android.os.Message; 41import android.os.RemoteException; 42import android.os.ServiceManager; 43import android.text.TextUtils; 44import android.util.Slog; 45import android.view.accessibility.AccessibilityEvent; 46import android.view.Display; 47import android.view.Gravity; 48import android.view.IWindowManager; 49import android.view.KeyEvent; 50import android.view.LayoutInflater; 51import android.view.MotionEvent; 52import android.view.SoundEffectConstants; 53import android.view.VelocityTracker; 54import android.view.View; 55import android.view.ViewConfiguration; 56import android.view.ViewGroup; 57import android.view.WindowManager; 58import android.view.WindowManagerImpl; 59import android.widget.ImageView; 60import android.widget.LinearLayout; 61import android.widget.RemoteViews; 62import android.widget.ScrollView; 63import android.widget.TextView; 64 65import com.android.internal.statusbar.StatusBarIcon; 66import com.android.internal.statusbar.StatusBarNotification; 67 68import com.android.systemui.R; 69import com.android.systemui.statusbar.*; 70import com.android.systemui.statusbar.policy.BatteryController; 71import com.android.systemui.statusbar.policy.BluetoothController; 72import com.android.systemui.statusbar.policy.CompatModeButton; 73import com.android.systemui.statusbar.policy.LocationController; 74import com.android.systemui.statusbar.policy.NetworkController; 75import com.android.systemui.statusbar.policy.Prefs; 76import com.android.systemui.recent.RecentsPanelView; 77import com.android.systemui.recent.carousel.RecentApplicationsActivity; 78 79public class TabletStatusBar extends StatusBar implements 80 HeightReceiver.OnBarHeightChangedListener, 81 InputMethodsPanel.OnHardKeyboardEnabledChangeListener { 82 public static final boolean DEBUG = false; 83 public static final String TAG = "TabletStatusBar"; 84 85 86 public static final int MSG_OPEN_NOTIFICATION_PANEL = 1000; 87 public static final int MSG_CLOSE_NOTIFICATION_PANEL = 1001; 88 public static final int MSG_OPEN_NOTIFICATION_PEEK = 1002; 89 public static final int MSG_CLOSE_NOTIFICATION_PEEK = 1003; 90 public static final int MSG_OPEN_RECENTS_PANEL = 1020; 91 public static final int MSG_CLOSE_RECENTS_PANEL = 1021; 92 public static final int MSG_SHOW_CHROME = 1030; 93 public static final int MSG_HIDE_CHROME = 1031; 94 public static final int MSG_OPEN_INPUT_METHODS_PANEL = 1040; 95 public static final int MSG_CLOSE_INPUT_METHODS_PANEL = 1041; 96 public static final int MSG_OPEN_COMPAT_MODE_PANEL = 1050; 97 public static final int MSG_CLOSE_COMPAT_MODE_PANEL = 1051; 98 public static final int MSG_STOP_TICKER = 2000; 99 100 // Fitts' Law assistance for LatinIME; see policy.EventHole 101 private static final boolean FAKE_SPACE_BAR = true; 102 103 // The height of the bar, as definied by the build. It may be taller if we're plugged 104 // into hdmi. 105 int mNaturalBarHeight = -1; 106 int mIconSize = -1; 107 int mIconHPadding = -1; 108 private int mMaxNotificationIcons = 5; 109 110 H mHandler = new H(); 111 112 IWindowManager mWindowManager; 113 114 // tracking all current notifications 115 private NotificationData mNotificationData = new NotificationData(); 116 117 TabletStatusBarView mStatusBarView; 118 View mNotificationArea; 119 View mNotificationTrigger; 120 NotificationIconArea mNotificationIconArea; 121 ViewGroup mNavigationArea; 122 123 boolean mNotificationDNDMode; 124 NotificationData.Entry mNotificationDNDDummyEntry; 125 126 ImageView mBackButton; 127 View mHomeButton; 128 View mMenuButton; 129 View mRecentButton; 130 131 ViewGroup mFeedbackIconArea; // notification icons, IME icon, compat icon 132 InputMethodButton mInputMethodSwitchButton; 133 CompatModeButton mCompatModeButton; 134 135 NotificationPanel mNotificationPanel; 136 WindowManager.LayoutParams mNotificationPanelParams; 137 NotificationPeekPanel mNotificationPeekWindow; 138 ViewGroup mNotificationPeekRow; 139 int mNotificationPeekIndex; 140 IBinder mNotificationPeekKey; 141 LayoutTransition mNotificationPeekScrubLeft, mNotificationPeekScrubRight; 142 143 int mNotificationPeekTapDuration; 144 int mNotificationFlingVelocity; 145 146 ViewGroup mPile; 147 148 HeightReceiver mHeightReceiver; 149 BatteryController mBatteryController; 150 BluetoothController mBluetoothController; 151 LocationController mLocationController; 152 NetworkController mNetworkController; 153 154 ViewGroup mBarContents; 155 LayoutTransition mBarContentsLayoutTransition; 156 157 // hide system chrome ("lights out") support 158 View mShadow; 159 160 NotificationIconArea.IconLayout mIconLayout; 161 162 TabletTicker mTicker; 163 164 View mFakeSpaceBar; 165 KeyEvent mSpaceBarKeyEvent = null; 166 167 // for disabling the status bar 168 int mDisabled = 0; 169 170 private RecentsPanelView mRecentsPanel; 171 private InputMethodsPanel mInputMethodsPanel; 172 private CompatModePanel mCompatModePanel; 173 174 public Context getContext() { return mContext; } 175 176 protected void addPanelWindows() { 177 final Context context = mContext; 178 final Resources res = mContext.getResources(); 179 180 // Notification Panel 181 mNotificationPanel = (NotificationPanel)View.inflate(context, 182 R.layout.status_bar_notification_panel, null); 183 mNotificationPanel.show(false, false); 184 mNotificationPanel.setOnTouchListener( 185 new TouchOutsideListener(MSG_CLOSE_NOTIFICATION_PANEL, mNotificationPanel)); 186 187 // the battery and network icons 188 mBatteryController.addIconView((ImageView)mNotificationPanel.findViewById(R.id.battery)); 189 mBatteryController.addLabelView( 190 (TextView)mNotificationPanel.findViewById(R.id.battery_text)); 191 mBluetoothController.addIconView( 192 (ImageView)mNotificationPanel.findViewById(R.id.bluetooth)); 193 mNetworkController.addCombinedSignalIconView( 194 (ImageView)mNotificationPanel.findViewById(R.id.network_signal)); 195 mNetworkController.addDataTypeIconView( 196 (ImageView)mNotificationPanel.findViewById(R.id.network_type)); 197 mNetworkController.addDataDirectionOverlayIconView( 198 (ImageView)mNotificationPanel.findViewById(R.id.network_direction)); 199 mNetworkController.addLabelView( 200 (TextView)mNotificationPanel.findViewById(R.id.network_text)); 201 mNetworkController.addLabelView( 202 (TextView)mBarContents.findViewById(R.id.network_text)); 203 204 mStatusBarView.setIgnoreChildren(0, mNotificationTrigger, mNotificationPanel); 205 206 WindowManager.LayoutParams lp = mNotificationPanelParams = new WindowManager.LayoutParams( 207 res.getDimensionPixelSize(R.dimen.notification_panel_width), 208 getNotificationPanelHeight(), 209 WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, 210 WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 211 | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS 212 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM 213 | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH 214 | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 215 PixelFormat.TRANSLUCENT); 216 lp.gravity = Gravity.BOTTOM | Gravity.RIGHT; 217 lp.setTitle("NotificationPanel"); 218 lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED 219 | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; 220 lp.windowAnimations = com.android.internal.R.style.Animation; // == no animation 221// lp.windowAnimations = com.android.internal.R.style.Animation_ZoomButtons; // simple fade 222 223 WindowManagerImpl.getDefault().addView(mNotificationPanel, lp); 224 225 // Notification preview window 226 mNotificationPeekWindow = (NotificationPeekPanel) View.inflate(context, 227 R.layout.status_bar_notification_peek, null); 228 mNotificationPeekWindow.setBar(this); 229 230 mNotificationPeekRow = (ViewGroup) mNotificationPeekWindow.findViewById(R.id.content); 231 mNotificationPeekWindow.setVisibility(View.GONE); 232 mNotificationPeekWindow.setOnTouchListener( 233 new TouchOutsideListener(MSG_CLOSE_NOTIFICATION_PEEK, mNotificationPeekWindow)); 234 mNotificationPeekScrubRight = new LayoutTransition(); 235 mNotificationPeekScrubRight.setAnimator(LayoutTransition.APPEARING, 236 ObjectAnimator.ofInt(null, "left", -512, 0)); 237 mNotificationPeekScrubRight.setAnimator(LayoutTransition.DISAPPEARING, 238 ObjectAnimator.ofInt(null, "left", -512, 0)); 239 mNotificationPeekScrubRight.setDuration(500); 240 241 mNotificationPeekScrubLeft = new LayoutTransition(); 242 mNotificationPeekScrubLeft.setAnimator(LayoutTransition.APPEARING, 243 ObjectAnimator.ofInt(null, "left", 512, 0)); 244 mNotificationPeekScrubLeft.setAnimator(LayoutTransition.DISAPPEARING, 245 ObjectAnimator.ofInt(null, "left", 512, 0)); 246 mNotificationPeekScrubLeft.setDuration(500); 247 248 // XXX: setIgnoreChildren? 249 lp = new WindowManager.LayoutParams( 250 512, // ViewGroup.LayoutParams.WRAP_CONTENT, 251 ViewGroup.LayoutParams.WRAP_CONTENT, 252 WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, 253 WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS 254 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM 255 | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, 256 PixelFormat.TRANSLUCENT); 257 lp.gravity = Gravity.BOTTOM | Gravity.RIGHT; 258 lp.y = res.getDimensionPixelOffset(R.dimen.peek_window_y_offset); 259 lp.setTitle("NotificationPeekWindow"); 260 lp.windowAnimations = com.android.internal.R.style.Animation_Toast; 261 262 WindowManagerImpl.getDefault().addView(mNotificationPeekWindow, lp); 263 264 // Recents Panel 265 mRecentsPanel = (RecentsPanelView) View.inflate(context, 266 R.layout.status_bar_recent_panel, null); 267 mRecentsPanel.setVisibility(View.GONE); 268 mRecentsPanel.setOnTouchListener(new TouchOutsideListener(MSG_CLOSE_RECENTS_PANEL, 269 mRecentsPanel)); 270 mStatusBarView.setIgnoreChildren(2, mRecentButton, mRecentsPanel); 271 272 lp = new WindowManager.LayoutParams( 273 ViewGroup.LayoutParams.WRAP_CONTENT, 274 ViewGroup.LayoutParams.WRAP_CONTENT, 275 WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, 276 WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 277 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM 278 | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH 279 | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 280 PixelFormat.TRANSLUCENT); 281 lp.gravity = Gravity.BOTTOM | Gravity.LEFT; 282 lp.setTitle("RecentsPanel"); 283 lp.windowAnimations = R.style.Animation_RecentPanel; 284 lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED 285 | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; 286 287 WindowManagerImpl.getDefault().addView(mRecentsPanel, lp); 288 mRecentsPanel.setBar(this); 289 290 // Input methods Panel 291 mInputMethodsPanel = (InputMethodsPanel) View.inflate(context, 292 R.layout.status_bar_input_methods_panel, null); 293 mInputMethodsPanel.setHardKeyboardEnabledChangeListener(this); 294 mInputMethodsPanel.setOnTouchListener(new TouchOutsideListener( 295 MSG_CLOSE_INPUT_METHODS_PANEL, mInputMethodsPanel)); 296 mInputMethodsPanel.setImeSwitchButton(mInputMethodSwitchButton); 297 mStatusBarView.setIgnoreChildren(3, mInputMethodSwitchButton, mInputMethodsPanel); 298 lp = new WindowManager.LayoutParams( 299 ViewGroup.LayoutParams.WRAP_CONTENT, 300 ViewGroup.LayoutParams.WRAP_CONTENT, 301 WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, 302 WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 303 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM 304 | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH 305 | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 306 PixelFormat.TRANSLUCENT); 307 lp.gravity = Gravity.BOTTOM | Gravity.RIGHT; 308 lp.setTitle("InputMethodsPanel"); 309 lp.windowAnimations = R.style.Animation_RecentPanel; 310 311 WindowManagerImpl.getDefault().addView(mInputMethodsPanel, lp); 312 313 // Compatibility mode selector panel 314 mCompatModePanel = (CompatModePanel) View.inflate(context, 315 R.layout.status_bar_compat_mode_panel, null); 316 mCompatModePanel.setOnTouchListener(new TouchOutsideListener( 317 MSG_CLOSE_COMPAT_MODE_PANEL, mCompatModePanel)); 318 mCompatModePanel.setTrigger(mCompatModeButton); 319 mCompatModePanel.setVisibility(View.GONE); 320 mStatusBarView.setIgnoreChildren(4, mCompatModeButton, mCompatModePanel); 321 lp = new WindowManager.LayoutParams( 322 250, 323 ViewGroup.LayoutParams.WRAP_CONTENT, 324 WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, 325 WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 326 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM 327 | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH 328 | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 329 PixelFormat.TRANSLUCENT); 330 lp.gravity = Gravity.BOTTOM | Gravity.RIGHT; 331 lp.setTitle("CompatModePanel"); 332 lp.windowAnimations = android.R.style.Animation_Dialog; 333 334 WindowManagerImpl.getDefault().addView(mCompatModePanel, lp); 335 } 336 337 private int getNotificationPanelHeight() { 338 final Resources res = mContext.getResources(); 339 final Display d = WindowManagerImpl.getDefault().getDefaultDisplay(); 340 return Math.max(res.getDimensionPixelSize(R.dimen.notification_panel_min_height), 341 d.getRealHeight()); 342 } 343 344 @Override 345 public void start() { 346 super.start(); // will add the main bar view 347 } 348 349 @Override 350 protected void onConfigurationChanged(Configuration newConfig) { 351 loadDimens(); 352 mNotificationPanelParams.height = getNotificationPanelHeight(); 353 WindowManagerImpl.getDefault().updateViewLayout(mNotificationPanel, 354 mNotificationPanelParams); 355 } 356 357 protected void loadDimens() { 358 final Resources res = mContext.getResources(); 359 360 mNaturalBarHeight = res.getDimensionPixelSize( 361 com.android.internal.R.dimen.system_bar_height); 362 363 int newIconSize = res.getDimensionPixelSize( 364 com.android.internal.R.dimen.system_bar_icon_size); 365 int newIconHPadding = res.getDimensionPixelSize( 366 R.dimen.status_bar_icon_padding); 367 368 if (newIconHPadding != mIconHPadding || newIconSize != mIconSize) { 369// Slog.d(TAG, "size=" + newIconSize + " padding=" + newIconHPadding); 370 mIconHPadding = newIconHPadding; 371 mIconSize = newIconSize; 372 reloadAllNotificationIcons(); // reload the tray 373 } 374 375 final int numIcons = res.getInteger(R.integer.config_maxNotificationIcons); 376 if (numIcons != mMaxNotificationIcons) { 377 mMaxNotificationIcons = numIcons; 378 if (DEBUG) Slog.d(TAG, "max notification icons: " + mMaxNotificationIcons); 379 reloadAllNotificationIcons(); 380 } 381 } 382 383 protected View makeStatusBarView() { 384 final Context context = mContext; 385 386 mWindowManager = IWindowManager.Stub.asInterface( 387 ServiceManager.getService(Context.WINDOW_SERVICE)); 388 389 // This guy will listen for HDMI plugged broadcasts so we can resize the 390 // status bar as appropriate. 391 mHeightReceiver = new HeightReceiver(mContext); 392 mHeightReceiver.registerReceiver(); 393 loadDimens(); 394 395 final TabletStatusBarView sb = (TabletStatusBarView)View.inflate( 396 context, R.layout.status_bar, null); 397 mStatusBarView = sb; 398 399 sb.setHandler(mHandler); 400 401 mBarContents = (ViewGroup) sb.findViewById(R.id.bar_contents); 402 // layout transitions for the status bar's contents 403 mBarContentsLayoutTransition = new LayoutTransition(); 404 // add/removal will fade as normal 405 mBarContentsLayoutTransition.setAnimator(LayoutTransition.APPEARING, 406 ObjectAnimator.ofFloat(null, "alpha", 0f, 1f)); 407 mBarContentsLayoutTransition.setAnimator(LayoutTransition.DISAPPEARING, 408 ObjectAnimator.ofFloat(null, "alpha", 1f, 0f)); 409 // no animations for siblings on change: just jump into place please 410 mBarContentsLayoutTransition.setAnimator(LayoutTransition.CHANGE_APPEARING, null); 411 mBarContentsLayoutTransition.setAnimator(LayoutTransition.CHANGE_DISAPPEARING, null); 412 // quick like bunny 413 mBarContentsLayoutTransition.setDuration(250 * (DEBUG?10:1)); 414 mBarContents.setLayoutTransition(mBarContentsLayoutTransition); 415 416 // the whole right-hand side of the bar 417 mNotificationArea = sb.findViewById(R.id.notificationArea); 418 419 // the button to open the notification area 420 mNotificationTrigger = sb.findViewById(R.id.notificationTrigger); 421 mNotificationTrigger.setOnTouchListener(new NotificationTriggerTouchListener()); 422 423 // the more notifications icon 424 mNotificationIconArea = (NotificationIconArea)sb.findViewById(R.id.notificationIcons); 425 426 // where the icons go 427 mIconLayout = (NotificationIconArea.IconLayout) sb.findViewById(R.id.icons); 428 mIconLayout.setOnTouchListener(new NotificationIconTouchListener()); 429 430 ViewConfiguration vc = ViewConfiguration.get(context); 431 mNotificationPeekTapDuration = vc.getTapTimeout(); 432 mNotificationFlingVelocity = 300; // px/s 433 434 mTicker = new TabletTicker(this); 435 436 // The icons 437 mLocationController = new LocationController(mContext); // will post a notification 438 439 mBatteryController = new BatteryController(mContext); 440 mBatteryController.addIconView((ImageView)sb.findViewById(R.id.battery)); 441 mBluetoothController = new BluetoothController(mContext); 442 mBluetoothController.addIconView((ImageView)sb.findViewById(R.id.bluetooth)); 443 mNetworkController = new NetworkController(mContext); 444 mNetworkController.addCombinedSignalIconView( 445 (ImageView)sb.findViewById(R.id.network_signal)); 446 mNetworkController.addDataTypeIconView( 447 (ImageView)sb.findViewById(R.id.network_type)); 448 mNetworkController.addDataDirectionOverlayIconView( 449 (ImageView)sb.findViewById(R.id.network_direction)); 450 451 // The navigation buttons 452 mBackButton = (ImageView)sb.findViewById(R.id.back); 453 mNavigationArea = (ViewGroup) sb.findViewById(R.id.navigationArea); 454 mHomeButton = mNavigationArea.findViewById(R.id.home); 455 mMenuButton = mNavigationArea.findViewById(R.id.menu); 456 mRecentButton = mNavigationArea.findViewById(R.id.recent_apps); 457 mRecentButton.setOnClickListener(mOnClickListener); 458 mNavigationArea.setLayoutTransition(mBarContentsLayoutTransition); 459 460 // The bar contents buttons 461 mFeedbackIconArea = (ViewGroup)sb.findViewById(R.id.feedbackIconArea); 462 mInputMethodSwitchButton = (InputMethodButton) sb.findViewById(R.id.imeSwitchButton); 463 // Overwrite the lister 464 mInputMethodSwitchButton.setOnClickListener(mOnClickListener); 465 466 mCompatModeButton = (CompatModeButton) sb.findViewById(R.id.compatModeButton); 467 mCompatModeButton.setOnClickListener(mOnClickListener); 468 469 // for redirecting errant bar taps to the IME 470 mFakeSpaceBar = sb.findViewById(R.id.fake_space_bar); 471 472 // "shadows" of the status bar features, for lights-out mode 473 mShadow = sb.findViewById(R.id.bar_shadow); 474 mShadow.setOnTouchListener( 475 new View.OnTouchListener() { 476 public boolean onTouch(View v, MotionEvent ev) { 477 if (ev.getAction() == MotionEvent.ACTION_DOWN) { 478 // even though setting the systemUI visibility below will turn these views 479 // on, we need them to come up faster so that they can catch this motion 480 // event 481 mShadow.setVisibility(View.GONE); 482 mBarContents.setVisibility(View.VISIBLE); 483 484 try { 485 mBarService.setSystemUiVisibility(View.STATUS_BAR_VISIBLE); 486 } catch (RemoteException ex) { 487 // system process dead 488 } 489 } 490 return false; 491 } 492 }); 493 494 // tuning parameters 495 final int LIGHTS_GOING_OUT_SYSBAR_DURATION = 600; 496 final int LIGHTS_GOING_OUT_SHADOW_DURATION = 1000; 497 final int LIGHTS_GOING_OUT_SHADOW_DELAY = 500; 498 499 final int LIGHTS_COMING_UP_SYSBAR_DURATION = 200; 500// final int LIGHTS_COMING_UP_SYSBAR_DELAY = 50; 501 final int LIGHTS_COMING_UP_SHADOW_DURATION = 0; 502 503 LayoutTransition xition = new LayoutTransition(); 504 xition.setAnimator(LayoutTransition.APPEARING, 505 ObjectAnimator.ofFloat(null, "alpha", 0.5f, 1f)); 506 xition.setDuration(LayoutTransition.APPEARING, LIGHTS_COMING_UP_SYSBAR_DURATION); 507 xition.setStartDelay(LayoutTransition.APPEARING, 0); 508 xition.setAnimator(LayoutTransition.DISAPPEARING, 509 ObjectAnimator.ofFloat(null, "alpha", 1f, 0f)); 510 xition.setDuration(LayoutTransition.DISAPPEARING, LIGHTS_GOING_OUT_SYSBAR_DURATION); 511 xition.setStartDelay(LayoutTransition.DISAPPEARING, 0); 512 ((ViewGroup)sb.findViewById(R.id.bar_contents_holder)).setLayoutTransition(xition); 513 514 xition = new LayoutTransition(); 515 xition.setAnimator(LayoutTransition.APPEARING, 516 ObjectAnimator.ofFloat(null, "alpha", 0f, 1f)); 517 xition.setDuration(LayoutTransition.APPEARING, LIGHTS_GOING_OUT_SHADOW_DURATION); 518 xition.setStartDelay(LayoutTransition.APPEARING, LIGHTS_GOING_OUT_SHADOW_DELAY); 519 xition.setAnimator(LayoutTransition.DISAPPEARING, 520 ObjectAnimator.ofFloat(null, "alpha", 1f, 0f)); 521 xition.setDuration(LayoutTransition.DISAPPEARING, LIGHTS_COMING_UP_SHADOW_DURATION); 522 xition.setStartDelay(LayoutTransition.DISAPPEARING, 0); 523 ((ViewGroup)sb.findViewById(R.id.bar_shadow_holder)).setLayoutTransition(xition); 524 525 // set the initial view visibility 526 setAreThereNotifications(); 527 528 // Add the windows 529 addPanelWindows(); 530 531 mPile = (ViewGroup)mNotificationPanel.findViewById(R.id.content); 532 mPile.removeAllViews(); 533 534 ScrollView scroller = (ScrollView)mPile.getParent(); 535 scroller.setFillViewport(true); 536 537 mHeightReceiver.addOnBarHeightChangedListener(this); 538 539 return sb; 540 } 541 542 public int getStatusBarHeight() { 543 return mHeightReceiver.getHeight(); 544 } 545 546 protected int getStatusBarGravity() { 547 return Gravity.BOTTOM | Gravity.FILL_HORIZONTAL; 548 } 549 550 public void onBarHeightChanged(int height) { 551 final WindowManager.LayoutParams lp 552 = (WindowManager.LayoutParams)mStatusBarView.getLayoutParams(); 553 if (lp == null) { 554 // haven't been added yet 555 return; 556 } 557 if (lp.height != height) { 558 lp.height = height; 559 final WindowManager wm = WindowManagerImpl.getDefault(); 560 wm.updateViewLayout(mStatusBarView, lp); 561 } 562 } 563 564 private class H extends Handler { 565 public void handleMessage(Message m) { 566 switch (m.what) { 567 case MSG_OPEN_NOTIFICATION_PEEK: 568 if (DEBUG) Slog.d(TAG, "opening notification peek window; arg=" + m.arg1); 569 570 if (m.arg1 >= 0) { 571 final int N = mNotificationData.size(); 572 573 if (!mNotificationDNDMode) { 574 if (mNotificationPeekIndex >= 0 && mNotificationPeekIndex < N) { 575 NotificationData.Entry entry = mNotificationData.get(N-1-mNotificationPeekIndex); 576 entry.icon.setBackgroundColor(0); 577 mNotificationPeekIndex = -1; 578 mNotificationPeekKey = null; 579 } 580 } 581 582 final int peekIndex = m.arg1; 583 if (peekIndex < N) { 584 //Slog.d(TAG, "loading peek: " + peekIndex); 585 NotificationData.Entry entry = 586 mNotificationDNDMode 587 ? mNotificationDNDDummyEntry 588 : mNotificationData.get(N-1-peekIndex); 589 NotificationData.Entry copy = new NotificationData.Entry( 590 entry.key, 591 entry.notification, 592 entry.icon); 593 inflateViews(copy, mNotificationPeekRow); 594 595 if (mNotificationDNDMode) { 596 copy.content.setOnClickListener(new View.OnClickListener() { 597 public void onClick(View v) { 598 SharedPreferences.Editor editor = Prefs.edit(mContext); 599 editor.putBoolean(Prefs.DO_NOT_DISTURB_PREF, false); 600 editor.apply(); 601 animateCollapse(); 602 } 603 }); 604 } 605 606 entry.icon.setBackgroundColor(0x20FFFFFF); 607 608// mNotificationPeekRow.setLayoutTransition( 609// peekIndex < mNotificationPeekIndex 610// ? mNotificationPeekScrubLeft 611// : mNotificationPeekScrubRight); 612 613 mNotificationPeekRow.removeAllViews(); 614 mNotificationPeekRow.addView(copy.row); 615 616 mNotificationPeekWindow.setVisibility(View.VISIBLE); 617 mNotificationPanel.show(false, true); 618 619 mNotificationPeekIndex = peekIndex; 620 mNotificationPeekKey = entry.key; 621 } 622 } 623 break; 624 case MSG_CLOSE_NOTIFICATION_PEEK: 625 if (DEBUG) Slog.d(TAG, "closing notification peek window"); 626 mNotificationPeekWindow.setVisibility(View.GONE); 627 mNotificationPeekRow.removeAllViews(); 628 629 final int N = mNotificationData.size(); 630 if (mNotificationPeekIndex >= 0 && mNotificationPeekIndex < N) { 631 NotificationData.Entry entry = 632 mNotificationDNDMode 633 ? mNotificationDNDDummyEntry 634 : mNotificationData.get(N-1-mNotificationPeekIndex); 635 entry.icon.setBackgroundColor(0); 636 } 637 638 mNotificationPeekIndex = -1; 639 mNotificationPeekKey = null; 640 break; 641 case MSG_OPEN_NOTIFICATION_PANEL: 642 if (DEBUG) Slog.d(TAG, "opening notifications panel"); 643 if (!mNotificationPanel.isShowing()) { 644 mNotificationPeekWindow.setVisibility(View.GONE); 645 mNotificationPanel.show(true, true); 646 mNotificationArea.setVisibility(View.INVISIBLE); 647 mTicker.halt(); 648 } 649 break; 650 case MSG_CLOSE_NOTIFICATION_PANEL: 651 if (DEBUG) Slog.d(TAG, "closing notifications panel"); 652 if (mNotificationPanel.isShowing()) { 653 mNotificationPanel.show(false, true); 654 mNotificationArea.setVisibility(View.VISIBLE); 655 } 656 break; 657 case MSG_OPEN_RECENTS_PANEL: 658 if (DEBUG) Slog.d(TAG, "opening recents panel"); 659 if (mRecentsPanel != null) { 660 disable(StatusBarManager.DISABLE_BACK); 661 mRecentsPanel.setVisibility(View.VISIBLE); 662 mRecentsPanel.show(true, true); 663 } 664 break; 665 case MSG_CLOSE_RECENTS_PANEL: 666 if (DEBUG) Slog.d(TAG, "closing recents panel"); 667 if (mRecentsPanel != null && mRecentsPanel.isShowing()) { 668 disable(StatusBarManager.DISABLE_NONE); 669 mRecentsPanel.show(false, true); 670 } 671 break; 672 case MSG_OPEN_INPUT_METHODS_PANEL: 673 if (DEBUG) Slog.d(TAG, "opening input methods panel"); 674 if (mInputMethodsPanel != null) mInputMethodsPanel.openPanel(); 675 break; 676 case MSG_CLOSE_INPUT_METHODS_PANEL: 677 if (DEBUG) Slog.d(TAG, "closing input methods panel"); 678 if (mInputMethodsPanel != null) mInputMethodsPanel.closePanel(false); 679 break; 680 case MSG_OPEN_COMPAT_MODE_PANEL: 681 if (DEBUG) Slog.d(TAG, "opening compat panel"); 682 if (mCompatModePanel != null) mCompatModePanel.openPanel(); 683 break; 684 case MSG_CLOSE_COMPAT_MODE_PANEL: 685 if (DEBUG) Slog.d(TAG, "closing compat panel"); 686 if (mCompatModePanel != null) mCompatModePanel.closePanel(); 687 break; 688 case MSG_SHOW_CHROME: 689 if (DEBUG) Slog.d(TAG, "hiding shadows (lights on)"); 690 mBarContents.setVisibility(View.VISIBLE); 691 mShadow.setVisibility(View.GONE); 692 notifyLightsChanged(true); 693 break; 694 case MSG_HIDE_CHROME: 695 if (DEBUG) Slog.d(TAG, "showing shadows (lights out)"); 696 animateCollapse(); 697 mBarContents.setVisibility(View.GONE); 698 mShadow.setVisibility(View.VISIBLE); 699 notifyLightsChanged(false); 700 break; 701 case MSG_STOP_TICKER: 702 mTicker.halt(); 703 break; 704 } 705 } 706 } 707 708 private void notifyLightsChanged(boolean shown) { 709 try { 710 Slog.d(TAG, "lights " + (shown?"on":"out")); 711 mWindowManager.statusBarVisibilityChanged( 712 shown ? View.STATUS_BAR_VISIBLE : View.STATUS_BAR_HIDDEN); 713 } catch (RemoteException ex) { 714 } 715 } 716 717 public void addIcon(String slot, int index, int viewIndex, StatusBarIcon icon) { 718 if (DEBUG) Slog.d(TAG, "addIcon(" + slot + ") -> " + icon); 719 } 720 721 public void updateIcon(String slot, int index, int viewIndex, 722 StatusBarIcon old, StatusBarIcon icon) { 723 if (DEBUG) Slog.d(TAG, "updateIcon(" + slot + ") -> " + icon); 724 } 725 726 public void removeIcon(String slot, int index, int viewIndex) { 727 if (DEBUG) Slog.d(TAG, "removeIcon(" + slot + ")"); 728 } 729 730 public void addNotification(IBinder key, StatusBarNotification notification) { 731 if (DEBUG) Slog.d(TAG, "addNotification(" + key + " -> " + notification + ")"); 732 addNotificationViews(key, notification); 733 734 final boolean immersive = isImmersive(); 735 if (false && immersive) { 736 // TODO: immersive mode popups for tablet 737 } else if (notification.notification.fullScreenIntent != null) { 738 // not immersive & a full-screen alert should be shown 739 Slog.w(TAG, "Notification has fullScreenIntent and activity is not immersive;" 740 + " sending fullScreenIntent"); 741 try { 742 notification.notification.fullScreenIntent.send(); 743 } catch (PendingIntent.CanceledException e) { 744 } 745 } else { 746 tick(key, notification, true); 747 } 748 749 setAreThereNotifications(); 750 } 751 752 public void updateNotification(IBinder key, StatusBarNotification notification) { 753 if (DEBUG) Slog.d(TAG, "updateNotification(" + key + " -> " + notification + ")"); 754 755 final NotificationData.Entry oldEntry = mNotificationData.findByKey(key); 756 if (oldEntry == null) { 757 Slog.w(TAG, "updateNotification for unknown key: " + key); 758 return; 759 } 760 761 final StatusBarNotification oldNotification = oldEntry.notification; 762 final RemoteViews oldContentView = oldNotification.notification.contentView; 763 764 final RemoteViews contentView = notification.notification.contentView; 765 766 if (DEBUG) { 767 Slog.d(TAG, "old notification: when=" + oldNotification.notification.when 768 + " ongoing=" + oldNotification.isOngoing() 769 + " expanded=" + oldEntry.expanded 770 + " contentView=" + oldContentView 771 + " rowParent=" + oldEntry.row.getParent()); 772 Slog.d(TAG, "new notification: when=" + notification.notification.when 773 + " ongoing=" + oldNotification.isOngoing() 774 + " contentView=" + contentView); 775 } 776 777 // Can we just reapply the RemoteViews in place? If when didn't change, the order 778 // didn't change. 779 boolean contentsUnchanged = oldEntry.expanded != null 780 && contentView != null && oldContentView != null 781 && contentView.getPackage() != null 782 && oldContentView.getPackage() != null 783 && oldContentView.getPackage().equals(contentView.getPackage()) 784 && oldContentView.getLayoutId() == contentView.getLayoutId(); 785 ViewGroup rowParent = (ViewGroup) oldEntry.row.getParent(); 786 boolean orderUnchanged = notification.notification.when==oldNotification.notification.when 787 && notification.priority == oldNotification.priority; 788 // priority now encompasses isOngoing() 789 boolean isLastAnyway = rowParent.indexOfChild(oldEntry.row) == rowParent.getChildCount()-1; 790 if (contentsUnchanged && (orderUnchanged || isLastAnyway)) { 791 if (DEBUG) Slog.d(TAG, "reusing notification for key: " + key); 792 oldEntry.notification = notification; 793 try { 794 // Reapply the RemoteViews 795 contentView.reapply(mContext, oldEntry.content); 796 // update the contentIntent 797 final PendingIntent contentIntent = notification.notification.contentIntent; 798 if (contentIntent != null) { 799 oldEntry.content.setOnClickListener(new NotificationClicker(contentIntent, 800 notification.pkg, notification.tag, notification.id)); 801 } else { 802 oldEntry.content.setOnClickListener(null); 803 } 804 // Update the icon. 805 final StatusBarIcon ic = new StatusBarIcon(notification.pkg, 806 notification.notification.icon, notification.notification.iconLevel, 807 notification.notification.number); 808 if (!oldEntry.icon.set(ic)) { 809 handleNotificationError(key, notification, "Couldn't update icon: " + ic); 810 return; 811 } 812 // Update the large icon 813 if (notification.notification.largeIcon != null) { 814 oldEntry.largeIcon.setImageBitmap(notification.notification.largeIcon); 815 } else { 816 oldEntry.largeIcon.getLayoutParams().width = 0; 817 oldEntry.largeIcon.setVisibility(View.INVISIBLE); 818 } 819 820 if (key == mNotificationPeekKey) { 821 // must update the peek window 822 Message peekMsg = mHandler.obtainMessage(MSG_OPEN_NOTIFICATION_PEEK); 823 peekMsg.arg1 = mNotificationPeekIndex; 824 mHandler.removeMessages(MSG_OPEN_NOTIFICATION_PEEK); 825 mHandler.sendMessage(peekMsg); 826 } 827 } 828 catch (RuntimeException e) { 829 // It failed to add cleanly. Log, and remove the view from the panel. 830 Slog.w(TAG, "Couldn't reapply views for package " + contentView.getPackage(), e); 831 removeNotificationViews(key); 832 addNotificationViews(key, notification); 833 } 834 } else { 835 if (DEBUG) Slog.d(TAG, "not reusing notification for key: " + key); 836 removeNotificationViews(key); 837 addNotificationViews(key, notification); 838 } 839 // fullScreenIntent doesn't happen on updates. You need to clear & repost a new 840 // notification. 841 final boolean immersive = isImmersive(); 842 if (false && immersive) { 843 // TODO: immersive mode 844 } else { 845 tick(key, notification, false); 846 } 847 848 setAreThereNotifications(); 849 } 850 851 public void removeNotification(IBinder key) { 852 if (DEBUG) Slog.d(TAG, "removeNotification(" + key + ")"); 853 removeNotificationViews(key); 854 mTicker.remove(key); 855 setAreThereNotifications(); 856 } 857 858 public void showClock(boolean show) { 859 View clock = mBarContents.findViewById(R.id.clock); 860 View network_text = mBarContents.findViewById(R.id.network_text); 861 if (clock != null) { 862 clock.setVisibility(show ? View.VISIBLE : View.GONE); 863 } 864 if (network_text != null) { 865 network_text.setVisibility((!show) ? View.VISIBLE : View.GONE); 866 } 867 } 868 869 public void disable(int state) { 870 int old = mDisabled; 871 int diff = state ^ old; 872 mDisabled = state; 873 874 // act accordingly 875 if ((diff & StatusBarManager.DISABLE_CLOCK) != 0) { 876 boolean show = (state & StatusBarManager.DISABLE_CLOCK) == 0; 877 Slog.i(TAG, "DISABLE_CLOCK: " + (show ? "no" : "yes")); 878 showClock(show); 879 } 880 if ((diff & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) { 881 boolean show = (state & StatusBarManager.DISABLE_SYSTEM_INFO) == 0; 882 Slog.i(TAG, "DISABLE_SYSTEM_INFO: " + (show ? "no" : "yes")); 883 mNotificationTrigger.setVisibility(show ? View.VISIBLE : View.GONE); 884 } 885 if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) { 886 if ((state & StatusBarManager.DISABLE_EXPAND) != 0) { 887 Slog.i(TAG, "DISABLE_EXPAND: yes"); 888 animateCollapse(); 889 } 890 } 891 if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { 892 mNotificationDNDMode = Prefs.read(mContext) 893 .getBoolean(Prefs.DO_NOT_DISTURB_PREF, Prefs.DO_NOT_DISTURB_DEFAULT); 894 895 if ((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { 896 Slog.i(TAG, "DISABLE_NOTIFICATION_ICONS: yes" + (mNotificationDNDMode?" (DND)":"")); 897 mTicker.halt(); 898 } else { 899 Slog.i(TAG, "DISABLE_NOTIFICATION_ICONS: no" + (mNotificationDNDMode?" (DND)":"")); 900 } 901 902 // refresh icons to show either notifications or the DND message 903 reloadAllNotificationIcons(); 904 } else if ((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { 905 if ((state & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { 906 mTicker.halt(); 907 } 908 } 909 if ((diff & StatusBarManager.DISABLE_NAVIGATION) != 0) { 910 if ((state & StatusBarManager.DISABLE_NAVIGATION) != 0) { 911 Slog.i(TAG, "DISABLE_NAVIGATION: yes"); 912 mNavigationArea.setVisibility(View.INVISIBLE); 913 mInputMethodSwitchButton.setScreenLocked(true); 914 } else { 915 Slog.i(TAG, "DISABLE_NAVIGATION: no"); 916 mNavigationArea.setVisibility(View.VISIBLE); 917 mInputMethodSwitchButton.setScreenLocked(false); 918 } 919 } 920 if ((diff & StatusBarManager.DISABLE_BACK) != 0) { 921 if ((state & StatusBarManager.DISABLE_BACK) != 0) { 922 Slog.i(TAG, "DISABLE_BACK: yes"); 923 mBackButton.setVisibility(View.INVISIBLE); 924 mInputMethodSwitchButton.setScreenLocked(true); 925 } else { 926 Slog.i(TAG, "DISABLE_BACK: no"); 927 mBackButton.setVisibility(View.VISIBLE); 928 mInputMethodSwitchButton.setScreenLocked(false); 929 } 930 } 931 932 } 933 934 private boolean hasTicker(Notification n) { 935 return n.tickerView != null || !TextUtils.isEmpty(n.tickerText); 936 } 937 938 private void tick(IBinder key, StatusBarNotification n, boolean firstTime) { 939 // Don't show the ticker when the windowshade is open. 940 if (mNotificationPanel.isShowing()) { 941 return; 942 } 943 // If they asked for FLAG_ONLY_ALERT_ONCE, then only show this notification 944 // if it's a new notification. 945 if (!firstTime && (n.notification.flags & Notification.FLAG_ONLY_ALERT_ONCE) != 0) { 946 return; 947 } 948 // Show the ticker if one is requested. Also don't do this 949 // until status bar window is attached to the window manager, 950 // because... well, what's the point otherwise? And trying to 951 // run a ticker without being attached will crash! 952 if (hasTicker(n.notification) && mStatusBarView.getWindowToken() != null) { 953 if (0 == (mDisabled & (StatusBarManager.DISABLE_NOTIFICATION_ICONS 954 | StatusBarManager.DISABLE_NOTIFICATION_TICKER))) { 955 mTicker.add(key, n); 956 mFeedbackIconArea.setVisibility(View.GONE); 957 } 958 } 959 } 960 961 // called by TabletTicker when it's done with all queued ticks 962 public void doneTicking() { 963 mFeedbackIconArea.setVisibility(View.VISIBLE); 964 } 965 966 public void animateExpand() { 967 mHandler.removeMessages(MSG_CLOSE_NOTIFICATION_PEEK); 968 mHandler.removeMessages(MSG_OPEN_NOTIFICATION_PEEK); 969 mHandler.sendEmptyMessage(MSG_CLOSE_NOTIFICATION_PEEK); 970 mHandler.removeMessages(MSG_OPEN_NOTIFICATION_PANEL); 971 mHandler.sendEmptyMessage(MSG_OPEN_NOTIFICATION_PANEL); 972 } 973 974 public void animateCollapse() { 975 mHandler.removeMessages(MSG_CLOSE_NOTIFICATION_PANEL); 976 mHandler.sendEmptyMessage(MSG_CLOSE_NOTIFICATION_PANEL); 977 mHandler.removeMessages(MSG_CLOSE_RECENTS_PANEL); 978 mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL); 979 mHandler.removeMessages(MSG_CLOSE_INPUT_METHODS_PANEL); 980 mHandler.sendEmptyMessage(MSG_CLOSE_INPUT_METHODS_PANEL); 981 mHandler.removeMessages(MSG_CLOSE_COMPAT_MODE_PANEL); 982 mHandler.sendEmptyMessage(MSG_CLOSE_COMPAT_MODE_PANEL); 983 mHandler.removeMessages(MSG_CLOSE_NOTIFICATION_PEEK); 984 mHandler.sendEmptyMessage(MSG_CLOSE_NOTIFICATION_PEEK); 985 } 986 987 // called by StatusBar 988 @Override 989 public void setLightsOn(boolean on) { 990 // Policy note: if the frontmost activity needs the menu key, we assume it is a legacy app 991 // that can't handle lights-out mode. 992 if (mMenuButton.getVisibility() == View.VISIBLE) { 993 on = true; 994 } 995 mHandler.removeMessages(MSG_HIDE_CHROME); 996 mHandler.removeMessages(MSG_SHOW_CHROME); 997 mHandler.sendEmptyMessage(on ? MSG_SHOW_CHROME : MSG_HIDE_CHROME); 998 } 999 1000 public void topAppWindowChanged(boolean windowVisible) { 1001 if (DEBUG) { 1002 Slog.d(TAG, (windowVisible?"showing":"hiding") + " the MENU button"); 1003 } 1004 mMenuButton.setVisibility(windowVisible ? View.VISIBLE : View.GONE); 1005 1006 // See above re: lights-out policy for legacy apps. 1007 if (windowVisible) setLightsOn(true); 1008 1009 // XXX: this is broken: http://b/4603422 1010 mCompatModeButton.refresh(); 1011 } 1012 1013 public void setImeWindowStatus(IBinder token, int vis, int backDisposition) { 1014 mInputMethodSwitchButton.setImeWindowStatus(token, 1015 (vis & InputMethodService.IME_ACTIVE) != 0); 1016 updateNotificationIcons(); 1017 mInputMethodsPanel.setImeToken(token); 1018 int res; 1019 switch (backDisposition) { 1020 case InputMethodService.BACK_DISPOSITION_WILL_NOT_DISMISS: 1021 res = R.drawable.ic_sysbar_back; 1022 break; 1023 case InputMethodService.BACK_DISPOSITION_WILL_DISMISS: 1024 res = R.drawable.ic_sysbar_back_ime; 1025 break; 1026 case InputMethodService.BACK_DISPOSITION_DEFAULT: 1027 default: 1028 if ((vis & InputMethodService.IME_VISIBLE) != 0) { 1029 res = R.drawable.ic_sysbar_back_ime; 1030 } else { 1031 res = R.drawable.ic_sysbar_back; 1032 } 1033 break; 1034 } 1035 mBackButton.setImageResource(res); 1036 if (FAKE_SPACE_BAR) { 1037 mFakeSpaceBar.setVisibility(((vis & InputMethodService.IME_VISIBLE) != 0) 1038 ? View.VISIBLE : View.GONE); 1039 } 1040 } 1041 1042 @Override 1043 public void setHardKeyboardStatus(boolean available, boolean enabled) { 1044 if (DEBUG) { 1045 Slog.d(TAG, "Set hard keyboard status: available=" + available 1046 + ", enabled=" + enabled); 1047 } 1048 mInputMethodSwitchButton.setHardKeyboardStatus(available); 1049 updateNotificationIcons(); 1050 mInputMethodsPanel.setHardKeyboardStatus(available, enabled); 1051 } 1052 1053 @Override 1054 public void onHardKeyboardEnabledChange(boolean enabled) { 1055 try { 1056 mBarService.setHardKeyboardEnabled(enabled); 1057 } catch (RemoteException ex) { 1058 } 1059 } 1060 1061 private boolean isImmersive() { 1062 try { 1063 return ActivityManagerNative.getDefault().isTopActivityImmersive(); 1064 //Slog.d(TAG, "Top activity is " + (immersive?"immersive":"not immersive")); 1065 } catch (RemoteException ex) { 1066 // the end is nigh 1067 return false; 1068 } 1069 } 1070 1071 private void setAreThereNotifications() { 1072 final boolean hasClearable = mNotificationData.hasClearableItems(); 1073 } 1074 1075 /** 1076 * Cancel this notification and tell the status bar service about the failure. Hold no locks. 1077 */ 1078 void handleNotificationError(IBinder key, StatusBarNotification n, String message) { 1079 removeNotification(key); 1080 try { 1081 mBarService.onNotificationError(n.pkg, n.tag, n.id, n.uid, n.initialPid, message); 1082 } catch (RemoteException ex) { 1083 // The end is nigh. 1084 } 1085 } 1086 1087 private void sendKey(KeyEvent key) { 1088 try { 1089 if (DEBUG) Slog.d(TAG, "injecting key event: " + key); 1090 mWindowManager.injectInputEventNoWait(key); 1091 } catch (RemoteException ex) { 1092 } 1093 } 1094 1095 private View.OnClickListener mOnClickListener = new View.OnClickListener() { 1096 public void onClick(View v) { 1097 if (v == mNotificationTrigger) { 1098 onClickNotificationTrigger(); 1099 } else if (v == mRecentButton) { 1100 onClickRecentButton(); 1101 } else if (v == mInputMethodSwitchButton) { 1102 onClickInputMethodSwitchButton(); 1103 } else if (v == mCompatModeButton) { 1104 onClickCompatModeButton(); 1105 } 1106 } 1107 }; 1108 1109 public void onClickNotificationTrigger() { 1110 if (DEBUG) Slog.d(TAG, "clicked notification icons; disabled=" + mDisabled); 1111 if ((mDisabled & StatusBarManager.DISABLE_EXPAND) == 0) { 1112 int msg = !mNotificationPanel.isShowing() 1113 ? MSG_OPEN_NOTIFICATION_PANEL 1114 : MSG_CLOSE_NOTIFICATION_PANEL; 1115 mHandler.removeMessages(msg); 1116 mHandler.sendEmptyMessage(msg); 1117 } 1118 } 1119 1120 public void onClickRecentButton() { 1121 if (DEBUG) Slog.d(TAG, "clicked recent apps; disabled=" + mDisabled); 1122 if (mRecentsPanel == null) { 1123 Intent intent = new Intent(); 1124 intent.setClass(mContext, RecentApplicationsActivity.class); 1125 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK 1126 | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); 1127 mContext.startActivity(intent); 1128 } else { 1129 if ((mDisabled & StatusBarManager.DISABLE_EXPAND) == 0) { 1130 int msg = (mRecentsPanel.getVisibility() == View.GONE) 1131 ? MSG_OPEN_RECENTS_PANEL 1132 : MSG_CLOSE_RECENTS_PANEL; 1133 mHandler.removeMessages(msg); 1134 mHandler.sendEmptyMessage(msg); 1135 } 1136 } 1137 } 1138 1139 public void onClickInputMethodSwitchButton() { 1140 if (DEBUG) Slog.d(TAG, "clicked input methods panel; disabled=" + mDisabled); 1141 int msg = (mInputMethodsPanel.getVisibility() == View.GONE) ? 1142 MSG_OPEN_INPUT_METHODS_PANEL : MSG_CLOSE_INPUT_METHODS_PANEL; 1143 mHandler.removeMessages(msg); 1144 mHandler.sendEmptyMessage(msg); 1145 } 1146 1147 public void onClickCompatModeButton() { 1148 int msg = (mCompatModePanel.getVisibility() == View.GONE) ? 1149 MSG_OPEN_COMPAT_MODE_PANEL : MSG_CLOSE_COMPAT_MODE_PANEL; 1150 mHandler.removeMessages(msg); 1151 mHandler.sendEmptyMessage(msg); 1152 } 1153 1154 public NotificationClicker makeClicker(PendingIntent intent, String pkg, String tag, int id) { 1155 return new NotificationClicker(intent, pkg, tag, id); 1156 } 1157 1158 private class NotificationClicker implements View.OnClickListener { 1159 private PendingIntent mIntent; 1160 private String mPkg; 1161 private String mTag; 1162 private int mId; 1163 1164 NotificationClicker(PendingIntent intent, String pkg, String tag, int id) { 1165 mIntent = intent; 1166 mPkg = pkg; 1167 mTag = tag; 1168 mId = id; 1169 } 1170 1171 public void onClick(View v) { 1172 try { 1173 // The intent we are sending is for the application, which 1174 // won't have permission to immediately start an activity after 1175 // the user switches to home. We know it is safe to do at this 1176 // point, so make sure new activity switches are now allowed. 1177 ActivityManagerNative.getDefault().resumeAppSwitches(); 1178 } catch (RemoteException e) { 1179 } 1180 1181 if (mIntent != null) { 1182 int[] pos = new int[2]; 1183 v.getLocationOnScreen(pos); 1184 Intent overlay = new Intent(); 1185 overlay.setSourceBounds( 1186 new Rect(pos[0], pos[1], pos[0]+v.getWidth(), pos[1]+v.getHeight())); 1187 try { 1188 mIntent.send(mContext, 0, overlay); 1189 } catch (PendingIntent.CanceledException e) { 1190 // the stack trace isn't very helpful here. Just log the exception message. 1191 Slog.w(TAG, "Sending contentIntent failed: " + e); 1192 } 1193 } 1194 1195 try { 1196 mBarService.onNotificationClick(mPkg, mTag, mId); 1197 } catch (RemoteException ex) { 1198 // system process is dead if we're here. 1199 } 1200 1201 // close the shade if it was open 1202 animateCollapse(); 1203 1204 // If this click was on the intruder alert, hide that instead 1205// mHandler.sendEmptyMessage(MSG_HIDE_INTRUDER); 1206 } 1207 } 1208 1209 StatusBarNotification removeNotificationViews(IBinder key) { 1210 NotificationData.Entry entry = mNotificationData.remove(key); 1211 if (entry == null) { 1212 Slog.w(TAG, "removeNotification for unknown key: " + key); 1213 return null; 1214 } 1215 // Remove the expanded view. 1216 ViewGroup rowParent = (ViewGroup)entry.row.getParent(); 1217 if (rowParent != null) rowParent.removeView(entry.row); 1218 1219 if (key == mNotificationPeekKey) { 1220 // must close the peek as well, since it's gone 1221 mHandler.sendEmptyMessage(MSG_CLOSE_NOTIFICATION_PEEK); 1222 } 1223 // Remove the icon. 1224// ViewGroup iconParent = (ViewGroup)entry.icon.getParent(); 1225// if (iconParent != null) iconParent.removeView(entry.icon); 1226 updateNotificationIcons(); 1227 1228 return entry.notification; 1229 } 1230 1231 private class NotificationTriggerTouchListener implements View.OnTouchListener { 1232 VelocityTracker mVT; 1233 float mInitialTouchX, mInitialTouchY; 1234 int mTouchSlop; 1235 1236 public NotificationTriggerTouchListener() { 1237 mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); 1238 } 1239 1240 public boolean onTouch(View v, MotionEvent event) { 1241// Slog.d(TAG, String.format("touch: (%.1f, %.1f) initial: (%.1f, %.1f)", 1242// event.getX(), 1243// event.getY(), 1244// mInitialTouchX, 1245// mInitialTouchY)); 1246 final int action = event.getAction(); 1247 switch (action) { 1248 case MotionEvent.ACTION_DOWN: 1249 mVT = VelocityTracker.obtain(); 1250 mInitialTouchX = event.getX(); 1251 mInitialTouchY = event.getY(); 1252 // fall through 1253 case MotionEvent.ACTION_OUTSIDE: 1254 case MotionEvent.ACTION_MOVE: 1255 // check for fling 1256 if (mVT != null) { 1257 mVT.addMovement(event); 1258 mVT.computeCurrentVelocity(1000); // pixels per second 1259 // require a little more oomph once we're already in peekaboo mode 1260 if (mVT.getYVelocity() < -mNotificationFlingVelocity) { 1261 animateExpand(); 1262 mVT.recycle(); 1263 mVT = null; 1264 } 1265 } 1266 return true; 1267 case MotionEvent.ACTION_UP: 1268 case MotionEvent.ACTION_CANCEL: 1269 if (mVT != null) { 1270 if (action == MotionEvent.ACTION_UP 1271 // was this a sloppy tap? 1272 && Math.abs(event.getX() - mInitialTouchX) < mTouchSlop 1273 && Math.abs(event.getY() - mInitialTouchY) < (mTouchSlop / 3) 1274 // dragging off the bottom doesn't count 1275 && (int)event.getY() < v.getBottom()) { 1276 animateExpand(); 1277 v.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED); 1278 v.playSoundEffect(SoundEffectConstants.CLICK); 1279 } 1280 1281 mVT.recycle(); 1282 mVT = null; 1283 return true; 1284 } 1285 } 1286 return false; 1287 } 1288 } 1289 1290 final static int NOTIFICATION_PEEK_HOLD_THRESH = 200; // ms 1291 final static int NOTIFICATION_PEEK_FADE_DELAY = 3000; // ms 1292 1293 public void resetNotificationPeekFadeTimer() { 1294 if (DEBUG) { 1295 Slog.d(TAG, "setting peek fade timer for " + NOTIFICATION_PEEK_FADE_DELAY 1296 + "ms from now"); 1297 } 1298 mHandler.removeMessages(MSG_CLOSE_NOTIFICATION_PEEK); 1299 mHandler.sendEmptyMessageDelayed(MSG_CLOSE_NOTIFICATION_PEEK, 1300 NOTIFICATION_PEEK_FADE_DELAY); 1301 } 1302 1303 private class NotificationIconTouchListener implements View.OnTouchListener { 1304 VelocityTracker mVT; 1305 int mPeekIndex; 1306 float mInitialTouchX, mInitialTouchY; 1307 int mTouchSlop; 1308 1309 public NotificationIconTouchListener() { 1310 mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); 1311 } 1312 1313 public boolean onTouch(View v, MotionEvent event) { 1314 boolean peeking = mNotificationPeekWindow.getVisibility() != View.GONE; 1315 boolean panelShowing = mNotificationPanel.isShowing(); 1316 if (panelShowing) return false; 1317 1318 int numIcons = mIconLayout.getChildCount(); 1319 int newPeekIndex = (int)(event.getX() * numIcons / mIconLayout.getWidth()); 1320 if (newPeekIndex > numIcons - 1) newPeekIndex = numIcons - 1; 1321 else if (newPeekIndex < 0) newPeekIndex = 0; 1322 1323 final int action = event.getAction(); 1324 switch (action) { 1325 case MotionEvent.ACTION_DOWN: 1326 mVT = VelocityTracker.obtain(); 1327 mInitialTouchX = event.getX(); 1328 mInitialTouchY = event.getY(); 1329 mPeekIndex = -1; 1330 1331 // fall through 1332 case MotionEvent.ACTION_OUTSIDE: 1333 case MotionEvent.ACTION_MOVE: 1334 // peek and switch icons if necessary 1335 1336 if (newPeekIndex != mPeekIndex) { 1337 mPeekIndex = newPeekIndex; 1338 1339 if (DEBUG) Slog.d(TAG, "will peek at notification #" + mPeekIndex); 1340 Message peekMsg = mHandler.obtainMessage(MSG_OPEN_NOTIFICATION_PEEK); 1341 peekMsg.arg1 = mPeekIndex; 1342 1343 mHandler.removeMessages(MSG_OPEN_NOTIFICATION_PEEK); 1344 1345 if (peeking) { 1346 // no delay if we're scrubbing left-right 1347 mHandler.sendMessage(peekMsg); 1348 } else { 1349 // wait for fling 1350 mHandler.sendMessageDelayed(peekMsg, NOTIFICATION_PEEK_HOLD_THRESH); 1351 } 1352 } 1353 1354 // check for fling 1355 if (mVT != null) { 1356 mVT.addMovement(event); 1357 mVT.computeCurrentVelocity(1000); // pixels per second 1358 // require a little more oomph once we're already in peekaboo mode 1359 if (!panelShowing && ( 1360 (peeking && mVT.getYVelocity() < -mNotificationFlingVelocity*3) 1361 || (mVT.getYVelocity() < -mNotificationFlingVelocity))) { 1362 mHandler.removeMessages(MSG_OPEN_NOTIFICATION_PEEK); 1363 mHandler.removeMessages(MSG_OPEN_NOTIFICATION_PANEL); 1364 mHandler.sendEmptyMessage(MSG_CLOSE_NOTIFICATION_PEEK); 1365 mHandler.sendEmptyMessage(MSG_OPEN_NOTIFICATION_PANEL); 1366 } 1367 } 1368 return true; 1369 case MotionEvent.ACTION_UP: 1370 case MotionEvent.ACTION_CANCEL: 1371 mHandler.removeMessages(MSG_OPEN_NOTIFICATION_PEEK); 1372 if (!peeking) { 1373 if (action == MotionEvent.ACTION_UP 1374 // was this a sloppy tap? 1375 && Math.abs(event.getX() - mInitialTouchX) < mTouchSlop 1376 && Math.abs(event.getY() - mInitialTouchY) < (mTouchSlop / 3) 1377 // dragging off the bottom doesn't count 1378 && (int)event.getY() < v.getBottom()) { 1379 Message peekMsg = mHandler.obtainMessage(MSG_OPEN_NOTIFICATION_PEEK); 1380 peekMsg.arg1 = mPeekIndex; 1381 mHandler.removeMessages(MSG_OPEN_NOTIFICATION_PEEK); 1382 mHandler.sendMessage(peekMsg); 1383 1384 v.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED); 1385 v.playSoundEffect(SoundEffectConstants.CLICK); 1386 1387 peeking = true; // not technically true yet, but the next line will run 1388 } 1389 } 1390 1391 if (peeking) { 1392 resetNotificationPeekFadeTimer(); 1393 } 1394 1395 mVT.recycle(); 1396 mVT = null; 1397 return true; 1398 } 1399 return false; 1400 } 1401 } 1402 1403 StatusBarIconView addNotificationViews(IBinder key, StatusBarNotification notification) { 1404 if (DEBUG) { 1405 Slog.d(TAG, "addNotificationViews(key=" + key + ", notification=" + notification); 1406 } 1407 // Construct the icon. 1408 final StatusBarIconView iconView = new StatusBarIconView(mContext, 1409 notification.pkg + "/0x" + Integer.toHexString(notification.id)); 1410 iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); 1411 1412 final StatusBarIcon ic = new StatusBarIcon(notification.pkg, 1413 notification.notification.icon, 1414 notification.notification.iconLevel, 1415 notification.notification.number); 1416 if (!iconView.set(ic)) { 1417 handleNotificationError(key, notification, "Couldn't attach StatusBarIcon: " + ic); 1418 return null; 1419 } 1420 // Construct the expanded view. 1421 NotificationData.Entry entry = new NotificationData.Entry(key, notification, iconView); 1422 if (!inflateViews(entry, mPile)) { 1423 handleNotificationError(key, notification, "Couldn't expand RemoteViews for: " 1424 + notification); 1425 return null; 1426 } 1427 1428 // Add the icon. 1429 int pos = mNotificationData.add(entry); 1430 if (DEBUG) { 1431 Slog.d(TAG, "addNotificationViews: added at " + pos); 1432 } 1433 updateNotificationIcons(); 1434 1435 return iconView; 1436 } 1437 1438 private void reloadAllNotificationIcons() { 1439 if (mIconLayout == null) return; 1440 mIconLayout.removeAllViews(); 1441 updateNotificationIcons(); 1442 } 1443 1444 private void updateNotificationIcons() { 1445 // XXX: need to implement a new limited linear layout class 1446 // to avoid removing & readding everything 1447 1448 if (mIconLayout == null) return; 1449 1450 // first, populate the main notification panel 1451 loadNotificationPanel(); 1452 1453 final LinearLayout.LayoutParams params 1454 = new LinearLayout.LayoutParams(mIconSize + 2*mIconHPadding, mNaturalBarHeight); 1455 1456 // alternate behavior in DND mode 1457 if (mNotificationDNDMode) { 1458 if (mIconLayout.getChildCount() == 0) { 1459 final StatusBarIconView iconView = new StatusBarIconView(mContext, "_dnd"); 1460 iconView.setImageResource(R.drawable.ic_notification_dnd); 1461 iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); 1462 iconView.setPadding(mIconHPadding, 0, mIconHPadding, 0); 1463 1464 final Notification dndNotification = new Notification.Builder(mContext) 1465 .setContentTitle(mContext.getText(R.string.notifications_off_title)) 1466 .setContentText(mContext.getText(R.string.notifications_off_text)) 1467 .setSmallIcon(R.drawable.ic_notification_dnd) 1468 .setOngoing(true) 1469 .getNotification(); 1470 1471 mNotificationDNDDummyEntry = new NotificationData.Entry( 1472 null, 1473 new StatusBarNotification("", 0, "", 0, 0, dndNotification), 1474 iconView); 1475 1476 mIconLayout.addView(iconView, params); 1477 } 1478 1479 return; 1480 } 1481 1482 int N = mNotificationData.size(); 1483 1484 if (DEBUG) { 1485 Slog.d(TAG, "refreshing icons: " + N + " notifications, mIconLayout=" + mIconLayout); 1486 } 1487 1488 ArrayList<View> toShow = new ArrayList<View>(); 1489 1490 // Extra Special Icons 1491 // The IME switcher and compatibility mode icons take the place of notifications. You didn't 1492 // need to see all those new emails, did you? 1493 int maxNotificationIconsCount = mMaxNotificationIcons; 1494 if (mInputMethodSwitchButton.getVisibility() != View.GONE) maxNotificationIconsCount --; 1495 if (mCompatModeButton.getVisibility() != View.GONE) maxNotificationIconsCount --; 1496 1497 for (int i=0; i< maxNotificationIconsCount; i++) { 1498 if (i>=N) break; 1499 toShow.add(mNotificationData.get(N-i-1).icon); 1500 } 1501 1502 ArrayList<View> toRemove = new ArrayList<View>(); 1503 for (int i=0; i<mIconLayout.getChildCount(); i++) { 1504 View child = mIconLayout.getChildAt(i); 1505 if (!toShow.contains(child)) { 1506 toRemove.add(child); 1507 } 1508 } 1509 1510 for (View remove : toRemove) { 1511 mIconLayout.removeView(remove); 1512 } 1513 1514 for (int i=0; i<toShow.size(); i++) { 1515 View v = toShow.get(i); 1516 v.setPadding(mIconHPadding, 0, mIconHPadding, 0); 1517 if (v.getParent() == null) { 1518 mIconLayout.addView(v, i, params); 1519 } 1520 } 1521 } 1522 1523 private void loadNotificationPanel() { 1524 int N = mNotificationData.size(); 1525 1526 ArrayList<View> toShow = new ArrayList<View>(); 1527 1528 for (int i=0; i<N; i++) { 1529 View row = mNotificationData.get(N-i-1).row; 1530 toShow.add(row); 1531 } 1532 1533 ArrayList<View> toRemove = new ArrayList<View>(); 1534 for (int i=0; i<mPile.getChildCount(); i++) { 1535 View child = mPile.getChildAt(i); 1536 if (!toShow.contains(child)) { 1537 toRemove.add(child); 1538 } 1539 } 1540 1541 for (View remove : toRemove) { 1542 mPile.removeView(remove); 1543 } 1544 1545 for (int i=0; i<toShow.size(); i++) { 1546 View v = toShow.get(i); 1547 if (v.getParent() == null) { 1548 mPile.addView(v, N-1-i); // the notification panel has newest at the bottom 1549 } 1550 } 1551 1552 mNotificationPanel.setNotificationCount(N); 1553 } 1554 1555 void workAroundBadLayerDrawableOpacity(View v) { 1556 LayerDrawable d = (LayerDrawable)v.getBackground(); 1557 if (d == null) return; 1558 v.setBackgroundDrawable(null); 1559 d.setOpacity(PixelFormat.TRANSLUCENT); 1560 v.setBackgroundDrawable(d); 1561 } 1562 1563 private boolean inflateViews(NotificationData.Entry entry, ViewGroup parent) { 1564 StatusBarNotification sbn = entry.notification; 1565 RemoteViews remoteViews = sbn.notification.contentView; 1566 if (remoteViews == null) { 1567 return false; 1568 } 1569 1570 // create the row view 1571 LayoutInflater inflater = (LayoutInflater)mContext.getSystemService( 1572 Context.LAYOUT_INFLATER_SERVICE); 1573 View row = inflater.inflate(R.layout.status_bar_notification_row, parent, false); 1574 workAroundBadLayerDrawableOpacity(row); 1575 View vetoButton = row.findViewById(R.id.veto); 1576 if (entry.notification.isClearable()) { 1577 final String _pkg = sbn.pkg; 1578 final String _tag = sbn.tag; 1579 final int _id = sbn.id; 1580 vetoButton.setOnClickListener(new View.OnClickListener() { 1581 public void onClick(View v) { 1582 try { 1583 mBarService.onNotificationClear(_pkg, _tag, _id); 1584 } catch (RemoteException ex) { 1585 // system process is dead if we're here. 1586 } 1587 } 1588 }); 1589 } else { 1590 if ((sbn.notification.flags & Notification.FLAG_ONGOING_EVENT) == 0) { 1591 vetoButton.setVisibility(View.INVISIBLE); 1592 } else { 1593 vetoButton.setVisibility(View.GONE); 1594 } 1595 } 1596 1597 // the large icon 1598 ImageView largeIcon = (ImageView)row.findViewById(R.id.large_icon); 1599 if (sbn.notification.largeIcon != null) { 1600 largeIcon.setImageBitmap(sbn.notification.largeIcon); 1601 } else { 1602 largeIcon.getLayoutParams().width = 0; 1603 largeIcon.setVisibility(View.INVISIBLE); 1604 } 1605 1606 // bind the click event to the content area 1607 ViewGroup content = (ViewGroup)row.findViewById(R.id.content); 1608 // XXX: update to allow controls within notification views 1609 content.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); 1610// content.setOnFocusChangeListener(mFocusChangeListener); 1611 PendingIntent contentIntent = sbn.notification.contentIntent; 1612 if (contentIntent != null) { 1613 content.setOnClickListener(new NotificationClicker(contentIntent, 1614 sbn.pkg, sbn.tag, sbn.id)); 1615 } else { 1616 content.setOnClickListener(null); 1617 } 1618 1619 View expanded = null; 1620 Exception exception = null; 1621 try { 1622 expanded = remoteViews.apply(mContext, content); 1623 } 1624 catch (RuntimeException e) { 1625 exception = e; 1626 } 1627 if (expanded == null) { 1628 final String ident = sbn.pkg + "/0x" + Integer.toHexString(sbn.id); 1629 Slog.e(TAG, "couldn't inflate view for notification " + ident, exception); 1630 return false; 1631 } else { 1632 content.addView(expanded); 1633 row.setDrawingCacheEnabled(true); 1634 } 1635 1636 entry.row = row; 1637 entry.content = content; 1638 entry.expanded = expanded; 1639 entry.largeIcon = largeIcon; 1640 1641 return true; 1642 } 1643 1644 public void userActivity() { 1645 } 1646 1647 public class TouchOutsideListener implements View.OnTouchListener { 1648 private int mMsg; 1649 private StatusBarPanel mPanel; 1650 1651 public TouchOutsideListener(int msg, StatusBarPanel panel) { 1652 mMsg = msg; 1653 mPanel = panel; 1654 } 1655 1656 public boolean onTouch(View v, MotionEvent ev) { 1657 final int action = ev.getAction(); 1658 if (action == MotionEvent.ACTION_OUTSIDE 1659 || (action == MotionEvent.ACTION_DOWN 1660 && !mPanel.isInContentArea((int)ev.getX(), (int)ev.getY()))) { 1661 mHandler.removeMessages(mMsg); 1662 mHandler.sendEmptyMessage(mMsg); 1663 return true; 1664 } 1665 return false; 1666 } 1667 } 1668 1669 public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { 1670 pw.print("mDisabled=0x"); 1671 pw.println(Integer.toHexString(mDisabled)); 1672 pw.println("mNetworkController:"); 1673 mNetworkController.dump(fd, pw, args); 1674 } 1675} 1676 1677 1678