PhoneStatusBar.java revision ab48b681401628a191a4a90d4906fa88edde95ba
1808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato/* 2808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * Copyright (C) 2010 The Android Open Source Project 3808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * 4808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * Licensed under the Apache License, Version 2.0 (the "License"); 5808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * you may not use this file except in compliance with the License. 6808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * You may obtain a copy of the License at 7808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * 8808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * http://www.apache.org/licenses/LICENSE-2.0 9808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * 10808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * Unless required by applicable law or agreed to in writing, software 11808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * distributed under the License is distributed on an "AS IS" BASIS, 12808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * See the License for the specific language governing permissions and 14808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * limitations under the License. 15808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato */ 16808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 17fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onoratopackage com.android.systemui.statusbar.phone; 18808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 190761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandlerimport android.animation.ObjectAnimator; 20fc8fa638617efb5695a1f89ea75375faebbe2a40Dianne Hackbornimport android.app.ActivityManager; 21808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.app.ActivityManagerNative; 22808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.app.Dialog; 2392d331883ada42e49001853e266cda2d9c8631b8Daniel Sandlerimport android.app.KeyguardManager; 24808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.app.Notification; 25808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.app.PendingIntent; 26808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.app.StatusBarManager; 27808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.content.BroadcastReceiver; 28808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.content.Context; 29808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.content.Intent; 30808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.content.IntentFilter; 31808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.content.res.Resources; 323b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurkaimport android.content.res.Configuration; 33808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.graphics.PixelFormat; 34808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.graphics.Rect; 35808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.graphics.drawable.Drawable; 36808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.os.IBinder; 37808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.os.RemoteException; 38808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.os.Handler; 39808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.os.Message; 401d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandlerimport android.os.ServiceManager; 41808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.os.SystemClock; 42d309056d36759446c91ff5c1e17a217bfa4fdcfbDaniel Sandlerimport android.provider.Settings; 43935865923fdad9f47061ff0aedfe92d0b912d5d6Joe Onoratoimport android.text.TextUtils; 4436412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandlerimport android.util.DisplayMetrics; 45808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.util.Slog; 46808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.util.Log; 47808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.Display; 48808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.Gravity; 491d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandlerimport android.view.IWindowManager; 50808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.KeyEvent; 51808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.LayoutInflater; 52808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.MotionEvent; 538956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandlerimport android.view.Surface; 54808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.VelocityTracker; 55808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.View; 56808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.ViewGroup; 57f2a16b27afd1ede5880d05eb9e19090c7e3e820eJim Millerimport android.view.ViewGroup.LayoutParams; 58808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.Window; 59808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.WindowManager; 60808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.WindowManagerImpl; 61808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.animation.Animation; 62808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.animation.AnimationUtils; 63808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.widget.ImageView; 64808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.widget.LinearLayout; 65808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.widget.RemoteViews; 66808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.widget.ScrollView; 67808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.widget.TextView; 68808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 69808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport java.io.FileDescriptor; 70808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport java.io.PrintWriter; 71808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport java.util.ArrayList; 72808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 73808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport com.android.internal.statusbar.StatusBarIcon; 74808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport com.android.internal.statusbar.StatusBarNotification; 75808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 76808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport com.android.systemui.R; 77ab48b681401628a191a4a90d4906fa88edde95baMichael Jurkaimport com.android.systemui.recent.RecentTasksLoader; 783b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurkaimport com.android.systemui.recent.RecentsPanelView; 79ab48b681401628a191a4a90d4906fa88edde95baMichael Jurkaimport com.android.systemui.recent.TaskDescription; 80fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onoratoimport com.android.systemui.statusbar.NotificationData; 81fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onoratoimport com.android.systemui.statusbar.StatusBar; 82fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onoratoimport com.android.systemui.statusbar.StatusBarIconView; 832e347429dfcd03b0827c7506ba6305ab0d1f4951Christian Robertsonimport com.android.systemui.statusbar.SignalClusterView; 84fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onoratoimport com.android.systemui.statusbar.policy.DateView; 852b69735e014872ca2183b4a39a8381daa337e146Daniel Sandlerimport com.android.systemui.statusbar.policy.BatteryController; 862b69735e014872ca2183b4a39a8381daa337e146Daniel Sandlerimport com.android.systemui.statusbar.policy.LocationController; 872b69735e014872ca2183b4a39a8381daa337e146Daniel Sandlerimport com.android.systemui.statusbar.policy.NetworkController; 888ba33c965f940070060585e45e1c833519bb45c9Daniel Sandlerimport com.android.systemui.statusbar.policy.NotificationRowLayout; 89808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 90fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onoratopublic class PhoneStatusBar extends StatusBar { 91fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato static final String TAG = "PhoneStatusBar"; 923b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka public static final boolean DEBUG = false; 9336412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler public static final boolean SPEW = false; 947579bca7a02477353700d3b716f172b4fab267c0Daniel Sandler public static final boolean DUMPTRUCK = true; // extra dumpsys info 95808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 9696e61c3c86b2aff3d298d8757ba51eb568c30543Daniel Sandler // additional instrumentation for testing purposes; intended to be left on during development 9796e61c3c86b2aff3d298d8757ba51eb568c30543Daniel Sandler public static final boolean CHATTY = DEBUG || true; 9896e61c3c86b2aff3d298d8757ba51eb568c30543Daniel Sandler 99808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public static final String ACTION_STATUSBAR_START 100808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato = "com.android.internal.policy.statusbar.START"; 101808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 102808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato static final int EXPANDED_LEAVE_ALONE = -10000; 103808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato static final int EXPANDED_FULL_OPEN = -10001; 104808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1058ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler private static final int MSG_ANIMATE = 100; 1068ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler private static final int MSG_ANIMATE_REVEAL = 101; 1078ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler private static final int MSG_OPEN_NOTIFICATION_PANEL = 1000; 1088ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler private static final int MSG_CLOSE_NOTIFICATION_PANEL = 1001; 109808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private static final int MSG_SHOW_INTRUDER = 1002; 110808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private static final int MSG_HIDE_INTRUDER = 1003; 1113b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka private static final int MSG_OPEN_RECENTS_PANEL = 1020; 1123b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka private static final int MSG_CLOSE_RECENTS_PANEL = 1021; 113808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 114808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // will likely move to a resource or other tunable param at some point 115808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private static final int INTRUDER_ALERT_DECAY_MS = 10000; 116808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 117dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler // fling gesture tuning parameters, scaled to display density 118dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler private float mSelfExpandVelocityPx; // classic value: 2000px/s 119dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler private float mSelfCollapseVelocityPx; // classic value: 2000px/s (will be negated to collapse "up") 120dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler private float mFlingExpandMinVelocityPx; // classic value: 200px/s 121dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler private float mFlingCollapseMinVelocityPx; // classic value: 200px/s 122dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler private float mCollapseMinDisplayFraction; // classic value: 0.08 (25px/min(320px,480px) on G1) 123dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler private float mExpandMinDisplayFraction; // classic value: 0.5 (drag open halfway to expand) 124dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler private float mFlingGestureMaxXVelocityPx; // classic value: 150px/s 125dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler 126dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler private float mExpandAccelPx; // classic value: 2000px/s/s 127dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler private float mCollapseAccelPx; // classic value: 2000px/s/s (will be negated to collapse "up") 128dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler 129fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato PhoneStatusBarPolicy mIconPolicy; 130808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1312b69735e014872ca2183b4a39a8381daa337e146Daniel Sandler // These are no longer handled by the policy, because we need custom strategies for them 1322b69735e014872ca2183b4a39a8381daa337e146Daniel Sandler BatteryController mBatteryController; 1332b69735e014872ca2183b4a39a8381daa337e146Daniel Sandler LocationController mLocationController; 1342b69735e014872ca2183b4a39a8381daa337e146Daniel Sandler NetworkController mNetworkController; 1352b69735e014872ca2183b4a39a8381daa337e146Daniel Sandler 1367c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler int mNaturalBarHeight = -1; 1377c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler int mIconSize = -1; 1387c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler int mIconHPadding = -1; 139808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Display mDisplay; 140808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1411d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler IWindowManager mWindowManager; 1421d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler 143fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato PhoneStatusBarView mStatusBarView; 144808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int mPixelFormat; 145808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato H mHandler = new H(); 146808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Object mQueueLock = new Object(); 147808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 148808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // icons 149808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato LinearLayout mIcons; 150808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato IconMerger mNotificationIcons; 151808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato LinearLayout mStatusIcons; 152808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 153808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // expanded notifications 154808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Dialog mExpandedDialog; 155808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ExpandedView mExpandedView; 156808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManager.LayoutParams mExpandedParams; 157808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ScrollView mScrollView; 158808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato View mExpandedContents; 159808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // top bar 160808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato TextView mNoNotificationsTitle; 1611347c30824ce3544dff03c93ffad9af7f0327e41Daniel Sandler View mClearButton; 162d309056d36759446c91ff5c1e17a217bfa4fdcfbDaniel Sandler View mSettingsButton; 163d309056d36759446c91ff5c1e17a217bfa4fdcfbDaniel Sandler 164808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // drag bar 165808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato CloseDragHandle mCloseView; 1667c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 1677c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler // all notifications 1687c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler NotificationData mNotificationData = new NotificationData(); 1698ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler NotificationRowLayout mPile; 1707c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 171808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // position 172808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int[] mPositionTmp = new int[2]; 173808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean mExpanded; 174808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean mExpandedVisible; 175808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 176808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // the date view 177808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato DateView mDateView; 178808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 179808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // for immersive activities 180808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private View mIntruderAlertView; 181808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1828956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler // on-screen navigation buttons 1830129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler private NavigationBarView mNavigationBarView = null; 1848956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 185808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // the tracker view 186808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato TrackingView mTrackingView; 187808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManager.LayoutParams mTrackingParams; 188808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int mTrackingPosition; // the position of the top of the tracking view. 189808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private boolean mPanelSlightlyVisible; 190808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 191808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // ticker 192808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private Ticker mTicker; 193808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private View mTickerView; 194808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private boolean mTicking; 195808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1967daf95d5526e3b60f5db29cbacd9a4852d99a6f4Michael Jurka // Recent apps 1973b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka private RecentsPanelView mRecentsPanel; 198ab48b681401628a191a4a90d4906fa88edde95baMichael Jurka private RecentTasksLoader mRecentTasksLoader; 1993b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 200808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Tracking finger for opening/closing. 201808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int mEdgeBorder; // corresponds to R.dimen.status_bar_edge_ignore 202808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean mTracking; 203808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato VelocityTracker mVelocityTracker; 204808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 205808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato static final int ANIM_FRAME_DURATION = (1000/60); 206808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 207808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean mAnimating; 208808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato long mCurAnimationTime; 209808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float mAnimY; 210808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float mAnimVel; 211808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float mAnimAccel; 212808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato long mAnimLastTime; 213808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean mAnimatingReveal = false; 214808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int mViewDelta; 215808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int[] mAbsPos = new int[2]; 216808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 217808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // for disabling the status bar 218808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int mDisabled = 0; 219808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 22060ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler // tracking calls to View.setSystemUiVisibility() 22160ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler int mSystemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE; 22260ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler 22336412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler DisplayMetrics mDisplayMetrics = new DisplayMetrics(); 2241dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn 225808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private class ExpandedDialog extends Dialog { 226808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ExpandedDialog(Context context) { 22736412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler super(context, com.android.internal.R.style.Theme_Translucent_NoTitleBar); 228808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 229808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 230808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato @Override 231808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public boolean dispatchKeyEvent(KeyEvent event) { 232808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean down = event.getAction() == KeyEvent.ACTION_DOWN; 233808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato switch (event.getKeyCode()) { 234808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato case KeyEvent.KEYCODE_BACK: 235808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!down) { 236808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato animateCollapse(); 237808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 238808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return true; 239808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 240808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return super.dispatchKeyEvent(event); 241808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 242808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 243808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 244808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato @Override 245f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato public void start() { 246f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)) 247f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato .getDefaultDisplay(); 248808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 2491d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler mWindowManager = IWindowManager.Stub.asInterface( 2501d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler ServiceManager.getService(Context.WINDOW_SERVICE)); 2511d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler 252f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato super.start(); 253808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 2548956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler addNavigationBar(); 2558956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 2568956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler //addIntruderView(); 257808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 258808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Lastly, call to the icon policy to install/update all the icons. 259fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato mIconPolicy = new PhoneStatusBarPolicy(mContext); 260808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 261808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 262808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // ================================================================================ 263808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Constructing the view 264808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // ================================================================================ 265808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato protected View makeStatusBarView() { 266f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato final Context context = mContext; 267808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 268808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Resources res = context.getResources(); 269808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 27036412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler mDisplay.getMetrics(mDisplayMetrics); 27136412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler if (DEBUG) { 27236412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler Slog.d(TAG, "makeStatusBarView: mDisplayMetrics=" + mDisplayMetrics); 27336412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler mDisplayMetrics = res.getDisplayMetrics(); 27436412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler Slog.d(TAG, "makeStatusBarView: mDisplayMetrics2=" + mDisplayMetrics); 27536412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler } 2767c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler loadDimens(); 277808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 2781dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size); 2791dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn 280808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ExpandedView expanded = (ExpandedView)View.inflate(context, 281808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato R.layout.status_bar_expanded, null); 282cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler if (DEBUG) { 283cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler expanded.setBackgroundColor(0x6000FF80); 284cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler } 285808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato expanded.mService = this; 286808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 287808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIntruderAlertView = View.inflate(context, R.layout.intruder_alert, null); 288808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIntruderAlertView.setVisibility(View.GONE); 289808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIntruderAlertView.setClickable(true); 290808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 29160ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler PhoneStatusBarView sb = (PhoneStatusBarView)View.inflate(context, 29260ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler R.layout.status_bar, null); 29360ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler sb.mService = this; 29460ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler mStatusBarView = sb; 29560ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler 2960129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler try { 2978c4706252228755ed181d19532b7e0cfec270ba4Adam Powell boolean showNav = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar); 2980129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler if (showNav) { 2990129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler mNavigationBarView = 3000129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler (NavigationBarView) View.inflate(context, R.layout.navigation_bar, null); 30160ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler 3026da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler mNavigationBarView.setDisabledFlags(mDisabled); 303e644b647837a2f2835c20423d0657cca19d3595aMathias Agopian 30460ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler sb.setOnSystemUiVisibilityChangeListener( 30560ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler new View.OnSystemUiVisibilityChangeListener() { 30660ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler @Override 30760ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler public void onSystemUiVisibilityChange(int visibility) { 30860ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler if (DEBUG) { 30960ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler Slog.d(TAG, "systemUi: " + visibility); 31060ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler } 31160ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler boolean hide = (0 != (visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION)); 31260ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler mNavigationBarView.setHidden(hide); 31360ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler } 31460ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler }); 3150129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler } 3160129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler } catch (Resources.NotFoundException ex) { 3170129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler // no nav bar for you 3180129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler } 3198956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 320808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // figure out which pixel-format to use for the status bar. 321f733c2aaa652f3ead60c8b2bc982dc9bdbc7df8eDaniel Sandler mPixelFormat = PixelFormat.OPAQUE; 322808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mStatusIcons = (LinearLayout)sb.findViewById(R.id.statusIcons); 323808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mNotificationIcons = (IconMerger)sb.findViewById(R.id.notificationIcons); 324808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIcons = (LinearLayout)sb.findViewById(R.id.icons); 325808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickerView = sb.findViewById(R.id.ticker); 326808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 327808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog = new ExpandedDialog(context); 328808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedView = expanded; 3298ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler mPile = (NotificationRowLayout)expanded.findViewById(R.id.latestItems); 3300761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler mExpandedContents = mPile; // was: expanded.findViewById(R.id.notificationLinearLayout); 331808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mNoNotificationsTitle = (TextView)expanded.findViewById(R.id.noNotificationsTitle); 332d714148bd2752c63a46f51b12cea288fb1f10528Daniel Sandler mNoNotificationsTitle.setVisibility(View.GONE); // disabling for now 333d714148bd2752c63a46f51b12cea288fb1f10528Daniel Sandler 3341347c30824ce3544dff03c93ffad9af7f0327e41Daniel Sandler mClearButton = expanded.findViewById(R.id.clear_all_button); 335808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mClearButton.setOnClickListener(mClearButtonListener); 3360761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler mClearButton.setAlpha(0f); 3378ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler mClearButton.setEnabled(false); 338d309056d36759446c91ff5c1e17a217bfa4fdcfbDaniel Sandler mDateView = (DateView)expanded.findViewById(R.id.date); 339d309056d36759446c91ff5c1e17a217bfa4fdcfbDaniel Sandler mSettingsButton = expanded.findViewById(R.id.settings_button); 340d309056d36759446c91ff5c1e17a217bfa4fdcfbDaniel Sandler mSettingsButton.setOnClickListener(mSettingsButtonListener); 341808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mScrollView = (ScrollView)expanded.findViewById(R.id.scroll); 342808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 343808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicker = new MyTicker(context, sb); 344808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 345808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato TickerView tickerView = (TickerView)sb.findViewById(R.id.tickerText); 346808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato tickerView.mTicker = mTicker; 347808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 348808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingView = (TrackingView)View.inflate(context, R.layout.status_bar_tracking, null); 349808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingView.mService = this; 350808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCloseView = (CloseDragHandle)mTrackingView.findViewById(R.id.close); 351808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCloseView.mService = this; 352808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 353808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore); 354808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 355808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // set the inital view visibility 356808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setAreThereNotifications(); 357808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 3582b69735e014872ca2183b4a39a8381daa337e146Daniel Sandler // Other icons 3592b69735e014872ca2183b4a39a8381daa337e146Daniel Sandler mLocationController = new LocationController(mContext); // will post a notification 3602b69735e014872ca2183b4a39a8381daa337e146Daniel Sandler mBatteryController = new BatteryController(mContext); 3612b69735e014872ca2183b4a39a8381daa337e146Daniel Sandler mBatteryController.addIconView((ImageView)sb.findViewById(R.id.battery)); 3622b69735e014872ca2183b4a39a8381daa337e146Daniel Sandler mNetworkController = new NetworkController(mContext); 3632e347429dfcd03b0827c7506ba6305ab0d1f4951Christian Robertson final SignalClusterView signalCluster = 3642e347429dfcd03b0827c7506ba6305ab0d1f4951Christian Robertson (SignalClusterView)sb.findViewById(R.id.signal_cluster); 3652e347429dfcd03b0827c7506ba6305ab0d1f4951Christian Robertson mNetworkController.addSignalCluster(signalCluster); 36628f89d40ee7bab93cf7b783f92dbb18bdc43e473Daniel Sandler signalCluster.setNetworkController(mNetworkController); 3672b69735e014872ca2183b4a39a8381daa337e146Daniel Sandler 3683b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka // Recents Panel 369ab48b681401628a191a4a90d4906fa88edde95baMichael Jurka mRecentTasksLoader = new RecentTasksLoader(context); 37017dfec7111fcc53a4f6ae6e92b4a7f85a278fe71Jim Miller updateRecentsPanel(); 3713b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 372808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // receive broadcasts 373808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato IntentFilter filter = new IntentFilter(); 374808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); 375808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); 376808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato filter.addAction(Intent.ACTION_SCREEN_OFF); 377808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato context.registerReceiver(mBroadcastReceiver, filter); 378808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 379808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return sb; 380808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 381808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 382f2a16b27afd1ede5880d05eb9e19090c7e3e820eJim Miller protected WindowManager.LayoutParams getRecentsLayoutParams(LayoutParams layoutParams) { 3833cd0a593937c0724d77db1e2e3995255cfae61acMichael Jurka boolean opaque = false; 3843b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka WindowManager.LayoutParams lp = new WindowManager.LayoutParams( 385f2a16b27afd1ede5880d05eb9e19090c7e3e820eJim Miller layoutParams.width, 386f2a16b27afd1ede5880d05eb9e19090c7e3e820eJim Miller layoutParams.height, 3873b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, 3883b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 3893b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM 390fc8fa638617efb5695a1f89ea75375faebbe2a40Dianne Hackborn | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, 3913cd0a593937c0724d77db1e2e3995255cfae61acMichael Jurka (opaque ? PixelFormat.OPAQUE : PixelFormat.TRANSLUCENT)); 392fc8fa638617efb5695a1f89ea75375faebbe2a40Dianne Hackborn if (ActivityManager.isHighEndGfx(mDisplay)) { 393fc8fa638617efb5695a1f89ea75375faebbe2a40Dianne Hackborn lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; 394fc8fa638617efb5695a1f89ea75375faebbe2a40Dianne Hackborn } 3953b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka lp.gravity = Gravity.BOTTOM | Gravity.LEFT; 3963b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka lp.setTitle("RecentsPanel"); 3973b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka lp.windowAnimations = R.style.Animation_RecentPanel; 3983b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED 3993b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; 4003b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka return lp; 4013b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 4023b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 40317dfec7111fcc53a4f6ae6e92b4a7f85a278fe71Jim Miller protected void updateRecentsPanel() { 4043b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka // Recents Panel 4053b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka boolean visible = false; 406ab48b681401628a191a4a90d4906fa88edde95baMichael Jurka ArrayList<TaskDescription> recentTasksList = null; 4073b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (mRecentsPanel != null) { 4088b09866a25ade5cd3630996adff8c976268ec637Michael Jurka visible = mRecentsPanel.isShowing(); 4093b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka WindowManagerImpl.getDefault().removeView(mRecentsPanel); 410ab48b681401628a191a4a90d4906fa88edde95baMichael Jurka if (visible) { 411ab48b681401628a191a4a90d4906fa88edde95baMichael Jurka recentTasksList = mRecentsPanel.getRecentTasksList(); 412ab48b681401628a191a4a90d4906fa88edde95baMichael Jurka } 4133b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 414f2a16b27afd1ede5880d05eb9e19090c7e3e820eJim Miller 415f2a16b27afd1ede5880d05eb9e19090c7e3e820eJim Miller // Provide RecentsPanelView with a temporary parent to allow layout params to work. 416f2a16b27afd1ede5880d05eb9e19090c7e3e820eJim Miller LinearLayout tmpRoot = new LinearLayout(mContext); 417f2a16b27afd1ede5880d05eb9e19090c7e3e820eJim Miller mRecentsPanel = (RecentsPanelView) LayoutInflater.from(mContext).inflate( 418f2a16b27afd1ede5880d05eb9e19090c7e3e820eJim Miller R.layout.status_bar_recent_panel, tmpRoot, false); 419ab48b681401628a191a4a90d4906fa88edde95baMichael Jurka mRecentsPanel.setRecentTasksLoader(mRecentTasksLoader); 420ab48b681401628a191a4a90d4906fa88edde95baMichael Jurka mRecentTasksLoader.setRecentsPanel(mRecentsPanel); 4213b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel.setOnTouchListener(new TouchOutsideListener(MSG_CLOSE_RECENTS_PANEL, 4223b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel)); 4233b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel.setVisibility(View.GONE); 424f2a16b27afd1ede5880d05eb9e19090c7e3e820eJim Miller WindowManager.LayoutParams lp = getRecentsLayoutParams(mRecentsPanel.getLayoutParams()); 4253b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 4263b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka WindowManagerImpl.getDefault().addView(mRecentsPanel, lp); 4273b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel.setBar(this); 4283b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (visible) { 429ab48b681401628a191a4a90d4906fa88edde95baMichael Jurka mRecentsPanel.show(true, false, recentTasksList); 4303b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 4313b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 4323b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 4333b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 434808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato protected int getStatusBarGravity() { 435808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return Gravity.TOP | Gravity.FILL_HORIZONTAL; 436808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 437808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 438dc10030581d6eec1c96acd62ed511f91d25d73a1Joe Onorato public int getStatusBarHeight() { 439f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato final Resources res = mContext.getResources(); 440dc10030581d6eec1c96acd62ed511f91d25d73a1Joe Onorato return res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); 441dc10030581d6eec1c96acd62ed511f91d25d73a1Joe Onorato } 442dc10030581d6eec1c96acd62ed511f91d25d73a1Joe Onorato 4435c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler private View.OnClickListener mRecentsClickListener = new View.OnClickListener() { 4445c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler public void onClick(View v) { 4455c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler toggleRecentApps(); 4465c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler } 4475c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler }; 4485c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler 4498956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler // For small-screen devices (read: phones) that lack hardware navigation buttons 4508956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler private void addNavigationBar() { 4510129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler if (mNavigationBarView == null) return; 45217dfec7111fcc53a4f6ae6e92b4a7f85a278fe71Jim Miller 4538956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler mNavigationBarView.reorient(); 45417dfec7111fcc53a4f6ae6e92b4a7f85a278fe71Jim Miller 4555c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler mNavigationBarView.getRecentsButton().setOnClickListener(mRecentsClickListener); 4565c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler 4578956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler WindowManagerImpl.getDefault().addView( 4588956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler mNavigationBarView, getNavigationBarLayoutParams()); 4598956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler } 4608956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 4618956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler private void repositionNavigationBar() { 4620129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler if (mNavigationBarView == null) return; 46317dfec7111fcc53a4f6ae6e92b4a7f85a278fe71Jim Miller 4648956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler mNavigationBarView.reorient(); 4655c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler 4665c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler mNavigationBarView.getRecentsButton().setOnClickListener(mRecentsClickListener); 4675c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler 4688956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler WindowManagerImpl.getDefault().updateViewLayout( 4698956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler mNavigationBarView, getNavigationBarLayoutParams()); 4708956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler } 4718956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 4728956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler private WindowManager.LayoutParams getNavigationBarLayoutParams() { 4738956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler WindowManager.LayoutParams lp = new WindowManager.LayoutParams( 4741f903c3b577d20f7db7e3d5875cafe577d0d845fDianne Hackborn LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 4758956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler WindowManager.LayoutParams.TYPE_NAVIGATION_BAR, 4768956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 0 4778956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler | WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING 4788956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE 479df89e65bf0fcc651d20b208c8d8d0b848fb43418Dianne Hackborn | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL 48098db5fabdad86dca379740d8050697950b9f026cJeff Brown | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH 48198db5fabdad86dca379740d8050697950b9f026cJeff Brown | WindowManager.LayoutParams.FLAG_SLIPPERY, 482a388449e632fadb75a0eae67f77ff618b3a39a01Daniel Sandler PixelFormat.OPAQUE); 483c638c1eb1bbed67d7d8f0d43f39137d766366f54Daniel Sandler // this will allow the navbar to run in an overlay on devices that support this 484c638c1eb1bbed67d7d8f0d43f39137d766366f54Daniel Sandler if (ActivityManager.isHighEndGfx(mDisplay)) { 485c638c1eb1bbed67d7d8f0d43f39137d766366f54Daniel Sandler lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; 486c638c1eb1bbed67d7d8f0d43f39137d766366f54Daniel Sandler } 4878956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 4888956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler lp.setTitle("NavigationBar"); 4898956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler lp.windowAnimations = 0; 4908956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 4918956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler return lp; 4928956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler } 4938956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 494dc10030581d6eec1c96acd62ed511f91d25d73a1Joe Onorato private void addIntruderView() { 495dc10030581d6eec1c96acd62ed511f91d25d73a1Joe Onorato final int height = getStatusBarHeight(); 496808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 497808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManager.LayoutParams lp = new WindowManager.LayoutParams( 498808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ViewGroup.LayoutParams.MATCH_PARENT, 499808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ViewGroup.LayoutParams.WRAP_CONTENT, 50029fc2c9705e1bb8ae098fca016032d2325031587Joe Onorato WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL, 501808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 502808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS 503808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL 504808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE 50546e75294d540fe807d78aec2582ae02cc38c7d42Jeff Brown | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM 50646e75294d540fe807d78aec2582ae02cc38c7d42Jeff Brown | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, 507808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato PixelFormat.TRANSLUCENT); 508808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.gravity = Gravity.TOP | Gravity.FILL_HORIZONTAL; 509808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.y += height * 1.5; // FIXME 510808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.setTitle("IntruderAlert"); 51159aed3885e7bf34b4d7c021db4243484fa267526Dianne Hackborn lp.packageName = mContext.getPackageName(); 51259aed3885e7bf34b4d7c021db4243484fa267526Dianne Hackborn lp.windowAnimations = R.style.Animation_StatusBar_IntruderAlert; 513808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 514808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManagerImpl.getDefault().addView(mIntruderAlertView, lp); 515808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 516808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 517808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void addIcon(String slot, int index, int viewIndex, StatusBarIcon icon) { 518808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "addIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex 519808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " icon=" + icon); 5206179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov StatusBarIconView view = new StatusBarIconView(mContext, slot, null); 521808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato view.set(icon); 522808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mStatusIcons.addView(view, viewIndex, new LinearLayout.LayoutParams(mIconSize, mIconSize)); 523808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 524808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 525808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void updateIcon(String slot, int index, int viewIndex, 526808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato StatusBarIcon old, StatusBarIcon icon) { 527808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "updateIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex 528808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " old=" + old + " icon=" + icon); 529808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato StatusBarIconView view = (StatusBarIconView)mStatusIcons.getChildAt(viewIndex); 530808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato view.set(icon); 531808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 532808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 533808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void removeIcon(String slot, int index, int viewIndex) { 534808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "removeIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex); 535808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mStatusIcons.removeViewAt(viewIndex); 536808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 537808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 538808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void addNotification(IBinder key, StatusBarNotification notification) { 539808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato StatusBarIconView iconView = addNotificationViews(key, notification); 540808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (iconView == null) return; 541808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 542808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean immersive = false; 543808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 544808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato immersive = ActivityManagerNative.getDefault().isTopActivityImmersive(); 5458355e932a033398625eef676ac93aec0cb084efeDaniel Sandler if (DEBUG) { 5468355e932a033398625eef676ac93aec0cb084efeDaniel Sandler Slog.d(TAG, "Top activity is " + (immersive?"immersive":"not immersive")); 5478355e932a033398625eef676ac93aec0cb084efeDaniel Sandler } 548808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (RemoteException ex) { 549808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 550808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (immersive) { 551808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((notification.notification.flags & Notification.FLAG_HIGH_PRIORITY) != 0) { 552808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "Presenting high-priority notification in immersive activity"); 553379020aec619c66d3e040de01f0726687fd2ad85Daniel Sandler // special new transient ticker mode 554808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // 1. Populate mIntruderAlertView 555808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 556808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ImageView alertIcon = (ImageView) mIntruderAlertView.findViewById(R.id.alertIcon); 557808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato TextView alertText = (TextView) mIntruderAlertView.findViewById(R.id.alertText); 558808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato alertIcon.setImageDrawable(StatusBarIconView.getIcon( 559808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato alertIcon.getContext(), 560808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato iconView.getStatusBarIcon())); 561808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato alertText.setText(notification.notification.tickerText); 562808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 563808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato View button = mIntruderAlertView.findViewById(R.id.intruder_alert_content); 564808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato button.setOnClickListener( 5657c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler new NotificationClicker(notification.notification.contentIntent, 566808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato notification.pkg, notification.tag, notification.id)); 567808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 568808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // 2. Animate mIntruderAlertView in 569808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.sendEmptyMessage(MSG_SHOW_INTRUDER); 570808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 571808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // 3. Set alarm to age the notification off (TODO) 572808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.removeMessages(MSG_HIDE_INTRUDER); 573808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.sendEmptyMessageDelayed(MSG_HIDE_INTRUDER, INTRUDER_ALERT_DECAY_MS); 574808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 575808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else if (notification.notification.fullScreenIntent != null) { 576808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // not immersive & a full-screen alert should be shown 5778355e932a033398625eef676ac93aec0cb084efeDaniel Sandler Slog.d(TAG, "Notification has fullScreenIntent; sending fullScreenIntent"); 578808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 579808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato notification.notification.fullScreenIntent.send(); 580808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (PendingIntent.CanceledException e) { 581808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 582808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 583808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // usual case: status bar visible & not immersive 584808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 585808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // show the ticker 586808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato tick(notification); 587808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 588808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 589808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Recalculate the position of the sliding windows and the titles. 590808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setAreThereNotifications(); 591808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(EXPANDED_LEAVE_ALONE); 592808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 593808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 594808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void updateNotification(IBinder key, StatusBarNotification notification) { 5957c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler if (DEBUG) Slog.d(TAG, "updateNotification(" + key + " -> " + notification + ")"); 596808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 5977c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler final NotificationData.Entry oldEntry = mNotificationData.findByKey(key); 5987c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler if (oldEntry == null) { 5997c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler Slog.w(TAG, "updateNotification for unknown key: " + key); 6007c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler return; 601808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 6027c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 603808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final StatusBarNotification oldNotification = oldEntry.notification; 604808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final RemoteViews oldContentView = oldNotification.notification.contentView; 605808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 606808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final RemoteViews contentView = notification.notification.contentView; 607808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 6087c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 60920cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler if (DEBUG) { 610808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "old notification: when=" + oldNotification.notification.when 611808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " ongoing=" + oldNotification.isOngoing() 612808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " expanded=" + oldEntry.expanded 61320cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler + " contentView=" + oldContentView 61420cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler + " rowParent=" + oldEntry.row.getParent()); 615808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "new notification: when=" + notification.notification.when 616808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " ongoing=" + oldNotification.isOngoing() 617808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " contentView=" + contentView); 618808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 619808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 62020cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler 621808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Can we just reapply the RemoteViews in place? If when didn't change, the order 622808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // didn't change. 62320cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler boolean contentsUnchanged = oldEntry.expanded != null 624808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato && contentView != null && oldContentView != null 625808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato && contentView.getPackage() != null 626808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato && oldContentView.getPackage() != null 627808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato && oldContentView.getPackage().equals(contentView.getPackage()) 62820cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler && oldContentView.getLayoutId() == contentView.getLayoutId(); 62920cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler ViewGroup rowParent = (ViewGroup) oldEntry.row.getParent(); 63020cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler boolean orderUnchanged = notification.notification.when==oldNotification.notification.when 63120cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler && notification.priority == oldNotification.priority; 63220cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler // priority now encompasses isOngoing() 6337c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler boolean isFirstAnyway = rowParent.indexOfChild(oldEntry.row) == 0; 6347c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler if (contentsUnchanged && (orderUnchanged || isFirstAnyway)) { 63520cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler if (DEBUG) Slog.d(TAG, "reusing notification for key: " + key); 636808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato oldEntry.notification = notification; 637808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 638808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Reapply the RemoteViews 639f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato contentView.reapply(mContext, oldEntry.content); 640808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // update the contentIntent 641808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final PendingIntent contentIntent = notification.notification.contentIntent; 642808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (contentIntent != null) { 643847fd751a9c9eb3cb02da1dca95d3d4b215c0b76Jeff Sharkey final View.OnClickListener listener = new NotificationClicker(contentIntent, 644847fd751a9c9eb3cb02da1dca95d3d4b215c0b76Jeff Sharkey notification.pkg, notification.tag, notification.id); 645847fd751a9c9eb3cb02da1dca95d3d4b215c0b76Jeff Sharkey oldEntry.largeIcon.setOnClickListener(listener); 646847fd751a9c9eb3cb02da1dca95d3d4b215c0b76Jeff Sharkey oldEntry.content.setOnClickListener(listener); 647184498ce5a8d77e1d9c45693363829daaeef9611Joe Onorato } else { 648847fd751a9c9eb3cb02da1dca95d3d4b215c0b76Jeff Sharkey oldEntry.largeIcon.setOnClickListener(null); 649184498ce5a8d77e1d9c45693363829daaeef9611Joe Onorato oldEntry.content.setOnClickListener(null); 650808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 651808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Update the icon. 652808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final StatusBarIcon ic = new StatusBarIcon(notification.pkg, 653808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato notification.notification.icon, notification.notification.iconLevel, 6547c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler notification.notification.number, 6557c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler notification.notification.tickerText); 656808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!oldEntry.icon.set(ic)) { 657808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato handleNotificationError(key, notification, "Couldn't update icon: " + ic); 658808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 659808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 660d5b858639cc32d27c003d7165969ec47288b3bfaDaniel Sandler // Update the large icon 661d5b858639cc32d27c003d7165969ec47288b3bfaDaniel Sandler if (notification.notification.largeIcon != null) { 662d5b858639cc32d27c003d7165969ec47288b3bfaDaniel Sandler oldEntry.largeIcon.setImageBitmap(notification.notification.largeIcon); 663d5b858639cc32d27c003d7165969ec47288b3bfaDaniel Sandler } else { 6647c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler oldEntry.largeIcon.getLayoutParams().width = 0; 6657c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler oldEntry.largeIcon.setVisibility(View.INVISIBLE); 666d5b858639cc32d27c003d7165969ec47288b3bfaDaniel Sandler } 667808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 668808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato catch (RuntimeException e) { 669808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // It failed to add cleanly. Log, and remove the view from the panel. 670808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.w(TAG, "Couldn't reapply views for package " + contentView.getPackage(), e); 671808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato removeNotificationViews(key); 672808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato addNotificationViews(key, notification); 673808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 674808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 675808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "not reusing notification"); 676808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato removeNotificationViews(key); 677808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato addNotificationViews(key, notification); 678808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 679808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 680808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Restart the ticker if it's still running 681935865923fdad9f47061ff0aedfe92d0b912d5d6Joe Onorato if (notification.notification.tickerText != null 682935865923fdad9f47061ff0aedfe92d0b912d5d6Joe Onorato && !TextUtils.equals(notification.notification.tickerText, 683935865923fdad9f47061ff0aedfe92d0b912d5d6Joe Onorato oldEntry.notification.notification.tickerText)) { 684935865923fdad9f47061ff0aedfe92d0b912d5d6Joe Onorato tick(notification); 685935865923fdad9f47061ff0aedfe92d0b912d5d6Joe Onorato } 686808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 687808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Recalculate the position of the sliding windows and the titles. 688808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setAreThereNotifications(); 689808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(EXPANDED_LEAVE_ALONE); 690808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 691808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 692808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void removeNotification(IBinder key) { 693808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "removeNotification key=" + key); 694808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato StatusBarNotification old = removeNotificationViews(key); 695808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 696808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (old != null) { 697808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Cancel the ticker if it's still running 698808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicker.removeEntry(old); 699808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 700808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Recalculate the position of the sliding windows and the titles. 701808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(EXPANDED_LEAVE_ALONE); 702808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 7030761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler 7040761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler setAreThereNotifications(); 705808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 706808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 7073b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka @Override 7083b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka protected void onConfigurationChanged(Configuration newConfig) { 70917dfec7111fcc53a4f6ae6e92b4a7f85a278fe71Jim Miller updateRecentsPanel(); 7103b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 7113b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 7123b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 713808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato View[] makeNotificationView(StatusBarNotification notification, ViewGroup parent) { 714808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Notification n = notification.notification; 715808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato RemoteViews remoteViews = n.contentView; 716808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (remoteViews == null) { 717808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return null; 718808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 719808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 720808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // create the row view 721f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato LayoutInflater inflater = (LayoutInflater)mContext.getSystemService( 722f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato Context.LAYOUT_INFLATER_SERVICE); 723755cc74e4cebdf67d21a2477512a4ac9b01e8323Joe Onorato View row = inflater.inflate(R.layout.status_bar_notification_row, parent, false); 724808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 725b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler // wire up the veto button 726b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler View vetoButton = row.findViewById(R.id.veto); 727b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler if (notification.isClearable()) { 728b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler final String _pkg = notification.pkg; 729b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler final String _tag = notification.tag; 730b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler final int _id = notification.id; 731b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler vetoButton.setOnClickListener(new View.OnClickListener() { 732b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler public void onClick(View v) { 733b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler try { 734b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler mBarService.onNotificationClear(_pkg, _tag, _id); 735b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } catch (RemoteException ex) { 736b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler // system process is dead if we're here. 737b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } 738b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } 739b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler }); 740b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } else { 741113045ab9cc6307b68cc669bbdd4ddbdf69b6230Daniel Sandler vetoButton.setVisibility(View.GONE); 742b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } 743113045ab9cc6307b68cc669bbdd4ddbdf69b6230Daniel Sandler vetoButton.setContentDescription(mContext.getString( 744113045ab9cc6307b68cc669bbdd4ddbdf69b6230Daniel Sandler R.string.accessibility_remove_notification)); 745b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler 746b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler // the large icon 747b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler ImageView largeIcon = (ImageView)row.findViewById(R.id.large_icon); 748b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler if (notification.notification.largeIcon != null) { 749b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler largeIcon.setImageBitmap(notification.notification.largeIcon); 750b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } else { 751b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler largeIcon.getLayoutParams().width = 0; 752b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler largeIcon.setVisibility(View.INVISIBLE); 753b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } 754b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler 755808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // bind the click event to the content area 756808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ViewGroup content = (ViewGroup)row.findViewById(R.id.content); 757808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato content.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); 758808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato content.setOnFocusChangeListener(mFocusChangeListener); 759808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato PendingIntent contentIntent = n.contentIntent; 760808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (contentIntent != null) { 761847fd751a9c9eb3cb02da1dca95d3d4b215c0b76Jeff Sharkey final View.OnClickListener listener = new NotificationClicker(contentIntent, 762847fd751a9c9eb3cb02da1dca95d3d4b215c0b76Jeff Sharkey notification.pkg, notification.tag, notification.id); 763847fd751a9c9eb3cb02da1dca95d3d4b215c0b76Jeff Sharkey largeIcon.setOnClickListener(listener); 764847fd751a9c9eb3cb02da1dca95d3d4b215c0b76Jeff Sharkey content.setOnClickListener(listener); 765184498ce5a8d77e1d9c45693363829daaeef9611Joe Onorato } else { 766847fd751a9c9eb3cb02da1dca95d3d4b215c0b76Jeff Sharkey largeIcon.setOnClickListener(null); 767184498ce5a8d77e1d9c45693363829daaeef9611Joe Onorato content.setOnClickListener(null); 768808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 769808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 770808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato View expanded = null; 771808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Exception exception = null; 772808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 773f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato expanded = remoteViews.apply(mContext, content); 774808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 775808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato catch (RuntimeException e) { 776808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato exception = e; 777808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 778808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (expanded == null) { 779808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato String ident = notification.pkg + "/0x" + Integer.toHexString(notification.id); 780808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.e(TAG, "couldn't inflate view for notification " + ident, exception); 781808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return null; 782808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 783808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato content.addView(expanded); 784808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato row.setDrawingCacheEnabled(true); 785808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 786808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 787808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return new View[] { row, content, expanded }; 788808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 789808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 790808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato StatusBarIconView addNotificationViews(IBinder key, StatusBarNotification notification) { 7917c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler if (DEBUG) { 7927c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler Slog.d(TAG, "addNotificationViews(key=" + key + ", notification=" + notification); 793808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 794808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Construct the icon. 795f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato final StatusBarIconView iconView = new StatusBarIconView(mContext, 7966179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov notification.pkg + "/0x" + Integer.toHexString(notification.id), 7976179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov notification.notification); 7987c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); 7997c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 8007c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler final StatusBarIcon ic = new StatusBarIcon(notification.pkg, 8017c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler notification.notification.icon, 8027c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler notification.notification.iconLevel, 8037c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler notification.notification.number, 8046179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov notification.notification.tickerText); 805808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!iconView.set(ic)) { 8067c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler handleNotificationError(key, notification, "Couldn't create icon: " + ic); 8077c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler return null; 8087c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 8097c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler // Construct the expanded view. 8107c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler NotificationData.Entry entry = new NotificationData.Entry(key, notification, iconView); 8117c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler if (!inflateViews(entry, mPile)) { 8127c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler handleNotificationError(key, notification, "Couldn't expand RemoteViews for: " 8137c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler + notification); 814808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return null; 815808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 8167c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 8177c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler // Add the expanded view and icon. 8187c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler int pos = mNotificationData.add(entry); 8197c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler if (DEBUG) { 8207c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler Slog.d(TAG, "addNotificationViews: added at " + pos); 8217c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 8227c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler updateNotificationIcons(); 8237c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 824808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return iconView; 825808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 826808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 8277c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler private void loadNotificationShade() { 8287c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler int N = mNotificationData.size(); 8297c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 8307c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler ArrayList<View> toShow = new ArrayList<View>(); 8317c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 8327c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler for (int i=0; i<N; i++) { 8337c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler View row = mNotificationData.get(N-i-1).row; 8347c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler toShow.add(row); 8357c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 8367c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 8377c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler ArrayList<View> toRemove = new ArrayList<View>(); 8387c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler for (int i=0; i<mPile.getChildCount(); i++) { 8397c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler View child = mPile.getChildAt(i); 8407c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler if (!toShow.contains(child)) { 8417c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler toRemove.add(child); 842808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 843808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 844808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 8457c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler for (View remove : toRemove) { 8467c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler mPile.removeView(remove); 8477c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 8487c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 8497c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler for (int i=0; i<toShow.size(); i++) { 8507c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler View v = toShow.get(i); 8517c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler if (v.getParent() == null) { 8527c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler mPile.addView(v, 0); // the notification shade has newest at the top 8537c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 8547c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 855808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 856808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 8577c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler private void reloadAllNotificationIcons() { 8587c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler if (mNotificationIcons == null) return; 8597c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler mNotificationIcons.removeAllViews(); 8607c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler updateNotificationIcons(); 8617c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 8627c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 8637c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler private void updateNotificationIcons() { 8647c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler loadNotificationShade(); 8657c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 8667c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler final LinearLayout.LayoutParams params 8677c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler = new LinearLayout.LayoutParams(mIconSize + 2*mIconHPadding, mNaturalBarHeight); 868808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 8697c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler int N = mNotificationData.size(); 8707c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 8717c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler if (DEBUG) { 8727c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler Slog.d(TAG, "refreshing icons: " + N + " notifications, mNotificationIcons=" + mNotificationIcons); 8737c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 8747c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 8757c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler ArrayList<View> toShow = new ArrayList<View>(); 8767c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 8777c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler for (int i=0; i<N; i++) { 8787c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler toShow.add(mNotificationData.get(N-i-1).icon); 8797c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 8807c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 8817c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler ArrayList<View> toRemove = new ArrayList<View>(); 8827c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler for (int i=0; i<mNotificationIcons.getChildCount(); i++) { 8837c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler View child = mNotificationIcons.getChildAt(i); 8847c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler if (!toShow.contains(child)) { 8857c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler toRemove.add(child); 8867c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 8877c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 8887c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 8897c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler for (View remove : toRemove) { 8907c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler mNotificationIcons.removeView(remove); 8917c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 8927c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 8937c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler for (int i=0; i<toShow.size(); i++) { 8947c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler View v = toShow.get(i); 8957c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler if (v.getParent() == null) { 8967c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler mNotificationIcons.addView(v, i, params); 8977c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 8987c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 8997c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 9007c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 9017c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler private boolean inflateViews(NotificationData.Entry entry, ViewGroup parent) { 9027c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler StatusBarNotification sbn = entry.notification; 9037c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler RemoteViews remoteViews = sbn.notification.contentView; 9047c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler if (remoteViews == null) { 9057c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler return false; 9067c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 9077c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 9087c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler // create the row view 9097c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler LayoutInflater inflater = (LayoutInflater)mContext.getSystemService( 9107c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler Context.LAYOUT_INFLATER_SERVICE); 9117c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler View row = inflater.inflate(R.layout.status_bar_notification_row, parent, false); 9127c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler View vetoButton = row.findViewById(R.id.veto); 9137c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler if (entry.notification.isClearable()) { 9147c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler final String _pkg = sbn.pkg; 9157c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler final String _tag = sbn.tag; 9167c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler final int _id = sbn.id; 9177c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler vetoButton.setOnClickListener(new View.OnClickListener() { 9187c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler public void onClick(View v) { 9197c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler try { 9207c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler mBarService.onNotificationClear(_pkg, _tag, _id); 9217c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } catch (RemoteException ex) { 9227c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler // system process is dead if we're here. 9237c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 9247c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 9257c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler }); 926808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 927113045ab9cc6307b68cc669bbdd4ddbdf69b6230Daniel Sandler vetoButton.setVisibility(View.GONE); 928808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 9297c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler vetoButton.setContentDescription(mContext.getString( 9307c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler R.string.accessibility_remove_notification)); 931808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 9327c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler // the large icon 9337c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler ImageView largeIcon = (ImageView)row.findViewById(R.id.large_icon); 9347c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler if (sbn.notification.largeIcon != null) { 9357c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler largeIcon.setImageBitmap(sbn.notification.largeIcon); 9367c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler largeIcon.setContentDescription(sbn.notification.tickerText); 9377c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } else { 9387c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler largeIcon.getLayoutParams().width = 0; 9397c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler largeIcon.setVisibility(View.INVISIBLE); 9407c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 9417c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler largeIcon.setContentDescription(sbn.notification.tickerText); 942808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 9437c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler // bind the click event to the content area 9447c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler ViewGroup content = (ViewGroup)row.findViewById(R.id.content); 9457c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler // XXX: update to allow controls within notification views 9467c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler content.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); 9477c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler// content.setOnFocusChangeListener(mFocusChangeListener); 9487c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler PendingIntent contentIntent = sbn.notification.contentIntent; 9497c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler if (contentIntent != null) { 950847fd751a9c9eb3cb02da1dca95d3d4b215c0b76Jeff Sharkey final View.OnClickListener listener = new NotificationClicker(contentIntent, 951847fd751a9c9eb3cb02da1dca95d3d4b215c0b76Jeff Sharkey sbn.pkg, sbn.tag, sbn.id); 952847fd751a9c9eb3cb02da1dca95d3d4b215c0b76Jeff Sharkey largeIcon.setOnClickListener(listener); 953847fd751a9c9eb3cb02da1dca95d3d4b215c0b76Jeff Sharkey content.setOnClickListener(listener); 954808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 955847fd751a9c9eb3cb02da1dca95d3d4b215c0b76Jeff Sharkey largeIcon.setOnClickListener(null); 9567c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler content.setOnClickListener(null); 9577c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 9587c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 9597c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler View expanded = null; 9607c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler Exception exception = null; 9617c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler try { 9627c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler expanded = remoteViews.apply(mContext, content); 963808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 9647c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler catch (RuntimeException e) { 9657c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler exception = e; 9667c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 9677c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler if (expanded == null) { 9687c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler final String ident = sbn.pkg + "/0x" + Integer.toHexString(sbn.id); 9697c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler Slog.e(TAG, "couldn't inflate view for notification " + ident, exception); 9707c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler return false; 9717c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } else { 9727c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler content.addView(expanded); 9737c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler row.setDrawingCacheEnabled(true); 9747c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 9757c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 9767c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler entry.row = row; 9777c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler entry.content = content; 9787c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler entry.expanded = expanded; 9797c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler entry.largeIcon = largeIcon; 9807c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 9817c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler return true; 9827c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 9837c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 9847c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler StatusBarNotification removeNotificationViews(IBinder key) { 9857c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler NotificationData.Entry entry = mNotificationData.remove(key); 9867c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler if (entry == null) { 9877c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler Slog.w(TAG, "removeNotification for unknown key: " + key); 9887c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler return null; 9897c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 9907c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler // Remove the expanded view. 9917c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler ViewGroup rowParent = (ViewGroup)entry.row.getParent(); 9927c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler if (rowParent != null) rowParent.removeView(entry.row); 9937c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler updateNotificationIcons(); 9947c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 9957c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler return entry.notification; 9967c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 9977c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 9987c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler private void setAreThereNotifications() { 9990761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler final boolean any = mNotificationData.size() > 0; 10007c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 10010761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler final boolean clearable = any && mNotificationData.hasClearableItems(); 10020761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler 10030761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler if (DEBUG) { 10040761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler Slog.d(TAG, "setAreThereNotifications: N=" + mNotificationData.size() 10050761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler + " any=" + any + " clearable=" + clearable); 10060761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler } 10070761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler 10080761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler if (mClearButton.isShown()) { 10090761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler if (clearable != (mClearButton.getAlpha() == 1.0f)) { 10100761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler ObjectAnimator.ofFloat(mClearButton, "alpha", 10110761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler clearable ? 1.0f : 0.0f) 10120761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler .setDuration(250) 10130761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler .start(); 10140761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler } 10150761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler } else { 10160761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler mClearButton.setAlpha(clearable ? 1.0f : 0.0f); 10170761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler } 10188ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler mClearButton.setEnabled(clearable); 10190761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler 1020d714148bd2752c63a46f51b12cea288fb1f10528Daniel Sandler /* 10210761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler if (mNoNotificationsTitle.isShown()) { 10220761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler if (any != (mNoNotificationsTitle.getAlpha() == 0.0f)) { 10230761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler ObjectAnimator a = ObjectAnimator.ofFloat(mNoNotificationsTitle, "alpha", 10240761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler (any ? 0.0f : 0.75f)); 10250761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler a.setDuration(any ? 0 : 500); 10260761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler a.setStartDelay(any ? 250 : 1000); 10270761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler a.start(); 10280761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler } 10290761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler } else { 10300761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler mNoNotificationsTitle.setAlpha(any ? 0.0f : 0.75f); 10310761e4cd95b6968dd4b1659a766ef504d13f6d50Daniel Sandler } 1032d714148bd2752c63a46f51b12cea288fb1f10528Daniel Sandler */ 1033808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1034808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1035f52c70b2ccf711f507723bc74a68ca8c3a12c57aJeff Sharkey public void showClock(boolean show) { 1036f52c70b2ccf711f507723bc74a68ca8c3a12c57aJeff Sharkey View clock = mStatusBarView.findViewById(R.id.clock); 1037f52c70b2ccf711f507723bc74a68ca8c3a12c57aJeff Sharkey if (clock != null) { 1038f52c70b2ccf711f507723bc74a68ca8c3a12c57aJeff Sharkey clock.setVisibility(show ? View.VISIBLE : View.GONE); 1039f52c70b2ccf711f507723bc74a68ca8c3a12c57aJeff Sharkey } 1040f52c70b2ccf711f507723bc74a68ca8c3a12c57aJeff Sharkey } 1041808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1042808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /** 1043808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * State is one or more of the DISABLE constants from StatusBarManager. 1044808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato */ 1045808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void disable(int state) { 1046808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int old = mDisabled; 1047808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int diff = state ^ old; 1048808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mDisabled = state; 1049808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1050e21f288358df2c1cea57c0a359dcf647baeb970dDaniel Sandler if (DEBUG) { 1051e21f288358df2c1cea57c0a359dcf647baeb970dDaniel Sandler Slog.d(TAG, String.format("disable: 0x%08x -> 0x%08x (diff: 0x%08x)", 1052e21f288358df2c1cea57c0a359dcf647baeb970dDaniel Sandler old, state, diff)); 1053e21f288358df2c1cea57c0a359dcf647baeb970dDaniel Sandler } 1054e21f288358df2c1cea57c0a359dcf647baeb970dDaniel Sandler 10556da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler StringBuilder flagdbg = new StringBuilder(); 10566da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler flagdbg.append("disable: < "); 10576da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler flagdbg.append(((state & StatusBarManager.DISABLE_EXPAND) != 0) ? "EXPAND" : "expand"); 10586da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler flagdbg.append(((diff & StatusBarManager.DISABLE_EXPAND) != 0) ? "* " : " "); 10596da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler flagdbg.append(((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) ? "ICONS" : "icons"); 10606da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler flagdbg.append(((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) ? "* " : " "); 10616da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler flagdbg.append(((state & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) ? "ALERTS" : "alerts"); 10626da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler flagdbg.append(((diff & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) ? "* " : " "); 10636da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler flagdbg.append(((state & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) ? "TICKER" : "ticker"); 10646da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler flagdbg.append(((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) ? "* " : " "); 10656da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler flagdbg.append(((state & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) ? "SYSTEM_INFO" : "system_info"); 10666da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler flagdbg.append(((diff & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) ? "* " : " "); 10676da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler flagdbg.append(((state & StatusBarManager.DISABLE_NAVIGATION) != 0) ? "NAVIGATION" : "navigation"); 10686da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler flagdbg.append(((diff & StatusBarManager.DISABLE_NAVIGATION) != 0) ? "* " : " "); 10696da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler flagdbg.append(((state & StatusBarManager.DISABLE_BACK) != 0) ? "BACK" : "back"); 10706da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler flagdbg.append(((diff & StatusBarManager.DISABLE_BACK) != 0) ? "* " : " "); 10716da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler flagdbg.append(((state & StatusBarManager.DISABLE_CLOCK) != 0) ? "CLOCK" : "clock"); 10726da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler flagdbg.append(((diff & StatusBarManager.DISABLE_CLOCK) != 0) ? "* " : " "); 10736da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler flagdbg.append(">"); 10746da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler Slog.d(TAG, flagdbg.toString()); 10756da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler 1076f52c70b2ccf711f507723bc74a68ca8c3a12c57aJeff Sharkey if ((diff & StatusBarManager.DISABLE_CLOCK) != 0) { 1077f52c70b2ccf711f507723bc74a68ca8c3a12c57aJeff Sharkey boolean show = (state & StatusBarManager.DISABLE_CLOCK) == 0; 1078f52c70b2ccf711f507723bc74a68ca8c3a12c57aJeff Sharkey showClock(show); 1079f52c70b2ccf711f507723bc74a68ca8c3a12c57aJeff Sharkey } 1080808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) { 1081808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((state & StatusBarManager.DISABLE_EXPAND) != 0) { 1082808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato animateCollapse(); 1083808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1084808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1085e21f288358df2c1cea57c0a359dcf647baeb970dDaniel Sandler 1086e3646dd8d96fb9756c8a7a4757ad5277e3801aedMike Lockwood if ((diff & (StatusBarManager.DISABLE_NAVIGATION | StatusBarManager.DISABLE_BACK)) != 0) { 10876da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler // the nav bar will take care of DISABLE_NAVIGATION and DISABLE_BACK 1088d9283b903125c875f973bf6f724f23e595bce756Daniel Sandler if (mNavigationBarView != null) mNavigationBarView.setDisabledFlags(state); 10896da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler 10906da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler if ((state & StatusBarManager.DISABLE_NAVIGATION) != 0) { 10916da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler // close recents if it's visible 10926da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler mHandler.removeMessages(MSG_CLOSE_RECENTS_PANEL); 10936da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL); 10946da2b76ea496129da5370bfafd667ee94907a356Daniel Sandler } 1095e21f288358df2c1cea57c0a359dcf647baeb970dDaniel Sandler } 1096e21f288358df2c1cea57c0a359dcf647baeb970dDaniel Sandler 1097808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { 1098808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { 1099808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mTicking) { 1100808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicker.halt(); 1101808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1102808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setNotificationIconVisibility(false, com.android.internal.R.anim.fade_out); 1103808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1104808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1105808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mExpandedVisible) { 1106808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in); 1107808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1108808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1109808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else if ((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { 1110808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mTicking && (state & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { 1111808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicker.halt(); 1112808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1113808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1114808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1115808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1116808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /** 1117808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * All changes to the status bar and notifications funnel through here and are batched. 1118808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato */ 1119808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private class H extends Handler { 1120808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void handleMessage(Message m) { 1121808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato switch (m.what) { 1122808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato case MSG_ANIMATE: 1123808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato doAnimation(); 1124808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato break; 1125808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato case MSG_ANIMATE_REVEAL: 1126808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato doRevealAnimation(); 1127808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato break; 11288ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler case MSG_OPEN_NOTIFICATION_PANEL: 11298ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler animateExpand(); 11308ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler break; 11318ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler case MSG_CLOSE_NOTIFICATION_PANEL: 11328ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler animateCollapse(); 11338ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler break; 1134808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato case MSG_SHOW_INTRUDER: 1135808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setIntruderAlertVisibility(true); 1136808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato break; 1137808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato case MSG_HIDE_INTRUDER: 1138808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setIntruderAlertVisibility(false); 1139808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato break; 11403b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka case MSG_OPEN_RECENTS_PANEL: 11413b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (DEBUG) Slog.d(TAG, "opening recents panel"); 11423b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (mRecentsPanel != null) { 11433b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel.show(true, true); 11443b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 11453b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka break; 11463b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka case MSG_CLOSE_RECENTS_PANEL: 11473b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (DEBUG) Slog.d(TAG, "closing recents panel"); 11483b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (mRecentsPanel != null && mRecentsPanel.isShowing()) { 11493b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel.show(false, true); 11503b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 11513b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka break; 1152808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1153808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1154808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1155808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1156808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato View.OnFocusChangeListener mFocusChangeListener = new View.OnFocusChangeListener() { 1157808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void onFocusChange(View v, boolean hasFocus) { 1158808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Because 'v' is a ViewGroup, all its children will be (un)selected 1159808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // too, which allows marqueeing to work. 1160808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato v.setSelected(hasFocus); 1161808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1162808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato }; 1163808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1164808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private void makeExpandedVisible() { 1165808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "Make expanded visible: expanded visible=" + mExpandedVisible); 1166808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpandedVisible) { 1167808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 1168808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1169808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedVisible = true; 1170808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato visibilityChanged(true); 1171808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1172808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(EXPANDED_LEAVE_ALONE); 1173808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; 1174808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; 117536412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler if (DEBUG) { 117636412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler Slog.d(TAG, "makeExpandedVisible: expanded params = " + mExpandedParams); 117736412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler } 1178808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().setAttributes(mExpandedParams); 1179808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedView.requestFocus(View.FOCUS_FORWARD); 1180808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingView.setVisibility(View.VISIBLE); 1181808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1182808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1183808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void animateExpand() { 1184808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "Animate expand: expanded=" + mExpanded); 1185808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) { 1186808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return ; 1187808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1188808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpanded) { 1189808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 1190808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1191808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1192808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato prepareTracking(0, true); 1193dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler performFling(0, mSelfExpandVelocityPx, true); 1194808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1195808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1196808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void animateCollapse() { 11973b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka animateCollapse(false); 11983b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 11993b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 12003b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka public void animateCollapse(boolean excludeRecents) { 12018ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler animateCollapse(excludeRecents, 1.0f); 12028ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler } 12038ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler 12048ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler public void animateCollapse(boolean excludeRecents, float velocityMultiplier) { 1205808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) { 1206808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "animateCollapse(): mExpanded=" + mExpanded 1207808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mExpandedVisible=" + mExpandedVisible 1208808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mExpanded=" + mExpanded 1209808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mAnimating=" + mAnimating 1210808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mAnimY=" + mAnimY 1211808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mAnimVel=" + mAnimVel); 1212808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1213808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 12143b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (!excludeRecents) { 12153b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mHandler.removeMessages(MSG_CLOSE_RECENTS_PANEL); 12163b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL); 12173b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 12183b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 1219808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mExpandedVisible) { 1220808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 1221808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1222808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1223808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int y; 1224808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mAnimating) { 1225808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato y = (int)mAnimY; 1226808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 122736412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler y = mDisplayMetrics.heightPixels-1; 1228808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1229808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Let the fling think that we're open so it goes in the right direction 1230808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // and doesn't try to re-open the windowshade. 1231808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpanded = true; 1232808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato prepareTracking(y, false); 12338ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler performFling(y, -mSelfCollapseVelocityPx*velocityMultiplier, true); 1234808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1235808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1236808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void performExpand() { 1237808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "performExpand: mExpanded=" + mExpanded); 1238808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) { 1239808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return ; 1240808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1241808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpanded) { 1242808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 1243808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1244808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1245808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpanded = true; 1246808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato makeExpandedVisible(); 1247808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(EXPANDED_FULL_OPEN); 1248808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1249808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (false) postStartTracing(); 1250808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1251808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1252808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void performCollapse() { 1253808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "performCollapse: mExpanded=" + mExpanded 1254808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mExpandedVisible=" + mExpandedVisible); 1255808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1256808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mExpandedVisible) { 1257808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 1258808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1259808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedVisible = false; 1260808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato visibilityChanged(false); 1261808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; 1262808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.flags &= ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; 1263808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().setAttributes(mExpandedParams); 1264808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingView.setVisibility(View.GONE); 1265808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1266808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((mDisabled & StatusBarManager.DISABLE_NOTIFICATION_ICONS) == 0) { 1267808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in); 1268808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1269808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1270808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mExpanded) { 1271808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 1272808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1273808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpanded = false; 1274808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1275808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1276808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void doAnimation() { 1277808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mAnimating) { 1278808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "doAnimation"); 1279808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "doAnimation before mAnimY=" + mAnimY); 1280808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato incrementAnim(); 1281808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "doAnimation after mAnimY=" + mAnimY); 128236412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler if (mAnimY >= mDisplayMetrics.heightPixels-1) { 1283808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "Animation completed to expanded state."); 1284808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimating = false; 1285808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(EXPANDED_FULL_OPEN); 1286808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato performExpand(); 1287808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1288808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato else if (mAnimY < mStatusBarView.getHeight()) { 1289808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "Animation completed to collapsed state."); 1290808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimating = false; 1291808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(0); 1292808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato performCollapse(); 1293808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1294808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato else { 1295808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos((int)mAnimY); 1296808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCurAnimationTime += ANIM_FRAME_DURATION; 1297808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.sendMessageAtTime(mHandler.obtainMessage(MSG_ANIMATE), mCurAnimationTime); 1298808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1299808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1300808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1301808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1302808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void stopTracking() { 1303808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTracking = false; 1304808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mVelocityTracker.recycle(); 1305808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mVelocityTracker = null; 1306808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1307808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1308808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void incrementAnim() { 1309808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato long now = SystemClock.uptimeMillis(); 1310808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float t = ((float)(now - mAnimLastTime)) / 1000; // ms -> s 1311808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final float y = mAnimY; 1312808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final float v = mAnimVel; // px/s 1313808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final float a = mAnimAccel; // px/s/s 1314808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimY = y + (v*t) + (0.5f*a*t*t); // px 1315808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimVel = v + (a*t); // px/s 1316808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimLastTime = now; // ms 1317808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato //Slog.d(TAG, "y=" + y + " v=" + v + " a=" + a + " t=" + t + " mAnimY=" + mAnimY 1318808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // + " mAnimAccel=" + mAnimAccel); 1319808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1320808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1321808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void doRevealAnimation() { 1322808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int h = mCloseView.getHeight() + mStatusBarView.getHeight(); 1323808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mAnimatingReveal && mAnimating && mAnimY < h) { 1324808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato incrementAnim(); 1325808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mAnimY >= h) { 1326808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimY = h; 1327808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos((int)mAnimY); 1328808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1329808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos((int)mAnimY); 1330808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCurAnimationTime += ANIM_FRAME_DURATION; 1331808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.sendMessageAtTime(mHandler.obtainMessage(MSG_ANIMATE_REVEAL), 1332808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCurAnimationTime); 1333808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1334808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1335808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1336808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1337808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void prepareTracking(int y, boolean opening) { 133896e61c3c86b2aff3d298d8757ba51eb568c30543Daniel Sandler if (CHATTY) { 133996e61c3c86b2aff3d298d8757ba51eb568c30543Daniel Sandler Slog.d(TAG, "panel: beginning to track the user's touch, y=" + y + " opening=" + opening); 134096e61c3c86b2aff3d298d8757ba51eb568c30543Daniel Sandler } 134196e61c3c86b2aff3d298d8757ba51eb568c30543Daniel Sandler 1342cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler // there are some race conditions that cause this to be inaccurate; let's recalculate it any 1343cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler // time we're about to drag the panel 1344cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler updateExpandedSize(); 1345cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler 1346808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTracking = true; 1347808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mVelocityTracker = VelocityTracker.obtain(); 1348808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (opening) { 1349dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler mAnimAccel = mExpandAccelPx; 1350dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler mAnimVel = mFlingExpandMinVelocityPx; 1351808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimY = mStatusBarView.getHeight(); 1352808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos((int)mAnimY); 1353808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimating = true; 1354808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimatingReveal = true; 1355808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.removeMessages(MSG_ANIMATE); 1356808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.removeMessages(MSG_ANIMATE_REVEAL); 1357808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato long now = SystemClock.uptimeMillis(); 1358808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimLastTime = now; 1359808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCurAnimationTime = now + ANIM_FRAME_DURATION; 1360808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimating = true; 1361808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.sendMessageAtTime(mHandler.obtainMessage(MSG_ANIMATE_REVEAL), 1362808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCurAnimationTime); 1363808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato makeExpandedVisible(); 1364808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1365808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // it's open, close it? 1366808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mAnimating) { 1367808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimating = false; 1368808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.removeMessages(MSG_ANIMATE); 1369808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1370808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(y + mViewDelta); 1371808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1372808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1373808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1374808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void performFling(int y, float vel, boolean always) { 137596e61c3c86b2aff3d298d8757ba51eb568c30543Daniel Sandler if (CHATTY) { 137696e61c3c86b2aff3d298d8757ba51eb568c30543Daniel Sandler Slog.d(TAG, "panel: will fling, y=" + y + " vel=" + vel); 137796e61c3c86b2aff3d298d8757ba51eb568c30543Daniel Sandler } 137896e61c3c86b2aff3d298d8757ba51eb568c30543Daniel Sandler 1379808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimatingReveal = false; 1380808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1381808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimY = y; 1382808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimVel = vel; 1383808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1384808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato //Slog.d(TAG, "starting with mAnimY=" + mAnimY + " mAnimVel=" + mAnimVel); 1385808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1386808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpanded) { 1387808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!always && ( 1388dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler vel > mFlingCollapseMinVelocityPx 1389dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler || (y > (mDisplayMetrics.heightPixels*(1f-mCollapseMinDisplayFraction)) && 1390dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler vel > -mFlingExpandMinVelocityPx))) { 1391808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // We are expanded, but they didn't move sufficiently to cause 1392808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // us to retract. Animate back to the expanded position. 1393dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler mAnimAccel = mExpandAccelPx; 1394808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (vel < 0) { 1395808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimVel = 0; 1396808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1397808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1398808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato else { 1399808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // We are expanded and are now going to animate away. 1400dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler mAnimAccel = -mCollapseAccelPx; 1401808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (vel > 0) { 1402808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimVel = 0; 1403808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1404808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1405808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1406808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (always || ( 1407dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler vel > mFlingExpandMinVelocityPx 1408dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler || (y > (mDisplayMetrics.heightPixels*(1f-mExpandMinDisplayFraction)) && 1409dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler vel > -mFlingCollapseMinVelocityPx))) { 1410808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // We are collapsed, and they moved enough to allow us to 1411808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // expand. Animate in the notifications. 1412dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler mAnimAccel = mExpandAccelPx; 1413808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (vel < 0) { 1414808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimVel = 0; 1415808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1416808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1417808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato else { 1418808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // We are collapsed, but they didn't move sufficiently to cause 1419808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // us to retract. Animate back to the collapsed position. 1420dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler mAnimAccel = -mCollapseAccelPx; 1421808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (vel > 0) { 1422808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimVel = 0; 1423808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1424808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1425808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1426808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato //Slog.d(TAG, "mAnimY=" + mAnimY + " mAnimVel=" + mAnimVel 1427808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // + " mAnimAccel=" + mAnimAccel); 1428808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1429808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato long now = SystemClock.uptimeMillis(); 1430808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimLastTime = now; 1431808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCurAnimationTime = now + ANIM_FRAME_DURATION; 1432808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimating = true; 1433808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.removeMessages(MSG_ANIMATE); 1434808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.removeMessages(MSG_ANIMATE_REVEAL); 1435808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.sendMessageAtTime(mHandler.obtainMessage(MSG_ANIMATE), mCurAnimationTime); 1436808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato stopTracking(); 1437808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1438808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1439808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean interceptTouchEvent(MotionEvent event) { 1440808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) { 1441808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "Touch: rawY=" + event.getRawY() + " event=" + event + " mDisabled=" 1442808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + mDisabled); 144396e61c3c86b2aff3d298d8757ba51eb568c30543Daniel Sandler } else if (CHATTY) { 1444fe172cc861448cf1115195cbad5b3300357c02f0Daniel Sandler if (event.getAction() != MotionEvent.ACTION_MOVE) { 144596e61c3c86b2aff3d298d8757ba51eb568c30543Daniel Sandler Slog.d(TAG, String.format( 1446fe172cc861448cf1115195cbad5b3300357c02f0Daniel Sandler "panel: %s at (%f, %f) mDisabled=0x%08x", 1447fe172cc861448cf1115195cbad5b3300357c02f0Daniel Sandler MotionEvent.actionToString(event.getAction()), 144896e61c3c86b2aff3d298d8757ba51eb568c30543Daniel Sandler event.getRawX(), event.getRawY(), mDisabled)); 144996e61c3c86b2aff3d298d8757ba51eb568c30543Daniel Sandler } 1450808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1451808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1452808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) { 1453808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return false; 1454808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1455808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 145668ebcdf3fd8b98fe35ec3e0b2e91fd254fcd807fJeff Brown final int action = event.getAction(); 1457808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int statusBarSize = mStatusBarView.getHeight(); 1458808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int hitSize = statusBarSize*2; 1459fe172cc861448cf1115195cbad5b3300357c02f0Daniel Sandler final int y = (int)event.getRawY(); 146068ebcdf3fd8b98fe35ec3e0b2e91fd254fcd807fJeff Brown if (action == MotionEvent.ACTION_DOWN) { 1461808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mExpanded) { 1462808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mViewDelta = statusBarSize - y; 1463808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1464808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingView.getLocationOnScreen(mAbsPos); 1465808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mViewDelta = mAbsPos[1] + mTrackingView.getHeight() - y; 1466808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1467808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((!mExpanded && y < hitSize) || 146836412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler (mExpanded && y > (mDisplayMetrics.heightPixels-hitSize))) { 1469808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1470808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // We drop events at the edge of the screen to make the windowshade come 1471808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // down by accident less, especially when pushing open a device with a keyboard 1472808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // that rotates (like g1 and droid) 1473808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int x = (int)event.getRawX(); 1474808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int edgeBorder = mEdgeBorder; 147536412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler if (x >= edgeBorder && x < mDisplayMetrics.widthPixels - edgeBorder) { 1476808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato prepareTracking(y, !mExpanded);// opening if we're not already fully visible 1477911fe30d5841d0622f3925a9fbc66d499965b111Jeff Brown trackMovement(event); 1478808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1479808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1480808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else if (mTracking) { 1481911fe30d5841d0622f3925a9fbc66d499965b111Jeff Brown trackMovement(event); 1482808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int minY = statusBarSize + mCloseView.getHeight(); 148368ebcdf3fd8b98fe35ec3e0b2e91fd254fcd807fJeff Brown if (action == MotionEvent.ACTION_MOVE) { 1484808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mAnimatingReveal && y < minY) { 1485808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // nothing 1486808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1487808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimatingReveal = false; 1488808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(y + mViewDelta); 1489808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 149068ebcdf3fd8b98fe35ec3e0b2e91fd254fcd807fJeff Brown } else if (action == MotionEvent.ACTION_UP 149168ebcdf3fd8b98fe35ec3e0b2e91fd254fcd807fJeff Brown || action == MotionEvent.ACTION_CANCEL) { 1492808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mVelocityTracker.computeCurrentVelocity(1000); 1493808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1494808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float yVel = mVelocityTracker.getYVelocity(); 1495808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean negative = yVel < 0; 1496808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1497808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float xVel = mVelocityTracker.getXVelocity(); 1498808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (xVel < 0) { 1499808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato xVel = -xVel; 1500808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1501dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler if (xVel > mFlingGestureMaxXVelocityPx) { 1502dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler xVel = mFlingGestureMaxXVelocityPx; // limit how much we care about the x axis 1503808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1504808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1505808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float vel = (float)Math.hypot(yVel, xVel); 1506808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (negative) { 1507808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato vel = -vel; 1508808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1509808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1510dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler if (CHATTY) { 1511dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler Slog.d(TAG, String.format("gesture: vraw=(%f,%f) vnorm=(%f,%f) vlinear=%f", 1512dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler mVelocityTracker.getXVelocity(), 1513dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler mVelocityTracker.getYVelocity(), 1514dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler xVel, yVel, 1515dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler vel)); 1516dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler } 1517dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler 1518fe172cc861448cf1115195cbad5b3300357c02f0Daniel Sandler performFling(y + mViewDelta, vel, false); 1519808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1520808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1521808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1522808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return false; 1523808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1524808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1525911fe30d5841d0622f3925a9fbc66d499965b111Jeff Brown private void trackMovement(MotionEvent event) { 1526911fe30d5841d0622f3925a9fbc66d499965b111Jeff Brown // Add movement to velocity tracker using raw screen X and Y coordinates instead 1527911fe30d5841d0622f3925a9fbc66d499965b111Jeff Brown // of window coordinates because the window frame may be moving at the same time. 1528911fe30d5841d0622f3925a9fbc66d499965b111Jeff Brown float deltaX = event.getRawX() - event.getX(); 1529911fe30d5841d0622f3925a9fbc66d499965b111Jeff Brown float deltaY = event.getRawY() - event.getY(); 1530911fe30d5841d0622f3925a9fbc66d499965b111Jeff Brown event.offsetLocation(deltaX, deltaY); 1531911fe30d5841d0622f3925a9fbc66d499965b111Jeff Brown mVelocityTracker.addMovement(event); 1532911fe30d5841d0622f3925a9fbc66d499965b111Jeff Brown event.offsetLocation(-deltaX, -deltaY); 1533911fe30d5841d0622f3925a9fbc66d499965b111Jeff Brown } 1534911fe30d5841d0622f3925a9fbc66d499965b111Jeff Brown 153560ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler @Override // CommandQueue 153660ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler public void setSystemUiVisibility(int vis) { 1537e137a1ea997036248c86e8fc0a94711020721f19Daniel Sandler final int old = mSystemUiVisibility; 1538e137a1ea997036248c86e8fc0a94711020721f19Daniel Sandler final int diff = vis ^ old; 1539e137a1ea997036248c86e8fc0a94711020721f19Daniel Sandler 1540e137a1ea997036248c86e8fc0a94711020721f19Daniel Sandler if (diff != 0) { 154160ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler mSystemUiVisibility = vis; 154260ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler 1543e137a1ea997036248c86e8fc0a94711020721f19Daniel Sandler if (0 != (diff & View.SYSTEM_UI_FLAG_LOW_PROFILE)) { 1544e137a1ea997036248c86e8fc0a94711020721f19Daniel Sandler final boolean lightsOut = (0 != (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE)); 1545e137a1ea997036248c86e8fc0a94711020721f19Daniel Sandler if (lightsOut) { 1546e137a1ea997036248c86e8fc0a94711020721f19Daniel Sandler animateCollapse(); 1547e137a1ea997036248c86e8fc0a94711020721f19Daniel Sandler } 154869314e72941c86734c12476d1e61459811159b74Daniel Sandler if (mNavigationBarView != null) { 154969314e72941c86734c12476d1e61459811159b74Daniel Sandler mNavigationBarView.setLowProfile(lightsOut); 155069314e72941c86734c12476d1e61459811159b74Daniel Sandler } 155160ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler } 155260ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler 155360ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler notifyUiVisibilityChanged(); 155460ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler } 155560ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler } 155660ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler 15579305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato public void setLightsOn(boolean on) { 155860ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler Log.v(TAG, "setLightsOn(" + on + ")"); 155960ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler if (on) { 156060ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler setSystemUiVisibility(mSystemUiVisibility & ~View.SYSTEM_UI_FLAG_LOW_PROFILE); 156160ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler } else { 156260ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler setSystemUiVisibility(mSystemUiVisibility | View.SYSTEM_UI_FLAG_LOW_PROFILE); 15639305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato } 15641d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler } 15651d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler 156660ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler private void notifyUiVisibilityChanged() { 15671d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler try { 156860ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler mWindowManager.statusBarVisibilityChanged(mSystemUiVisibility); 15691d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler } catch (RemoteException ex) { 15701d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler } 15719305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato } 15729305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato 15735c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler public void topAppWindowChanged(boolean showMenu) { 15745c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler if (DEBUG) { 15755c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler Slog.d(TAG, (showMenu?"showing":"hiding") + " the MENU button"); 15765c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler } 15775c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler if (mNavigationBarView != null) { 1578f1ebcee22442e0bc2aa86582d352b5ee78257db3Daniel Sandler mNavigationBarView.setMenuVisibility(showMenu); 15795c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler } 15805c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler 15815c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler // See above re: lights-out policy for legacy apps. 15825c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler if (showMenu) setLightsOn(true); 15835c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler } 15845c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler 1585e02d808abf370965c3c4e4d38af11bc69110fde2Daniel Sandler // Not supported 1586857fd9b8562c29913e03ed29288bd1802d37dc60Joe Onorato public void setImeWindowStatus(IBinder token, int vis, int backDisposition) { } 15872992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown @Override 15882992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown public void setHardKeyboardStatus(boolean available, boolean enabled) { } 1589e02d808abf370965c3c4e4d38af11bc69110fde2Daniel Sandler 15907c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler public NotificationClicker makeClicker(PendingIntent intent, String pkg, String tag, int id) { 15917c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler return new NotificationClicker(intent, pkg, tag, id); 15927c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 15937c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 15947c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler private class NotificationClicker implements View.OnClickListener { 1595808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private PendingIntent mIntent; 1596808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private String mPkg; 1597808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private String mTag; 1598808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private int mId; 1599808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 16007c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler NotificationClicker(PendingIntent intent, String pkg, String tag, int id) { 1601808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIntent = intent; 1602808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mPkg = pkg; 1603808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTag = tag; 1604808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mId = id; 1605808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1606808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1607808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void onClick(View v) { 1608808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 1609808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // The intent we are sending is for the application, which 1610808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // won't have permission to immediately start an activity after 1611808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // the user switches to home. We know it is safe to do at this 1612808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // point, so make sure new activity switches are now allowed. 1613808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ActivityManagerNative.getDefault().resumeAppSwitches(); 161490c52de28691ca0bbbf7c039ef20f85ce46882ccDianne Hackborn // Also, notifications can be launched from the lock screen, 161590c52de28691ca0bbbf7c039ef20f85ce46882ccDianne Hackborn // so dismiss the lock screen when the activity starts. 161690c52de28691ca0bbbf7c039ef20f85ce46882ccDianne Hackborn ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity(); 1617808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (RemoteException e) { 1618808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1619808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1620808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mIntent != null) { 1621808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int[] pos = new int[2]; 1622808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato v.getLocationOnScreen(pos); 1623808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Intent overlay = new Intent(); 1624808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato overlay.setSourceBounds( 1625808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato new Rect(pos[0], pos[1], pos[0]+v.getWidth(), pos[1]+v.getHeight())); 1626808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 1627f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato mIntent.send(mContext, 0, overlay); 1628808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (PendingIntent.CanceledException e) { 1629808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // the stack trace isn't very helpful here. Just log the exception message. 1630808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.w(TAG, "Sending contentIntent failed: " + e); 1631808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 163292d331883ada42e49001853e266cda2d9c8631b8Daniel Sandler 163392d331883ada42e49001853e266cda2d9c8631b8Daniel Sandler KeyguardManager kgm = 163492d331883ada42e49001853e266cda2d9c8631b8Daniel Sandler (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE); 163592d331883ada42e49001853e266cda2d9c8631b8Daniel Sandler if (kgm != null) kgm.exitKeyguardSecurely(null); 1636808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1637808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1638808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 1639808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mBarService.onNotificationClick(mPkg, mTag, mId); 1640808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (RemoteException ex) { 1641808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // system process is dead if we're here. 1642808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1643808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1644808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // close the shade if it was open 1645808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato animateCollapse(); 1646808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1647808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // If this click was on the intruder alert, hide that instead 1648808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.sendEmptyMessage(MSG_HIDE_INTRUDER); 1649808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1650808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1651808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1652808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private void tick(StatusBarNotification n) { 1653808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Show the ticker if one is requested. Also don't do this 1654808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // until status bar window is attached to the window manager, 1655808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // because... well, what's the point otherwise? And trying to 1656808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // run a ticker without being attached will crash! 1657808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (n.notification.tickerText != null && mStatusBarView.getWindowToken() != null) { 1658808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (0 == (mDisabled & (StatusBarManager.DISABLE_NOTIFICATION_ICONS 1659808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | StatusBarManager.DISABLE_NOTIFICATION_TICKER))) { 1660808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicker.addEntry(n); 1661808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1662808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1663808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1664808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1665808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /** 1666808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * Cancel this notification and tell the StatusBarManagerService / NotificationManagerService 1667808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * about the failure. 1668808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * 1669808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * WARNING: this will call back into us. Don't hold any locks. 1670808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato */ 1671808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void handleNotificationError(IBinder key, StatusBarNotification n, String message) { 1672808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato removeNotification(key); 1673808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 1674808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mBarService.onNotificationError(n.pkg, n.tag, n.id, n.uid, n.initialPid, message); 1675808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (RemoteException ex) { 1676808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // The end is nigh. 1677808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1678808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1679808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1680808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private class MyTicker extends Ticker { 1681dfa08db1652585a8cf27f929371c7ca6bf18ca60Daniel Sandler MyTicker(Context context, View sb) { 1682808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato super(context, sb); 1683808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1684808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1685808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato @Override 1686dfa08db1652585a8cf27f929371c7ca6bf18ca60Daniel Sandler public void tickerStarting() { 1687808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicking = true; 1688808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIcons.setVisibility(View.GONE); 1689808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickerView.setVisibility(View.VISIBLE); 1690808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickerView.startAnimation(loadAnim(com.android.internal.R.anim.push_up_in, null)); 1691808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIcons.startAnimation(loadAnim(com.android.internal.R.anim.push_up_out, null)); 1692808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1693808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1694808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato @Override 1695dfa08db1652585a8cf27f929371c7ca6bf18ca60Daniel Sandler public void tickerDone() { 1696808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIcons.setVisibility(View.VISIBLE); 1697808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickerView.setVisibility(View.GONE); 1698808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIcons.startAnimation(loadAnim(com.android.internal.R.anim.push_down_in, null)); 1699808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickerView.startAnimation(loadAnim(com.android.internal.R.anim.push_down_out, 1700808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickingDoneListener)); 1701808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1702808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1703dfa08db1652585a8cf27f929371c7ca6bf18ca60Daniel Sandler public void tickerHalting() { 1704808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIcons.setVisibility(View.VISIBLE); 1705808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickerView.setVisibility(View.GONE); 1706808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIcons.startAnimation(loadAnim(com.android.internal.R.anim.fade_in, null)); 1707808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickerView.startAnimation(loadAnim(com.android.internal.R.anim.fade_out, 1708808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickingDoneListener)); 1709808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1710808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1711808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1712808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Animation.AnimationListener mTickingDoneListener = new Animation.AnimationListener() {; 1713808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void onAnimationEnd(Animation animation) { 1714808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicking = false; 1715808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1716808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void onAnimationRepeat(Animation animation) { 1717808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1718808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void onAnimationStart(Animation animation) { 1719808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1720808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato }; 1721808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1722808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private Animation loadAnim(int id, Animation.AnimationListener listener) { 1723f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato Animation anim = AnimationUtils.loadAnimation(mContext, id); 1724808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (listener != null) { 1725808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato anim.setAnimationListener(listener); 1726808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1727808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return anim; 1728808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1729808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1730808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public String viewInfo(View v) { 1731808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return "(" + v.getLeft() + "," + v.getTop() + ")(" + v.getRight() + "," + v.getBottom() 1732808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " " + v.getWidth() + "x" + v.getHeight() + ")"; 1733808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1734808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1735f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { 1736808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato synchronized (mQueueLock) { 1737808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println("Current Status Bar state:"); 1738808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mExpanded=" + mExpanded 1739808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + ", mExpandedVisible=" + mExpandedVisible); 1740808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mTicking=" + mTicking); 1741808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mTracking=" + mTracking); 1742808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mAnimating=" + mAnimating 1743808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + ", mAnimY=" + mAnimY + ", mAnimVel=" + mAnimVel 1744808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + ", mAnimAccel=" + mAnimAccel); 1745808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mCurAnimationTime=" + mCurAnimationTime 1746808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mAnimLastTime=" + mAnimLastTime); 17471dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn pw.println(" mAnimatingReveal=" + mAnimatingReveal 1748808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mViewDelta=" + mViewDelta); 174936412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler pw.println(" mDisplayMetrics=" + mDisplayMetrics); 1750808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mExpandedParams: " + mExpandedParams); 1751808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mExpandedView: " + viewInfo(mExpandedView)); 1752808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mExpandedDialog: " + mExpandedDialog); 1753808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mTrackingParams: " + mTrackingParams); 1754808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mTrackingView: " + viewInfo(mTrackingView)); 17557c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler pw.println(" mPile: " + viewInfo(mPile)); 1756808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mNoNotificationsTitle: " + viewInfo(mNoNotificationsTitle)); 1757808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mCloseView: " + viewInfo(mCloseView)); 1758808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mTickerView: " + viewInfo(mTickerView)); 1759808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mScrollView: " + viewInfo(mScrollView) 1760808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " scroll " + mScrollView.getScrollX() + "," + mScrollView.getScrollY()); 1761808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 17627579bca7a02477353700d3b716f172b4fab267c0Daniel Sandler 17637579bca7a02477353700d3b716f172b4fab267c0Daniel Sandler if (DUMPTRUCK) { 17647579bca7a02477353700d3b716f172b4fab267c0Daniel Sandler synchronized (mNotificationData) { 17657579bca7a02477353700d3b716f172b4fab267c0Daniel Sandler int N = mNotificationData.size(); 17667579bca7a02477353700d3b716f172b4fab267c0Daniel Sandler pw.println(" notification icons: " + N); 17677579bca7a02477353700d3b716f172b4fab267c0Daniel Sandler for (int i=0; i<N; i++) { 17687579bca7a02477353700d3b716f172b4fab267c0Daniel Sandler NotificationData.Entry e = mNotificationData.get(i); 17697579bca7a02477353700d3b716f172b4fab267c0Daniel Sandler pw.println(" [" + i + "] key=" + e.key + " icon=" + e.icon); 17707579bca7a02477353700d3b716f172b4fab267c0Daniel Sandler StatusBarNotification n = e.notification; 17717579bca7a02477353700d3b716f172b4fab267c0Daniel Sandler pw.println(" pkg=" + n.pkg + " id=" + n.id + " priority=" + n.priority); 17727579bca7a02477353700d3b716f172b4fab267c0Daniel Sandler pw.println(" notification=" + n.notification); 17737579bca7a02477353700d3b716f172b4fab267c0Daniel Sandler pw.println(" tickerText=\"" + n.notification.tickerText + "\""); 17747579bca7a02477353700d3b716f172b4fab267c0Daniel Sandler } 1775808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 17767579bca7a02477353700d3b716f172b4fab267c0Daniel Sandler 17777579bca7a02477353700d3b716f172b4fab267c0Daniel Sandler int N = mStatusIcons.getChildCount(); 17787579bca7a02477353700d3b716f172b4fab267c0Daniel Sandler pw.println(" system icons: " + N); 1779808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato for (int i=0; i<N; i++) { 17807579bca7a02477353700d3b716f172b4fab267c0Daniel Sandler StatusBarIconView ic = (StatusBarIconView) mStatusIcons.getChildAt(i); 17817579bca7a02477353700d3b716f172b4fab267c0Daniel Sandler pw.println(" [" + i + "] icon=" + ic); 1782808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 17837579bca7a02477353700d3b716f172b4fab267c0Daniel Sandler 178489d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler if (false) { 178589d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler pw.println("see the logcat for a dump of the views we have created."); 178689d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler // must happen on ui thread 178789d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler mHandler.post(new Runnable() { 178889d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler public void run() { 178989d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler mStatusBarView.getLocationOnScreen(mAbsPos); 179089d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler Slog.d(TAG, "mStatusBarView: ----- (" + mAbsPos[0] + "," + mAbsPos[1] 179189d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler + ") " + mStatusBarView.getWidth() + "x" 179289d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler + mStatusBarView.getHeight()); 179389d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler mStatusBarView.debug(); 179489d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler 179589d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler mExpandedView.getLocationOnScreen(mAbsPos); 179689d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler Slog.d(TAG, "mExpandedView: ----- (" + mAbsPos[0] + "," + mAbsPos[1] 179789d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler + ") " + mExpandedView.getWidth() + "x" 179889d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler + mExpandedView.getHeight()); 179989d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler mExpandedView.debug(); 180089d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler 180189d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler mTrackingView.getLocationOnScreen(mAbsPos); 180289d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler Slog.d(TAG, "mTrackingView: ----- (" + mAbsPos[0] + "," + mAbsPos[1] 180389d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler + ") " + mTrackingView.getWidth() + "x" 180489d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler + mTrackingView.getHeight()); 180589d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler mTrackingView.debug(); 180689d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler } 180789d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler }); 180889d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler } 1809808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 181089d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler 181189d97131bd7fd7494c3469dfdf6351a84bae62bfDaniel Sandler mNetworkController.dump(fd, pw, args); 1812808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1813808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1814808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void onBarViewAttached() { 1815808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManager.LayoutParams lp; 1816808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int pixelFormat; 1817808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Drawable bg; 1818808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1819808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /// ---------- Tracking View -------------- 1820808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato bg = mTrackingView.getBackground(); 1821808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (bg != null) { 1822808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pixelFormat = bg.getOpacity(); 1823808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1824808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1825808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp = new WindowManager.LayoutParams( 1826808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ViewGroup.LayoutParams.MATCH_PARENT, 1827808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ViewGroup.LayoutParams.MATCH_PARENT, 182829fc2c9705e1bb8ae098fca016032d2325031587Joe Onorato WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL, 182936412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler 0 183036412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 1831808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS 1832808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, 183349f58407340a2282e0c0ff31043bee8937bd6bffDaniel Sandler PixelFormat.TRANSLUCENT); 1834b69f7015e7233d1c22d474f7f6850d4d93b2b790Daniel Sandler if (ActivityManager.isHighEndGfx(mDisplay)) { 1835b69f7015e7233d1c22d474f7f6850d4d93b2b790Daniel Sandler lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; 1836b69f7015e7233d1c22d474f7f6850d4d93b2b790Daniel Sandler } 1837808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato// lp.token = mStatusBarView.getWindowToken(); 1838808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.gravity = Gravity.TOP | Gravity.FILL_HORIZONTAL; 1839808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.setTitle("TrackingView"); 1840808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.y = mTrackingPosition; 1841808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingParams = lp; 1842808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1843808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManagerImpl.getDefault().addView(mTrackingView, lp); 1844808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1845808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1846808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void onTrackingViewAttached() { 1847808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManager.LayoutParams lp; 1848808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int pixelFormat; 1849808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1850808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /// ---------- Expanded View -------------- 1851808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pixelFormat = PixelFormat.TRANSLUCENT; 1852808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1853808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp = mExpandedDialog.getWindow().getAttributes(); 1854808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.x = 0; 185536412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler mTrackingPosition = lp.y = mDisplayMetrics.heightPixels; // sufficiently large negative 185629fc2c9705e1bb8ae098fca016032d2325031587Joe Onorato lp.type = WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL; 185736412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler lp.flags = 0 185836412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 1859808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS 1860808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL 1861808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_DITHER 1862808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; 1863b69f7015e7233d1c22d474f7f6850d4d93b2b790Daniel Sandler if (ActivityManager.isHighEndGfx(mDisplay)) { 1864b69f7015e7233d1c22d474f7f6850d4d93b2b790Daniel Sandler lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; 1865b69f7015e7233d1c22d474f7f6850d4d93b2b790Daniel Sandler } 1866808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.format = pixelFormat; 1867808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.gravity = Gravity.TOP | Gravity.FILL_HORIZONTAL; 1868808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.setTitle("StatusBarExpanded"); 1869808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams = lp; 18701dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn updateExpandedSize(); 18711dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn mExpandedDialog.getWindow().setFormat(pixelFormat); 1872808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1873808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); 1874808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.setContentView(mExpandedView, 1875808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1876808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ViewGroup.LayoutParams.MATCH_PARENT)); 1877808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().setBackgroundDrawable(null); 1878808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.show(); 1879808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1880808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1881808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void setNotificationIconVisibility(boolean visible, int anim) { 1882808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int old = mNotificationIcons.getVisibility(); 1883808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int v = visible ? View.VISIBLE : View.INVISIBLE; 1884808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (old != v) { 1885808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mNotificationIcons.setVisibility(v); 1886808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mNotificationIcons.startAnimation(loadAnim(anim, null)); 1887808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1888808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1889808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 18901dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn void updateExpandedInvisiblePosition() { 18911dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn if (mTrackingView != null) { 189236412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler mTrackingPosition = -mDisplayMetrics.heightPixels; 18931dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn if (mTrackingParams != null) { 18941dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn mTrackingParams.y = mTrackingPosition; 18951dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn WindowManagerImpl.getDefault().updateViewLayout(mTrackingView, mTrackingParams); 18961dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn } 18971dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn } 18981dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn if (mExpandedParams != null) { 189936412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler mExpandedParams.y = -mDisplayMetrics.heightPixels; 19001dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn mExpandedDialog.getWindow().setAttributes(mExpandedParams); 19011dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn } 19021dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn } 19031dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn 1904808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void updateExpandedViewPos(int expandedPosition) { 1905808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) { 1906808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "updateExpandedViewPos before expandedPosition=" + expandedPosition 1907cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler + " mTrackingParams.y=" + ((mTrackingParams == null) ? "?" : mTrackingParams.y) 1908808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mTrackingPosition=" + mTrackingPosition); 1909808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1910808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1911808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int h = mStatusBarView.getHeight(); 191236412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler int disph = mDisplayMetrics.heightPixels; 1913808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1914808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // If the expanded view is not visible, make sure they're still off screen. 1915808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Maybe the view was resized. 1916808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mExpandedVisible) { 19171dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn updateExpandedInvisiblePosition(); 1918808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 1919808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1920808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1921808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // tracking view... 1922808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int pos; 1923808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (expandedPosition == EXPANDED_FULL_OPEN) { 1924808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pos = h; 1925808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1926808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato else if (expandedPosition == EXPANDED_LEAVE_ALONE) { 1927808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pos = mTrackingPosition; 1928808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1929808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato else { 1930808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (expandedPosition <= disph) { 1931808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pos = expandedPosition; 1932808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1933808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pos = disph; 1934808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1935808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pos -= disph-h; 1936808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1937808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingPosition = mTrackingParams.y = pos; 1938808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingParams.height = disph-h; 1939808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManagerImpl.getDefault().updateViewLayout(mTrackingView, mTrackingParams); 1940808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1941808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpandedParams != null) { 19421dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn if (mCloseView.getWindowVisibility() == View.VISIBLE) { 19431dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn mCloseView.getLocationInWindow(mPositionTmp); 19441dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn final int closePos = mPositionTmp[1]; 1945808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 19461dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn mExpandedContents.getLocationInWindow(mPositionTmp); 19471dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn final int contentsBottom = mPositionTmp[1] + mExpandedContents.getHeight(); 1948808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 19491dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn mExpandedParams.y = pos + mTrackingView.getHeight() 19501dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn - (mTrackingParams.height-closePos) - contentsBottom; 1951cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler 1952cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler if (SPEW) { 1953cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler Slog.d(PhoneStatusBar.TAG, 1954cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler "pos=" + pos + 1955cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler " trackingHeight=" + mTrackingView.getHeight() + 1956cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler " (trackingParams.height - closePos)=" + 1957cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler (mTrackingParams.height - closePos) + 1958cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler " contentsBottom=" + contentsBottom); 1959cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler } 1960cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler 19611dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn } else { 19621dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn // If the tracking view is not yet visible, then we can't have 19631dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn // a good value of the close view location. We need to wait for 19641dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn // it to be visible to do a layout. 196536412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler mExpandedParams.y = -mDisplayMetrics.heightPixels; 19661dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn } 1967808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int max = h; 1968808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpandedParams.y > max) { 1969808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.y = max; 1970808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1971808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int min = mTrackingPosition; 1972808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpandedParams.y < min) { 1973808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.y = min; 1974808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1975808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1976808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean visible = (mTrackingPosition + mTrackingView.getHeight()) > h; 1977808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!visible) { 1978808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // if the contents aren't visible, move the expanded view way off screen 1979808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // because the window itself extends below the content view. 1980808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.y = -disph; 1981808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1982808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().setAttributes(mExpandedParams); 1983808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1984808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // As long as this isn't just a repositioning that's not supposed to affect 1985808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // the user's perception of what's showing, call to say that the visibility 1986808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // has changed. (Otherwise, someone else will call to do that). 1987808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (expandedPosition != EXPANDED_LEAVE_ALONE) { 1988808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "updateExpandedViewPos visibilityChanged(" + visible + ")"); 1989808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato visibilityChanged(visible); 1990808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1991808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1992808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1993808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) { 1994808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "updateExpandedViewPos after expandedPosition=" + expandedPosition 1995808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mTrackingParams.y=" + mTrackingParams.y 1996808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mTrackingPosition=" + mTrackingPosition 1997808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mExpandedParams.y=" + mExpandedParams.y 1998808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mExpandedParams.height=" + mExpandedParams.height); 1999808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2000808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2001808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 20021dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn int getExpandedHeight(int disph) { 2003cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler if (DEBUG) { 2004cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler Slog.d(TAG, "getExpandedHeight(" + disph + "): sbView=" 2005cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler + mStatusBarView.getHeight() + " closeView=" + mCloseView.getHeight()); 2006cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler } 20071dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn return disph - mStatusBarView.getHeight() - mCloseView.getHeight(); 2008808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2009808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 20101dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn void updateDisplaySize() { 201136412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler mDisplay.getMetrics(mDisplayMetrics); 201236412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler if (DEBUG) { 201336412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler Slog.d(TAG, "updateDisplaySize: " + mDisplayMetrics); 201436412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler } 20151dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn updateExpandedSize(); 20161dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn } 20171dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn 20181dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn void updateExpandedSize() { 2019cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler if (DEBUG) { 2020cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler Slog.d(TAG, "updateExpandedSize()"); 2021cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler } 202236412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler if (mExpandedDialog != null && mExpandedParams != null && mDisplayMetrics != null) { 202336412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler mExpandedParams.width = mDisplayMetrics.widthPixels; 202436412a7e7c4929bdac1221b7ced9e73d0d204691Daniel Sandler mExpandedParams.height = getExpandedHeight(mDisplayMetrics.heightPixels); 20251dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn if (!mExpandedVisible) { 20261dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn updateExpandedInvisiblePosition(); 20271dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn } else { 20281dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn mExpandedDialog.getWindow().setAttributes(mExpandedParams); 20291dacf2772d0099ae74f42f81d162a3d0e180ffb7Dianne Hackborn } 2030cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler if (DEBUG) { 2031cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler Slog.d(TAG, "updateExpandedSize: height=" + mExpandedParams.height + " " + 2032cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler (mExpandedVisible ? "VISIBLE":"INVISIBLE")); 2033cf336e10c03a802bd96df164c49b069cb7ad6819Daniel Sandler } 2034808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2035808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2036808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 20373b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka public void toggleRecentApps() { 20383b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka int msg = (mRecentsPanel.getVisibility() == View.GONE) 20393b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka ? MSG_OPEN_RECENTS_PANEL : MSG_CLOSE_RECENTS_PANEL; 20403b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mHandler.removeMessages(msg); 20413b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mHandler.sendEmptyMessage(msg); 20423b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 20433b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 2044808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /** 2045808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * The LEDs are turned o)ff when the notification panel is shown, even just a little bit. 2046808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * This was added last-minute and is inconsistent with the way the rest of the notifications 2047808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * are handled, because the notification isn't really cancelled. The lights are just 2048808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * turned off. If any other notifications happen, the lights will turn back on. Steve says 2049808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * this is what he wants. (see bug 1131461) 2050808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato */ 2051808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void visibilityChanged(boolean visible) { 2052808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mPanelSlightlyVisible != visible) { 2053808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mPanelSlightlyVisible = visible; 2054808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 2055808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mBarService.onPanelRevealed(); 2056808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (RemoteException ex) { 2057808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Won't fail unless the world has ended. 2058808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2059808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2060808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2061808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 2062808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void performDisableActions(int net) { 2063808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int old = mDisabled; 2064808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int diff = net ^ old; 2065808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mDisabled = net; 2066808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 2067808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // act accordingly 2068808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) { 2069808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((net & StatusBarManager.DISABLE_EXPAND) != 0) { 2070808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "DISABLE_EXPAND: yes"); 2071808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato animateCollapse(); 2072808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2073808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2074808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { 2075808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((net & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { 2076808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: yes"); 2077808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mTicking) { 2078808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mNotificationIcons.setVisibility(View.INVISIBLE); 2079808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicker.halt(); 2080808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 2081808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setNotificationIconVisibility(false, com.android.internal.R.anim.fade_out); 2082808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2083808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 2084808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: no"); 2085808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mExpandedVisible) { 2086808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in); 2087808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2088808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2089808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else if ((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { 2090808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mTicking && (net & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { 2091808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicker.halt(); 2092808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2093808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2094808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2095808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 2096808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private View.OnClickListener mClearButtonListener = new View.OnClickListener() { 20978ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler final int mini(int a, int b) { 20988ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler return (b>a?a:b); 20998ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler } 2100808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void onClick(View v) { 21018ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler synchronized (mNotificationData) { 21028ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler // let's also queue up 400ms worth of animated dismissals 21038ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler final int N = mini(5, mPile.getChildCount()); 21048ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler 21058ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler final ArrayList<View> snapshot = new ArrayList<View>(N); 21068ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler for (int i=0; i<N; i++) { 21078ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler final View child = mPile.getChildAt(i); 21088ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler if (mPile.canChildBeDismissed(child)) snapshot.add(child); 21098ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler } 21108ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler new Thread(new Runnable() { 21118ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler @Override 21128ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler public void run() { 21138ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler final int ROW_DELAY = 100; 21148ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler 21158ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler mHandler.postDelayed(new Runnable() { 21168ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler public void run() { 21178ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler animateCollapse(false, 0f); 21188ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler } 21198ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler }, (N-1) * ROW_DELAY); 21208ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler 21218ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler mHandler.postDelayed(new Runnable() { 21228ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler public void run() { 21238ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler try { 21248ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler mBarService.onClearAllNotifications(); 21258ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler } catch (RemoteException ex) { } 21268ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler } 21278ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler }, N * ROW_DELAY + 500); 21288ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler 21298ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler mPile.setAnimateBounds(false); // temporarily disable some re-layouts 21308ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler 21318ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler for (View v : snapshot) { 21328ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler final View _v = v; 21338ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler mHandler.post(new Runnable() { 21348ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler @Override 21358ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler public void run() { 21368ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler mPile.dismissRowAnimated(_v, (int)(ROW_DELAY*0.25f)); 21378ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler } 21388ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler }); 21398ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler try { 21408ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler Thread.sleep(ROW_DELAY); 21418ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler } catch (InterruptedException ex) { } 21428ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler } 21438ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler 21448ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler mPile.setAnimateBounds(true); // reenable layout animation 21458ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler } 21468ba33c965f940070060585e45e1c833519bb45c9Daniel Sandler }).start(); 2147808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2148808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2149808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato }; 2150808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 2151d309056d36759446c91ff5c1e17a217bfa4fdcfbDaniel Sandler private View.OnClickListener mSettingsButtonListener = new View.OnClickListener() { 2152d309056d36759446c91ff5c1e17a217bfa4fdcfbDaniel Sandler public void onClick(View v) { 2153d309056d36759446c91ff5c1e17a217bfa4fdcfbDaniel Sandler v.getContext().startActivity(new Intent(Settings.ACTION_SETTINGS) 2154d309056d36759446c91ff5c1e17a217bfa4fdcfbDaniel Sandler .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); 2155d309056d36759446c91ff5c1e17a217bfa4fdcfbDaniel Sandler animateCollapse(); 2156d309056d36759446c91ff5c1e17a217bfa4fdcfbDaniel Sandler } 2157d309056d36759446c91ff5c1e17a217bfa4fdcfbDaniel Sandler }; 2158d309056d36759446c91ff5c1e17a217bfa4fdcfbDaniel Sandler 2159808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { 2160808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void onReceive(Context context, Intent intent) { 2161808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato String action = intent.getAction(); 2162808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action) 2163808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato || Intent.ACTION_SCREEN_OFF.equals(action)) { 21643b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka boolean excludeRecents = false; 21653b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) { 2166edbdd3a024ca35c331036823dde1f484d3333b31Daniel Sandler String reason = intent.getStringExtra("reason"); 21673b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (reason != null) { 21683b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka excludeRecents = reason.equals("recentapps"); 21693b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 21703b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 21713b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka animateCollapse(excludeRecents); 2172808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2173808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) { 21748956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler repositionNavigationBar(); 2175808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateResources(); 2176808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2177808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2178808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato }; 2179808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 2180808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private void setIntruderAlertVisibility(boolean vis) { 2181808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIntruderAlertView.setVisibility(vis ? View.VISIBLE : View.GONE); 2182808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2183808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 2184808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /** 2185808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * Reload some of our resources when the configuration changes. 2186808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * 2187808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * We don't reload everything when the configuration changes -- we probably 2188808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * should, but getting that smooth is tough. Someday we'll fix that. In the 2189808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * meantime, just update the things that we know change. 2190808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato */ 2191808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void updateResources() { 2192f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato final Context context = mContext; 2193f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato final Resources res = context.getResources(); 2194808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 21951347c30824ce3544dff03c93ffad9af7f0327e41Daniel Sandler if (mClearButton instanceof TextView) { 21961347c30824ce3544dff03c93ffad9af7f0327e41Daniel Sandler ((TextView)mClearButton).setText(context.getText(R.string.status_bar_clear_all_button)); 21971347c30824ce3544dff03c93ffad9af7f0327e41Daniel Sandler } 2198f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato mNoNotificationsTitle.setText(context.getText(R.string.status_bar_no_notifications_title)); 2199808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 22007c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler loadDimens(); 22017c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 22027c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 22037c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler protected void loadDimens() { 22047c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler final Resources res = mContext.getResources(); 22057c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 22067c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler mNaturalBarHeight = res.getDimensionPixelSize( 22077c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler com.android.internal.R.dimen.status_bar_height); 22087c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 22097c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler int newIconSize = res.getDimensionPixelSize( 22107c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler com.android.internal.R.dimen.status_bar_icon_size); 22117c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler int newIconHPadding = res.getDimensionPixelSize( 22127c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler R.dimen.status_bar_icon_padding); 22137c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 22147c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler if (newIconHPadding != mIconHPadding || newIconSize != mIconSize) { 22157c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler// Slog.d(TAG, "size=" + newIconSize + " padding=" + newIconHPadding); 22167c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler mIconHPadding = newIconHPadding; 22177c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler mIconSize = newIconSize; 22187c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler //reloadAllNotificationIcons(); // reload the tray 22197c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler } 22207c3e39de22c68e69c4924b339132f8e3bf3f96afDaniel Sandler 2221808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore); 2222808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 2223dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler mSelfExpandVelocityPx = res.getDimension(R.dimen.self_expand_velocity); 2224dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler mSelfCollapseVelocityPx = res.getDimension(R.dimen.self_collapse_velocity); 2225dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler mFlingExpandMinVelocityPx = res.getDimension(R.dimen.fling_expand_min_velocity); 2226dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler mFlingCollapseMinVelocityPx = res.getDimension(R.dimen.fling_collapse_min_velocity); 2227dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler 2228dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler mCollapseMinDisplayFraction = res.getFraction(R.dimen.collapse_min_display_fraction, 1, 1); 2229dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler mExpandMinDisplayFraction = res.getFraction(R.dimen.expand_min_display_fraction, 1, 1); 2230dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler 2231dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler mExpandAccelPx = res.getDimension(R.dimen.expand_accel); 2232dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler mCollapseAccelPx = res.getDimension(R.dimen.collapse_accel); 2233dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler 2234dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler mFlingGestureMaxXVelocityPx = res.getDimension(R.dimen.fling_gesture_max_x_velocity); 2235dc940eaa67db0108f8a8629826dbb3c5c7d779e9Daniel Sandler 2236808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (false) Slog.v(TAG, "updateResources"); 2237808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2238808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 2239808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // 2240808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // tracing 2241808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // 2242808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 2243808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void postStartTracing() { 2244808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.postDelayed(mStartTracing, 3000); 2245808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2246808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 2247808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void vibrate() { 2248f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato android.os.Vibrator vib = (android.os.Vibrator)mContext.getSystemService( 2249f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato Context.VIBRATOR_SERVICE); 2250808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato vib.vibrate(250); 2251808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2252808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 2253808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Runnable mStartTracing = new Runnable() { 2254808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void run() { 2255808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato vibrate(); 2256808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato SystemClock.sleep(250); 2257808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "startTracing"); 2258808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato android.os.Debug.startMethodTracing("/data/statusbar-traces/trace"); 2259808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.postDelayed(mStopTracing, 10000); 2260808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2261808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato }; 2262808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 2263808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Runnable mStopTracing = new Runnable() { 2264808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void run() { 2265808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato android.os.Debug.stopMethodTracing(); 2266808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "stopTracing"); 2267808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato vibrate(); 2268808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 2269808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato }; 22703b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 22713b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka public class TouchOutsideListener implements View.OnTouchListener { 22723b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka private int mMsg; 22733b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka private RecentsPanelView mPanel; 22743b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 22753b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka public TouchOutsideListener(int msg, RecentsPanelView panel) { 22763b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mMsg = msg; 22773b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mPanel = panel; 22783b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 22793b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 22803b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka public boolean onTouch(View v, MotionEvent ev) { 22813b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka final int action = ev.getAction(); 22823b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (action == MotionEvent.ACTION_OUTSIDE 22833b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka || (action == MotionEvent.ACTION_DOWN 22843b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka && !mPanel.isInContentArea((int)ev.getX(), (int)ev.getY()))) { 22853b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mHandler.removeMessages(mMsg); 22863b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mHandler.sendEmptyMessage(mMsg); 22873b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka return true; 22883b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 22893b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka return false; 22903b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 22913b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 2292808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato} 2293808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 2294