PhoneStatusBar.java revision d5b858639cc32d27c003d7165969ec47288b3bfa
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; 56f2a16b27afd1ede5880d05eb9e19090c7e3e820eJim Millerimport android.view.ViewGroup.LayoutParams; 57808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.Window; 58808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.WindowManager; 59808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.WindowManagerImpl; 60808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.animation.Animation; 61808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.view.animation.AnimationUtils; 62808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.widget.ImageView; 63808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.widget.LinearLayout; 64808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.widget.RemoteViews; 65808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.widget.ScrollView; 66808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.widget.TextView; 67808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport android.widget.FrameLayout; 68808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 69808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport java.io.FileDescriptor; 70808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport java.io.PrintWriter; 71808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport java.util.ArrayList; 72808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport java.util.HashMap; 73808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport java.util.Set; 74808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 75808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport com.android.internal.statusbar.StatusBarIcon; 76808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport com.android.internal.statusbar.StatusBarIconList; 77808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport com.android.internal.statusbar.StatusBarNotification; 78808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 79808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratoimport com.android.systemui.R; 803b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurkaimport com.android.systemui.recent.RecentsPanelView; 81fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onoratoimport com.android.systemui.statusbar.NotificationData; 82fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onoratoimport com.android.systemui.statusbar.StatusBar; 83fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onoratoimport com.android.systemui.statusbar.StatusBarIconView; 84fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onoratoimport com.android.systemui.statusbar.policy.DateView; 85808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 86808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 87fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onoratopublic class PhoneStatusBar extends StatusBar { 88fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato static final String TAG = "PhoneStatusBar"; 89808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato static final boolean SPEW = false; 903b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka public static final boolean DEBUG = false; 91808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 92808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public static final String ACTION_STATUSBAR_START 93808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato = "com.android.internal.policy.statusbar.START"; 94808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 95808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato static final int EXPANDED_LEAVE_ALONE = -10000; 96808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato static final int EXPANDED_FULL_OPEN = -10001; 97808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 98808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private static final int MSG_ANIMATE = 1000; 99808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private static final int MSG_ANIMATE_REVEAL = 1001; 100808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private static final int MSG_SHOW_INTRUDER = 1002; 101808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private static final int MSG_HIDE_INTRUDER = 1003; 1023b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka private static final int MSG_OPEN_RECENTS_PANEL = 1020; 1033b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka private static final int MSG_CLOSE_RECENTS_PANEL = 1021; 104808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 105808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // will likely move to a resource or other tunable param at some point 106808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private static final int INTRUDER_ALERT_DECAY_MS = 10000; 107808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 108fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato PhoneStatusBarPolicy mIconPolicy; 109808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 110808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int mIconSize; 111808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Display mDisplay; 112808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1131d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler IWindowManager mWindowManager; 1141d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler 115fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato PhoneStatusBarView mStatusBarView; 116808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int mPixelFormat; 117808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato H mHandler = new H(); 118808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Object mQueueLock = new Object(); 119808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 120808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // icons 121808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato LinearLayout mIcons; 122808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato IconMerger mNotificationIcons; 123808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato LinearLayout mStatusIcons; 124808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 125808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // expanded notifications 126808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Dialog mExpandedDialog; 127808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ExpandedView mExpandedView; 128808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManager.LayoutParams mExpandedParams; 129808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ScrollView mScrollView; 130808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato View mNotificationLinearLayout; 131808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato View mExpandedContents; 132808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // top bar 133808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato TextView mNoNotificationsTitle; 134808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato TextView mClearButton; 135808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // drag bar 136808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato CloseDragHandle mCloseView; 137808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // ongoing 138808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato NotificationData mOngoing = new NotificationData(); 139808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato TextView mOngoingTitle; 140d42497e516521891a9d6ffa0daab75ef016725f5Daniel Sandler ViewGroup mOngoingItems; 141808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // latest 142808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato NotificationData mLatest = new NotificationData(); 143808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato TextView mLatestTitle; 144d42497e516521891a9d6ffa0daab75ef016725f5Daniel Sandler ViewGroup mLatestItems; 145808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // position 146808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int[] mPositionTmp = new int[2]; 147808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean mExpanded; 148808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean mExpandedVisible; 149808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 150808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // the date view 151808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato DateView mDateView; 152808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 153808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // for immersive activities 154808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private View mIntruderAlertView; 155808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1568956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler // on-screen navigation buttons 1570129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler private NavigationBarView mNavigationBarView = null; 1588956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 159808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // the tracker view 160808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato TrackingView mTrackingView; 161808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManager.LayoutParams mTrackingParams; 162808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int mTrackingPosition; // the position of the top of the tracking view. 163808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private boolean mPanelSlightlyVisible; 164808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 165808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // ticker 166808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private Ticker mTicker; 167808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private View mTickerView; 168808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private boolean mTicking; 169808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1703b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka // Recent applications 1713b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka private RecentsPanelView mRecentsPanel; 1723b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 173808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Tracking finger for opening/closing. 174808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int mEdgeBorder; // corresponds to R.dimen.status_bar_edge_ignore 175808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean mTracking; 176808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato VelocityTracker mVelocityTracker; 177808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 178808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato static final int ANIM_FRAME_DURATION = (1000/60); 179808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 180808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean mAnimating; 181808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato long mCurAnimationTime; 182808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float mDisplayHeight; 183808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float mAnimY; 184808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float mAnimVel; 185808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float mAnimAccel; 186808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato long mAnimLastTime; 187808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean mAnimatingReveal = false; 188808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int mViewDelta; 189808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int[] mAbsPos = new int[2]; 190808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 191808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // for disabling the status bar 192808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int mDisabled = 0; 193808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 194808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private class ExpandedDialog extends Dialog { 195808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ExpandedDialog(Context context) { 196808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato super(context, com.android.internal.R.style.Theme_Light_NoTitleBar); 197808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 198808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 199808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato @Override 200808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public boolean dispatchKeyEvent(KeyEvent event) { 201808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean down = event.getAction() == KeyEvent.ACTION_DOWN; 202808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato switch (event.getKeyCode()) { 203808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato case KeyEvent.KEYCODE_BACK: 204808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!down) { 205808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato animateCollapse(); 206808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 207808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return true; 208808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 209808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return super.dispatchKeyEvent(event); 210808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 211808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 212808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 213808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato @Override 214f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato public void start() { 215f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)) 216f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato .getDefaultDisplay(); 217808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 2181d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler mWindowManager = IWindowManager.Stub.asInterface( 2191d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler ServiceManager.getService(Context.WINDOW_SERVICE)); 2201d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler 221f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato super.start(); 222808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 2238956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler addNavigationBar(); 2248956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 2258956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler //addIntruderView(); 226808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 227808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Lastly, call to the icon policy to install/update all the icons. 228fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato mIconPolicy = new PhoneStatusBarPolicy(mContext); 229808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 230808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 231808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // ================================================================================ 232808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Constructing the view 233808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // ================================================================================ 234808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato protected View makeStatusBarView() { 235f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato final Context context = mContext; 236808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 237808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Resources res = context.getResources(); 238808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 239808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size); 240808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 241808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ExpandedView expanded = (ExpandedView)View.inflate(context, 242808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato R.layout.status_bar_expanded, null); 243808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato expanded.mService = this; 244808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 245808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIntruderAlertView = View.inflate(context, R.layout.intruder_alert, null); 246808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIntruderAlertView.setVisibility(View.GONE); 247808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIntruderAlertView.setClickable(true); 248808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 2490129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler try { 2508c4706252228755ed181d19532b7e0cfec270ba4Adam Powell boolean showNav = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar); 2510129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler if (showNav) { 2520129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler mNavigationBarView = 2530129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler (NavigationBarView) View.inflate(context, R.layout.navigation_bar, null); 2540129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler } 2550129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler } catch (Resources.NotFoundException ex) { 2560129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler // no nav bar for you 2570129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler } 2588956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 259fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato PhoneStatusBarView sb = (PhoneStatusBarView)View.inflate(context, 260fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato R.layout.status_bar, null); 261808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato sb.mService = this; 262808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 263808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // figure out which pixel-format to use for the status bar. 264808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mPixelFormat = PixelFormat.TRANSLUCENT; 265808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Drawable bg = sb.getBackground(); 266808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (bg != null) { 267808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mPixelFormat = bg.getOpacity(); 268808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 269808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 270808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mStatusBarView = sb; 271808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mStatusIcons = (LinearLayout)sb.findViewById(R.id.statusIcons); 272808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mNotificationIcons = (IconMerger)sb.findViewById(R.id.notificationIcons); 273808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIcons = (LinearLayout)sb.findViewById(R.id.icons); 274808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickerView = sb.findViewById(R.id.ticker); 275808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mDateView = (DateView)sb.findViewById(R.id.date); 276808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 277808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog = new ExpandedDialog(context); 278808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedView = expanded; 279808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedContents = expanded.findViewById(R.id.notificationLinearLayout); 280808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mOngoingTitle = (TextView)expanded.findViewById(R.id.ongoingTitle); 281d42497e516521891a9d6ffa0daab75ef016725f5Daniel Sandler mOngoingItems = (ViewGroup)expanded.findViewById(R.id.ongoingItems); 282808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mLatestTitle = (TextView)expanded.findViewById(R.id.latestTitle); 283d42497e516521891a9d6ffa0daab75ef016725f5Daniel Sandler mLatestItems = (ViewGroup)expanded.findViewById(R.id.latestItems); 284808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mNoNotificationsTitle = (TextView)expanded.findViewById(R.id.noNotificationsTitle); 285808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mClearButton = (TextView)expanded.findViewById(R.id.clear_all_button); 286808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mClearButton.setOnClickListener(mClearButtonListener); 287808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mScrollView = (ScrollView)expanded.findViewById(R.id.scroll); 288808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mNotificationLinearLayout = expanded.findViewById(R.id.notificationLinearLayout); 289808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 290808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mOngoingTitle.setVisibility(View.GONE); 291808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mLatestTitle.setVisibility(View.GONE); 292808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 293808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicker = new MyTicker(context, sb); 294808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 295808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato TickerView tickerView = (TickerView)sb.findViewById(R.id.tickerText); 296808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato tickerView.mTicker = mTicker; 297808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 298808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingView = (TrackingView)View.inflate(context, R.layout.status_bar_tracking, null); 299808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingView.mService = this; 300808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCloseView = (CloseDragHandle)mTrackingView.findViewById(R.id.close); 301808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCloseView.mService = this; 302808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 303808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore); 304808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 305808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // set the inital view visibility 306808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setAreThereNotifications(); 307808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mDateView.setVisibility(View.INVISIBLE); 308808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 3093b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka // Recents Panel 31017dfec7111fcc53a4f6ae6e92b4a7f85a278fe71Jim Miller updateRecentsPanel(); 3113b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 312808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // receive broadcasts 313808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato IntentFilter filter = new IntentFilter(); 314808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); 315808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); 316808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato filter.addAction(Intent.ACTION_SCREEN_OFF); 317808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato context.registerReceiver(mBroadcastReceiver, filter); 318808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 319808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return sb; 320808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 321808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 322f2a16b27afd1ede5880d05eb9e19090c7e3e820eJim Miller protected WindowManager.LayoutParams getRecentsLayoutParams(LayoutParams layoutParams) { 3233b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka boolean translucent = false; 3243b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka WindowManager.LayoutParams lp = new WindowManager.LayoutParams( 325f2a16b27afd1ede5880d05eb9e19090c7e3e820eJim Miller layoutParams.width, 326f2a16b27afd1ede5880d05eb9e19090c7e3e820eJim Miller layoutParams.height, 3273b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, 3283b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 3293b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM 3303b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH 3313b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 3323b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka (translucent ? PixelFormat.OPAQUE : PixelFormat.TRANSLUCENT)); 3333b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka lp.gravity = Gravity.BOTTOM | Gravity.LEFT; 3343b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka lp.setTitle("RecentsPanel"); 3353b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka lp.windowAnimations = R.style.Animation_RecentPanel; 3363b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED 3373b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; 3383b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka return lp; 3393b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 3403b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 34117dfec7111fcc53a4f6ae6e92b4a7f85a278fe71Jim Miller protected void updateRecentsPanel() { 3423b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka // Recents Panel 3433b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka boolean visible = false; 3443b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (mRecentsPanel != null) { 3453b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka visible = mRecentsPanel.getVisibility() == View.VISIBLE; 3463b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka WindowManagerImpl.getDefault().removeView(mRecentsPanel); 3473b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 348f2a16b27afd1ede5880d05eb9e19090c7e3e820eJim Miller 349f2a16b27afd1ede5880d05eb9e19090c7e3e820eJim Miller // Provide RecentsPanelView with a temporary parent to allow layout params to work. 350f2a16b27afd1ede5880d05eb9e19090c7e3e820eJim Miller LinearLayout tmpRoot = new LinearLayout(mContext); 351f2a16b27afd1ede5880d05eb9e19090c7e3e820eJim Miller mRecentsPanel = (RecentsPanelView) LayoutInflater.from(mContext).inflate( 352f2a16b27afd1ede5880d05eb9e19090c7e3e820eJim Miller R.layout.status_bar_recent_panel, tmpRoot, false); 3533b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 3543b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel.setOnTouchListener(new TouchOutsideListener(MSG_CLOSE_RECENTS_PANEL, 3553b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel)); 3563b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel.setVisibility(View.GONE); 357f2a16b27afd1ede5880d05eb9e19090c7e3e820eJim Miller WindowManager.LayoutParams lp = getRecentsLayoutParams(mRecentsPanel.getLayoutParams()); 3583b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 3593b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka WindowManagerImpl.getDefault().addView(mRecentsPanel, lp); 3603b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel.setBar(this); 3613b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (visible) { 3623b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka // need to set visibility to View.GONE earlier since that 3633b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka // triggers refreshing application list 3643b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel.setVisibility(View.VISIBLE); 3653b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel.show(true, false); 3663b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 3673b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 3683b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 3693b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 370808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato protected int getStatusBarGravity() { 371808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return Gravity.TOP | Gravity.FILL_HORIZONTAL; 372808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 373808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 374dc10030581d6eec1c96acd62ed511f91d25d73a1Joe Onorato public int getStatusBarHeight() { 375f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato final Resources res = mContext.getResources(); 376dc10030581d6eec1c96acd62ed511f91d25d73a1Joe Onorato return res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); 377dc10030581d6eec1c96acd62ed511f91d25d73a1Joe Onorato } 378dc10030581d6eec1c96acd62ed511f91d25d73a1Joe Onorato 3795c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler private View.OnClickListener mRecentsClickListener = new View.OnClickListener() { 3805c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler public void onClick(View v) { 3815c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler toggleRecentApps(); 3825c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler } 3835c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler }; 3845c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler 3858956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler // For small-screen devices (read: phones) that lack hardware navigation buttons 3868956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler private void addNavigationBar() { 3870129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler if (mNavigationBarView == null) return; 38817dfec7111fcc53a4f6ae6e92b4a7f85a278fe71Jim Miller 3898956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler mNavigationBarView.reorient(); 39017dfec7111fcc53a4f6ae6e92b4a7f85a278fe71Jim Miller 3915c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler mNavigationBarView.getRecentsButton().setOnClickListener(mRecentsClickListener); 3925c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler 3938956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler WindowManagerImpl.getDefault().addView( 3948956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler mNavigationBarView, getNavigationBarLayoutParams()); 3958956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler } 3968956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 3978956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler private void repositionNavigationBar() { 3980129b31ff493bb0aa10b778cbeacbec5964644f8Daniel Sandler if (mNavigationBarView == null) return; 39917dfec7111fcc53a4f6ae6e92b4a7f85a278fe71Jim Miller 4008956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler mNavigationBarView.reorient(); 4015c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler 4025c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler mNavigationBarView.getRecentsButton().setOnClickListener(mRecentsClickListener); 4035c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler 4048956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler WindowManagerImpl.getDefault().updateViewLayout( 4058956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler mNavigationBarView, getNavigationBarLayoutParams()); 4068956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler } 4078956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 4088956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler private WindowManager.LayoutParams getNavigationBarLayoutParams() { 4098956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler final int rotation = mDisplay.getRotation(); 4108956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler final boolean sideways = 4118956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270); 4128956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 4138956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler final Resources res = mContext.getResources(); 4148956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler final int size = res.getDimensionPixelSize(R.dimen.navigation_bar_size); 4158956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 4168956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler WindowManager.LayoutParams lp = new WindowManager.LayoutParams( 4178956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler sideways ? size : ViewGroup.LayoutParams.MATCH_PARENT, 4188956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler sideways ? ViewGroup.LayoutParams.MATCH_PARENT : size, 4198956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler WindowManager.LayoutParams.TYPE_NAVIGATION_BAR, 4208956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 0 4218956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 4228956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS 4238956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler | WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING 4248956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE 42598db5fabdad86dca379740d8050697950b9f026cJeff Brown | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH 42698db5fabdad86dca379740d8050697950b9f026cJeff Brown | WindowManager.LayoutParams.FLAG_SLIPPERY, 4278956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler PixelFormat.TRANSLUCENT); 4288956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 4298956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler lp.setTitle("NavigationBar"); 4308956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler switch (rotation) { 4318956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler case Surface.ROTATION_90: 4328956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler // device has been turned 90deg counter-clockwise 4338956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler lp.gravity = Gravity.RIGHT | Gravity.FILL_VERTICAL; 4348956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler break; 4358956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler case Surface.ROTATION_270: 4368956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler // device has been turned 90deg clockwise 437f86f898f8afe73d81b34543dcb2c30d8bf7da563Daniel Sandler lp.gravity = (NavigationBarView.NAVBAR_ALWAYS_AT_RIGHT ? Gravity.RIGHT 438f86f898f8afe73d81b34543dcb2c30d8bf7da563Daniel Sandler : Gravity.LEFT) 439f86f898f8afe73d81b34543dcb2c30d8bf7da563Daniel Sandler | Gravity.FILL_VERTICAL; 4408956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler break; 4418956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler default: 4428956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler lp.gravity = Gravity.BOTTOM | Gravity.FILL_HORIZONTAL; 4438956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler break; 4448956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler } 4458956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler lp.windowAnimations = 0; 4468956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 4478956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler return lp; 4488956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler } 4498956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler 450dc10030581d6eec1c96acd62ed511f91d25d73a1Joe Onorato private void addIntruderView() { 451dc10030581d6eec1c96acd62ed511f91d25d73a1Joe Onorato final int height = getStatusBarHeight(); 452808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 453808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManager.LayoutParams lp = new WindowManager.LayoutParams( 454808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ViewGroup.LayoutParams.MATCH_PARENT, 455808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ViewGroup.LayoutParams.WRAP_CONTENT, 45629fc2c9705e1bb8ae098fca016032d2325031587Joe Onorato WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL, 457808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 458808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS 459808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL 460808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE 46146e75294d540fe807d78aec2582ae02cc38c7d42Jeff Brown | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM 46246e75294d540fe807d78aec2582ae02cc38c7d42Jeff Brown | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, 463808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato PixelFormat.TRANSLUCENT); 464808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.gravity = Gravity.TOP | Gravity.FILL_HORIZONTAL; 465808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.y += height * 1.5; // FIXME 466808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.setTitle("IntruderAlert"); 467808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.windowAnimations = com.android.internal.R.style.Animation_StatusBar_IntruderAlert; 468808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 469808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManagerImpl.getDefault().addView(mIntruderAlertView, lp); 470808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 471808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 472808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void addIcon(String slot, int index, int viewIndex, StatusBarIcon icon) { 473808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "addIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex 474808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " icon=" + icon); 4756179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov StatusBarIconView view = new StatusBarIconView(mContext, slot, null); 476808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato view.set(icon); 477808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mStatusIcons.addView(view, viewIndex, new LinearLayout.LayoutParams(mIconSize, mIconSize)); 478808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 479808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 480808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void updateIcon(String slot, int index, int viewIndex, 481808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato StatusBarIcon old, StatusBarIcon icon) { 482808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "updateIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex 483808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " old=" + old + " icon=" + icon); 484808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato StatusBarIconView view = (StatusBarIconView)mStatusIcons.getChildAt(viewIndex); 485808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato view.set(icon); 486808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 487808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 488808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void removeIcon(String slot, int index, int viewIndex) { 489808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "removeIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex); 490808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mStatusIcons.removeViewAt(viewIndex); 491808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 492808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 493808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void addNotification(IBinder key, StatusBarNotification notification) { 494808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato StatusBarIconView iconView = addNotificationViews(key, notification); 495808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (iconView == null) return; 496808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 497808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean immersive = false; 498808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 499808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato immersive = ActivityManagerNative.getDefault().isTopActivityImmersive(); 500808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "Top activity is " + (immersive?"immersive":"not immersive")); 501808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (RemoteException ex) { 502808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 503808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (immersive) { 504808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((notification.notification.flags & Notification.FLAG_HIGH_PRIORITY) != 0) { 505808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "Presenting high-priority notification in immersive activity"); 506379020aec619c66d3e040de01f0726687fd2ad85Daniel Sandler // special new transient ticker mode 507808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // 1. Populate mIntruderAlertView 508808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 509808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ImageView alertIcon = (ImageView) mIntruderAlertView.findViewById(R.id.alertIcon); 510808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato TextView alertText = (TextView) mIntruderAlertView.findViewById(R.id.alertText); 511808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato alertIcon.setImageDrawable(StatusBarIconView.getIcon( 512808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato alertIcon.getContext(), 513808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato iconView.getStatusBarIcon())); 514808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato alertText.setText(notification.notification.tickerText); 515808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 516808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato View button = mIntruderAlertView.findViewById(R.id.intruder_alert_content); 517808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato button.setOnClickListener( 518808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato new Launcher(notification.notification.contentIntent, 519808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato notification.pkg, notification.tag, notification.id)); 520808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 521808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // 2. Animate mIntruderAlertView in 522808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.sendEmptyMessage(MSG_SHOW_INTRUDER); 523808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 524808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // 3. Set alarm to age the notification off (TODO) 525808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.removeMessages(MSG_HIDE_INTRUDER); 526808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.sendEmptyMessageDelayed(MSG_HIDE_INTRUDER, INTRUDER_ALERT_DECAY_MS); 527808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 528808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else if (notification.notification.fullScreenIntent != null) { 529808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // not immersive & a full-screen alert should be shown 530808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "Notification has fullScreenIntent and activity is not immersive;" 531808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " sending fullScreenIntent"); 532808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 533808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato notification.notification.fullScreenIntent.send(); 534808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (PendingIntent.CanceledException e) { 535808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 536808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 537808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // usual case: status bar visible & not immersive 538808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 539808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // show the ticker 540808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato tick(notification); 541808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 542808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 543808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Recalculate the position of the sliding windows and the titles. 544808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setAreThereNotifications(); 545808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(EXPANDED_LEAVE_ALONE); 546808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 547808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 548808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void updateNotification(IBinder key, StatusBarNotification notification) { 549808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "updateNotification key=" + key + " notification=" + notification); 550808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 551808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato NotificationData oldList; 552379020aec619c66d3e040de01f0726687fd2ad85Daniel Sandler NotificationData.Entry oldEntry = mOngoing.findByKey(key); 553379020aec619c66d3e040de01f0726687fd2ad85Daniel Sandler if (oldEntry != null) { 554808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato oldList = mOngoing; 555808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 556379020aec619c66d3e040de01f0726687fd2ad85Daniel Sandler oldEntry = mLatest.findByKey(key); 557379020aec619c66d3e040de01f0726687fd2ad85Daniel Sandler if (oldEntry == null) { 558808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.w(TAG, "updateNotification for unknown key: " + key); 559808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 560808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 561808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato oldList = mLatest; 562808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 563808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final StatusBarNotification oldNotification = oldEntry.notification; 564808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final RemoteViews oldContentView = oldNotification.notification.contentView; 565808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 566808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final RemoteViews contentView = notification.notification.contentView; 567808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 56820cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler if (DEBUG) { 569808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "old notification: when=" + oldNotification.notification.when 570808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " ongoing=" + oldNotification.isOngoing() 571808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " expanded=" + oldEntry.expanded 57220cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler + " contentView=" + oldContentView 57320cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler + " rowParent=" + oldEntry.row.getParent()); 574808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "new notification: when=" + notification.notification.when 575808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " ongoing=" + oldNotification.isOngoing() 576808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " contentView=" + contentView); 577808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 578808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 57920cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler 580808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Can we just reapply the RemoteViews in place? If when didn't change, the order 581808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // didn't change. 58220cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler boolean contentsUnchanged = oldEntry.expanded != null 583808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato && contentView != null && oldContentView != null 584808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato && contentView.getPackage() != null 585808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato && oldContentView.getPackage() != null 586808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato && oldContentView.getPackage().equals(contentView.getPackage()) 58720cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler && oldContentView.getLayoutId() == contentView.getLayoutId(); 58820cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler ViewGroup rowParent = (ViewGroup) oldEntry.row.getParent(); 58920cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler boolean orderUnchanged = notification.notification.when==oldNotification.notification.when 59020cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler && notification.priority == oldNotification.priority; 59120cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler // priority now encompasses isOngoing() 59220cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler boolean isLastAnyway = rowParent.indexOfChild(oldEntry.row) == rowParent.getChildCount()-1; 59320cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler if (contentsUnchanged && (orderUnchanged || isLastAnyway)) { 59420cdb151c9f1a956eee9eebe77459e14029ad131Daniel Sandler if (DEBUG) Slog.d(TAG, "reusing notification for key: " + key); 595808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato oldEntry.notification = notification; 596808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 597808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Reapply the RemoteViews 598f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato contentView.reapply(mContext, oldEntry.content); 599808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // update the contentIntent 600808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final PendingIntent contentIntent = notification.notification.contentIntent; 601808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (contentIntent != null) { 602808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato oldEntry.content.setOnClickListener(new Launcher(contentIntent, 603808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato notification.pkg, notification.tag, notification.id)); 604184498ce5a8d77e1d9c45693363829daaeef9611Joe Onorato } else { 605184498ce5a8d77e1d9c45693363829daaeef9611Joe Onorato oldEntry.content.setOnClickListener(null); 606808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 607808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Update the icon. 608808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final StatusBarIcon ic = new StatusBarIcon(notification.pkg, 609808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato notification.notification.icon, notification.notification.iconLevel, 6106179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov notification.notification.number, notification.notification.tickerText); 611808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!oldEntry.icon.set(ic)) { 612808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato handleNotificationError(key, notification, "Couldn't update icon: " + ic); 613808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 614808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 615d5b858639cc32d27c003d7165969ec47288b3bfaDaniel Sandler // Update the large icon 616d5b858639cc32d27c003d7165969ec47288b3bfaDaniel Sandler if (notification.notification.largeIcon != null) { 617d5b858639cc32d27c003d7165969ec47288b3bfaDaniel Sandler oldEntry.largeIcon.setImageBitmap(notification.notification.largeIcon); 618d5b858639cc32d27c003d7165969ec47288b3bfaDaniel Sandler } else { 619d5b858639cc32d27c003d7165969ec47288b3bfaDaniel Sandler oldEntry.largeIcon.getLayoutParams().width = 0; 620d5b858639cc32d27c003d7165969ec47288b3bfaDaniel Sandler oldEntry.largeIcon.setVisibility(View.INVISIBLE); 621d5b858639cc32d27c003d7165969ec47288b3bfaDaniel Sandler } 622d5b858639cc32d27c003d7165969ec47288b3bfaDaniel Sandler 623808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 624808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato catch (RuntimeException e) { 625808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // It failed to add cleanly. Log, and remove the view from the panel. 626808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.w(TAG, "Couldn't reapply views for package " + contentView.getPackage(), e); 627808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato removeNotificationViews(key); 628808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato addNotificationViews(key, notification); 629808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 630808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 631808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "not reusing notification"); 632808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato removeNotificationViews(key); 633808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato addNotificationViews(key, notification); 634808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 635808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 636808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Restart the ticker if it's still running 637935865923fdad9f47061ff0aedfe92d0b912d5d6Joe Onorato if (notification.notification.tickerText != null 638935865923fdad9f47061ff0aedfe92d0b912d5d6Joe Onorato && !TextUtils.equals(notification.notification.tickerText, 639935865923fdad9f47061ff0aedfe92d0b912d5d6Joe Onorato oldEntry.notification.notification.tickerText)) { 640935865923fdad9f47061ff0aedfe92d0b912d5d6Joe Onorato tick(notification); 641935865923fdad9f47061ff0aedfe92d0b912d5d6Joe Onorato } 642808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 643808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Recalculate the position of the sliding windows and the titles. 644808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setAreThereNotifications(); 645808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(EXPANDED_LEAVE_ALONE); 646808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 647808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 648808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void removeNotification(IBinder key) { 649808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "removeNotification key=" + key); 650808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato StatusBarNotification old = removeNotificationViews(key); 651808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 652808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (old != null) { 653808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Cancel the ticker if it's still running 654808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicker.removeEntry(old); 655808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 656808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Recalculate the position of the sliding windows and the titles. 657808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setAreThereNotifications(); 658808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(EXPANDED_LEAVE_ALONE); 659808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 660808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 661808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 662808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private int chooseIconIndex(boolean isOngoing, int viewIndex) { 663808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int latestSize = mLatest.size(); 664808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (isOngoing) { 665808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return latestSize + (mOngoing.size() - viewIndex); 666808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 667808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return latestSize - viewIndex; 668808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 669808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 670808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 6713b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka @Override 6723b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka protected void onConfigurationChanged(Configuration newConfig) { 67317dfec7111fcc53a4f6ae6e92b4a7f85a278fe71Jim Miller updateRecentsPanel(); 6743b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 6753b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 6763b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 677808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato View[] makeNotificationView(StatusBarNotification notification, ViewGroup parent) { 678808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Notification n = notification.notification; 679808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato RemoteViews remoteViews = n.contentView; 680808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (remoteViews == null) { 681808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return null; 682808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 683808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 684808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // create the row view 685f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato LayoutInflater inflater = (LayoutInflater)mContext.getSystemService( 686f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato Context.LAYOUT_INFLATER_SERVICE); 687755cc74e4cebdf67d21a2477512a4ac9b01e8323Joe Onorato View row = inflater.inflate(R.layout.status_bar_notification_row, parent, false); 688808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 689b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler // wire up the veto button 690b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler View vetoButton = row.findViewById(R.id.veto); 691b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler if (notification.isClearable()) { 692b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler final String _pkg = notification.pkg; 693b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler final String _tag = notification.tag; 694b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler final int _id = notification.id; 695b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler vetoButton.setOnClickListener(new View.OnClickListener() { 696b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler public void onClick(View v) { 697b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler try { 698b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler mBarService.onNotificationClear(_pkg, _tag, _id); 699b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } catch (RemoteException ex) { 700b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler // system process is dead if we're here. 701b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } 702b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } 703b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler }); 704b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } else { 705b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler if ((notification.notification.flags & Notification.FLAG_ONGOING_EVENT) == 0) { 706b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler vetoButton.setVisibility(View.INVISIBLE); 707b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } else { 708b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler vetoButton.setVisibility(View.GONE); 709b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } 710b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } 711b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler 712b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler // the large icon 713b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler ImageView largeIcon = (ImageView)row.findViewById(R.id.large_icon); 714b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler if (notification.notification.largeIcon != null) { 715b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler largeIcon.setImageBitmap(notification.notification.largeIcon); 716b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } else { 717b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler largeIcon.getLayoutParams().width = 0; 718b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler largeIcon.setVisibility(View.INVISIBLE); 719b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler } 720b48e74b10c3ef14d6c30381d8893abaddd50f2b2Daniel Sandler 721808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // bind the click event to the content area 722808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ViewGroup content = (ViewGroup)row.findViewById(R.id.content); 723808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato content.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); 724808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato content.setOnFocusChangeListener(mFocusChangeListener); 725808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato PendingIntent contentIntent = n.contentIntent; 726808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (contentIntent != null) { 727808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato content.setOnClickListener(new Launcher(contentIntent, notification.pkg, 728808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato notification.tag, notification.id)); 729184498ce5a8d77e1d9c45693363829daaeef9611Joe Onorato } else { 730184498ce5a8d77e1d9c45693363829daaeef9611Joe Onorato content.setOnClickListener(null); 731808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 732808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 733808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato View expanded = null; 734808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Exception exception = null; 735808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 736f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato expanded = remoteViews.apply(mContext, content); 737808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 738808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato catch (RuntimeException e) { 739808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato exception = e; 740808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 741808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (expanded == null) { 742808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato String ident = notification.pkg + "/0x" + Integer.toHexString(notification.id); 743808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.e(TAG, "couldn't inflate view for notification " + ident, exception); 744808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return null; 745808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 746808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato content.addView(expanded); 747808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato row.setDrawingCacheEnabled(true); 748808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 749808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 750808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return new View[] { row, content, expanded }; 751808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 752808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 753808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato StatusBarIconView addNotificationViews(IBinder key, StatusBarNotification notification) { 754808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato NotificationData list; 755808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ViewGroup parent; 756808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final boolean isOngoing = notification.isOngoing(); 757808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (isOngoing) { 758808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato list = mOngoing; 759808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato parent = mOngoingItems; 760808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 761808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato list = mLatest; 762808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato parent = mLatestItems; 763808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 764808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Construct the expanded view. 765808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final View[] views = makeNotificationView(notification, parent); 766808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (views == null) { 767808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato handleNotificationError(key, notification, "Couldn't expand RemoteViews for: " 768808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + notification); 769808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return null; 770808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 771808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final View row = views[0]; 772808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final View content = views[1]; 773808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final View expanded = views[2]; 774808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Construct the icon. 775f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato final StatusBarIconView iconView = new StatusBarIconView(mContext, 7766179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov notification.pkg + "/0x" + Integer.toHexString(notification.id), 7776179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov notification.notification); 778808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final StatusBarIcon ic = new StatusBarIcon(notification.pkg, notification.notification.icon, 7796179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov notification.notification.iconLevel, notification.notification.number, 7806179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov notification.notification.tickerText); 781808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!iconView.set(ic)) { 782808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato handleNotificationError(key, notification, "Coulding create icon: " + ic); 783808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return null; 784808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 785808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Add the expanded view. 786808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int viewIndex = list.add(key, notification, row, content, expanded, iconView); 787808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato parent.addView(row, viewIndex); 788808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Add the icon. 789808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int iconIndex = chooseIconIndex(isOngoing, viewIndex); 790066b5c5166c1f5342bd42aa0d68f784a5f4c1dd1Joe Onorato mNotificationIcons.addView(iconView, iconIndex); 791808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return iconView; 792808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 793808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 794808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato StatusBarNotification removeNotificationViews(IBinder key) { 795808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato NotificationData.Entry entry = mOngoing.remove(key); 796808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (entry == null) { 797808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato entry = mLatest.remove(key); 798808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (entry == null) { 799808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.w(TAG, "removeNotification for unknown key: " + key); 800808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return null; 801808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 802808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 803808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Remove the expanded view. 804808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ((ViewGroup)entry.row.getParent()).removeView(entry.row); 805808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Remove the icon. 806808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ((ViewGroup)entry.icon.getParent()).removeView(entry.icon); 807808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 808808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return entry.notification; 809808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 810808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 811808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private void setAreThereNotifications() { 812808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean ongoing = mOngoing.hasVisibleItems(); 813808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean latest = mLatest.hasVisibleItems(); 814808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 815808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // (no ongoing notifications are clearable) 816808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mLatest.hasClearableItems()) { 817808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mClearButton.setVisibility(View.VISIBLE); 818808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 819808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mClearButton.setVisibility(View.INVISIBLE); 820808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 821808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 822808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mOngoingTitle.setVisibility(ongoing ? View.VISIBLE : View.GONE); 823808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mLatestTitle.setVisibility(latest ? View.VISIBLE : View.GONE); 824808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 825808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (ongoing || latest) { 826808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mNoNotificationsTitle.setVisibility(View.GONE); 827808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 828808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mNoNotificationsTitle.setVisibility(View.VISIBLE); 829808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 830808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 831808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 832808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 833808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /** 834808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * State is one or more of the DISABLE constants from StatusBarManager. 835808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato */ 836808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void disable(int state) { 837808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int old = mDisabled; 838808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int diff = state ^ old; 839808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mDisabled = state; 840808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 841808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) { 842808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((state & StatusBarManager.DISABLE_EXPAND) != 0) { 843808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "DISABLE_EXPAND: yes"); 844808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato animateCollapse(); 845808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 846808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 847808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { 848808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { 849808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: yes"); 850808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mTicking) { 851808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicker.halt(); 852808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 853808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setNotificationIconVisibility(false, com.android.internal.R.anim.fade_out); 854808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 855808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 856808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: no"); 857808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mExpandedVisible) { 858808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in); 859808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 860808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 861808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else if ((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { 862808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mTicking && (state & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { 863808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "DISABLE_NOTIFICATION_TICKER: yes"); 864808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicker.halt(); 865808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 866808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 867808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 868808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 869808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /** 870808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * All changes to the status bar and notifications funnel through here and are batched. 871808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato */ 872808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private class H extends Handler { 873808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void handleMessage(Message m) { 874808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato switch (m.what) { 875808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato case MSG_ANIMATE: 876808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato doAnimation(); 877808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato break; 878808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato case MSG_ANIMATE_REVEAL: 879808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato doRevealAnimation(); 880808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato break; 881808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato case MSG_SHOW_INTRUDER: 882808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setIntruderAlertVisibility(true); 883808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato break; 884808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato case MSG_HIDE_INTRUDER: 885808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setIntruderAlertVisibility(false); 886808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato break; 8873b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka case MSG_OPEN_RECENTS_PANEL: 8883b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (DEBUG) Slog.d(TAG, "opening recents panel"); 8893b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (mRecentsPanel != null) { 8903b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka disable(StatusBarManager.DISABLE_BACK); 8913b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel.setVisibility(View.VISIBLE); 8923b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel.show(true, true); 8933b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 8943b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka break; 8953b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka case MSG_CLOSE_RECENTS_PANEL: 8963b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (DEBUG) Slog.d(TAG, "closing recents panel"); 8973b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (mRecentsPanel != null && mRecentsPanel.isShowing()) { 8983b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka disable(StatusBarManager.DISABLE_NONE); 8993b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mRecentsPanel.show(false, true); 9003b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 9013b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka break; 902808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 903808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 904808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 905808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 906808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato View.OnFocusChangeListener mFocusChangeListener = new View.OnFocusChangeListener() { 907808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void onFocusChange(View v, boolean hasFocus) { 908808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Because 'v' is a ViewGroup, all its children will be (un)selected 909808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // too, which allows marqueeing to work. 910808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato v.setSelected(hasFocus); 911808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 912808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato }; 913808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 914808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private void makeExpandedVisible() { 915808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "Make expanded visible: expanded visible=" + mExpandedVisible); 916808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpandedVisible) { 917808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 918808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 919808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedVisible = true; 920808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato visibilityChanged(true); 921808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 922808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(EXPANDED_LEAVE_ALONE); 923808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; 924808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; 925808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().setAttributes(mExpandedParams); 926808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedView.requestFocus(View.FOCUS_FORWARD); 927808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingView.setVisibility(View.VISIBLE); 928808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 929808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mTicking) { 930808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setDateViewVisibility(true, com.android.internal.R.anim.fade_in); 931808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 932808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 933808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 934808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void animateExpand() { 935808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "Animate expand: expanded=" + mExpanded); 936808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) { 937808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return ; 938808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 939808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpanded) { 940808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 941808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 942808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 943808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato prepareTracking(0, true); 944808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato performFling(0, 2000.0f, true); 945808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 946808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 947808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void animateCollapse() { 9483b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka animateCollapse(false); 9493b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 9503b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 9513b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka public void animateCollapse(boolean excludeRecents) { 952808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) { 953808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "animateCollapse(): mExpanded=" + mExpanded 954808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mExpandedVisible=" + mExpandedVisible 955808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mExpanded=" + mExpanded 956808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mAnimating=" + mAnimating 957808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mAnimY=" + mAnimY 958808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mAnimVel=" + mAnimVel); 959808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 960808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 9613b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (!excludeRecents) { 9623b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mHandler.removeMessages(MSG_CLOSE_RECENTS_PANEL); 9633b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL); 9643b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 9653b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 966808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mExpandedVisible) { 967808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 968808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 969808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 970808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int y; 971808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mAnimating) { 972808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato y = (int)mAnimY; 973808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 974808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato y = mDisplay.getHeight()-1; 975808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 976808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Let the fling think that we're open so it goes in the right direction 977808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // and doesn't try to re-open the windowshade. 978808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpanded = true; 979808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato prepareTracking(y, false); 980808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato performFling(y, -2000.0f, true); 981808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 982808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 983808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void performExpand() { 984808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "performExpand: mExpanded=" + mExpanded); 985808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) { 986808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return ; 987808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 988808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpanded) { 989808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 990808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 991808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 992808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpanded = true; 993808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato makeExpandedVisible(); 994808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(EXPANDED_FULL_OPEN); 995808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 996808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (false) postStartTracing(); 997808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 998808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 999808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void performCollapse() { 1000808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "performCollapse: mExpanded=" + mExpanded 1001808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mExpandedVisible=" + mExpandedVisible); 1002808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1003808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mExpandedVisible) { 1004808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 1005808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1006808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedVisible = false; 1007808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato visibilityChanged(false); 1008808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; 1009808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.flags &= ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; 1010808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().setAttributes(mExpandedParams); 1011808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingView.setVisibility(View.GONE); 1012808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1013808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((mDisabled & StatusBarManager.DISABLE_NOTIFICATION_ICONS) == 0) { 1014808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in); 1015808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1016808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setDateViewVisibility(false, com.android.internal.R.anim.fade_out); 1017808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1018808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mExpanded) { 1019808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 1020808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1021808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpanded = false; 1022808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1023808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1024808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void doAnimation() { 1025808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mAnimating) { 1026808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "doAnimation"); 1027808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "doAnimation before mAnimY=" + mAnimY); 1028808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato incrementAnim(); 1029808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "doAnimation after mAnimY=" + mAnimY); 1030808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mAnimY >= mDisplay.getHeight()-1) { 1031808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "Animation completed to expanded state."); 1032808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimating = false; 1033808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(EXPANDED_FULL_OPEN); 1034808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato performExpand(); 1035808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1036808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato else if (mAnimY < mStatusBarView.getHeight()) { 1037808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "Animation completed to collapsed state."); 1038808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimating = false; 1039808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(0); 1040808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato performCollapse(); 1041808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1042808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato else { 1043808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos((int)mAnimY); 1044808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCurAnimationTime += ANIM_FRAME_DURATION; 1045808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.sendMessageAtTime(mHandler.obtainMessage(MSG_ANIMATE), mCurAnimationTime); 1046808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1047808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1048808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1049808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1050808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void stopTracking() { 1051808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTracking = false; 1052808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mVelocityTracker.recycle(); 1053808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mVelocityTracker = null; 1054808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1055808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1056808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void incrementAnim() { 1057808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato long now = SystemClock.uptimeMillis(); 1058808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float t = ((float)(now - mAnimLastTime)) / 1000; // ms -> s 1059808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final float y = mAnimY; 1060808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final float v = mAnimVel; // px/s 1061808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final float a = mAnimAccel; // px/s/s 1062808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimY = y + (v*t) + (0.5f*a*t*t); // px 1063808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimVel = v + (a*t); // px/s 1064808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimLastTime = now; // ms 1065808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato //Slog.d(TAG, "y=" + y + " v=" + v + " a=" + a + " t=" + t + " mAnimY=" + mAnimY 1066808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // + " mAnimAccel=" + mAnimAccel); 1067808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1068808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1069808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void doRevealAnimation() { 1070808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int h = mCloseView.getHeight() + mStatusBarView.getHeight(); 1071808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mAnimatingReveal && mAnimating && mAnimY < h) { 1072808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato incrementAnim(); 1073808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mAnimY >= h) { 1074808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimY = h; 1075808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos((int)mAnimY); 1076808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1077808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos((int)mAnimY); 1078808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCurAnimationTime += ANIM_FRAME_DURATION; 1079808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.sendMessageAtTime(mHandler.obtainMessage(MSG_ANIMATE_REVEAL), 1080808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCurAnimationTime); 1081808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1082808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1083808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1084808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1085808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void prepareTracking(int y, boolean opening) { 1086808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTracking = true; 1087808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mVelocityTracker = VelocityTracker.obtain(); 1088808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (opening) { 1089808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimAccel = 2000.0f; 1090808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimVel = 200; 1091808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimY = mStatusBarView.getHeight(); 1092808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos((int)mAnimY); 1093808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimating = true; 1094808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimatingReveal = true; 1095808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.removeMessages(MSG_ANIMATE); 1096808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.removeMessages(MSG_ANIMATE_REVEAL); 1097808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato long now = SystemClock.uptimeMillis(); 1098808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimLastTime = now; 1099808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCurAnimationTime = now + ANIM_FRAME_DURATION; 1100808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimating = true; 1101808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.sendMessageAtTime(mHandler.obtainMessage(MSG_ANIMATE_REVEAL), 1102808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCurAnimationTime); 1103808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato makeExpandedVisible(); 1104808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1105808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // it's open, close it? 1106808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mAnimating) { 1107808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimating = false; 1108808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.removeMessages(MSG_ANIMATE); 1109808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1110808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(y + mViewDelta); 1111808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1112808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1113808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1114808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void performFling(int y, float vel, boolean always) { 1115808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimatingReveal = false; 1116808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mDisplayHeight = mDisplay.getHeight(); 1117808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1118808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimY = y; 1119808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimVel = vel; 1120808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1121808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato //Slog.d(TAG, "starting with mAnimY=" + mAnimY + " mAnimVel=" + mAnimVel); 1122808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1123808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpanded) { 1124808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!always && ( 1125808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato vel > 200.0f 1126808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato || (y > (mDisplayHeight-25) && vel > -200.0f))) { 1127808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // We are expanded, but they didn't move sufficiently to cause 1128808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // us to retract. Animate back to the expanded position. 1129808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimAccel = 2000.0f; 1130808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (vel < 0) { 1131808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimVel = 0; 1132808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1133808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1134808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato else { 1135808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // We are expanded and are now going to animate away. 1136808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimAccel = -2000.0f; 1137808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (vel > 0) { 1138808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimVel = 0; 1139808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1140808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1141808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1142808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (always || ( 1143808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato vel > 200.0f 1144808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato || (y > (mDisplayHeight/2) && vel > -200.0f))) { 1145808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // We are collapsed, and they moved enough to allow us to 1146808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // expand. Animate in the notifications. 1147808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimAccel = 2000.0f; 1148808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (vel < 0) { 1149808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimVel = 0; 1150808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1151808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1152808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato else { 1153808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // We are collapsed, but they didn't move sufficiently to cause 1154808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // us to retract. Animate back to the collapsed position. 1155808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimAccel = -2000.0f; 1156808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (vel > 0) { 1157808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimVel = 0; 1158808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1159808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1160808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1161808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato //Slog.d(TAG, "mAnimY=" + mAnimY + " mAnimVel=" + mAnimVel 1162808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // + " mAnimAccel=" + mAnimAccel); 1163808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1164808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato long now = SystemClock.uptimeMillis(); 1165808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimLastTime = now; 1166808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCurAnimationTime = now + ANIM_FRAME_DURATION; 1167808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimating = true; 1168808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.removeMessages(MSG_ANIMATE); 1169808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.removeMessages(MSG_ANIMATE_REVEAL); 1170808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.sendMessageAtTime(mHandler.obtainMessage(MSG_ANIMATE), mCurAnimationTime); 1171808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato stopTracking(); 1172808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1173808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1174808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean interceptTouchEvent(MotionEvent event) { 1175808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) { 1176808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "Touch: rawY=" + event.getRawY() + " event=" + event + " mDisabled=" 1177808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + mDisabled); 1178808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1179808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1180808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) { 1181808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return false; 1182808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1183808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1184808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int statusBarSize = mStatusBarView.getHeight(); 1185808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int hitSize = statusBarSize*2; 1186808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (event.getAction() == MotionEvent.ACTION_DOWN) { 1187808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int y = (int)event.getRawY(); 1188808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1189808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mExpanded) { 1190808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mViewDelta = statusBarSize - y; 1191808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1192808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingView.getLocationOnScreen(mAbsPos); 1193808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mViewDelta = mAbsPos[1] + mTrackingView.getHeight() - y; 1194808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1195808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((!mExpanded && y < hitSize) || 1196808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato (mExpanded && y > (mDisplay.getHeight()-hitSize))) { 1197808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1198808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // We drop events at the edge of the screen to make the windowshade come 1199808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // down by accident less, especially when pushing open a device with a keyboard 1200808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // that rotates (like g1 and droid) 1201808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int x = (int)event.getRawX(); 1202808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int edgeBorder = mEdgeBorder; 1203808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (x >= edgeBorder && x < mDisplay.getWidth() - edgeBorder) { 1204808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato prepareTracking(y, !mExpanded);// opening if we're not already fully visible 1205808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mVelocityTracker.addMovement(event); 1206808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1207808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1208808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else if (mTracking) { 1209808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mVelocityTracker.addMovement(event); 1210808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int minY = statusBarSize + mCloseView.getHeight(); 1211808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (event.getAction() == MotionEvent.ACTION_MOVE) { 1212808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int y = (int)event.getRawY(); 1213808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mAnimatingReveal && y < minY) { 1214808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // nothing 1215808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1216808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mAnimatingReveal = false; 1217808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateExpandedViewPos(y + mViewDelta); 1218808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1219808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else if (event.getAction() == MotionEvent.ACTION_UP) { 1220808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mVelocityTracker.computeCurrentVelocity(1000); 1221808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1222808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float yVel = mVelocityTracker.getYVelocity(); 1223808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean negative = yVel < 0; 1224808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1225808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float xVel = mVelocityTracker.getXVelocity(); 1226808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (xVel < 0) { 1227808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato xVel = -xVel; 1228808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1229808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (xVel > 150.0f) { 1230808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato xVel = 150.0f; // limit how much we care about the x axis 1231808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1232808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1233808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato float vel = (float)Math.hypot(yVel, xVel); 1234808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (negative) { 1235808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato vel = -vel; 1236808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1237808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1238808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato performFling((int)event.getRawY(), vel, false); 1239808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1240808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1241808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1242808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return false; 1243808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1244808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 12459305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato public void setLightsOn(boolean on) { 12461d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler Log.v(TAG, "lights " + (on ? "on" : "off")); 12479305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato if (!on) { 12489305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato // All we do for "lights out" mode on a phone is hide the status bar, 12499305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato // which the window manager does. But we do need to hide the windowshade 12509305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato // on our own. 12519305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato animateCollapse(); 12529305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato } 12531d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler notifyLightsChanged(on); 12541d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler } 12551d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler 12561d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler private void notifyLightsChanged(boolean shown) { 12571d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler try { 12581d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler Slog.d(TAG, "lights " + (shown?"on":"out")); 12591d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler mWindowManager.statusBarVisibilityChanged( 12601d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler shown ? View.STATUS_BAR_VISIBLE : View.STATUS_BAR_HIDDEN); 12611d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler } catch (RemoteException ex) { 12621d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler } 12639305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato } 12649305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato 12655c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler public void topAppWindowChanged(boolean showMenu) { 12665c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler if (DEBUG) { 12675c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler Slog.d(TAG, (showMenu?"showing":"hiding") + " the MENU button"); 12685c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler } 12695c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler if (mNavigationBarView != null) { 12705c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler mNavigationBarView.getMenuButton().setVisibility(showMenu 12715c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler ? View.VISIBLE : View.INVISIBLE); 12725c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler } 12735c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler 12745c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler // See above re: lights-out policy for legacy apps. 12755c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler if (showMenu) setLightsOn(true); 12765c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler } 12775c8da949804ed4b55dcebae63796714e0028b488Daniel Sandler 1278e02d808abf370965c3c4e4d38af11bc69110fde2Daniel Sandler // Not supported 1279857fd9b8562c29913e03ed29288bd1802d37dc60Joe Onorato public void setImeWindowStatus(IBinder token, int vis, int backDisposition) { } 12802992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown @Override 12812992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown public void setHardKeyboardStatus(boolean available, boolean enabled) { } 1282e02d808abf370965c3c4e4d38af11bc69110fde2Daniel Sandler 1283808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private class Launcher implements View.OnClickListener { 1284808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private PendingIntent mIntent; 1285808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private String mPkg; 1286808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private String mTag; 1287808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private int mId; 1288808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1289808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Launcher(PendingIntent intent, String pkg, String tag, int id) { 1290808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIntent = intent; 1291808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mPkg = pkg; 1292808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTag = tag; 1293808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mId = id; 1294808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1295808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1296808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void onClick(View v) { 1297808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 1298808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // The intent we are sending is for the application, which 1299808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // won't have permission to immediately start an activity after 1300808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // the user switches to home. We know it is safe to do at this 1301808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // point, so make sure new activity switches are now allowed. 1302808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ActivityManagerNative.getDefault().resumeAppSwitches(); 1303808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (RemoteException e) { 1304808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1305808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1306808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mIntent != null) { 1307808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int[] pos = new int[2]; 1308808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato v.getLocationOnScreen(pos); 1309808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Intent overlay = new Intent(); 1310808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato overlay.setSourceBounds( 1311808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato new Rect(pos[0], pos[1], pos[0]+v.getWidth(), pos[1]+v.getHeight())); 1312808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 1313f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato mIntent.send(mContext, 0, overlay); 1314808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (PendingIntent.CanceledException e) { 1315808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // the stack trace isn't very helpful here. Just log the exception message. 1316808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.w(TAG, "Sending contentIntent failed: " + e); 1317808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1318808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1319808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1320808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 1321808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mBarService.onNotificationClick(mPkg, mTag, mId); 1322808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (RemoteException ex) { 1323808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // system process is dead if we're here. 1324808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1325808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1326808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // close the shade if it was open 1327808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato animateCollapse(); 1328808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1329808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // If this click was on the intruder alert, hide that instead 1330808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.sendEmptyMessage(MSG_HIDE_INTRUDER); 1331808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1332808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1333808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1334808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private void tick(StatusBarNotification n) { 1335808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Show the ticker if one is requested. Also don't do this 1336808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // until status bar window is attached to the window manager, 1337808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // because... well, what's the point otherwise? And trying to 1338808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // run a ticker without being attached will crash! 1339808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (n.notification.tickerText != null && mStatusBarView.getWindowToken() != null) { 1340808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (0 == (mDisabled & (StatusBarManager.DISABLE_NOTIFICATION_ICONS 1341808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | StatusBarManager.DISABLE_NOTIFICATION_TICKER))) { 1342808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicker.addEntry(n); 1343808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1344808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1345808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1346808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1347808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /** 1348808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * Cancel this notification and tell the StatusBarManagerService / NotificationManagerService 1349808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * about the failure. 1350808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * 1351808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * WARNING: this will call back into us. Don't hold any locks. 1352808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato */ 1353808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void handleNotificationError(IBinder key, StatusBarNotification n, String message) { 1354808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato removeNotification(key); 1355808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 1356808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mBarService.onNotificationError(n.pkg, n.tag, n.id, n.uid, n.initialPid, message); 1357808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (RemoteException ex) { 1358808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // The end is nigh. 1359808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1360808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1361808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1362808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private class MyTicker extends Ticker { 1363dfa08db1652585a8cf27f929371c7ca6bf18ca60Daniel Sandler MyTicker(Context context, View sb) { 1364808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato super(context, sb); 1365808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1366808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1367808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato @Override 1368dfa08db1652585a8cf27f929371c7ca6bf18ca60Daniel Sandler public void tickerStarting() { 1369808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicking = true; 1370808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIcons.setVisibility(View.GONE); 1371808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickerView.setVisibility(View.VISIBLE); 1372808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickerView.startAnimation(loadAnim(com.android.internal.R.anim.push_up_in, null)); 1373808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIcons.startAnimation(loadAnim(com.android.internal.R.anim.push_up_out, null)); 1374808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpandedVisible) { 1375808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setDateViewVisibility(false, com.android.internal.R.anim.push_up_out); 1376808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1377808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1378808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1379808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato @Override 1380dfa08db1652585a8cf27f929371c7ca6bf18ca60Daniel Sandler public void tickerDone() { 1381808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIcons.setVisibility(View.VISIBLE); 1382808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickerView.setVisibility(View.GONE); 1383808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIcons.startAnimation(loadAnim(com.android.internal.R.anim.push_down_in, null)); 1384808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickerView.startAnimation(loadAnim(com.android.internal.R.anim.push_down_out, 1385808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickingDoneListener)); 1386808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpandedVisible) { 1387808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setDateViewVisibility(true, com.android.internal.R.anim.push_down_in); 1388808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1389808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1390808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1391dfa08db1652585a8cf27f929371c7ca6bf18ca60Daniel Sandler public void tickerHalting() { 1392808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIcons.setVisibility(View.VISIBLE); 1393808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickerView.setVisibility(View.GONE); 1394808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIcons.startAnimation(loadAnim(com.android.internal.R.anim.fade_in, null)); 1395808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickerView.startAnimation(loadAnim(com.android.internal.R.anim.fade_out, 1396808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTickingDoneListener)); 1397808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpandedVisible) { 1398808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setDateViewVisibility(true, com.android.internal.R.anim.fade_in); 1399808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1400808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1401808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1402808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1403808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Animation.AnimationListener mTickingDoneListener = new Animation.AnimationListener() {; 1404808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void onAnimationEnd(Animation animation) { 1405808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicking = false; 1406808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1407808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void onAnimationRepeat(Animation animation) { 1408808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1409808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void onAnimationStart(Animation animation) { 1410808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1411808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato }; 1412808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1413808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private Animation loadAnim(int id, Animation.AnimationListener listener) { 1414f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato Animation anim = AnimationUtils.loadAnimation(mContext, id); 1415808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (listener != null) { 1416808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato anim.setAnimationListener(listener); 1417808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1418808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return anim; 1419808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1420808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1421808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public String viewInfo(View v) { 1422808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return "(" + v.getLeft() + "," + v.getTop() + ")(" + v.getRight() + "," + v.getBottom() 1423808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " " + v.getWidth() + "x" + v.getHeight() + ")"; 1424808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1425808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1426f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { 1427808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato synchronized (mQueueLock) { 1428808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println("Current Status Bar state:"); 1429808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mExpanded=" + mExpanded 1430808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + ", mExpandedVisible=" + mExpandedVisible); 1431808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mTicking=" + mTicking); 1432808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mTracking=" + mTracking); 1433808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mAnimating=" + mAnimating 1434808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + ", mAnimY=" + mAnimY + ", mAnimVel=" + mAnimVel 1435808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + ", mAnimAccel=" + mAnimAccel); 1436808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mCurAnimationTime=" + mCurAnimationTime 1437808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mAnimLastTime=" + mAnimLastTime); 1438808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mDisplayHeight=" + mDisplayHeight 1439808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mAnimatingReveal=" + mAnimatingReveal 1440808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mViewDelta=" + mViewDelta); 1441808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mDisplayHeight=" + mDisplayHeight); 1442808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mExpandedParams: " + mExpandedParams); 1443808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mExpandedView: " + viewInfo(mExpandedView)); 1444808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mExpandedDialog: " + mExpandedDialog); 1445808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mTrackingParams: " + mTrackingParams); 1446808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mTrackingView: " + viewInfo(mTrackingView)); 1447808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mOngoingTitle: " + viewInfo(mOngoingTitle)); 1448808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mOngoingItems: " + viewInfo(mOngoingItems)); 1449808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mLatestTitle: " + viewInfo(mLatestTitle)); 1450808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mLatestItems: " + viewInfo(mLatestItems)); 1451808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mNoNotificationsTitle: " + viewInfo(mNoNotificationsTitle)); 1452808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mCloseView: " + viewInfo(mCloseView)); 1453808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mTickerView: " + viewInfo(mTickerView)); 1454808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" mScrollView: " + viewInfo(mScrollView) 1455808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " scroll " + mScrollView.getScrollX() + "," + mScrollView.getScrollY()); 1456808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println("mNotificationLinearLayout: " + viewInfo(mNotificationLinearLayout)); 1457808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1458808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /* 1459808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato synchronized (mNotificationData) { 1460808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int N = mNotificationData.ongoingCount(); 1461808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" ongoingCount.size=" + N); 1462808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato for (int i=0; i<N; i++) { 1463808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato StatusBarNotification n = mNotificationData.getOngoing(i); 1464808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" [" + i + "] key=" + n.key + " view=" + n.view); 1465808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" data=" + n.data); 1466808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1467808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato N = mNotificationData.latestCount(); 1468808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" ongoingCount.size=" + N); 1469808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato for (int i=0; i<N; i++) { 1470808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato StatusBarNotification n = mNotificationData.getLatest(i); 1471808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" [" + i + "] key=" + n.key + " view=" + n.view); 1472808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println(" data=" + n.data); 1473808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1474808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1475808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato */ 1476808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1477808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (false) { 1478808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pw.println("see the logcat for a dump of the views we have created."); 1479808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // must happen on ui thread 1480808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.post(new Runnable() { 1481808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void run() { 1482808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mStatusBarView.getLocationOnScreen(mAbsPos); 1483808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "mStatusBarView: ----- (" + mAbsPos[0] + "," + mAbsPos[1] 1484808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + ") " + mStatusBarView.getWidth() + "x" 1485808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + mStatusBarView.getHeight()); 1486808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mStatusBarView.debug(); 1487808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1488808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedView.getLocationOnScreen(mAbsPos); 1489808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "mExpandedView: ----- (" + mAbsPos[0] + "," + mAbsPos[1] 1490808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + ") " + mExpandedView.getWidth() + "x" 1491808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + mExpandedView.getHeight()); 1492808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedView.debug(); 1493808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1494808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingView.getLocationOnScreen(mAbsPos); 1495808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "mTrackingView: ----- (" + mAbsPos[0] + "," + mAbsPos[1] 1496808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + ") " + mTrackingView.getWidth() + "x" 1497808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + mTrackingView.getHeight()); 1498808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingView.debug(); 1499808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1500808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato }); 1501808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1502808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1503808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1504808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void onBarViewAttached() { 1505808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManager.LayoutParams lp; 1506808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int pixelFormat; 1507808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Drawable bg; 1508808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1509808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /// ---------- Tracking View -------------- 1510808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pixelFormat = PixelFormat.RGBX_8888; 1511808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato bg = mTrackingView.getBackground(); 1512808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (bg != null) { 1513808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pixelFormat = bg.getOpacity(); 1514808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1515808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1516808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp = new WindowManager.LayoutParams( 1517808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ViewGroup.LayoutParams.MATCH_PARENT, 1518808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ViewGroup.LayoutParams.MATCH_PARENT, 151929fc2c9705e1bb8ae098fca016032d2325031587Joe Onorato WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL, 1520808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 1521808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS 1522808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, 1523808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pixelFormat); 1524808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato// lp.token = mStatusBarView.getWindowToken(); 1525808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.gravity = Gravity.TOP | Gravity.FILL_HORIZONTAL; 1526808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.setTitle("TrackingView"); 1527808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.y = mTrackingPosition; 1528808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingParams = lp; 1529808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1530808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManagerImpl.getDefault().addView(mTrackingView, lp); 1531808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1532808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1533808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void onTrackingViewAttached() { 1534808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManager.LayoutParams lp; 1535808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int pixelFormat; 1536808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Drawable bg; 1537808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1538808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /// ---------- Expanded View -------------- 1539808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pixelFormat = PixelFormat.TRANSLUCENT; 1540808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1541808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int disph = mDisplay.getHeight(); 1542808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp = mExpandedDialog.getWindow().getAttributes(); 1543808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.width = ViewGroup.LayoutParams.MATCH_PARENT; 1544808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.height = getExpandedHeight(); 1545808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.x = 0; 1546808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingPosition = lp.y = -disph; // sufficiently large negative 154729fc2c9705e1bb8ae098fca016032d2325031587Joe Onorato lp.type = WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL; 1548808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 1549808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS 1550808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL 1551808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_DITHER 1552808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; 1553808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.format = pixelFormat; 1554808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.gravity = Gravity.TOP | Gravity.FILL_HORIZONTAL; 1555808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato lp.setTitle("StatusBarExpanded"); 1556808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().setAttributes(lp); 1557808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().setFormat(pixelFormat); 1558808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams = lp; 1559808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1560808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); 1561808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.setContentView(mExpandedView, 1562808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1563808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato ViewGroup.LayoutParams.MATCH_PARENT)); 1564808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().setBackgroundDrawable(null); 1565808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.show(); 1566808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato FrameLayout hack = (FrameLayout)mExpandedView.getParent(); 1567808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1568808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1569808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void setDateViewVisibility(boolean visible, int anim) { 1570808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mDateView.setVisibility(visible ? View.VISIBLE : View.INVISIBLE); 1571808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mDateView.startAnimation(loadAnim(anim, null)); 1572808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1573808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1574808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void setNotificationIconVisibility(boolean visible, int anim) { 1575808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int old = mNotificationIcons.getVisibility(); 1576808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int v = visible ? View.VISIBLE : View.INVISIBLE; 1577808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (old != v) { 1578808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mNotificationIcons.setVisibility(v); 1579808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mNotificationIcons.startAnimation(loadAnim(anim, null)); 1580808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1581808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1582808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1583808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void updateExpandedViewPos(int expandedPosition) { 1584808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) { 1585808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "updateExpandedViewPos before expandedPosition=" + expandedPosition 1586808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mTrackingParams.y=" + mTrackingParams.y 1587808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mTrackingPosition=" + mTrackingPosition); 1588808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1589808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1590808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int h = mStatusBarView.getHeight(); 1591808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int disph = mDisplay.getHeight(); 1592808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1593808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // If the expanded view is not visible, make sure they're still off screen. 1594808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Maybe the view was resized. 1595808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mExpandedVisible) { 1596808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mTrackingView != null) { 1597808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingPosition = -disph; 1598808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mTrackingParams != null) { 1599808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingParams.y = mTrackingPosition; 1600808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManagerImpl.getDefault().updateViewLayout(mTrackingView, mTrackingParams); 1601808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1602808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1603808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpandedParams != null) { 1604808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.y = -disph; 1605808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().setAttributes(mExpandedParams); 1606808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1607808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return; 1608808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1609808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1610808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // tracking view... 1611808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int pos; 1612808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (expandedPosition == EXPANDED_FULL_OPEN) { 1613808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pos = h; 1614808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1615808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato else if (expandedPosition == EXPANDED_LEAVE_ALONE) { 1616808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pos = mTrackingPosition; 1617808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1618808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato else { 1619808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (expandedPosition <= disph) { 1620808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pos = expandedPosition; 1621808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1622808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pos = disph; 1623808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1624808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato pos -= disph-h; 1625808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1626808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingPosition = mTrackingParams.y = pos; 1627808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTrackingParams.height = disph-h; 1628808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato WindowManagerImpl.getDefault().updateViewLayout(mTrackingView, mTrackingParams); 1629808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1630808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpandedParams != null) { 1631808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mCloseView.getLocationInWindow(mPositionTmp); 1632808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int closePos = mPositionTmp[1]; 1633808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1634808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedContents.getLocationInWindow(mPositionTmp); 1635808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato final int contentsBottom = mPositionTmp[1] + mExpandedContents.getHeight(); 1636808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1637808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.y = pos + mTrackingView.getHeight() 1638808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato - (mTrackingParams.height-closePos) - contentsBottom; 1639808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int max = h; 1640808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpandedParams.y > max) { 1641808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.y = max; 1642808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1643808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int min = mTrackingPosition; 1644808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpandedParams.y < min) { 1645808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.y = min; 1646808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1647808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1648808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato boolean visible = (mTrackingPosition + mTrackingView.getHeight()) > h; 1649808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!visible) { 1650808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // if the contents aren't visible, move the expanded view way off screen 1651808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // because the window itself extends below the content view. 1652808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.y = -disph; 1653808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1654808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().setAttributes(mExpandedParams); 1655808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1656808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // As long as this isn't just a repositioning that's not supposed to affect 1657808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // the user's perception of what's showing, call to say that the visibility 1658808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // has changed. (Otherwise, someone else will call to do that). 1659808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (expandedPosition != EXPANDED_LEAVE_ALONE) { 1660808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) Slog.d(TAG, "updateExpandedViewPos visibilityChanged(" + visible + ")"); 1661808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato visibilityChanged(visible); 1662808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1663808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1664808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1665808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (SPEW) { 1666808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "updateExpandedViewPos after expandedPosition=" + expandedPosition 1667808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mTrackingParams.y=" + mTrackingParams.y 1668808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mTrackingPosition=" + mTrackingPosition 1669808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mExpandedParams.y=" + mExpandedParams.y 1670808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato + " mExpandedParams.height=" + mExpandedParams.height); 1671808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1672808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1673808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1674808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int getExpandedHeight() { 1675808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato return mDisplay.getHeight() - mStatusBarView.getHeight() - mCloseView.getHeight(); 1676808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1677808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1678808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void updateExpandedHeight() { 1679808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mExpandedView != null) { 1680808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedParams.height = getExpandedHeight(); 1681808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mExpandedDialog.getWindow().setAttributes(mExpandedParams); 1682808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1683808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1684808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 16851d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler public void userActivity() { 16861d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler try { 16871d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler mBarService.setSystemUiVisibility(View.STATUS_BAR_VISIBLE); 16881d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler } catch (RemoteException ex) { } 16891d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler } 16901d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler 16913b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka public void toggleRecentApps() { 16923b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka int msg = (mRecentsPanel.getVisibility() == View.GONE) 16933b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka ? MSG_OPEN_RECENTS_PANEL : MSG_CLOSE_RECENTS_PANEL; 16943b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mHandler.removeMessages(msg); 16953b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mHandler.sendEmptyMessage(msg); 16963b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 16973b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 1698808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /** 1699808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * The LEDs are turned o)ff when the notification panel is shown, even just a little bit. 1700808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * This was added last-minute and is inconsistent with the way the rest of the notifications 1701808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * are handled, because the notification isn't really cancelled. The lights are just 1702808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * turned off. If any other notifications happen, the lights will turn back on. Steve says 1703808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * this is what he wants. (see bug 1131461) 1704808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato */ 1705808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void visibilityChanged(boolean visible) { 1706808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mPanelSlightlyVisible != visible) { 1707808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mPanelSlightlyVisible = visible; 1708808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 1709808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mBarService.onPanelRevealed(); 1710808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (RemoteException ex) { 1711808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // Won't fail unless the world has ended. 1712808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1713808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1714808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1715808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1716808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void performDisableActions(int net) { 1717808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int old = mDisabled; 1718808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato int diff = net ^ old; 1719808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mDisabled = net; 1720808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1721808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // act accordingly 1722808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) { 1723808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((net & StatusBarManager.DISABLE_EXPAND) != 0) { 1724808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "DISABLE_EXPAND: yes"); 1725808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato animateCollapse(); 1726808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1727808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1728808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { 1729808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if ((net & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { 1730808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: yes"); 1731808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mTicking) { 1732808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mNotificationIcons.setVisibility(View.INVISIBLE); 1733808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicker.halt(); 1734808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1735808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setNotificationIconVisibility(false, com.android.internal.R.anim.fade_out); 1736808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1737808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else { 1738808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: no"); 1739808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (!mExpandedVisible) { 1740808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in); 1741808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1742808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1743808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } else if ((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { 1744808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (mTicking && (net & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { 1745808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mTicker.halt(); 1746808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1747808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1748808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1749808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1750808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private View.OnClickListener mClearButtonListener = new View.OnClickListener() { 1751808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void onClick(View v) { 1752808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato try { 1753808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mBarService.onClearAllNotifications(); 1754808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } catch (RemoteException ex) { 1755808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // system process is dead if we're here. 1756808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1757808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato animateCollapse(); 1758808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1759808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato }; 1760808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1761808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { 1762808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void onReceive(Context context, Intent intent) { 1763808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato String action = intent.getAction(); 1764808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action) 1765808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato || Intent.ACTION_SCREEN_OFF.equals(action)) { 17663b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka boolean excludeRecents = false; 17673b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) { 1768edbdd3a024ca35c331036823dde1f484d3333b31Daniel Sandler String reason = intent.getStringExtra("reason"); 17693b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (reason != null) { 17703b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka excludeRecents = reason.equals("recentapps"); 17713b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 17723b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 17733b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka animateCollapse(excludeRecents); 1774808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1775808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) { 17768956dbbc5f292d8b79072ae73b25f2114c8c7479Daniel Sandler repositionNavigationBar(); 1777808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato updateResources(); 1778808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1779808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1780808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato }; 1781808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1782808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato private void setIntruderAlertVisibility(boolean vis) { 1783808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mIntruderAlertView.setVisibility(vis ? View.VISIBLE : View.GONE); 1784808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1785808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1786808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato /** 1787808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * Reload some of our resources when the configuration changes. 1788808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * 1789808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * We don't reload everything when the configuration changes -- we probably 1790808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * should, but getting that smooth is tough. Someday we'll fix that. In the 1791808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato * meantime, just update the things that we know change. 1792808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato */ 1793808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void updateResources() { 1794f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato final Context context = mContext; 1795f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato final Resources res = context.getResources(); 1796808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1797f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato mClearButton.setText(context.getText(R.string.status_bar_clear_all_button)); 1798f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato mOngoingTitle.setText(context.getText(R.string.status_bar_ongoing_events_title)); 1799f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato mLatestTitle.setText(context.getText(R.string.status_bar_latest_events_title)); 1800f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato mNoNotificationsTitle.setText(context.getText(R.string.status_bar_no_notifications_title)); 1801808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1802808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore); 1803808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1804808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato if (false) Slog.v(TAG, "updateResources"); 1805808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1806808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1807808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // 1808808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // tracing 1809808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato // 1810808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1811808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void postStartTracing() { 1812808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.postDelayed(mStartTracing, 3000); 1813808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1814808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1815808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato void vibrate() { 1816f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato android.os.Vibrator vib = (android.os.Vibrator)mContext.getSystemService( 1817f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dcJoe Onorato Context.VIBRATOR_SERVICE); 1818808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato vib.vibrate(250); 1819808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1820808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1821808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Runnable mStartTracing = new Runnable() { 1822808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void run() { 1823808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato vibrate(); 1824808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato SystemClock.sleep(250); 1825808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "startTracing"); 1826808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato android.os.Debug.startMethodTracing("/data/statusbar-traces/trace"); 1827808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato mHandler.postDelayed(mStopTracing, 10000); 1828808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1829808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato }; 1830808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1831808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Runnable mStopTracing = new Runnable() { 1832808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato public void run() { 1833808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato android.os.Debug.stopMethodTracing(); 1834808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato Slog.d(TAG, "stopTracing"); 1835808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato vibrate(); 1836808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato } 1837808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato }; 18383b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 18393b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka public class TouchOutsideListener implements View.OnTouchListener { 18403b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka private int mMsg; 18413b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka private RecentsPanelView mPanel; 18423b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 18433b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka public TouchOutsideListener(int msg, RecentsPanelView panel) { 18443b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mMsg = msg; 18453b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mPanel = panel; 18463b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 18473b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 18483b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka public boolean onTouch(View v, MotionEvent ev) { 18493b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka final int action = ev.getAction(); 18503b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka if (action == MotionEvent.ACTION_OUTSIDE 18513b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka || (action == MotionEvent.ACTION_DOWN 18523b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka && !mPanel.isInContentArea((int)ev.getX(), (int)ev.getY()))) { 18533b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mHandler.removeMessages(mMsg); 18543b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mHandler.sendEmptyMessage(mMsg); 18553b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka return true; 18563b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 18573b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka return false; 18583b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 18593b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 1860808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato} 1861808182dc874e93582da38d013a4a790d6bc08fc9Joe Onorato 1862