PhoneStatusBar.java revision 8c4706252228755ed181d19532b7e0cfec270ba4
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 19808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.app.Service; 20808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.app.ActivityManagerNative; 21808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.app.Dialog; 22808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.app.Notification; 23808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.app.PendingIntent; 24808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.app.Service; 25808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.app.StatusBarManager; 26808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.content.BroadcastReceiver; 27808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.content.Context; 28808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.content.Intent; 29808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.content.IntentFilter; 30808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.content.res.Resources; 313b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurkaimport android.content.res.Configuration; 32808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.graphics.PixelFormat; 33808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.graphics.Rect; 34808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.graphics.drawable.Drawable; 35808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.net.Uri; 363b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurkaimport android.os.Bundle; 37808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.os.IBinder; 38808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.os.RemoteException; 39808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.os.Handler; 40808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.os.Message; 411d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandlerimport android.os.ServiceManager; 42808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.os.SystemClock; 43935865923fdad9f47061ff0aedfe92d0b912d5d6Joe Onoratoimport android.text.TextUtils; 44808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.util.Slog; 45808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.util.Log; 46808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.Display; 47808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.Gravity; 481d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandlerimport android.view.IWindowManager; 49808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.KeyEvent; 50808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.LayoutInflater; 51808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.MotionEvent; 528956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandlerimport android.view.Surface; 53808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.VelocityTracker; 54808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.View; 55808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.ViewGroup; 56808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.Window; 57808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.WindowManager; 58808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.WindowManagerImpl; 59808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.animation.Animation; 60808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.animation.AnimationUtils; 61808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.widget.ImageView; 62808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.widget.LinearLayout; 63808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.widget.RemoteViews; 64808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.widget.ScrollView; 65808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.widget.TextView; 66808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.widget.FrameLayout; 67808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 68808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport java.io.FileDescriptor; 69808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport java.io.PrintWriter; 70808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport java.util.ArrayList; 71808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport java.util.HashMap; 72808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport java.util.Set; 73808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 74808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport com.android.internal.statusbar.StatusBarIcon; 75808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport com.android.internal.statusbar.StatusBarIconList; 76808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport com.android.internal.statusbar.StatusBarNotification; 77808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 78808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport com.android.systemui.R; 793b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurkaimport com.android.systemui.recent.RecentsPanelView; 80fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onoratoimport com.android.systemui.statusbar.NotificationData; 81fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onoratoimport com.android.systemui.statusbar.StatusBar; 82fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onoratoimport com.android.systemui.statusbar.StatusBarIconView; 83fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onoratoimport com.android.systemui.statusbar.policy.DateView; 84808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 85808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 86fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onoratopublic class PhoneStatusBar extends StatusBar { 87fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato static final String TAG = "PhoneStatusBar"; 88808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato static final boolean SPEW = false; 893b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka public static final boolean DEBUG = false; 90808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 91808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public static final String ACTION_STATUSBAR_START 92808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato = "com.android.internal.policy.statusbar.START"; 93808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 94808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato static final int EXPANDED_LEAVE_ALONE = -10000; 95808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato static final int EXPANDED_FULL_OPEN = -10001; 96808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 97808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private static final int MSG_ANIMATE = 1000; 98808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private static final int MSG_ANIMATE_REVEAL = 1001; 99808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private static final int MSG_SHOW_INTRUDER = 1002; 100808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private static final int MSG_HIDE_INTRUDER = 1003; 1013b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka private static final int MSG_OPEN_RECENTS_PANEL = 1020; 1023b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka private static final int MSG_CLOSE_RECENTS_PANEL = 1021; 103808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 104808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // will likely move to a resource or other tunable param at some point 105808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private static final int INTRUDER_ALERT_DECAY_MS = 10000; 106808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 107fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato PhoneStatusBarPolicy mIconPolicy; 108808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 109808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int mIconSize; 110808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Display mDisplay; 111808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1121d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler IWindowManager mWindowManager; 1131d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler 114fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato PhoneStatusBarView mStatusBarView; 115808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int mPixelFormat; 116808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato H mHandler = new H(); 117808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Object mQueueLock = new Object(); 118808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 119808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // icons 120808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato LinearLayout mIcons; 121808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato IconMerger mNotificationIcons; 122808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato LinearLayout mStatusIcons; 123808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 124808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // expanded notifications 125808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Dialog mExpandedDialog; 126808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ExpandedView mExpandedView; 127808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManager.LayoutParams mExpandedParams; 128808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ScrollView mScrollView; 129808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato View mNotificationLinearLayout; 130808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato View mExpandedContents; 131808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // top bar 132808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato TextView mNoNotificationsTitle; 133808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato TextView mClearButton; 134808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // drag bar 135808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato CloseDragHandle mCloseView; 136808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // ongoing 137808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato NotificationData mOngoing = new NotificationData(); 138808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato TextView mOngoingTitle; 139d42497e516521891a9d6ffa0daab75ef016725f5Daniel Sandler ViewGroup mOngoingItems; 140808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // latest 141808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato NotificationData mLatest = new NotificationData(); 142808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato TextView mLatestTitle; 143d42497e516521891a9d6ffa0daab75ef016725f5Daniel Sandler ViewGroup mLatestItems; 144808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // position 145808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int[] mPositionTmp = new int[2]; 146808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean mExpanded; 147808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean mExpandedVisible; 148808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 149808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // the date view 150808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato DateView mDateView; 151808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 152808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // for immersive activities 153808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private View mIntruderAlertView; 154808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1558956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler // on-screen navigation buttons 1560129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler private NavigationBarView mNavigationBarView = null; 1578956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 158808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // the tracker view 159808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato TrackingView mTrackingView; 160808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManager.LayoutParams mTrackingParams; 161808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int mTrackingPosition; // the position of the top of the tracking view. 162808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private boolean mPanelSlightlyVisible; 163808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 164808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // ticker 165808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private Ticker mTicker; 166808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private View mTickerView; 167808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private boolean mTicking; 168808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1693b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka // Recent applications 1703b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka private RecentsPanelView mRecentsPanel; 1713b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 172808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Tracking finger for opening/closing. 173808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int mEdgeBorder; // corresponds to R.dimen.status_bar_edge_ignore 174808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean mTracking; 175808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato VelocityTracker mVelocityTracker; 176808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 177808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato static final int ANIM_FRAME_DURATION = (1000/60); 178808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 179808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean mAnimating; 180808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato long mCurAnimationTime; 181808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float mDisplayHeight; 182808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float mAnimY; 183808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float mAnimVel; 184808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float mAnimAccel; 185808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato long mAnimLastTime; 186808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean mAnimatingReveal = false; 187808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int mViewDelta; 188808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int[] mAbsPos = new int[2]; 189808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 190808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // for disabling the status bar 191808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int mDisabled = 0; 192808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 193808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private class ExpandedDialog extends Dialog { 194808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ExpandedDialog(Context context) { 195808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato super(context, com.android.internal.R.style.Theme_Light_NoTitleBar); 196808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 197808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 198808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato @Override 199808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public boolean dispatchKeyEvent(KeyEvent event) { 200808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean down = event.getAction() == KeyEvent.ACTION_DOWN; 201808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato switch (event.getKeyCode()) { 202808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato case KeyEvent.KEYCODE_BACK: 203808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!down) { 204808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato animateCollapse(); 205808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 206808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return true; 207808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 208808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return super.dispatchKeyEvent(event); 209808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 210808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 211808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 212808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato @Override 213f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato public void start() { 214f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)) 215f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato .getDefaultDisplay(); 216808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 2171d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler mWindowManager = IWindowManager.Stub.asInterface( 2181d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler ServiceManager.getService(Context.WINDOW_SERVICE)); 2191d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler 220f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato super.start(); 221808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 2228956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler addNavigationBar(); 2238956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 2248956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler //addIntruderView(); 225808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 226808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Lastly, call to the icon policy to install/update all the icons. 227fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato mIconPolicy = new PhoneStatusBarPolicy(mContext); 228808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 229808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 230808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // ================================================================================ 231808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Constructing the view 232808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // ================================================================================ 233808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato protected View makeStatusBarView() { 234f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato final Context context = mContext; 235808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 236808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Resources res = context.getResources(); 237808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 238808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size); 239808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 240808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ExpandedView expanded = (ExpandedView)View.inflate(context, 241808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato R.layout.status_bar_expanded, null); 242808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato expanded.mService = this; 243808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 244808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIntruderAlertView = View.inflate(context, R.layout.intruder_alert, null); 245808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIntruderAlertView.setVisibility(View.GONE); 246808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIntruderAlertView.setClickable(true); 247808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 2480129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler try { 2498c4706252228755ed181d19532b7e0cfec270ba4Adam Powell boolean showNav = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar); 2500129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler if (showNav) { 2510129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler mNavigationBarView = 2520129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler (NavigationBarView) View.inflate(context, R.layout.navigation_bar, null); 2530129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler } 2540129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler } catch (Resources.NotFoundException ex) { 2550129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler // no nav bar for you 2560129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler } 2578956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 258fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato PhoneStatusBarView sb = (PhoneStatusBarView)View.inflate(context, 259fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato R.layout.status_bar, null); 260808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato sb.mService = this; 261808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 262808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // figure out which pixel-format to use for the status bar. 263808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mPixelFormat = PixelFormat.TRANSLUCENT; 264808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Drawable bg = sb.getBackground(); 265808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (bg != null) { 266808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mPixelFormat = bg.getOpacity(); 267808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 268808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 269808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mStatusBarView = sb; 270808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mStatusIcons = (LinearLayout)sb.findViewById(R.id.statusIcons); 271808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mNotificationIcons = (IconMerger)sb.findViewById(R.id.notificationIcons); 272808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIcons = (LinearLayout)sb.findViewById(R.id.icons); 273808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickerView = sb.findViewById(R.id.ticker); 274808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mDateView = (DateView)sb.findViewById(R.id.date); 275808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 276808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog = new ExpandedDialog(context); 277808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedView = expanded; 278808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedContents = expanded.findViewById(R.id.notificationLinearLayout); 279808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mOngoingTitle = (TextView)expanded.findViewById(R.id.ongoingTitle); 280d42497e516521891a9d6ffa0daab75ef016725f5Daniel Sandler mOngoingItems = (ViewGroup)expanded.findViewById(R.id.ongoingItems); 281808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mLatestTitle = (TextView)expanded.findViewById(R.id.latestTitle); 282d42497e516521891a9d6ffa0daab75ef016725f5Daniel Sandler mLatestItems = (ViewGroup)expanded.findViewById(R.id.latestItems); 283808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mNoNotificationsTitle = (TextView)expanded.findViewById(R.id.noNotificationsTitle); 284808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mClearButton = (TextView)expanded.findViewById(R.id.clear_all_button); 285808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mClearButton.setOnClickListener(mClearButtonListener); 286808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mScrollView = (ScrollView)expanded.findViewById(R.id.scroll); 287808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mNotificationLinearLayout = expanded.findViewById(R.id.notificationLinearLayout); 288808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 289808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mOngoingTitle.setVisibility(View.GONE); 290808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mLatestTitle.setVisibility(View.GONE); 291808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 292808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicker = new MyTicker(context, sb); 293808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 294808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato TickerView tickerView = (TickerView)sb.findViewById(R.id.tickerText); 295808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato tickerView.mTicker = mTicker; 296808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 297808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingView = (TrackingView)View.inflate(context, R.layout.status_bar_tracking, null); 298808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingView.mService = this; 299808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCloseView = (CloseDragHandle)mTrackingView.findViewById(R.id.close); 300808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCloseView.mService = this; 301808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 302808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore); 303808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 304808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // set the inital view visibility 305808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setAreThereNotifications(); 306808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mDateView.setVisibility(View.INVISIBLE); 307808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 3083b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka // Recents Panel 3093b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka initializeRecentsPanel(); 3103b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 311808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // receive broadcasts 312808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato IntentFilter filter = new IntentFilter(); 313808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); 314808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); 315808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato filter.addAction(Intent.ACTION_SCREEN_OFF); 316808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato context.registerReceiver(mBroadcastReceiver, filter); 317808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 318808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return sb; 319808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 320808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 3213b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka protected WindowManager.LayoutParams getRecentsLayoutParams() { 3223b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka boolean translucent = false; 3233b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka WindowManager.LayoutParams lp = new WindowManager.LayoutParams( 3243b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka ViewGroup.LayoutParams.WRAP_CONTENT, 3253b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka ViewGroup.LayoutParams.WRAP_CONTENT, 3263b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, 3273b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 3283b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM 3293b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH 3303b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 3313b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka (translucent ? PixelFormat.OPAQUE : PixelFormat.TRANSLUCENT)); 3323b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka lp.gravity = Gravity.BOTTOM | Gravity.LEFT; 3333b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka lp.setTitle("RecentsPanel"); 3343b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka lp.windowAnimations = R.style.Animation_RecentPanel; 3353b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED 3363b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; 3373b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka return lp; 3383b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 3393b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 3403b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka protected void initializeRecentsPanel() { 3413b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka // Recents Panel 3423b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka boolean visible = false; 3433b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (mRecentsPanel != null) { 3443b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka visible = mRecentsPanel.getVisibility() == View.VISIBLE; 3453b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka WindowManagerImpl.getDefault().removeView(mRecentsPanel); 3463b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 3473b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel = (RecentsPanelView) View.inflate(mContext, 3483b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka R.layout.status_bar_recent_panel, null); 3493b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 3503b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel.setOnTouchListener(new TouchOutsideListener(MSG_CLOSE_RECENTS_PANEL, 3513b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel)); 3523b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel.setVisibility(View.GONE); 3533b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka WindowManager.LayoutParams lp = getRecentsLayoutParams(); 3543b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 3553b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka WindowManagerImpl.getDefault().addView(mRecentsPanel, lp); 3563b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel.setBar(this); 3573b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (visible) { 3583b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka // need to set visibility to View.GONE earlier since that 3593b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka // triggers refreshing application list 3603b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel.setVisibility(View.VISIBLE); 3613b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel.show(true, false); 3623b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 3633b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 3643b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 3653b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 366808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato protected int getStatusBarGravity() { 367808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return Gravity.TOP | Gravity.FILL_HORIZONTAL; 368808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 369808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 370dc10030581d6eec1c96acd62ed511f91d25d73a1Joe Onorato public int getStatusBarHeight() { 371f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato final Resources res = mContext.getResources(); 372dc10030581d6eec1c96acd62ed511f91d25d73a1Joe Onorato return res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); 373dc10030581d6eec1c96acd62ed511f91d25d73a1Joe Onorato } 374dc10030581d6eec1c96acd62ed511f91d25d73a1Joe Onorato 3755c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler private View.OnClickListener mRecentsClickListener = new View.OnClickListener() { 3765c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler public void onClick(View v) { 3775c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler toggleRecentApps(); 3785c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler } 3795c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler }; 3805c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler 3818956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler // For small-screen devices (read: phones) that lack hardware navigation buttons 3828956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler private void addNavigationBar() { 3830129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler if (mNavigationBarView == null) return; 3840129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler 3858956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler mNavigationBarView.reorient(); 3865c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler 3875c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler mNavigationBarView.getRecentsButton().setOnClickListener(mRecentsClickListener); 3885c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler 3898956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler WindowManagerImpl.getDefault().addView( 3908956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler mNavigationBarView, getNavigationBarLayoutParams()); 3918956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler } 3928956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 3938956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler private void repositionNavigationBar() { 3940129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler if (mNavigationBarView == null) return; 3950129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler 3968956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler mNavigationBarView.reorient(); 3975c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler 3985c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler mNavigationBarView.getRecentsButton().setOnClickListener(mRecentsClickListener); 3995c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler 4008956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler WindowManagerImpl.getDefault().updateViewLayout( 4018956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler mNavigationBarView, getNavigationBarLayoutParams()); 4028956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler } 4038956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 4048956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler private WindowManager.LayoutParams getNavigationBarLayoutParams() { 4058956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler final int rotation = mDisplay.getRotation(); 4068956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler final boolean sideways = 4078956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270); 4088956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 4098956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler final Resources res = mContext.getResources(); 4108956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler final int size = res.getDimensionPixelSize(R.dimen.navigation_bar_size); 4118956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 4128956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler WindowManager.LayoutParams lp = new WindowManager.LayoutParams( 4138956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler sideways ? size : ViewGroup.LayoutParams.MATCH_PARENT, 4148956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler sideways ? ViewGroup.LayoutParams.MATCH_PARENT : size, 4158956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler WindowManager.LayoutParams.TYPE_NAVIGATION_BAR, 4168956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 0 4178956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 4188956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS 4198956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler | WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING 4208956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE 42198db5fabdad86dca379740d8050697950b9f026cJeff Brown | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH 42298db5fabdad86dca379740d8050697950b9f026cJeff Brown | WindowManager.LayoutParams.FLAG_SLIPPERY, 4238956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler PixelFormat.TRANSLUCENT); 4248956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 4258956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler lp.setTitle("NavigationBar"); 4268956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler switch (rotation) { 4278956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler case Surface.ROTATION_90: 4288956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler // device has been turned 90deg counter-clockwise 4298956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler lp.gravity = Gravity.RIGHT | Gravity.FILL_VERTICAL; 4308956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler break; 4318956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler case Surface.ROTATION_270: 4328956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler // device has been turned 90deg clockwise 433f86f898f8afe73d81b34543dcb2c30d8bf7da563Daniel Sandler lp.gravity = (NavigationBarView.NAVBAR_ALWAYS_AT_RIGHT ? Gravity.RIGHT 434f86f898f8afe73d81b34543dcb2c30d8bf7da563Daniel Sandler : Gravity.LEFT) 435f86f898f8afe73d81b34543dcb2c30d8bf7da563Daniel Sandler | Gravity.FILL_VERTICAL; 4368956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler break; 4378956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler default: 4388956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler lp.gravity = Gravity.BOTTOM | Gravity.FILL_HORIZONTAL; 4398956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler break; 4408956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler } 4418956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler lp.windowAnimations = 0; 4428956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 4438956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler return lp; 4448956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler } 4458956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 446dc10030581d6eec1c96acd62ed511f91d25d73a1Joe Onorato private void addIntruderView() { 447dc10030581d6eec1c96acd62ed511f91d25d73a1Joe Onorato final int height = getStatusBarHeight(); 448808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 449808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManager.LayoutParams lp = new WindowManager.LayoutParams( 450808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ViewGroup.LayoutParams.MATCH_PARENT, 451808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ViewGroup.LayoutParams.WRAP_CONTENT, 45229fc2c9705e1bb8ae098fca016032d2325031587Joe Onorato WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL, 453808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 454808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS 455808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL 456808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE 45746e75294d540fe807d78aec2582ae02cc38c7d42Jeff Brown | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM 45846e75294d540fe807d78aec2582ae02cc38c7d42Jeff Brown | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, 459808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato PixelFormat.TRANSLUCENT); 460808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.gravity = Gravity.TOP | Gravity.FILL_HORIZONTAL; 461808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.y += height * 1.5; // FIXME 462808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.setTitle("IntruderAlert"); 463808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.windowAnimations = com.android.internal.R.style.Animation_StatusBar_IntruderAlert; 464808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 465808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManagerImpl.getDefault().addView(mIntruderAlertView, lp); 466808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 467808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 468808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void addIcon(String slot, int index, int viewIndex, StatusBarIcon icon) { 469808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "addIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex 470808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " icon=" + icon); 471f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato StatusBarIconView view = new StatusBarIconView(mContext, slot); 472808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato view.set(icon); 473808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mStatusIcons.addView(view, viewIndex, new LinearLayout.LayoutParams(mIconSize, mIconSize)); 474808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 475808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 476808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void updateIcon(String slot, int index, int viewIndex, 477808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato StatusBarIcon old, StatusBarIcon icon) { 478808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "updateIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex 479808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " old=" + old + " icon=" + icon); 480808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato StatusBarIconView view = (StatusBarIconView)mStatusIcons.getChildAt(viewIndex); 481808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato view.set(icon); 482808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 483808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 484808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void removeIcon(String slot, int index, int viewIndex) { 485808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "removeIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex); 486808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mStatusIcons.removeViewAt(viewIndex); 487808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 488808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 489808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void addNotification(IBinder key, StatusBarNotification notification) { 490808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato StatusBarIconView iconView = addNotificationViews(key, notification); 491808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (iconView == null) return; 492808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 493808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean immersive = false; 494808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 495808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato immersive = ActivityManagerNative.getDefault().isTopActivityImmersive(); 496808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "Top activity is " + (immersive?"immersive":"not immersive")); 497808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (RemoteException ex) { 498808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 499808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (immersive) { 500808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((notification.notification.flags & Notification.FLAG_HIGH_PRIORITY) != 0) { 501808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "Presenting high-priority notification in immersive activity"); 502379020aec619c66d3e040de01f0726687fd2ad85Daniel Sandler // special new transient ticker mode 503808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // 1. Populate mIntruderAlertView 504808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 505808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ImageView alertIcon = (ImageView) mIntruderAlertView.findViewById(R.id.alertIcon); 506808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato TextView alertText = (TextView) mIntruderAlertView.findViewById(R.id.alertText); 507808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato alertIcon.setImageDrawable(StatusBarIconView.getIcon( 508808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato alertIcon.getContext(), 509808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato iconView.getStatusBarIcon())); 510808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato alertText.setText(notification.notification.tickerText); 511808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 512808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato View button = mIntruderAlertView.findViewById(R.id.intruder_alert_content); 513808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato button.setOnClickListener( 514808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato new Launcher(notification.notification.contentIntent, 515808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato notification.pkg, notification.tag, notification.id)); 516808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 517808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // 2. Animate mIntruderAlertView in 518808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.sendEmptyMessage(MSG_SHOW_INTRUDER); 519808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 520808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // 3. Set alarm to age the notification off (TODO) 521808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.removeMessages(MSG_HIDE_INTRUDER); 522808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.sendEmptyMessageDelayed(MSG_HIDE_INTRUDER, INTRUDER_ALERT_DECAY_MS); 523808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 524808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else if (notification.notification.fullScreenIntent != null) { 525808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // not immersive & a full-screen alert should be shown 526808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "Notification has fullScreenIntent and activity is not immersive;" 527808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " sending fullScreenIntent"); 528808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 529808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato notification.notification.fullScreenIntent.send(); 530808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (PendingIntent.CanceledException e) { 531808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 532808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 533808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // usual case: status bar visible & not immersive 534808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 535808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // show the ticker 536808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato tick(notification); 537808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 538808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 539808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Recalculate the position of the sliding windows and the titles. 540808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setAreThereNotifications(); 541808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(EXPANDED_LEAVE_ALONE); 542808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 543808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 544808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void updateNotification(IBinder key, StatusBarNotification notification) { 545808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "updateNotification key=" + key + " notification=" + notification); 546808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 547808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato NotificationData oldList; 548379020aec619c66d3e040de01f0726687fd2ad85Daniel Sandler NotificationData.Entry oldEntry = mOngoing.findByKey(key); 549379020aec619c66d3e040de01f0726687fd2ad85Daniel Sandler if (oldEntry != null) { 550808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato oldList = mOngoing; 551808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 552379020aec619c66d3e040de01f0726687fd2ad85Daniel Sandler oldEntry = mLatest.findByKey(key); 553379020aec619c66d3e040de01f0726687fd2ad85Daniel Sandler if (oldEntry == null) { 554808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.w(TAG, "updateNotification for unknown key: " + key); 555808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 556808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 557808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato oldList = mLatest; 558808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 559808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final StatusBarNotification oldNotification = oldEntry.notification; 560808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final RemoteViews oldContentView = oldNotification.notification.contentView; 561808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 562808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final RemoteViews contentView = notification.notification.contentView; 563808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 564808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (false) { 565808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "old notification: when=" + oldNotification.notification.when 566808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " ongoing=" + oldNotification.isOngoing() 567808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " expanded=" + oldEntry.expanded 568808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " contentView=" + oldContentView); 569808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "new notification: when=" + notification.notification.when 570808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " ongoing=" + oldNotification.isOngoing() 571808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " contentView=" + contentView); 572808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 573808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 574808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Can we just reapply the RemoteViews in place? If when didn't change, the order 575808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // didn't change. 576808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (notification.notification.when == oldNotification.notification.when 577808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato && notification.isOngoing() == oldNotification.isOngoing() 578808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato && oldEntry.expanded != null 579808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato && contentView != null && oldContentView != null 580808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato && contentView.getPackage() != null 581808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato && oldContentView.getPackage() != null 582808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato && oldContentView.getPackage().equals(contentView.getPackage()) 583808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato && oldContentView.getLayoutId() == contentView.getLayoutId()) { 584808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "reusing notification"); 585808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato oldEntry.notification = notification; 586808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 587808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Reapply the RemoteViews 588f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato contentView.reapply(mContext, oldEntry.content); 589808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // update the contentIntent 590808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final PendingIntent contentIntent = notification.notification.contentIntent; 591808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (contentIntent != null) { 592808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato oldEntry.content.setOnClickListener(new Launcher(contentIntent, 593808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato notification.pkg, notification.tag, notification.id)); 594184498ce5a8d77e1d9c45693363829daaeef9611Joe Onorato } else { 595184498ce5a8d77e1d9c45693363829daaeef9611Joe Onorato oldEntry.content.setOnClickListener(null); 596808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 597808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Update the icon. 598808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final StatusBarIcon ic = new StatusBarIcon(notification.pkg, 599808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato notification.notification.icon, notification.notification.iconLevel, 600808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato notification.notification.number); 601808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!oldEntry.icon.set(ic)) { 602808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato handleNotificationError(key, notification, "Couldn't update icon: " + ic); 603808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 604808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 605808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 606808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato catch (RuntimeException e) { 607808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // It failed to add cleanly. Log, and remove the view from the panel. 608808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.w(TAG, "Couldn't reapply views for package " + contentView.getPackage(), e); 609808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato removeNotificationViews(key); 610808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato addNotificationViews(key, notification); 611808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 612808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 613808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "not reusing notification"); 614808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato removeNotificationViews(key); 615808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato addNotificationViews(key, notification); 616808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 617808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 618808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Restart the ticker if it's still running 619935865923fdad9f47061ff0aedfe92d0b912d5d6Joe Onorato if (notification.notification.tickerText != null 620935865923fdad9f47061ff0aedfe92d0b912d5d6Joe Onorato && !TextUtils.equals(notification.notification.tickerText, 621935865923fdad9f47061ff0aedfe92d0b912d5d6Joe Onorato oldEntry.notification.notification.tickerText)) { 622935865923fdad9f47061ff0aedfe92d0b912d5d6Joe Onorato tick(notification); 623935865923fdad9f47061ff0aedfe92d0b912d5d6Joe Onorato } 624808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 625808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Recalculate the position of the sliding windows and the titles. 626808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setAreThereNotifications(); 627808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(EXPANDED_LEAVE_ALONE); 628808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 629808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 630808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void removeNotification(IBinder key) { 631808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "removeNotification key=" + key); 632808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato StatusBarNotification old = removeNotificationViews(key); 633808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 634808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (old != null) { 635808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Cancel the ticker if it's still running 636808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicker.removeEntry(old); 637808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 638808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Recalculate the position of the sliding windows and the titles. 639808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setAreThereNotifications(); 640808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(EXPANDED_LEAVE_ALONE); 641808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 642808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 643808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 644808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private int chooseIconIndex(boolean isOngoing, int viewIndex) { 645808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int latestSize = mLatest.size(); 646808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (isOngoing) { 647808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return latestSize + (mOngoing.size() - viewIndex); 648808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 649808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return latestSize - viewIndex; 650808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 651808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 652808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 6533b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka @Override 6543b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka protected void onConfigurationChanged(Configuration newConfig) { 6553b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka initializeRecentsPanel(); 6563b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 6573b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 6583b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 659808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato View[] makeNotificationView(StatusBarNotification notification, ViewGroup parent) { 660808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Notification n = notification.notification; 661808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato RemoteViews remoteViews = n.contentView; 662808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (remoteViews == null) { 663808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return null; 664808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 665808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 666808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // create the row view 667f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato LayoutInflater inflater = (LayoutInflater)mContext.getSystemService( 668f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato Context.LAYOUT_INFLATER_SERVICE); 669755cc74e4cebdf67d21a2477512a4ac9b01e8323Joe Onorato View row = inflater.inflate(R.layout.status_bar_notification_row, parent, false); 670808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 671b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler // wire up the veto button 672b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler View vetoButton = row.findViewById(R.id.veto); 673b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler if (notification.isClearable()) { 674b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler final String _pkg = notification.pkg; 675b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler final String _tag = notification.tag; 676b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler final int _id = notification.id; 677b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler vetoButton.setOnClickListener(new View.OnClickListener() { 678b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler public void onClick(View v) { 679b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler try { 680b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler mBarService.onNotificationClear(_pkg, _tag, _id); 681b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } catch (RemoteException ex) { 682b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler // system process is dead if we're here. 683b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } 684b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } 685b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler }); 686b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } else { 687b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler if ((notification.notification.flags & Notification.FLAG_ONGOING_EVENT) == 0) { 688b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler vetoButton.setVisibility(View.INVISIBLE); 689b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } else { 690b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler vetoButton.setVisibility(View.GONE); 691b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } 692b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } 693b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler 694b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler // the large icon 695b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler ImageView largeIcon = (ImageView)row.findViewById(R.id.large_icon); 696b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler if (notification.notification.largeIcon != null) { 697b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler largeIcon.setImageBitmap(notification.notification.largeIcon); 698b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } else { 699b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler largeIcon.getLayoutParams().width = 0; 700b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler largeIcon.setVisibility(View.INVISIBLE); 701b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } 702b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler 703808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // bind the click event to the content area 704808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ViewGroup content = (ViewGroup)row.findViewById(R.id.content); 705808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato content.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); 706808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato content.setOnFocusChangeListener(mFocusChangeListener); 707808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato PendingIntent contentIntent = n.contentIntent; 708808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (contentIntent != null) { 709808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato content.setOnClickListener(new Launcher(contentIntent, notification.pkg, 710808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato notification.tag, notification.id)); 711184498ce5a8d77e1d9c45693363829daaeef9611Joe Onorato } else { 712184498ce5a8d77e1d9c45693363829daaeef9611Joe Onorato content.setOnClickListener(null); 713808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 714808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 715808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato View expanded = null; 716808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Exception exception = null; 717808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 718f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato expanded = remoteViews.apply(mContext, content); 719808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 720808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato catch (RuntimeException e) { 721808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato exception = e; 722808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 723808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (expanded == null) { 724808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato String ident = notification.pkg + "/0x" + Integer.toHexString(notification.id); 725808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.e(TAG, "couldn't inflate view for notification " + ident, exception); 726808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return null; 727808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 728808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato content.addView(expanded); 729808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato row.setDrawingCacheEnabled(true); 730808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 731808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 732808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return new View[] { row, content, expanded }; 733808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 734808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 735808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato StatusBarIconView addNotificationViews(IBinder key, StatusBarNotification notification) { 736808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato NotificationData list; 737808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ViewGroup parent; 738808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final boolean isOngoing = notification.isOngoing(); 739808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (isOngoing) { 740808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato list = mOngoing; 741808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato parent = mOngoingItems; 742808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 743808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato list = mLatest; 744808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato parent = mLatestItems; 745808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 746808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Construct the expanded view. 747808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final View[] views = makeNotificationView(notification, parent); 748808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (views == null) { 749808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato handleNotificationError(key, notification, "Couldn't expand RemoteViews for: " 750808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + notification); 751808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return null; 752808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 753808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final View row = views[0]; 754808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final View content = views[1]; 755808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final View expanded = views[2]; 756808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Construct the icon. 757f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato final StatusBarIconView iconView = new StatusBarIconView(mContext, 758808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato notification.pkg + "/0x" + Integer.toHexString(notification.id)); 759808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final StatusBarIcon ic = new StatusBarIcon(notification.pkg, notification.notification.icon, 760808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato notification.notification.iconLevel, notification.notification.number); 761808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!iconView.set(ic)) { 762808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato handleNotificationError(key, notification, "Coulding create icon: " + ic); 763808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return null; 764808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 765808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Add the expanded view. 766808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int viewIndex = list.add(key, notification, row, content, expanded, iconView); 767808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato parent.addView(row, viewIndex); 768808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Add the icon. 769808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int iconIndex = chooseIconIndex(isOngoing, viewIndex); 770066b5c5166c1f5342bd42aa0d68f784a5f4c1dd1Joe Onorato mNotificationIcons.addView(iconView, iconIndex); 771808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return iconView; 772808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 773808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 774808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato StatusBarNotification removeNotificationViews(IBinder key) { 775808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato NotificationData.Entry entry = mOngoing.remove(key); 776808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (entry == null) { 777808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato entry = mLatest.remove(key); 778808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (entry == null) { 779808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.w(TAG, "removeNotification for unknown key: " + key); 780808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return null; 781808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 782808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 783808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Remove the expanded view. 784808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ((ViewGroup)entry.row.getParent()).removeView(entry.row); 785808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Remove the icon. 786808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ((ViewGroup)entry.icon.getParent()).removeView(entry.icon); 787808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 788808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return entry.notification; 789808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 790808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 791808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private void setAreThereNotifications() { 792808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean ongoing = mOngoing.hasVisibleItems(); 793808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean latest = mLatest.hasVisibleItems(); 794808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 795808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // (no ongoing notifications are clearable) 796808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mLatest.hasClearableItems()) { 797808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mClearButton.setVisibility(View.VISIBLE); 798808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 799808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mClearButton.setVisibility(View.INVISIBLE); 800808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 801808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 802808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mOngoingTitle.setVisibility(ongoing ? View.VISIBLE : View.GONE); 803808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mLatestTitle.setVisibility(latest ? View.VISIBLE : View.GONE); 804808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 805808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (ongoing || latest) { 806808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mNoNotificationsTitle.setVisibility(View.GONE); 807808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 808808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mNoNotificationsTitle.setVisibility(View.VISIBLE); 809808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 810808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 811808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 812808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 813808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /** 814808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * State is one or more of the DISABLE constants from StatusBarManager. 815808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato */ 816808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void disable(int state) { 817808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int old = mDisabled; 818808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int diff = state ^ old; 819808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mDisabled = state; 820808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 821808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) { 822808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((state & StatusBarManager.DISABLE_EXPAND) != 0) { 823808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "DISABLE_EXPAND: yes"); 824808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato animateCollapse(); 825808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 826808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 827808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { 828808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { 829808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: yes"); 830808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mTicking) { 831808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicker.halt(); 832808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 833808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setNotificationIconVisibility(false, com.android.internal.R.anim.fade_out); 834808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 835808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 836808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: no"); 837808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mExpandedVisible) { 838808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in); 839808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 840808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 841808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else if ((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { 842808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mTicking && (state & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { 843808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "DISABLE_NOTIFICATION_TICKER: yes"); 844808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicker.halt(); 845808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 846808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 847808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 848808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 849808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /** 850808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * All changes to the status bar and notifications funnel through here and are batched. 851808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato */ 852808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private class H extends Handler { 853808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void handleMessage(Message m) { 854808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato switch (m.what) { 855808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato case MSG_ANIMATE: 856808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato doAnimation(); 857808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato break; 858808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato case MSG_ANIMATE_REVEAL: 859808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato doRevealAnimation(); 860808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato break; 861808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato case MSG_SHOW_INTRUDER: 862808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setIntruderAlertVisibility(true); 863808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato break; 864808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato case MSG_HIDE_INTRUDER: 865808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setIntruderAlertVisibility(false); 866808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato break; 8673b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka case MSG_OPEN_RECENTS_PANEL: 8683b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (DEBUG) Slog.d(TAG, "opening recents panel"); 8693b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (mRecentsPanel != null) { 8703b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka disable(StatusBarManager.DISABLE_BACK); 8713b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel.setVisibility(View.VISIBLE); 8723b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel.show(true, true); 8733b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 8743b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka break; 8753b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka case MSG_CLOSE_RECENTS_PANEL: 8763b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (DEBUG) Slog.d(TAG, "closing recents panel"); 8773b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (mRecentsPanel != null && mRecentsPanel.isShowing()) { 8783b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka disable(StatusBarManager.DISABLE_NONE); 8793b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel.show(false, true); 8803b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 8813b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka break; 882808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 883808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 884808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 885808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 886808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato View.OnFocusChangeListener mFocusChangeListener = new View.OnFocusChangeListener() { 887808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void onFocusChange(View v, boolean hasFocus) { 888808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Because 'v' is a ViewGroup, all its children will be (un)selected 889808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // too, which allows marqueeing to work. 890808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato v.setSelected(hasFocus); 891808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 892808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato }; 893808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 894808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private void makeExpandedVisible() { 895808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "Make expanded visible: expanded visible=" + mExpandedVisible); 896808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpandedVisible) { 897808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 898808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 899808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedVisible = true; 900808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato visibilityChanged(true); 901808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 902808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(EXPANDED_LEAVE_ALONE); 903808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; 904808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; 905808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().setAttributes(mExpandedParams); 906808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedView.requestFocus(View.FOCUS_FORWARD); 907808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingView.setVisibility(View.VISIBLE); 908808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 909808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mTicking) { 910808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setDateViewVisibility(true, com.android.internal.R.anim.fade_in); 911808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 912808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 913808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 914808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void animateExpand() { 915808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "Animate expand: expanded=" + mExpanded); 916808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) { 917808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return ; 918808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 919808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpanded) { 920808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 921808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 922808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 923808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato prepareTracking(0, true); 924808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato performFling(0, 2000.0f, true); 925808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 926808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 927808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void animateCollapse() { 9283b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka animateCollapse(false); 9293b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 9303b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 9313b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka public void animateCollapse(boolean excludeRecents) { 932808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) { 933808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "animateCollapse(): mExpanded=" + mExpanded 934808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mExpandedVisible=" + mExpandedVisible 935808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mExpanded=" + mExpanded 936808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mAnimating=" + mAnimating 937808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mAnimY=" + mAnimY 938808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mAnimVel=" + mAnimVel); 939808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 940808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 9413b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (!excludeRecents) { 9423b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mHandler.removeMessages(MSG_CLOSE_RECENTS_PANEL); 9433b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL); 9443b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 9453b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 946808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mExpandedVisible) { 947808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 948808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 949808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 950808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int y; 951808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mAnimating) { 952808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato y = (int)mAnimY; 953808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 954808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato y = mDisplay.getHeight()-1; 955808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 956808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Let the fling think that we're open so it goes in the right direction 957808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // and doesn't try to re-open the windowshade. 958808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpanded = true; 959808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato prepareTracking(y, false); 960808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato performFling(y, -2000.0f, true); 961808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 962808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 963808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void performExpand() { 964808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "performExpand: mExpanded=" + mExpanded); 965808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) { 966808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return ; 967808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 968808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpanded) { 969808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 970808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 971808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 972808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpanded = true; 973808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato makeExpandedVisible(); 974808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(EXPANDED_FULL_OPEN); 975808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 976808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (false) postStartTracing(); 977808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 978808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 979808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void performCollapse() { 980808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "performCollapse: mExpanded=" + mExpanded 981808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mExpandedVisible=" + mExpandedVisible); 982808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 983808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mExpandedVisible) { 984808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 985808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 986808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedVisible = false; 987808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato visibilityChanged(false); 988808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; 989808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.flags &= ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; 990808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().setAttributes(mExpandedParams); 991808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingView.setVisibility(View.GONE); 992808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 993808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((mDisabled & StatusBarManager.DISABLE_NOTIFICATION_ICONS) == 0) { 994808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in); 995808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 996808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setDateViewVisibility(false, com.android.internal.R.anim.fade_out); 997808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 998808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mExpanded) { 999808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 1000808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1001808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpanded = false; 1002808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1003808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1004808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void doAnimation() { 1005808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mAnimating) { 1006808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "doAnimation"); 1007808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "doAnimation before mAnimY=" + mAnimY); 1008808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato incrementAnim(); 1009808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "doAnimation after mAnimY=" + mAnimY); 1010808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mAnimY >= mDisplay.getHeight()-1) { 1011808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "Animation completed to expanded state."); 1012808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimating = false; 1013808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(EXPANDED_FULL_OPEN); 1014808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato performExpand(); 1015808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1016808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato else if (mAnimY < mStatusBarView.getHeight()) { 1017808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "Animation completed to collapsed state."); 1018808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimating = false; 1019808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(0); 1020808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato performCollapse(); 1021808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1022808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato else { 1023808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos((int)mAnimY); 1024808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCurAnimationTime += ANIM_FRAME_DURATION; 1025808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.sendMessageAtTime(mHandler.obtainMessage(MSG_ANIMATE), mCurAnimationTime); 1026808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1027808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1028808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1029808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1030808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void stopTracking() { 1031808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTracking = false; 1032808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mVelocityTracker.recycle(); 1033808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mVelocityTracker = null; 1034808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1035808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1036808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void incrementAnim() { 1037808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato long now = SystemClock.uptimeMillis(); 1038808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float t = ((float)(now - mAnimLastTime)) / 1000; // ms -> s 1039808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final float y = mAnimY; 1040808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final float v = mAnimVel; // px/s 1041808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final float a = mAnimAccel; // px/s/s 1042808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimY = y + (v*t) + (0.5f*a*t*t); // px 1043808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimVel = v + (a*t); // px/s 1044808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimLastTime = now; // ms 1045808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato //Slog.d(TAG, "y=" + y + " v=" + v + " a=" + a + " t=" + t + " mAnimY=" + mAnimY 1046808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // + " mAnimAccel=" + mAnimAccel); 1047808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1048808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1049808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void doRevealAnimation() { 1050808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int h = mCloseView.getHeight() + mStatusBarView.getHeight(); 1051808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mAnimatingReveal && mAnimating && mAnimY < h) { 1052808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato incrementAnim(); 1053808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mAnimY >= h) { 1054808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimY = h; 1055808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos((int)mAnimY); 1056808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1057808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos((int)mAnimY); 1058808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCurAnimationTime += ANIM_FRAME_DURATION; 1059808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.sendMessageAtTime(mHandler.obtainMessage(MSG_ANIMATE_REVEAL), 1060808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCurAnimationTime); 1061808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1062808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1063808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1064808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1065808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void prepareTracking(int y, boolean opening) { 1066808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTracking = true; 1067808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mVelocityTracker = VelocityTracker.obtain(); 1068808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (opening) { 1069808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimAccel = 2000.0f; 1070808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimVel = 200; 1071808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimY = mStatusBarView.getHeight(); 1072808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos((int)mAnimY); 1073808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimating = true; 1074808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimatingReveal = true; 1075808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.removeMessages(MSG_ANIMATE); 1076808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.removeMessages(MSG_ANIMATE_REVEAL); 1077808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato long now = SystemClock.uptimeMillis(); 1078808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimLastTime = now; 1079808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCurAnimationTime = now + ANIM_FRAME_DURATION; 1080808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimating = true; 1081808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.sendMessageAtTime(mHandler.obtainMessage(MSG_ANIMATE_REVEAL), 1082808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCurAnimationTime); 1083808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato makeExpandedVisible(); 1084808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1085808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // it's open, close it? 1086808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mAnimating) { 1087808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimating = false; 1088808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.removeMessages(MSG_ANIMATE); 1089808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1090808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(y + mViewDelta); 1091808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1092808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1093808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1094808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void performFling(int y, float vel, boolean always) { 1095808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimatingReveal = false; 1096808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mDisplayHeight = mDisplay.getHeight(); 1097808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1098808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimY = y; 1099808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimVel = vel; 1100808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1101808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato //Slog.d(TAG, "starting with mAnimY=" + mAnimY + " mAnimVel=" + mAnimVel); 1102808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1103808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpanded) { 1104808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!always && ( 1105808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato vel > 200.0f 1106808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato || (y > (mDisplayHeight-25) && vel > -200.0f))) { 1107808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // We are expanded, but they didn't move sufficiently to cause 1108808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // us to retract. Animate back to the expanded position. 1109808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimAccel = 2000.0f; 1110808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (vel < 0) { 1111808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimVel = 0; 1112808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1113808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1114808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato else { 1115808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // We are expanded and are now going to animate away. 1116808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimAccel = -2000.0f; 1117808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (vel > 0) { 1118808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimVel = 0; 1119808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1120808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1121808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1122808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (always || ( 1123808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato vel > 200.0f 1124808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato || (y > (mDisplayHeight/2) && vel > -200.0f))) { 1125808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // We are collapsed, and they moved enough to allow us to 1126808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // expand. Animate in the notifications. 1127808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimAccel = 2000.0f; 1128808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (vel < 0) { 1129808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimVel = 0; 1130808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1131808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1132808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato else { 1133808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // We are collapsed, but they didn't move sufficiently to cause 1134808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // us to retract. Animate back to the collapsed position. 1135808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimAccel = -2000.0f; 1136808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (vel > 0) { 1137808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimVel = 0; 1138808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1139808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1140808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1141808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato //Slog.d(TAG, "mAnimY=" + mAnimY + " mAnimVel=" + mAnimVel 1142808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // + " mAnimAccel=" + mAnimAccel); 1143808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1144808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato long now = SystemClock.uptimeMillis(); 1145808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimLastTime = now; 1146808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCurAnimationTime = now + ANIM_FRAME_DURATION; 1147808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimating = true; 1148808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.removeMessages(MSG_ANIMATE); 1149808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.removeMessages(MSG_ANIMATE_REVEAL); 1150808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.sendMessageAtTime(mHandler.obtainMessage(MSG_ANIMATE), mCurAnimationTime); 1151808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato stopTracking(); 1152808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1153808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1154808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean interceptTouchEvent(MotionEvent event) { 1155808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) { 1156808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "Touch: rawY=" + event.getRawY() + " event=" + event + " mDisabled=" 1157808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + mDisabled); 1158808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1159808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1160808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) { 1161808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return false; 1162808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1163808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1164808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int statusBarSize = mStatusBarView.getHeight(); 1165808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int hitSize = statusBarSize*2; 1166808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (event.getAction() == MotionEvent.ACTION_DOWN) { 1167808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int y = (int)event.getRawY(); 1168808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1169808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mExpanded) { 1170808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mViewDelta = statusBarSize - y; 1171808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1172808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingView.getLocationOnScreen(mAbsPos); 1173808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mViewDelta = mAbsPos[1] + mTrackingView.getHeight() - y; 1174808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1175808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((!mExpanded && y < hitSize) || 1176808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato (mExpanded && y > (mDisplay.getHeight()-hitSize))) { 1177808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1178808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // We drop events at the edge of the screen to make the windowshade come 1179808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // down by accident less, especially when pushing open a device with a keyboard 1180808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // that rotates (like g1 and droid) 1181808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int x = (int)event.getRawX(); 1182808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int edgeBorder = mEdgeBorder; 1183808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (x >= edgeBorder && x < mDisplay.getWidth() - edgeBorder) { 1184808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato prepareTracking(y, !mExpanded);// opening if we're not already fully visible 1185808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mVelocityTracker.addMovement(event); 1186808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1187808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1188808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else if (mTracking) { 1189808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mVelocityTracker.addMovement(event); 1190808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int minY = statusBarSize + mCloseView.getHeight(); 1191808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (event.getAction() == MotionEvent.ACTION_MOVE) { 1192808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int y = (int)event.getRawY(); 1193808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mAnimatingReveal && y < minY) { 1194808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // nothing 1195808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1196808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimatingReveal = false; 1197808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(y + mViewDelta); 1198808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1199808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else if (event.getAction() == MotionEvent.ACTION_UP) { 1200808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mVelocityTracker.computeCurrentVelocity(1000); 1201808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1202808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float yVel = mVelocityTracker.getYVelocity(); 1203808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean negative = yVel < 0; 1204808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1205808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float xVel = mVelocityTracker.getXVelocity(); 1206808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (xVel < 0) { 1207808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato xVel = -xVel; 1208808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1209808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (xVel > 150.0f) { 1210808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato xVel = 150.0f; // limit how much we care about the x axis 1211808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1212808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1213808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float vel = (float)Math.hypot(yVel, xVel); 1214808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (negative) { 1215808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato vel = -vel; 1216808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1217808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1218808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato performFling((int)event.getRawY(), vel, false); 1219808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1220808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1221808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1222808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return false; 1223808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1224808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 12259305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato public void setLightsOn(boolean on) { 12261d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler Log.v(TAG, "lights " + (on ? "on" : "off")); 12279305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato if (!on) { 12289305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato // All we do for "lights out" mode on a phone is hide the status bar, 12299305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato // which the window manager does. But we do need to hide the windowshade 12309305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato // on our own. 12319305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato animateCollapse(); 12329305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato } 12331d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler notifyLightsChanged(on); 12341d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler } 12351d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler 12361d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler private void notifyLightsChanged(boolean shown) { 12371d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler try { 12381d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler Slog.d(TAG, "lights " + (shown?"on":"out")); 12391d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler mWindowManager.statusBarVisibilityChanged( 12401d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler shown ? View.STATUS_BAR_VISIBLE : View.STATUS_BAR_HIDDEN); 12411d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler } catch (RemoteException ex) { 12421d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler } 12439305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato } 12449305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato 12455c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler public void topAppWindowChanged(boolean showMenu) { 12465c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler if (DEBUG) { 12475c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler Slog.d(TAG, (showMenu?"showing":"hiding") + " the MENU button"); 12485c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler } 12495c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler if (mNavigationBarView != null) { 12505c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler mNavigationBarView.getMenuButton().setVisibility(showMenu 12515c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler ? View.VISIBLE : View.INVISIBLE); 12525c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler } 12535c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler 12545c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler // See above re: lights-out policy for legacy apps. 12555c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler if (showMenu) setLightsOn(true); 12565c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler } 12575c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler 1258e02d808abf370965c3c4e4d38af11bc69110fde2Daniel Sandler // Not supported 1259857fd9b8562c29913e03ed29288bd1802d37dc60Joe Onorato public void setImeWindowStatus(IBinder token, int vis, int backDisposition) { } 12602992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown @Override 12612992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown public void setHardKeyboardStatus(boolean available, boolean enabled) { } 1262e02d808abf370965c3c4e4d38af11bc69110fde2Daniel Sandler 1263808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private class Launcher implements View.OnClickListener { 1264808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private PendingIntent mIntent; 1265808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private String mPkg; 1266808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private String mTag; 1267808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private int mId; 1268808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1269808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Launcher(PendingIntent intent, String pkg, String tag, int id) { 1270808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIntent = intent; 1271808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mPkg = pkg; 1272808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTag = tag; 1273808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mId = id; 1274808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1275808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1276808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void onClick(View v) { 1277808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 1278808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // The intent we are sending is for the application, which 1279808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // won't have permission to immediately start an activity after 1280808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // the user switches to home. We know it is safe to do at this 1281808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // point, so make sure new activity switches are now allowed. 1282808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ActivityManagerNative.getDefault().resumeAppSwitches(); 1283808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (RemoteException e) { 1284808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1285808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1286808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mIntent != null) { 1287808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int[] pos = new int[2]; 1288808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato v.getLocationOnScreen(pos); 1289808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Intent overlay = new Intent(); 1290808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato overlay.setSourceBounds( 1291808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato new Rect(pos[0], pos[1], pos[0]+v.getWidth(), pos[1]+v.getHeight())); 1292808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 1293f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato mIntent.send(mContext, 0, overlay); 1294808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (PendingIntent.CanceledException e) { 1295808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // the stack trace isn't very helpful here. Just log the exception message. 1296808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.w(TAG, "Sending contentIntent failed: " + e); 1297808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1298808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1299808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1300808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 1301808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mBarService.onNotificationClick(mPkg, mTag, mId); 1302808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (RemoteException ex) { 1303808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // system process is dead if we're here. 1304808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1305808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1306808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // close the shade if it was open 1307808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato animateCollapse(); 1308808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1309808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // If this click was on the intruder alert, hide that instead 1310808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.sendEmptyMessage(MSG_HIDE_INTRUDER); 1311808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1312808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1313808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1314808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private void tick(StatusBarNotification n) { 1315808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Show the ticker if one is requested. Also don't do this 1316808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // until status bar window is attached to the window manager, 1317808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // because... well, what's the point otherwise? And trying to 1318808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // run a ticker without being attached will crash! 1319808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (n.notification.tickerText != null && mStatusBarView.getWindowToken() != null) { 1320808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (0 == (mDisabled & (StatusBarManager.DISABLE_NOTIFICATION_ICONS 1321808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | StatusBarManager.DISABLE_NOTIFICATION_TICKER))) { 1322808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicker.addEntry(n); 1323808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1324808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1325808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1326808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1327808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /** 1328808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * Cancel this notification and tell the StatusBarManagerService / NotificationManagerService 1329808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * about the failure. 1330808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * 1331808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * WARNING: this will call back into us. Don't hold any locks. 1332808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato */ 1333808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void handleNotificationError(IBinder key, StatusBarNotification n, String message) { 1334808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato removeNotification(key); 1335808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 1336808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mBarService.onNotificationError(n.pkg, n.tag, n.id, n.uid, n.initialPid, message); 1337808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (RemoteException ex) { 1338808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // The end is nigh. 1339808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1340808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1341808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1342808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private class MyTicker extends Ticker { 1343dfa08db1652585a8cf27f929371c7ca6bf18ca60Daniel Sandler MyTicker(Context context, View sb) { 1344808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato super(context, sb); 1345808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1346808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1347808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato @Override 1348dfa08db1652585a8cf27f929371c7ca6bf18ca60Daniel Sandler public void tickerStarting() { 1349808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicking = true; 1350808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIcons.setVisibility(View.GONE); 1351808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickerView.setVisibility(View.VISIBLE); 1352808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickerView.startAnimation(loadAnim(com.android.internal.R.anim.push_up_in, null)); 1353808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIcons.startAnimation(loadAnim(com.android.internal.R.anim.push_up_out, null)); 1354808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpandedVisible) { 1355808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setDateViewVisibility(false, com.android.internal.R.anim.push_up_out); 1356808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1357808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1358808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1359808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato @Override 1360dfa08db1652585a8cf27f929371c7ca6bf18ca60Daniel Sandler public void tickerDone() { 1361808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIcons.setVisibility(View.VISIBLE); 1362808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickerView.setVisibility(View.GONE); 1363808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIcons.startAnimation(loadAnim(com.android.internal.R.anim.push_down_in, null)); 1364808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickerView.startAnimation(loadAnim(com.android.internal.R.anim.push_down_out, 1365808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickingDoneListener)); 1366808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpandedVisible) { 1367808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setDateViewVisibility(true, com.android.internal.R.anim.push_down_in); 1368808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1369808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1370808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1371dfa08db1652585a8cf27f929371c7ca6bf18ca60Daniel Sandler public void tickerHalting() { 1372808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIcons.setVisibility(View.VISIBLE); 1373808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickerView.setVisibility(View.GONE); 1374808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIcons.startAnimation(loadAnim(com.android.internal.R.anim.fade_in, null)); 1375808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickerView.startAnimation(loadAnim(com.android.internal.R.anim.fade_out, 1376808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickingDoneListener)); 1377808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpandedVisible) { 1378808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setDateViewVisibility(true, com.android.internal.R.anim.fade_in); 1379808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1380808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1381808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1382808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1383808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Animation.AnimationListener mTickingDoneListener = new Animation.AnimationListener() {; 1384808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void onAnimationEnd(Animation animation) { 1385808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicking = false; 1386808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1387808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void onAnimationRepeat(Animation animation) { 1388808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1389808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void onAnimationStart(Animation animation) { 1390808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1391808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato }; 1392808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1393808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private Animation loadAnim(int id, Animation.AnimationListener listener) { 1394f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato Animation anim = AnimationUtils.loadAnimation(mContext, id); 1395808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (listener != null) { 1396808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato anim.setAnimationListener(listener); 1397808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1398808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return anim; 1399808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1400808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1401808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public String viewInfo(View v) { 1402808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return "(" + v.getLeft() + "," + v.getTop() + ")(" + v.getRight() + "," + v.getBottom() 1403808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " " + v.getWidth() + "x" + v.getHeight() + ")"; 1404808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1405808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1406f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { 1407808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato synchronized (mQueueLock) { 1408808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println("Current Status Bar state:"); 1409808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mExpanded=" + mExpanded 1410808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + ", mExpandedVisible=" + mExpandedVisible); 1411808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mTicking=" + mTicking); 1412808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mTracking=" + mTracking); 1413808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mAnimating=" + mAnimating 1414808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + ", mAnimY=" + mAnimY + ", mAnimVel=" + mAnimVel 1415808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + ", mAnimAccel=" + mAnimAccel); 1416808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mCurAnimationTime=" + mCurAnimationTime 1417808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mAnimLastTime=" + mAnimLastTime); 1418808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mDisplayHeight=" + mDisplayHeight 1419808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mAnimatingReveal=" + mAnimatingReveal 1420808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mViewDelta=" + mViewDelta); 1421808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mDisplayHeight=" + mDisplayHeight); 1422808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mExpandedParams: " + mExpandedParams); 1423808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mExpandedView: " + viewInfo(mExpandedView)); 1424808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mExpandedDialog: " + mExpandedDialog); 1425808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mTrackingParams: " + mTrackingParams); 1426808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mTrackingView: " + viewInfo(mTrackingView)); 1427808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mOngoingTitle: " + viewInfo(mOngoingTitle)); 1428808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mOngoingItems: " + viewInfo(mOngoingItems)); 1429808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mLatestTitle: " + viewInfo(mLatestTitle)); 1430808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mLatestItems: " + viewInfo(mLatestItems)); 1431808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mNoNotificationsTitle: " + viewInfo(mNoNotificationsTitle)); 1432808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mCloseView: " + viewInfo(mCloseView)); 1433808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mTickerView: " + viewInfo(mTickerView)); 1434808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mScrollView: " + viewInfo(mScrollView) 1435808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " scroll " + mScrollView.getScrollX() + "," + mScrollView.getScrollY()); 1436808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println("mNotificationLinearLayout: " + viewInfo(mNotificationLinearLayout)); 1437808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1438808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /* 1439808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato synchronized (mNotificationData) { 1440808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int N = mNotificationData.ongoingCount(); 1441808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" ongoingCount.size=" + N); 1442808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato for (int i=0; i<N; i++) { 1443808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato StatusBarNotification n = mNotificationData.getOngoing(i); 1444808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" [" + i + "] key=" + n.key + " view=" + n.view); 1445808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" data=" + n.data); 1446808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1447808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato N = mNotificationData.latestCount(); 1448808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" ongoingCount.size=" + N); 1449808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato for (int i=0; i<N; i++) { 1450808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato StatusBarNotification n = mNotificationData.getLatest(i); 1451808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" [" + i + "] key=" + n.key + " view=" + n.view); 1452808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" data=" + n.data); 1453808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1454808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1455808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato */ 1456808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1457808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (false) { 1458808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println("see the logcat for a dump of the views we have created."); 1459808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // must happen on ui thread 1460808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.post(new Runnable() { 1461808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void run() { 1462808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mStatusBarView.getLocationOnScreen(mAbsPos); 1463808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "mStatusBarView: ----- (" + mAbsPos[0] + "," + mAbsPos[1] 1464808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + ") " + mStatusBarView.getWidth() + "x" 1465808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + mStatusBarView.getHeight()); 1466808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mStatusBarView.debug(); 1467808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1468808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedView.getLocationOnScreen(mAbsPos); 1469808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "mExpandedView: ----- (" + mAbsPos[0] + "," + mAbsPos[1] 1470808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + ") " + mExpandedView.getWidth() + "x" 1471808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + mExpandedView.getHeight()); 1472808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedView.debug(); 1473808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1474808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingView.getLocationOnScreen(mAbsPos); 1475808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "mTrackingView: ----- (" + mAbsPos[0] + "," + mAbsPos[1] 1476808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + ") " + mTrackingView.getWidth() + "x" 1477808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + mTrackingView.getHeight()); 1478808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingView.debug(); 1479808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1480808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato }); 1481808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1482808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1483808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1484808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void onBarViewAttached() { 1485808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManager.LayoutParams lp; 1486808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int pixelFormat; 1487808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Drawable bg; 1488808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1489808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /// ---------- Tracking View -------------- 1490808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pixelFormat = PixelFormat.RGBX_8888; 1491808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato bg = mTrackingView.getBackground(); 1492808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (bg != null) { 1493808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pixelFormat = bg.getOpacity(); 1494808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1495808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1496808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp = new WindowManager.LayoutParams( 1497808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ViewGroup.LayoutParams.MATCH_PARENT, 1498808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ViewGroup.LayoutParams.MATCH_PARENT, 149929fc2c9705e1bb8ae098fca016032d2325031587Joe Onorato WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL, 1500808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 1501808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS 1502808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, 1503808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pixelFormat); 1504808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato// lp.token = mStatusBarView.getWindowToken(); 1505808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.gravity = Gravity.TOP | Gravity.FILL_HORIZONTAL; 1506808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.setTitle("TrackingView"); 1507808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.y = mTrackingPosition; 1508808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingParams = lp; 1509808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1510808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManagerImpl.getDefault().addView(mTrackingView, lp); 1511808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1512808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1513808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void onTrackingViewAttached() { 1514808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManager.LayoutParams lp; 1515808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int pixelFormat; 1516808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Drawable bg; 1517808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1518808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /// ---------- Expanded View -------------- 1519808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pixelFormat = PixelFormat.TRANSLUCENT; 1520808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1521808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int disph = mDisplay.getHeight(); 1522808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp = mExpandedDialog.getWindow().getAttributes(); 1523808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.width = ViewGroup.LayoutParams.MATCH_PARENT; 1524808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.height = getExpandedHeight(); 1525808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.x = 0; 1526808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingPosition = lp.y = -disph; // sufficiently large negative 152729fc2c9705e1bb8ae098fca016032d2325031587Joe Onorato lp.type = WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL; 1528808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 1529808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS 1530808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL 1531808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_DITHER 1532808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; 1533808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.format = pixelFormat; 1534808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.gravity = Gravity.TOP | Gravity.FILL_HORIZONTAL; 1535808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.setTitle("StatusBarExpanded"); 1536808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().setAttributes(lp); 1537808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().setFormat(pixelFormat); 1538808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams = lp; 1539808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1540808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); 1541808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.setContentView(mExpandedView, 1542808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1543808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ViewGroup.LayoutParams.MATCH_PARENT)); 1544808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().setBackgroundDrawable(null); 1545808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.show(); 1546808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato FrameLayout hack = (FrameLayout)mExpandedView.getParent(); 1547808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1548808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1549808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void setDateViewVisibility(boolean visible, int anim) { 1550808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mDateView.setVisibility(visible ? View.VISIBLE : View.INVISIBLE); 1551808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mDateView.startAnimation(loadAnim(anim, null)); 1552808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1553808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1554808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void setNotificationIconVisibility(boolean visible, int anim) { 1555808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int old = mNotificationIcons.getVisibility(); 1556808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int v = visible ? View.VISIBLE : View.INVISIBLE; 1557808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (old != v) { 1558808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mNotificationIcons.setVisibility(v); 1559808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mNotificationIcons.startAnimation(loadAnim(anim, null)); 1560808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1561808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1562808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1563808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void updateExpandedViewPos(int expandedPosition) { 1564808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) { 1565808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "updateExpandedViewPos before expandedPosition=" + expandedPosition 1566808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mTrackingParams.y=" + mTrackingParams.y 1567808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mTrackingPosition=" + mTrackingPosition); 1568808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1569808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1570808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int h = mStatusBarView.getHeight(); 1571808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int disph = mDisplay.getHeight(); 1572808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1573808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // If the expanded view is not visible, make sure they're still off screen. 1574808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Maybe the view was resized. 1575808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mExpandedVisible) { 1576808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mTrackingView != null) { 1577808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingPosition = -disph; 1578808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mTrackingParams != null) { 1579808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingParams.y = mTrackingPosition; 1580808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManagerImpl.getDefault().updateViewLayout(mTrackingView, mTrackingParams); 1581808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1582808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1583808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpandedParams != null) { 1584808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.y = -disph; 1585808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().setAttributes(mExpandedParams); 1586808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1587808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 1588808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1589808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1590808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // tracking view... 1591808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int pos; 1592808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (expandedPosition == EXPANDED_FULL_OPEN) { 1593808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pos = h; 1594808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1595808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato else if (expandedPosition == EXPANDED_LEAVE_ALONE) { 1596808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pos = mTrackingPosition; 1597808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1598808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato else { 1599808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (expandedPosition <= disph) { 1600808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pos = expandedPosition; 1601808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1602808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pos = disph; 1603808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1604808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pos -= disph-h; 1605808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1606808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingPosition = mTrackingParams.y = pos; 1607808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingParams.height = disph-h; 1608808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManagerImpl.getDefault().updateViewLayout(mTrackingView, mTrackingParams); 1609808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1610808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpandedParams != null) { 1611808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCloseView.getLocationInWindow(mPositionTmp); 1612808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int closePos = mPositionTmp[1]; 1613808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1614808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedContents.getLocationInWindow(mPositionTmp); 1615808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int contentsBottom = mPositionTmp[1] + mExpandedContents.getHeight(); 1616808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1617808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.y = pos + mTrackingView.getHeight() 1618808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato - (mTrackingParams.height-closePos) - contentsBottom; 1619808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int max = h; 1620808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpandedParams.y > max) { 1621808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.y = max; 1622808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1623808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int min = mTrackingPosition; 1624808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpandedParams.y < min) { 1625808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.y = min; 1626808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1627808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1628808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean visible = (mTrackingPosition + mTrackingView.getHeight()) > h; 1629808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!visible) { 1630808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // if the contents aren't visible, move the expanded view way off screen 1631808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // because the window itself extends below the content view. 1632808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.y = -disph; 1633808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1634808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().setAttributes(mExpandedParams); 1635808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1636808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // As long as this isn't just a repositioning that's not supposed to affect 1637808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // the user's perception of what's showing, call to say that the visibility 1638808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // has changed. (Otherwise, someone else will call to do that). 1639808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (expandedPosition != EXPANDED_LEAVE_ALONE) { 1640808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "updateExpandedViewPos visibilityChanged(" + visible + ")"); 1641808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato visibilityChanged(visible); 1642808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1643808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1644808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1645808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) { 1646808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "updateExpandedViewPos after expandedPosition=" + expandedPosition 1647808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mTrackingParams.y=" + mTrackingParams.y 1648808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mTrackingPosition=" + mTrackingPosition 1649808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mExpandedParams.y=" + mExpandedParams.y 1650808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mExpandedParams.height=" + mExpandedParams.height); 1651808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1652808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1653808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1654808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int getExpandedHeight() { 1655808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return mDisplay.getHeight() - mStatusBarView.getHeight() - mCloseView.getHeight(); 1656808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1657808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1658808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void updateExpandedHeight() { 1659808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpandedView != null) { 1660808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.height = getExpandedHeight(); 1661808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().setAttributes(mExpandedParams); 1662808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1663808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1664808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 16651d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler public void userActivity() { 16661d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler try { 16671d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler mBarService.setSystemUiVisibility(View.STATUS_BAR_VISIBLE); 16681d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler } catch (RemoteException ex) { } 16691d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler } 16701d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler 16713b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka public void toggleRecentApps() { 16723b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka int msg = (mRecentsPanel.getVisibility() == View.GONE) 16733b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka ? MSG_OPEN_RECENTS_PANEL : MSG_CLOSE_RECENTS_PANEL; 16743b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mHandler.removeMessages(msg); 16753b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mHandler.sendEmptyMessage(msg); 16763b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 16773b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 1678808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /** 1679808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * The LEDs are turned o)ff when the notification panel is shown, even just a little bit. 1680808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * This was added last-minute and is inconsistent with the way the rest of the notifications 1681808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * are handled, because the notification isn't really cancelled. The lights are just 1682808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * turned off. If any other notifications happen, the lights will turn back on. Steve says 1683808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * this is what he wants. (see bug 1131461) 1684808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato */ 1685808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void visibilityChanged(boolean visible) { 1686808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mPanelSlightlyVisible != visible) { 1687808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mPanelSlightlyVisible = visible; 1688808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 1689808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mBarService.onPanelRevealed(); 1690808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (RemoteException ex) { 1691808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Won't fail unless the world has ended. 1692808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1693808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1694808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1695808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1696808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void performDisableActions(int net) { 1697808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int old = mDisabled; 1698808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int diff = net ^ old; 1699808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mDisabled = net; 1700808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1701808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // act accordingly 1702808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) { 1703808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((net & StatusBarManager.DISABLE_EXPAND) != 0) { 1704808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "DISABLE_EXPAND: yes"); 1705808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato animateCollapse(); 1706808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1707808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1708808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { 1709808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((net & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { 1710808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: yes"); 1711808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mTicking) { 1712808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mNotificationIcons.setVisibility(View.INVISIBLE); 1713808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicker.halt(); 1714808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1715808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setNotificationIconVisibility(false, com.android.internal.R.anim.fade_out); 1716808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1717808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1718808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: no"); 1719808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mExpandedVisible) { 1720808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in); 1721808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1722808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1723808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else if ((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { 1724808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mTicking && (net & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { 1725808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicker.halt(); 1726808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1727808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1728808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1729808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1730808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private View.OnClickListener mClearButtonListener = new View.OnClickListener() { 1731808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void onClick(View v) { 1732808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 1733808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mBarService.onClearAllNotifications(); 1734808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (RemoteException ex) { 1735808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // system process is dead if we're here. 1736808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1737808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato animateCollapse(); 1738808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1739808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato }; 1740808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1741808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { 1742808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void onReceive(Context context, Intent intent) { 1743808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato String action = intent.getAction(); 1744808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action) 1745808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato || Intent.ACTION_SCREEN_OFF.equals(action)) { 17463b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka boolean excludeRecents = false; 17473b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) { 1748edbdd3a024ca35c331036823dde1f484d3333b31Daniel Sandler String reason = intent.getStringExtra("reason"); 17493b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (reason != null) { 17503b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka excludeRecents = reason.equals("recentapps"); 17513b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 17523b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 17533b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka animateCollapse(excludeRecents); 1754808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1755808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) { 17568956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler repositionNavigationBar(); 1757808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateResources(); 1758808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1759808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1760808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato }; 1761808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1762808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private void setIntruderAlertVisibility(boolean vis) { 1763808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIntruderAlertView.setVisibility(vis ? View.VISIBLE : View.GONE); 1764808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1765808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1766808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /** 1767808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * Reload some of our resources when the configuration changes. 1768808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * 1769808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * We don't reload everything when the configuration changes -- we probably 1770808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * should, but getting that smooth is tough. Someday we'll fix that. In the 1771808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * meantime, just update the things that we know change. 1772808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato */ 1773808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void updateResources() { 1774f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato final Context context = mContext; 1775f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato final Resources res = context.getResources(); 1776808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1777f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato mClearButton.setText(context.getText(R.string.status_bar_clear_all_button)); 1778f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato mOngoingTitle.setText(context.getText(R.string.status_bar_ongoing_events_title)); 1779f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato mLatestTitle.setText(context.getText(R.string.status_bar_latest_events_title)); 1780f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato mNoNotificationsTitle.setText(context.getText(R.string.status_bar_no_notifications_title)); 1781808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1782808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore); 1783808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1784808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (false) Slog.v(TAG, "updateResources"); 1785808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1786808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1787808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // 1788808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // tracing 1789808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // 1790808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1791808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void postStartTracing() { 1792808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.postDelayed(mStartTracing, 3000); 1793808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1794808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1795808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void vibrate() { 1796f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato android.os.Vibrator vib = (android.os.Vibrator)mContext.getSystemService( 1797f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato Context.VIBRATOR_SERVICE); 1798808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato vib.vibrate(250); 1799808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1800808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1801808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Runnable mStartTracing = new Runnable() { 1802808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void run() { 1803808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato vibrate(); 1804808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato SystemClock.sleep(250); 1805808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "startTracing"); 1806808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato android.os.Debug.startMethodTracing("/data/statusbar-traces/trace"); 1807808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.postDelayed(mStopTracing, 10000); 1808808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1809808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato }; 1810808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1811808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Runnable mStopTracing = new Runnable() { 1812808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void run() { 1813808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato android.os.Debug.stopMethodTracing(); 1814808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "stopTracing"); 1815808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato vibrate(); 1816808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1817808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato }; 18183b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 18193b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka public class TouchOutsideListener implements View.OnTouchListener { 18203b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka private int mMsg; 18213b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka private RecentsPanelView mPanel; 18223b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 18233b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka public TouchOutsideListener(int msg, RecentsPanelView panel) { 18243b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mMsg = msg; 18253b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mPanel = panel; 18263b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 18273b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 18283b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka public boolean onTouch(View v, MotionEvent ev) { 18293b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka final int action = ev.getAction(); 18303b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (action == MotionEvent.ACTION_OUTSIDE 18313b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka || (action == MotionEvent.ACTION_DOWN 18323b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka && !mPanel.isInContentArea((int)ev.getX(), (int)ev.getY()))) { 18333b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mHandler.removeMessages(mMsg); 18343b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mHandler.sendEmptyMessage(mMsg); 18353b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka return true; 18363b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 18373b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka return false; 18383b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 18393b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 1840808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato} 1841808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1842