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