Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Joe Onorato | 79de0c5 | 2010-05-26 17:03:26 -0400 | [diff] [blame] | 17 | package com.android.systemui.statusbar; |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 18 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 19 | import android.app.ActivityManager; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 20 | import android.app.ActivityManagerNative; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 21 | import android.app.Notification; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 22 | import android.app.PendingIntent; |
Adam Powell | 0fc5b2b | 2012-07-18 18:20:29 -0700 | [diff] [blame] | 23 | import android.app.TaskStackBuilder; |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 24 | import android.content.BroadcastReceiver; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 25 | import android.content.Context; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 26 | import android.content.Intent; |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 27 | import android.content.IntentFilter; |
Daniel Sandler | 96fd7c1 | 2012-03-30 16:37:36 -0400 | [diff] [blame] | 28 | import android.content.pm.ApplicationInfo; |
| 29 | import android.content.pm.PackageManager.NameNotFoundException; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 30 | import android.content.res.Configuration; |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 31 | import android.database.ContentObserver; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 32 | import android.graphics.Rect; |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 33 | import android.net.Uri; |
Daniel Sandler | 96fd7c1 | 2012-03-30 16:37:36 -0400 | [diff] [blame] | 34 | import android.os.Build; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 35 | import android.os.Handler; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 36 | import android.os.IBinder; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 37 | import android.os.Message; |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 38 | import android.os.PowerManager; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 39 | import android.os.RemoteException; |
| 40 | import android.os.ServiceManager; |
Dianne Hackborn | f02b60a | 2012-08-16 10:48:27 -0700 | [diff] [blame] | 41 | import android.os.UserHandle; |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 42 | import android.provider.Settings; |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 43 | import android.service.dreams.DreamService; |
| 44 | import android.service.dreams.IDreamManager; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 45 | import android.service.notification.StatusBarNotification; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 46 | import android.text.TextUtils; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 47 | import android.util.Log; |
Daniel Sandler | c638c1e | 2011-08-24 16:19:23 -0700 | [diff] [blame] | 48 | import android.view.Display; |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 49 | import android.view.IWindowManager; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 50 | import android.view.LayoutInflater; |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 51 | import android.view.MenuItem; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 52 | import android.view.MotionEvent; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 53 | import android.view.View; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 54 | import android.view.ViewGroup; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 55 | import android.view.ViewGroup.LayoutParams; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 56 | import android.view.WindowManager; |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 57 | import android.view.WindowManagerGlobal; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 58 | import android.widget.ImageView; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 59 | import android.widget.LinearLayout; |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 60 | import android.widget.PopupMenu; |
Michael Jurka | a600fd9 | 2012-06-25 15:57:05 -0700 | [diff] [blame] | 61 | import android.widget.RemoteViews; |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 62 | import android.widget.TextView; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 63 | |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 64 | import com.android.internal.statusbar.IStatusBarService; |
| 65 | import com.android.internal.statusbar.StatusBarIcon; |
| 66 | import com.android.internal.statusbar.StatusBarIconList; |
| 67 | import com.android.internal.widget.SizeAdaptiveLayout; |
| 68 | import com.android.systemui.R; |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 69 | import com.android.systemui.RecentsComponent; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 70 | import com.android.systemui.SearchPanelView; |
| 71 | import com.android.systemui.SystemUI; |
Jim Miller | a999d46 | 2013-10-30 13:58:11 -0700 | [diff] [blame] | 72 | import com.android.systemui.statusbar.phone.KeyguardTouchDelegate; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 73 | import com.android.systemui.statusbar.policy.NotificationRowLayout; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 74 | |
Michael Jurka | a600fd9 | 2012-06-25 15:57:05 -0700 | [diff] [blame] | 75 | import java.util.ArrayList; |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 76 | import java.util.Locale; |
Joe Onorato | 1c95ecb | 2010-06-28 17:19:12 -0400 | [diff] [blame] | 77 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 78 | public abstract class BaseStatusBar extends SystemUI implements |
Michael Jurka | cb2522c | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 79 | CommandQueue.Callbacks { |
Daniel Sandler | 198a030 | 2012-08-17 16:04:31 -0400 | [diff] [blame] | 80 | public static final String TAG = "StatusBar"; |
| 81 | public static final boolean DEBUG = false; |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 82 | public static final boolean MULTIUSER_DEBUG = false; |
Joe Onorato | 1c95ecb | 2010-06-28 17:19:12 -0400 | [diff] [blame] | 83 | |
Michael Jurka | cb2522c | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 84 | protected static final int MSG_TOGGLE_RECENTS_PANEL = 1020; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 85 | protected static final int MSG_CLOSE_RECENTS_PANEL = 1021; |
| 86 | protected static final int MSG_PRELOAD_RECENT_APPS = 1022; |
| 87 | protected static final int MSG_CANCEL_PRELOAD_RECENT_APPS = 1023; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 88 | protected static final int MSG_OPEN_SEARCH_PANEL = 1024; |
| 89 | protected static final int MSG_CLOSE_SEARCH_PANEL = 1025; |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 90 | protected static final int MSG_SHOW_HEADS_UP = 1026; |
| 91 | protected static final int MSG_HIDE_HEADS_UP = 1027; |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 92 | protected static final int MSG_ESCALATE_HEADS_UP = 1028; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 93 | |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 94 | protected static final boolean ENABLE_HEADS_UP = true; |
| 95 | // scores above this threshold should be displayed in heads up mode. |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 96 | protected static final int INTERRUPTION_THRESHOLD = 11; |
| 97 | protected static final String SETTING_HEADS_UP = "heads_up_enabled"; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 98 | |
Michael Jurka | 56a5783 | 2012-05-14 13:24:43 -0700 | [diff] [blame] | 99 | // Should match the value in PhoneWindowManager |
| 100 | public static final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps"; |
| 101 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 102 | public static final int EXPANDED_LEAVE_ALONE = -10000; |
| 103 | public static final int EXPANDED_FULL_OPEN = -10001; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 104 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 105 | protected CommandQueue mCommandQueue; |
| 106 | protected IStatusBarService mBarService; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 107 | protected H mHandler = createHandler(); |
| 108 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 109 | // all notifications |
| 110 | protected NotificationData mNotificationData = new NotificationData(); |
| 111 | protected NotificationRowLayout mPile; |
| 112 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 113 | protected NotificationData.Entry mInterruptingNotificationEntry; |
| 114 | protected long mInterruptingNotificationTime; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 115 | |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 116 | // used to notify status bar for suppressing notification LED |
| 117 | protected boolean mPanelSlightlyVisible; |
| 118 | |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 119 | // Search panel |
| 120 | protected SearchPanelView mSearchPanelView; |
| 121 | |
Daniel Sandler | 469e96e | 2012-05-04 15:56:19 -0400 | [diff] [blame] | 122 | protected PopupMenu mNotificationBlamePopup; |
| 123 | |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 124 | protected int mCurrentUserId = 0; |
| 125 | |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 126 | protected int mLayoutDirection = -1; // invalid |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 127 | private Locale mLocale; |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 128 | protected boolean mUseHeadsUp = false; |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 129 | |
| 130 | protected IDreamManager mDreamManager; |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 131 | PowerManager mPowerManager; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 132 | protected int mRowHeight; |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 133 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 134 | // UI-specific methods |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 135 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 136 | /** |
| 137 | * Create all windows necessary for the status bar (including navigation, overlay panels, etc) |
| 138 | * and add them to the window manager. |
| 139 | */ |
| 140 | protected abstract void createAndAddWindows(); |
Joe Onorato | 1c95ecb | 2010-06-28 17:19:12 -0400 | [diff] [blame] | 141 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 142 | protected WindowManager mWindowManager; |
| 143 | protected IWindowManager mWindowManagerService; |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 144 | protected abstract void refreshLayout(int layoutDirection); |
| 145 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 146 | protected Display mDisplay; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 147 | |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 148 | private boolean mDeviceProvisioned = false; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 149 | |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 150 | private RecentsComponent mRecents; |
| 151 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 152 | public IStatusBarService getStatusBarService() { |
| 153 | return mBarService; |
| 154 | } |
Joe Onorato | 2039e48 | 2010-11-29 14:54:24 -0800 | [diff] [blame] | 155 | |
Daniel Sandler | 3ffdcc7 | 2012-09-23 14:31:48 -0400 | [diff] [blame] | 156 | public boolean isDeviceProvisioned() { |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 157 | return mDeviceProvisioned; |
| 158 | } |
| 159 | |
| 160 | private ContentObserver mProvisioningObserver = new ContentObserver(new Handler()) { |
| 161 | @Override |
| 162 | public void onChange(boolean selfChange) { |
Jeff Brown | bf6f6f9 | 2012-09-25 15:03:20 -0700 | [diff] [blame] | 163 | final boolean provisioned = 0 != Settings.Global.getInt( |
| 164 | mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0); |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 165 | if (provisioned != mDeviceProvisioned) { |
| 166 | mDeviceProvisioned = provisioned; |
| 167 | updateNotificationIcons(); |
| 168 | } |
| 169 | } |
| 170 | }; |
| 171 | |
Dianne Hackborn | 1927ae8 | 2012-06-22 15:21:36 -0700 | [diff] [blame] | 172 | private RemoteViews.OnClickHandler mOnClickHandler = new RemoteViews.OnClickHandler() { |
| 173 | @Override |
| 174 | public boolean onClickHandler(View view, PendingIntent pendingIntent, Intent fillInIntent) { |
Daniel Sandler | 198a030 | 2012-08-17 16:04:31 -0400 | [diff] [blame] | 175 | if (DEBUG) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 176 | Log.v(TAG, "Notification click handler invoked for intent: " + pendingIntent); |
Daniel Sandler | 198a030 | 2012-08-17 16:04:31 -0400 | [diff] [blame] | 177 | } |
Dianne Hackborn | 1927ae8 | 2012-06-22 15:21:36 -0700 | [diff] [blame] | 178 | final boolean isActivity = pendingIntent.isActivity(); |
| 179 | if (isActivity) { |
| 180 | try { |
| 181 | // The intent we are sending is for the application, which |
| 182 | // won't have permission to immediately start an activity after |
| 183 | // the user switches to home. We know it is safe to do at this |
| 184 | // point, so make sure new activity switches are now allowed. |
| 185 | ActivityManagerNative.getDefault().resumeAppSwitches(); |
| 186 | // Also, notifications can be launched from the lock screen, |
| 187 | // so dismiss the lock screen when the activity starts. |
| 188 | ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity(); |
| 189 | } catch (RemoteException e) { |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | boolean handled = super.onClickHandler(view, pendingIntent, fillInIntent); |
| 194 | |
| 195 | if (isActivity && handled) { |
| 196 | // close the shade if it was open |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 197 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
Dianne Hackborn | 1927ae8 | 2012-06-22 15:21:36 -0700 | [diff] [blame] | 198 | visibilityChanged(false); |
| 199 | } |
| 200 | return handled; |
| 201 | } |
| 202 | }; |
| 203 | |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 204 | private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { |
| 205 | @Override |
| 206 | public void onReceive(Context context, Intent intent) { |
| 207 | String action = intent.getAction(); |
| 208 | if (Intent.ACTION_USER_SWITCHED.equals(action)) { |
| 209 | mCurrentUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1); |
| 210 | if (true) Log.v(TAG, "userId " + mCurrentUserId + " is in the house"); |
| 211 | userSwitched(mCurrentUserId); |
| 212 | } |
| 213 | } |
| 214 | }; |
| 215 | |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 216 | public void start() { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 217 | mWindowManager = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); |
| 218 | mWindowManagerService = WindowManagerGlobal.getWindowManagerService(); |
| 219 | mDisplay = mWindowManager.getDefaultDisplay(); |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 220 | |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 221 | mDreamManager = IDreamManager.Stub.asInterface( |
| 222 | ServiceManager.checkService(DreamService.DREAM_SERVICE)); |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 223 | mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); |
| 224 | |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 225 | mProvisioningObserver.onChange(false); // set up |
| 226 | mContext.getContentResolver().registerContentObserver( |
Jeff Brown | bf6f6f9 | 2012-09-25 15:03:20 -0700 | [diff] [blame] | 227 | Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED), true, |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 228 | mProvisioningObserver); |
| 229 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 230 | mBarService = IStatusBarService.Stub.asInterface( |
| 231 | ServiceManager.getService(Context.STATUS_BAR_SERVICE)); |
Joe Onorato | 1c95ecb | 2010-06-28 17:19:12 -0400 | [diff] [blame] | 232 | |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 233 | mRecents = getComponent(RecentsComponent.class); |
| 234 | |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 235 | mLocale = mContext.getResources().getConfiguration().locale; |
| 236 | mLayoutDirection = TextUtils.getLayoutDirectionFromLocale(mLocale); |
| 237 | |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 238 | // Connect in to the status bar manager service |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 239 | StatusBarIconList iconList = new StatusBarIconList(); |
Joe Onorato | 75199e3 | 2010-05-29 17:22:51 -0400 | [diff] [blame] | 240 | ArrayList<IBinder> notificationKeys = new ArrayList<IBinder>(); |
| 241 | ArrayList<StatusBarNotification> notifications = new ArrayList<StatusBarNotification>(); |
Joe Onorato | 66d7d01 | 2010-05-14 10:05:10 -0700 | [diff] [blame] | 242 | mCommandQueue = new CommandQueue(this, iconList); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 243 | |
Jeff Brown | 2992ea7 | 2011-01-28 22:04:14 -0800 | [diff] [blame] | 244 | int[] switches = new int[7]; |
satok | cd7cd29 | 2010-11-20 15:46:23 +0900 | [diff] [blame] | 245 | ArrayList<IBinder> binders = new ArrayList<IBinder>(); |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 246 | try { |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 247 | mBarService.registerStatusBar(mCommandQueue, iconList, notificationKeys, notifications, |
satok | cd7cd29 | 2010-11-20 15:46:23 +0900 | [diff] [blame] | 248 | switches, binders); |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 249 | } catch (RemoteException ex) { |
| 250 | // If the system process isn't there we're doomed anyway. |
| 251 | } |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 252 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 253 | createAndAddWindows(); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 254 | |
Joe Onorato | e4c7b3f | 2010-10-30 12:15:03 -0700 | [diff] [blame] | 255 | disable(switches[0]); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 256 | setSystemUiVisibility(switches[1], 0xffffffff); |
Dianne Hackborn | 7d04932 | 2011-06-14 15:00:32 -0700 | [diff] [blame] | 257 | topAppWindowChanged(switches[2] != 0); |
satok | cd7cd29 | 2010-11-20 15:46:23 +0900 | [diff] [blame] | 258 | // StatusBarManagerService has a back up of IME token and it's restored here. |
Joe Onorato | 857fd9b | 2011-01-27 15:08:35 -0800 | [diff] [blame] | 259 | setImeWindowStatus(binders.get(0), switches[3], switches[4]); |
Jeff Brown | 2992ea7 | 2011-01-28 22:04:14 -0800 | [diff] [blame] | 260 | setHardKeyboardStatus(switches[5] != 0, switches[6] != 0); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 261 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 262 | // Set up the initial icon state |
Joe Onorato | 75199e3 | 2010-05-29 17:22:51 -0400 | [diff] [blame] | 263 | int N = iconList.size(); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 264 | int viewIndex = 0; |
| 265 | for (int i=0; i<N; i++) { |
| 266 | StatusBarIcon icon = iconList.getIcon(i); |
| 267 | if (icon != null) { |
| 268 | addIcon(iconList.getSlot(i), i, viewIndex, icon); |
| 269 | viewIndex++; |
| 270 | } |
| 271 | } |
| 272 | |
Joe Onorato | 75199e3 | 2010-05-29 17:22:51 -0400 | [diff] [blame] | 273 | // Set up the initial notification state |
| 274 | N = notificationKeys.size(); |
Joe Onorato | 75199e3 | 2010-05-29 17:22:51 -0400 | [diff] [blame] | 275 | if (N == notifications.size()) { |
| 276 | for (int i=0; i<N; i++) { |
| 277 | addNotification(notificationKeys.get(i), notifications.get(i)); |
| 278 | } |
| 279 | } else { |
| 280 | Log.wtf(TAG, "Notification list length mismatch: keys=" + N |
| 281 | + " notifications=" + notifications.size()); |
| 282 | } |
| 283 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 284 | if (DEBUG) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 285 | Log.d(TAG, String.format( |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 286 | "init: icons=%d disabled=0x%08x lights=0x%08x menu=0x%08x imeButton=0x%08x", |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 287 | iconList.size(), |
| 288 | switches[0], |
| 289 | switches[1], |
| 290 | switches[2], |
| 291 | switches[3] |
| 292 | )); |
Joe Onorato | 1c95ecb | 2010-06-28 17:19:12 -0400 | [diff] [blame] | 293 | } |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 294 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 295 | mCurrentUserId = ActivityManager.getCurrentUser(); |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 296 | |
| 297 | IntentFilter filter = new IntentFilter(); |
| 298 | filter.addAction(Intent.ACTION_USER_SWITCHED); |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 299 | mContext.registerReceiver(mBroadcastReceiver, filter); |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | public void userSwitched(int newUserId) { |
| 303 | // should be overridden |
| 304 | } |
| 305 | |
| 306 | public boolean notificationIsForCurrentUser(StatusBarNotification n) { |
| 307 | final int thisUserId = mCurrentUserId; |
| 308 | final int notificationUserId = n.getUserId(); |
| 309 | if (DEBUG && MULTIUSER_DEBUG) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 310 | Log.v(TAG, String.format("%s: current userid: %d, notification userid: %d", |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 311 | n, thisUserId, notificationUserId)); |
| 312 | } |
Dianne Hackborn | 50cdf7c3 | 2012-09-23 17:08:57 -0700 | [diff] [blame] | 313 | return notificationUserId == UserHandle.USER_ALL |
| 314 | || thisUserId == notificationUserId; |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 315 | } |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 316 | |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 317 | @Override |
| 318 | protected void onConfigurationChanged(Configuration newConfig) { |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 319 | final Locale locale = mContext.getResources().getConfiguration().locale; |
| 320 | final int ld = TextUtils.getLayoutDirectionFromLocale(locale); |
| 321 | if (! locale.equals(mLocale) || ld != mLayoutDirection) { |
| 322 | if (DEBUG) { |
| 323 | Log.v(TAG, String.format( |
| 324 | "config changed locale/LD: %s (%d) -> %s (%d)", mLocale, mLayoutDirection, |
| 325 | locale, ld)); |
| 326 | } |
| 327 | mLocale = locale; |
| 328 | mLayoutDirection = ld; |
| 329 | refreshLayout(ld); |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 330 | } |
| 331 | } |
| 332 | |
Winson Chung | c57ccf0 | 2011-10-13 15:04:59 -0700 | [diff] [blame] | 333 | protected View updateNotificationVetoButton(View row, StatusBarNotification n) { |
| 334 | View vetoButton = row.findViewById(R.id.veto); |
Chris Wren | 6d15a36 | 2013-08-20 18:46:29 -0400 | [diff] [blame] | 335 | if (n.isClearable() || (mInterruptingNotificationEntry != null |
| 336 | && mInterruptingNotificationEntry.row == row)) { |
Daniel Sandler | 4f91efd | 2013-04-25 16:38:41 -0400 | [diff] [blame] | 337 | final String _pkg = n.getPackageName(); |
Daniel Sandler | e6f7f2e | 2013-04-25 15:44:16 -0400 | [diff] [blame] | 338 | final String _tag = n.getTag(); |
| 339 | final int _id = n.getId(); |
Winson Chung | c57ccf0 | 2011-10-13 15:04:59 -0700 | [diff] [blame] | 340 | vetoButton.setOnClickListener(new View.OnClickListener() { |
| 341 | public void onClick(View v) { |
Casey Burkhardt | bac221f | 2012-10-03 18:13:58 -0700 | [diff] [blame] | 342 | // Accessibility feedback |
| 343 | v.announceForAccessibility( |
| 344 | mContext.getString(R.string.accessibility_notification_dismissed)); |
Winson Chung | c57ccf0 | 2011-10-13 15:04:59 -0700 | [diff] [blame] | 345 | try { |
| 346 | mBarService.onNotificationClear(_pkg, _tag, _id); |
Casey Burkhardt | bac221f | 2012-10-03 18:13:58 -0700 | [diff] [blame] | 347 | |
Winson Chung | c57ccf0 | 2011-10-13 15:04:59 -0700 | [diff] [blame] | 348 | } catch (RemoteException ex) { |
| 349 | // system process is dead if we're here. |
| 350 | } |
| 351 | } |
| 352 | }); |
| 353 | vetoButton.setVisibility(View.VISIBLE); |
| 354 | } else { |
| 355 | vetoButton.setVisibility(View.GONE); |
| 356 | } |
Casey Burkhardt | bac221f | 2012-10-03 18:13:58 -0700 | [diff] [blame] | 357 | vetoButton.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO); |
Winson Chung | c57ccf0 | 2011-10-13 15:04:59 -0700 | [diff] [blame] | 358 | return vetoButton; |
| 359 | } |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 360 | |
Daniel Sandler | 96fd7c1 | 2012-03-30 16:37:36 -0400 | [diff] [blame] | 361 | |
| 362 | protected void applyLegacyRowBackground(StatusBarNotification sbn, View content) { |
Daniel Sandler | e6f7f2e | 2013-04-25 15:44:16 -0400 | [diff] [blame] | 363 | if (sbn.getNotification().contentView.getLayoutId() != |
Daniel Sandler | 96fd7c1 | 2012-03-30 16:37:36 -0400 | [diff] [blame] | 364 | com.android.internal.R.layout.notification_template_base) { |
| 365 | int version = 0; |
| 366 | try { |
Daniel Sandler | 4f91efd | 2013-04-25 16:38:41 -0400 | [diff] [blame] | 367 | ApplicationInfo info = mContext.getPackageManager().getApplicationInfo(sbn.getPackageName(), 0); |
Daniel Sandler | 96fd7c1 | 2012-03-30 16:37:36 -0400 | [diff] [blame] | 368 | version = info.targetSdkVersion; |
| 369 | } catch (NameNotFoundException ex) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 370 | Log.e(TAG, "Failed looking up ApplicationInfo for " + sbn.getPackageName(), ex); |
Daniel Sandler | 96fd7c1 | 2012-03-30 16:37:36 -0400 | [diff] [blame] | 371 | } |
| 372 | if (version > 0 && version < Build.VERSION_CODES.GINGERBREAD) { |
| 373 | content.setBackgroundResource(R.drawable.notification_row_legacy_bg); |
| 374 | } else { |
Chris Wren | d84e593 | 2012-04-19 17:58:03 -0400 | [diff] [blame] | 375 | content.setBackgroundResource(com.android.internal.R.drawable.notification_bg); |
Daniel Sandler | 96fd7c1 | 2012-03-30 16:37:36 -0400 | [diff] [blame] | 376 | } |
| 377 | } |
| 378 | } |
| 379 | |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 380 | private void startApplicationDetailsActivity(String packageName) { |
| 381 | Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, |
| 382 | Uri.fromParts("package", packageName, null)); |
Adam Powell | 0fc5b2b | 2012-07-18 18:20:29 -0700 | [diff] [blame] | 383 | intent.setComponent(intent.resolveActivity(mContext.getPackageManager())); |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 384 | TaskStackBuilder.create(mContext).addNextIntentWithParentStack(intent).startActivities( |
| 385 | null, UserHandle.CURRENT); |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 386 | } |
| 387 | |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 388 | protected View.OnLongClickListener getNotificationLongClicker() { |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 389 | return new View.OnLongClickListener() { |
| 390 | @Override |
| 391 | public boolean onLongClick(View v) { |
| 392 | final String packageNameF = (String) v.getTag(); |
| 393 | if (packageNameF == null) return false; |
Jeff Sharkey | af232ed | 2012-04-30 15:19:39 -0700 | [diff] [blame] | 394 | if (v.getWindowToken() == null) return false; |
Daniel Sandler | 469e96e | 2012-05-04 15:56:19 -0400 | [diff] [blame] | 395 | mNotificationBlamePopup = new PopupMenu(mContext, v); |
| 396 | mNotificationBlamePopup.getMenuInflater().inflate( |
| 397 | R.menu.notification_popup_menu, |
| 398 | mNotificationBlamePopup.getMenu()); |
| 399 | mNotificationBlamePopup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 400 | public boolean onMenuItemClick(MenuItem item) { |
| 401 | if (item.getItemId() == R.id.notification_inspect_item) { |
| 402 | startApplicationDetailsActivity(packageNameF); |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 403 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 404 | } else { |
| 405 | return false; |
| 406 | } |
| 407 | return true; |
| 408 | } |
| 409 | }); |
Daniel Sandler | 469e96e | 2012-05-04 15:56:19 -0400 | [diff] [blame] | 410 | mNotificationBlamePopup.show(); |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 411 | |
| 412 | return true; |
| 413 | } |
| 414 | }; |
| 415 | } |
| 416 | |
Daniel Sandler | 469e96e | 2012-05-04 15:56:19 -0400 | [diff] [blame] | 417 | public void dismissPopups() { |
| 418 | if (mNotificationBlamePopup != null) { |
| 419 | mNotificationBlamePopup.dismiss(); |
| 420 | mNotificationBlamePopup = null; |
| 421 | } |
| 422 | } |
| 423 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 424 | public void onHeadsUpDismissed() { |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 425 | } |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 426 | |
| 427 | @Override |
| 428 | public void toggleRecentApps() { |
Michael Jurka | cb2522c | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 429 | int msg = MSG_TOGGLE_RECENTS_PANEL; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 430 | mHandler.removeMessages(msg); |
| 431 | mHandler.sendEmptyMessage(msg); |
| 432 | } |
| 433 | |
| 434 | @Override |
| 435 | public void preloadRecentApps() { |
| 436 | int msg = MSG_PRELOAD_RECENT_APPS; |
| 437 | mHandler.removeMessages(msg); |
| 438 | mHandler.sendEmptyMessage(msg); |
| 439 | } |
| 440 | |
| 441 | @Override |
| 442 | public void cancelPreloadRecentApps() { |
| 443 | int msg = MSG_CANCEL_PRELOAD_RECENT_APPS; |
| 444 | mHandler.removeMessages(msg); |
| 445 | mHandler.sendEmptyMessage(msg); |
| 446 | } |
| 447 | |
| 448 | @Override |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 449 | public void showSearchPanel() { |
| 450 | int msg = MSG_OPEN_SEARCH_PANEL; |
| 451 | mHandler.removeMessages(msg); |
| 452 | mHandler.sendEmptyMessage(msg); |
| 453 | } |
| 454 | |
| 455 | @Override |
| 456 | public void hideSearchPanel() { |
| 457 | int msg = MSG_CLOSE_SEARCH_PANEL; |
| 458 | mHandler.removeMessages(msg); |
| 459 | mHandler.sendEmptyMessage(msg); |
| 460 | } |
| 461 | |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 462 | protected abstract WindowManager.LayoutParams getSearchLayoutParams( |
| 463 | LayoutParams layoutParams); |
| 464 | |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 465 | protected void updateSearchPanel() { |
| 466 | // Search Panel |
| 467 | boolean visible = false; |
| 468 | if (mSearchPanelView != null) { |
| 469 | visible = mSearchPanelView.isShowing(); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 470 | mWindowManager.removeView(mSearchPanelView); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 471 | } |
| 472 | |
| 473 | // Provide SearchPanel with a temporary parent to allow layout params to work. |
| 474 | LinearLayout tmpRoot = new LinearLayout(mContext); |
| 475 | mSearchPanelView = (SearchPanelView) LayoutInflater.from(mContext).inflate( |
| 476 | R.layout.status_bar_search_panel, tmpRoot, false); |
| 477 | mSearchPanelView.setOnTouchListener( |
| 478 | new TouchOutsideListener(MSG_CLOSE_SEARCH_PANEL, mSearchPanelView)); |
| 479 | mSearchPanelView.setVisibility(View.GONE); |
| 480 | |
| 481 | WindowManager.LayoutParams lp = getSearchLayoutParams(mSearchPanelView.getLayoutParams()); |
| 482 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 483 | mWindowManager.addView(mSearchPanelView, lp); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 484 | mSearchPanelView.setBar(this); |
| 485 | if (visible) { |
| 486 | mSearchPanelView.show(true, false); |
| 487 | } |
| 488 | } |
| 489 | |
Michael Jurka | ecc395a | 2012-03-30 05:31:46 -0700 | [diff] [blame] | 490 | protected H createHandler() { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 491 | return new H(); |
| 492 | } |
| 493 | |
Michael Jurka | 56a5783 | 2012-05-14 13:24:43 -0700 | [diff] [blame] | 494 | static void sendCloseSystemWindows(Context context, String reason) { |
| 495 | if (ActivityManagerNative.isSystemReady()) { |
| 496 | try { |
| 497 | ActivityManagerNative.getDefault().closeSystemDialogs(reason); |
| 498 | } catch (RemoteException e) { |
| 499 | } |
| 500 | } |
| 501 | } |
| 502 | |
Michael Jurka | cb2522c | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 503 | protected abstract View getStatusBarView(); |
| 504 | |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 505 | protected View.OnTouchListener mRecentsPreloadOnTouchListener = new View.OnTouchListener() { |
| 506 | // additional optimization when we have software system buttons - start loading the recent |
| 507 | // tasks on touch down |
| 508 | @Override |
| 509 | public boolean onTouch(View v, MotionEvent event) { |
| 510 | int action = event.getAction() & MotionEvent.ACTION_MASK; |
| 511 | if (action == MotionEvent.ACTION_DOWN) { |
| 512 | preloadRecentTasksList(); |
| 513 | } else if (action == MotionEvent.ACTION_CANCEL) { |
| 514 | cancelPreloadingRecentTasksList(); |
| 515 | } else if (action == MotionEvent.ACTION_UP) { |
| 516 | if (!v.isPressed()) { |
| 517 | cancelPreloadingRecentTasksList(); |
| 518 | } |
| 519 | |
| 520 | } |
| 521 | return false; |
| 522 | } |
| 523 | }; |
| 524 | |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 525 | protected void toggleRecentsActivity() { |
| 526 | if (mRecents != null) { |
| 527 | mRecents.toggleRecents(mDisplay, mLayoutDirection, getStatusBarView()); |
| 528 | } |
| 529 | } |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 530 | |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 531 | protected void preloadRecentTasksList() { |
| 532 | if (mRecents != null) { |
| 533 | mRecents.preloadRecentTasksList(); |
| 534 | } |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 535 | } |
| 536 | |
| 537 | protected void cancelPreloadingRecentTasksList() { |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 538 | if (mRecents != null) { |
| 539 | mRecents.cancelPreloadingRecentTasksList(); |
| 540 | } |
| 541 | } |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 542 | |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 543 | protected void closeRecents() { |
| 544 | if (mRecents != null) { |
| 545 | mRecents.closeRecents(); |
| 546 | } |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 547 | } |
| 548 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 549 | public abstract void resetHeadsUpDecayTimer(); |
| 550 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 551 | protected class H extends Handler { |
| 552 | public void handleMessage(Message m) { |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 553 | Intent intent; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 554 | switch (m.what) { |
Michael Jurka | cb2522c | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 555 | case MSG_TOGGLE_RECENTS_PANEL: |
Michael Jurka | cb2522c | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 556 | toggleRecentsActivity(); |
| 557 | break; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 558 | case MSG_CLOSE_RECENTS_PANEL: |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 559 | closeRecents(); |
Michael Jurka | cb2522c | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 560 | break; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 561 | case MSG_PRELOAD_RECENT_APPS: |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 562 | preloadRecentTasksList(); |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 563 | break; |
| 564 | case MSG_CANCEL_PRELOAD_RECENT_APPS: |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 565 | cancelPreloadingRecentTasksList(); |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 566 | break; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 567 | case MSG_OPEN_SEARCH_PANEL: |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 568 | if (DEBUG) Log.d(TAG, "opening search panel"); |
Jim Miller | 0799440 | 2012-05-02 14:22:27 -0700 | [diff] [blame] | 569 | if (mSearchPanelView != null && mSearchPanelView.isAssistantAvailable()) { |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 570 | mSearchPanelView.show(true, true); |
Jim Miller | ad178a4 | 2013-10-08 20:03:38 -0700 | [diff] [blame] | 571 | onShowSearchPanel(); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 572 | } |
| 573 | break; |
| 574 | case MSG_CLOSE_SEARCH_PANEL: |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 575 | if (DEBUG) Log.d(TAG, "closing search panel"); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 576 | if (mSearchPanelView != null && mSearchPanelView.isShowing()) { |
| 577 | mSearchPanelView.show(false, true); |
Jim Miller | ad178a4 | 2013-10-08 20:03:38 -0700 | [diff] [blame] | 578 | onHideSearchPanel(); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 579 | } |
| 580 | break; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 581 | } |
| 582 | } |
| 583 | } |
| 584 | |
| 585 | public class TouchOutsideListener implements View.OnTouchListener { |
| 586 | private int mMsg; |
| 587 | private StatusBarPanel mPanel; |
| 588 | |
| 589 | public TouchOutsideListener(int msg, StatusBarPanel panel) { |
| 590 | mMsg = msg; |
| 591 | mPanel = panel; |
| 592 | } |
| 593 | |
| 594 | public boolean onTouch(View v, MotionEvent ev) { |
| 595 | final int action = ev.getAction(); |
| 596 | if (action == MotionEvent.ACTION_OUTSIDE |
| 597 | || (action == MotionEvent.ACTION_DOWN |
| 598 | && !mPanel.isInContentArea((int)ev.getX(), (int)ev.getY()))) { |
| 599 | mHandler.removeMessages(mMsg); |
| 600 | mHandler.sendEmptyMessage(mMsg); |
| 601 | return true; |
| 602 | } |
| 603 | return false; |
| 604 | } |
| 605 | } |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 606 | |
| 607 | protected void workAroundBadLayerDrawableOpacity(View v) { |
| 608 | } |
| 609 | |
Jim Miller | ad178a4 | 2013-10-08 20:03:38 -0700 | [diff] [blame] | 610 | protected void onHideSearchPanel() { |
| 611 | } |
| 612 | |
| 613 | protected void onShowSearchPanel() { |
| 614 | } |
| 615 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 616 | public boolean inflateViews(NotificationData.Entry entry, ViewGroup parent) { |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 617 | int minHeight = |
| 618 | mContext.getResources().getDimensionPixelSize(R.dimen.notification_min_height); |
| 619 | int maxHeight = |
| 620 | mContext.getResources().getDimensionPixelSize(R.dimen.notification_max_height); |
| 621 | StatusBarNotification sbn = entry.notification; |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 622 | RemoteViews contentView = sbn.getNotification().contentView; |
| 623 | RemoteViews bigContentView = sbn.getNotification().bigContentView; |
| 624 | if (contentView == null) { |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 625 | return false; |
| 626 | } |
| 627 | |
| 628 | // create the row view |
| 629 | LayoutInflater inflater = (LayoutInflater)mContext.getSystemService( |
| 630 | Context.LAYOUT_INFLATER_SERVICE); |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 631 | ExpandableNotificationRow row = (ExpandableNotificationRow) inflater.inflate( |
| 632 | R.layout.status_bar_notification_row, parent, false); |
Daniel Sandler | bc5559f | 2012-04-19 01:08:15 -0400 | [diff] [blame] | 633 | |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 634 | // for blaming (see SwipeHelper.setLongPressListener) |
Daniel Sandler | 4f91efd | 2013-04-25 16:38:41 -0400 | [diff] [blame] | 635 | row.setTag(sbn.getPackageName()); |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 636 | |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 637 | workAroundBadLayerDrawableOpacity(row); |
| 638 | View vetoButton = updateNotificationVetoButton(row, sbn); |
| 639 | vetoButton.setContentDescription(mContext.getString( |
| 640 | R.string.accessibility_remove_notification)); |
| 641 | |
| 642 | // NB: the large icon is now handled entirely by the template |
| 643 | |
| 644 | // bind the click event to the content area |
| 645 | ViewGroup content = (ViewGroup)row.findViewById(R.id.content); |
| 646 | ViewGroup adaptive = (ViewGroup)row.findViewById(R.id.adaptive); |
Daniel Sandler | bc5559f | 2012-04-19 01:08:15 -0400 | [diff] [blame] | 647 | |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 648 | content.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); |
Daniel Sandler | bc5559f | 2012-04-19 01:08:15 -0400 | [diff] [blame] | 649 | |
Daniel Sandler | e6f7f2e | 2013-04-25 15:44:16 -0400 | [diff] [blame] | 650 | PendingIntent contentIntent = sbn.getNotification().contentIntent; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 651 | if (contentIntent != null) { |
| 652 | final View.OnClickListener listener = new NotificationClicker(contentIntent, |
Daniel Sandler | 4f91efd | 2013-04-25 16:38:41 -0400 | [diff] [blame] | 653 | sbn.getPackageName(), sbn.getTag(), sbn.getId()); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 654 | content.setOnClickListener(listener); |
| 655 | } else { |
| 656 | content.setOnClickListener(null); |
| 657 | } |
| 658 | |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 659 | View contentViewLocal = null; |
| 660 | View bigContentViewLocal = null; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 661 | try { |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 662 | contentViewLocal = contentView.apply(mContext, adaptive, mOnClickHandler); |
| 663 | if (bigContentView != null) { |
| 664 | bigContentViewLocal = bigContentView.apply(mContext, adaptive, mOnClickHandler); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 665 | } |
| 666 | } |
| 667 | catch (RuntimeException e) { |
Daniel Sandler | 4f91efd | 2013-04-25 16:38:41 -0400 | [diff] [blame] | 668 | final String ident = sbn.getPackageName() + "/0x" + Integer.toHexString(sbn.getId()); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 669 | Log.e(TAG, "couldn't inflate view for notification " + ident, e); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 670 | return false; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 671 | } |
| 672 | |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 673 | if (contentViewLocal != null) { |
Daniel Sandler | 8680bf8 | 2012-05-15 16:52:52 -0400 | [diff] [blame] | 674 | SizeAdaptiveLayout.LayoutParams params = |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 675 | new SizeAdaptiveLayout.LayoutParams(contentViewLocal.getLayoutParams()); |
Chris Wren | ed5cc0e | 2012-06-21 11:25:58 -0400 | [diff] [blame] | 676 | params.minHeight = minHeight; |
| 677 | params.maxHeight = minHeight; |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 678 | adaptive.addView(contentViewLocal, params); |
Daniel Sandler | 8680bf8 | 2012-05-15 16:52:52 -0400 | [diff] [blame] | 679 | } |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 680 | if (bigContentViewLocal != null) { |
Daniel Sandler | 8680bf8 | 2012-05-15 16:52:52 -0400 | [diff] [blame] | 681 | SizeAdaptiveLayout.LayoutParams params = |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 682 | new SizeAdaptiveLayout.LayoutParams(bigContentViewLocal.getLayoutParams()); |
Chris Wren | ed5cc0e | 2012-06-21 11:25:58 -0400 | [diff] [blame] | 683 | params.minHeight = minHeight+1; |
Daniel Sandler | 8680bf8 | 2012-05-15 16:52:52 -0400 | [diff] [blame] | 684 | params.maxHeight = maxHeight; |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 685 | adaptive.addView(bigContentViewLocal, params); |
Daniel Sandler | 8680bf8 | 2012-05-15 16:52:52 -0400 | [diff] [blame] | 686 | } |
| 687 | row.setDrawingCacheEnabled(true); |
| 688 | |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 689 | applyLegacyRowBackground(sbn, content); |
| 690 | |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 691 | if (MULTIUSER_DEBUG) { |
| 692 | TextView debug = (TextView) row.findViewById(R.id.debug_info); |
| 693 | if (debug != null) { |
| 694 | debug.setVisibility(View.VISIBLE); |
| 695 | debug.setText("U " + entry.notification.getUserId()); |
| 696 | } |
| 697 | } |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 698 | entry.row = row; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 699 | entry.row.setRowHeight(mRowHeight); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 700 | entry.content = content; |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 701 | entry.expanded = contentViewLocal; |
| 702 | entry.setBigContentView(bigContentViewLocal); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 703 | |
| 704 | return true; |
| 705 | } |
| 706 | |
| 707 | public NotificationClicker makeClicker(PendingIntent intent, String pkg, String tag, int id) { |
| 708 | return new NotificationClicker(intent, pkg, tag, id); |
| 709 | } |
| 710 | |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 711 | protected class NotificationClicker implements View.OnClickListener { |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 712 | private PendingIntent mIntent; |
| 713 | private String mPkg; |
| 714 | private String mTag; |
| 715 | private int mId; |
| 716 | |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 717 | public NotificationClicker(PendingIntent intent, String pkg, String tag, int id) { |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 718 | mIntent = intent; |
| 719 | mPkg = pkg; |
| 720 | mTag = tag; |
| 721 | mId = id; |
| 722 | } |
| 723 | |
| 724 | public void onClick(View v) { |
| 725 | try { |
| 726 | // The intent we are sending is for the application, which |
| 727 | // won't have permission to immediately start an activity after |
| 728 | // the user switches to home. We know it is safe to do at this |
| 729 | // point, so make sure new activity switches are now allowed. |
| 730 | ActivityManagerNative.getDefault().resumeAppSwitches(); |
| 731 | // Also, notifications can be launched from the lock screen, |
| 732 | // so dismiss the lock screen when the activity starts. |
| 733 | ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity(); |
| 734 | } catch (RemoteException e) { |
| 735 | } |
| 736 | |
| 737 | if (mIntent != null) { |
| 738 | int[] pos = new int[2]; |
| 739 | v.getLocationOnScreen(pos); |
| 740 | Intent overlay = new Intent(); |
| 741 | overlay.setSourceBounds( |
| 742 | new Rect(pos[0], pos[1], pos[0]+v.getWidth(), pos[1]+v.getHeight())); |
| 743 | try { |
| 744 | mIntent.send(mContext, 0, overlay); |
| 745 | } catch (PendingIntent.CanceledException e) { |
| 746 | // the stack trace isn't very helpful here. Just log the exception message. |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 747 | Log.w(TAG, "Sending contentIntent failed: " + e); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 748 | } |
| 749 | |
Jim Miller | a999d46 | 2013-10-30 13:58:11 -0700 | [diff] [blame] | 750 | KeyguardTouchDelegate.getInstance(mContext).dismiss(); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 751 | } |
| 752 | |
| 753 | try { |
| 754 | mBarService.onNotificationClick(mPkg, mTag, mId); |
| 755 | } catch (RemoteException ex) { |
| 756 | // system process is dead if we're here. |
| 757 | } |
| 758 | |
| 759 | // close the shade if it was open |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 760 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 761 | visibilityChanged(false); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 762 | } |
| 763 | } |
| 764 | /** |
| 765 | * The LEDs are turned o)ff when the notification panel is shown, even just a little bit. |
| 766 | * This was added last-minute and is inconsistent with the way the rest of the notifications |
| 767 | * are handled, because the notification isn't really cancelled. The lights are just |
| 768 | * turned off. If any other notifications happen, the lights will turn back on. Steve says |
| 769 | * this is what he wants. (see bug 1131461) |
| 770 | */ |
| 771 | protected void visibilityChanged(boolean visible) { |
| 772 | if (mPanelSlightlyVisible != visible) { |
| 773 | mPanelSlightlyVisible = visible; |
| 774 | try { |
| 775 | mBarService.onPanelRevealed(); |
| 776 | } catch (RemoteException ex) { |
| 777 | // Won't fail unless the world has ended. |
| 778 | } |
| 779 | } |
| 780 | } |
| 781 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 782 | /** |
| 783 | * Cancel this notification and tell the StatusBarManagerService / NotificationManagerService |
| 784 | * about the failure. |
| 785 | * |
| 786 | * WARNING: this will call back into us. Don't hold any locks. |
| 787 | */ |
| 788 | void handleNotificationError(IBinder key, StatusBarNotification n, String message) { |
| 789 | removeNotification(key); |
| 790 | try { |
Daniel Sandler | 4f91efd | 2013-04-25 16:38:41 -0400 | [diff] [blame] | 791 | mBarService.onNotificationError(n.getPackageName(), n.getTag(), n.getId(), n.getUid(), n.getInitialPid(), message); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 792 | } catch (RemoteException ex) { |
| 793 | // The end is nigh. |
| 794 | } |
| 795 | } |
| 796 | |
| 797 | protected StatusBarNotification removeNotificationViews(IBinder key) { |
| 798 | NotificationData.Entry entry = mNotificationData.remove(key); |
| 799 | if (entry == null) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 800 | Log.w(TAG, "removeNotification for unknown key: " + key); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 801 | return null; |
| 802 | } |
| 803 | // Remove the expanded view. |
| 804 | ViewGroup rowParent = (ViewGroup)entry.row.getParent(); |
| 805 | if (rowParent != null) rowParent.removeView(entry.row); |
Chris Wren | 8fd1265 | 2012-05-09 21:25:57 -0400 | [diff] [blame] | 806 | updateExpansionStates(); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 807 | updateNotificationIcons(); |
| 808 | |
| 809 | return entry.notification; |
| 810 | } |
| 811 | |
Chris Wren | f0048ce | 2013-08-07 16:43:43 -0400 | [diff] [blame] | 812 | protected NotificationData.Entry createNotificationViews(IBinder key, |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 813 | StatusBarNotification notification) { |
| 814 | if (DEBUG) { |
Chris Wren | f0048ce | 2013-08-07 16:43:43 -0400 | [diff] [blame] | 815 | Log.d(TAG, "createNotificationViews(key=" + key + ", notification=" + notification); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 816 | } |
| 817 | // Construct the icon. |
| 818 | final StatusBarIconView iconView = new StatusBarIconView(mContext, |
Daniel Sandler | 4f91efd | 2013-04-25 16:38:41 -0400 | [diff] [blame] | 819 | notification.getPackageName() + "/0x" + Integer.toHexString(notification.getId()), |
John Spurlock | e6f0a71 | 2013-09-03 16:23:49 -0400 | [diff] [blame] | 820 | notification.getNotification()); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 821 | iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); |
| 822 | |
Daniel Sandler | 4f91efd | 2013-04-25 16:38:41 -0400 | [diff] [blame] | 823 | final StatusBarIcon ic = new StatusBarIcon(notification.getPackageName(), |
Daniel Sandler | e6f7f2e | 2013-04-25 15:44:16 -0400 | [diff] [blame] | 824 | notification.getUser(), |
| 825 | notification.getNotification().icon, |
| 826 | notification.getNotification().iconLevel, |
| 827 | notification.getNotification().number, |
| 828 | notification.getNotification().tickerText); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 829 | if (!iconView.set(ic)) { |
| 830 | handleNotificationError(key, notification, "Couldn't create icon: " + ic); |
| 831 | return null; |
| 832 | } |
| 833 | // Construct the expanded view. |
| 834 | NotificationData.Entry entry = new NotificationData.Entry(key, notification, iconView); |
| 835 | if (!inflateViews(entry, mPile)) { |
| 836 | handleNotificationError(key, notification, "Couldn't expand RemoteViews for: " |
| 837 | + notification); |
| 838 | return null; |
| 839 | } |
Chris Wren | f0048ce | 2013-08-07 16:43:43 -0400 | [diff] [blame] | 840 | return entry; |
| 841 | } |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 842 | |
Chris Wren | f0048ce | 2013-08-07 16:43:43 -0400 | [diff] [blame] | 843 | protected void addNotificationViews(NotificationData.Entry entry) { |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 844 | // Add the expanded view and icon. |
| 845 | int pos = mNotificationData.add(entry); |
| 846 | if (DEBUG) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 847 | Log.d(TAG, "addNotificationViews: added at " + pos); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 848 | } |
Chris Wren | 8fd1265 | 2012-05-09 21:25:57 -0400 | [diff] [blame] | 849 | updateExpansionStates(); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 850 | updateNotificationIcons(); |
Chris Wren | f0048ce | 2013-08-07 16:43:43 -0400 | [diff] [blame] | 851 | } |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 852 | |
Chris Wren | f0048ce | 2013-08-07 16:43:43 -0400 | [diff] [blame] | 853 | private void addNotificationViews(IBinder key, StatusBarNotification notification) { |
| 854 | addNotificationViews(createNotificationViews(key, notification)); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 855 | } |
| 856 | |
Chris Wren | 8fd1265 | 2012-05-09 21:25:57 -0400 | [diff] [blame] | 857 | protected void updateExpansionStates() { |
| 858 | int N = mNotificationData.size(); |
| 859 | for (int i = 0; i < N; i++) { |
| 860 | NotificationData.Entry entry = mNotificationData.get(i); |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 861 | if (!entry.row.isUserLocked()) { |
Chris Wren | 3ddab0d | 2012-08-02 16:52:21 -0400 | [diff] [blame] | 862 | if (i == (N-1)) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 863 | if (DEBUG) Log.d(TAG, "expanding top notification at " + i); |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 864 | entry.row.setExpanded(true); |
Chris Wren | 8fd1265 | 2012-05-09 21:25:57 -0400 | [diff] [blame] | 865 | } else { |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 866 | if (!entry.row.isUserExpanded()) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 867 | if (DEBUG) Log.d(TAG, "collapsing notification at " + i); |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 868 | entry.row.setExpanded(false); |
Chris Wren | 3ddab0d | 2012-08-02 16:52:21 -0400 | [diff] [blame] | 869 | } else { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 870 | if (DEBUG) Log.d(TAG, "ignoring user-modified notification at " + i); |
Chris Wren | 3ddab0d | 2012-08-02 16:52:21 -0400 | [diff] [blame] | 871 | } |
Chris Wren | 8fd1265 | 2012-05-09 21:25:57 -0400 | [diff] [blame] | 872 | } |
Chris Wren | 3ddab0d | 2012-08-02 16:52:21 -0400 | [diff] [blame] | 873 | } else { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 874 | if (DEBUG) Log.d(TAG, "ignoring notification being held by user at " + i); |
Chris Wren | 8fd1265 | 2012-05-09 21:25:57 -0400 | [diff] [blame] | 875 | } |
| 876 | } |
| 877 | } |
| 878 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 879 | protected abstract void haltTicker(); |
| 880 | protected abstract void setAreThereNotifications(); |
| 881 | protected abstract void updateNotificationIcons(); |
| 882 | protected abstract void tick(IBinder key, StatusBarNotification n, boolean firstTime); |
| 883 | protected abstract void updateExpandedViewPos(int expandedPosition); |
Chris Wren | 8fd1265 | 2012-05-09 21:25:57 -0400 | [diff] [blame] | 884 | protected abstract int getExpandedViewMaxHeight(); |
Jim Miller | b4238e0 | 2012-05-14 15:26:20 -0700 | [diff] [blame] | 885 | protected abstract boolean shouldDisableNavbarGestures(); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 886 | |
| 887 | protected boolean isTopNotification(ViewGroup parent, NotificationData.Entry entry) { |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 888 | return parent != null && parent.indexOfChild(entry.row) == 0; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 889 | } |
| 890 | |
| 891 | public void updateNotification(IBinder key, StatusBarNotification notification) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 892 | if (DEBUG) Log.d(TAG, "updateNotification(" + key + " -> " + notification + ")"); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 893 | |
| 894 | final NotificationData.Entry oldEntry = mNotificationData.findByKey(key); |
| 895 | if (oldEntry == null) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 896 | Log.w(TAG, "updateNotification for unknown key: " + key); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 897 | return; |
| 898 | } |
| 899 | |
| 900 | final StatusBarNotification oldNotification = oldEntry.notification; |
| 901 | |
| 902 | // XXX: modify when we do something more intelligent with the two content views |
Daniel Sandler | e6f7f2e | 2013-04-25 15:44:16 -0400 | [diff] [blame] | 903 | final RemoteViews oldContentView = oldNotification.getNotification().contentView; |
| 904 | final RemoteViews contentView = notification.getNotification().contentView; |
| 905 | final RemoteViews oldBigContentView = oldNotification.getNotification().bigContentView; |
| 906 | final RemoteViews bigContentView = notification.getNotification().bigContentView; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 907 | |
| 908 | if (DEBUG) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 909 | Log.d(TAG, "old notification: when=" + oldNotification.getNotification().when |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 910 | + " ongoing=" + oldNotification.isOngoing() |
| 911 | + " expanded=" + oldEntry.expanded |
| 912 | + " contentView=" + oldContentView |
Chris Wren | e9e3772 | 2012-05-11 17:40:14 -0400 | [diff] [blame] | 913 | + " bigContentView=" + oldBigContentView |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 914 | + " rowParent=" + oldEntry.row.getParent()); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 915 | Log.d(TAG, "new notification: when=" + notification.getNotification().when |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 916 | + " ongoing=" + oldNotification.isOngoing() |
Chris Wren | e9e3772 | 2012-05-11 17:40:14 -0400 | [diff] [blame] | 917 | + " contentView=" + contentView |
| 918 | + " bigContentView=" + bigContentView); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 919 | } |
| 920 | |
| 921 | // Can we just reapply the RemoteViews in place? If when didn't change, the order |
| 922 | // didn't change. |
Chris Wren | e9e3772 | 2012-05-11 17:40:14 -0400 | [diff] [blame] | 923 | |
| 924 | // 1U is never null |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 925 | boolean contentsUnchanged = oldEntry.expanded != null |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 926 | && contentView.getPackage() != null |
| 927 | && oldContentView.getPackage() != null |
| 928 | && oldContentView.getPackage().equals(contentView.getPackage()) |
| 929 | && oldContentView.getLayoutId() == contentView.getLayoutId(); |
Chris Wren | e9e3772 | 2012-05-11 17:40:14 -0400 | [diff] [blame] | 930 | // large view may be null |
| 931 | boolean bigContentsUnchanged = |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 932 | (oldEntry.getBigContentView() == null && bigContentView == null) |
| 933 | || ((oldEntry.getBigContentView() != null && bigContentView != null) |
Chris Wren | e9e3772 | 2012-05-11 17:40:14 -0400 | [diff] [blame] | 934 | && bigContentView.getPackage() != null |
| 935 | && oldBigContentView.getPackage() != null |
| 936 | && oldBigContentView.getPackage().equals(bigContentView.getPackage()) |
| 937 | && oldBigContentView.getLayoutId() == bigContentView.getLayoutId()); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 938 | ViewGroup rowParent = (ViewGroup) oldEntry.row.getParent(); |
Daniel Sandler | e6f7f2e | 2013-04-25 15:44:16 -0400 | [diff] [blame] | 939 | boolean orderUnchanged = notification.getNotification().when== oldNotification.getNotification().when |
| 940 | && notification.getScore() == oldNotification.getScore(); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 941 | // score now encompasses/supersedes isOngoing() |
| 942 | |
Daniel Sandler | e6f7f2e | 2013-04-25 15:44:16 -0400 | [diff] [blame] | 943 | boolean updateTicker = notification.getNotification().tickerText != null |
| 944 | && !TextUtils.equals(notification.getNotification().tickerText, |
| 945 | oldEntry.notification.getNotification().tickerText); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 946 | boolean isTopAnyway = isTopNotification(rowParent, oldEntry); |
Chris Wren | e9e3772 | 2012-05-11 17:40:14 -0400 | [diff] [blame] | 947 | if (contentsUnchanged && bigContentsUnchanged && (orderUnchanged || isTopAnyway)) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 948 | if (DEBUG) Log.d(TAG, "reusing notification for key: " + key); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 949 | oldEntry.notification = notification; |
| 950 | try { |
Chris Wren | e03f4e1 | 2013-08-08 16:48:48 -0400 | [diff] [blame] | 951 | updateNotificationViews(oldEntry, notification); |
| 952 | |
| 953 | if (ENABLE_HEADS_UP && mInterruptingNotificationEntry != null |
| 954 | && oldNotification == mInterruptingNotificationEntry.notification) { |
| 955 | if (!shouldInterrupt(notification)) { |
| 956 | if (DEBUG) Log.d(TAG, "no longer interrupts!"); |
| 957 | mHandler.sendEmptyMessage(MSG_HIDE_HEADS_UP); |
| 958 | } else { |
| 959 | if (DEBUG) Log.d(TAG, "updating the current heads up:" + notification); |
| 960 | mInterruptingNotificationEntry.notification = notification; |
| 961 | updateNotificationViews(mInterruptingNotificationEntry, notification); |
| 962 | } |
Chris Wren | e9e3772 | 2012-05-11 17:40:14 -0400 | [diff] [blame] | 963 | } |
Chris Wren | e03f4e1 | 2013-08-08 16:48:48 -0400 | [diff] [blame] | 964 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 965 | // Update the icon. |
Daniel Sandler | 4f91efd | 2013-04-25 16:38:41 -0400 | [diff] [blame] | 966 | final StatusBarIcon ic = new StatusBarIcon(notification.getPackageName(), |
Daniel Sandler | e6f7f2e | 2013-04-25 15:44:16 -0400 | [diff] [blame] | 967 | notification.getUser(), |
| 968 | notification.getNotification().icon, notification.getNotification().iconLevel, |
| 969 | notification.getNotification().number, |
| 970 | notification.getNotification().tickerText); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 971 | if (!oldEntry.icon.set(ic)) { |
| 972 | handleNotificationError(key, notification, "Couldn't update icon: " + ic); |
| 973 | return; |
| 974 | } |
Chris Wren | 8fd1265 | 2012-05-09 21:25:57 -0400 | [diff] [blame] | 975 | updateExpansionStates(); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 976 | } |
| 977 | catch (RuntimeException e) { |
| 978 | // It failed to add cleanly. Log, and remove the view from the panel. |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 979 | Log.w(TAG, "Couldn't reapply views for package " + contentView.getPackage(), e); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 980 | removeNotificationViews(key); |
| 981 | addNotificationViews(key, notification); |
| 982 | } |
| 983 | } else { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 984 | if (DEBUG) Log.d(TAG, "not reusing notification for key: " + key); |
| 985 | if (DEBUG) Log.d(TAG, "contents was " + (contentsUnchanged ? "unchanged" : "changed")); |
| 986 | if (DEBUG) Log.d(TAG, "order was " + (orderUnchanged ? "unchanged" : "changed")); |
| 987 | if (DEBUG) Log.d(TAG, "notification is " + (isTopAnyway ? "top" : "not top")); |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 988 | final boolean wasExpanded = oldEntry.row.isUserExpanded(); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 989 | removeNotificationViews(key); |
Chris Wren | e03f4e1 | 2013-08-08 16:48:48 -0400 | [diff] [blame] | 990 | addNotificationViews(key, notification); // will also replace the heads up |
Chris Wren | c9433ecb | 2012-06-27 17:37:03 -0400 | [diff] [blame] | 991 | if (wasExpanded) { |
| 992 | final NotificationData.Entry newEntry = mNotificationData.findByKey(key); |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 993 | newEntry.row.setExpanded(true); |
| 994 | newEntry.row.setUserExpanded(true); |
Chris Wren | c9433ecb | 2012-06-27 17:37:03 -0400 | [diff] [blame] | 995 | } |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 996 | } |
| 997 | |
| 998 | // Update the veto button accordingly (and as a result, whether this row is |
| 999 | // swipe-dismissable) |
| 1000 | updateNotificationVetoButton(oldEntry.row, notification); |
| 1001 | |
John Spurlock | 61e3683 | 2012-09-10 09:43:27 -0400 | [diff] [blame] | 1002 | // Is this for you? |
| 1003 | boolean isForCurrentUser = notificationIsForCurrentUser(notification); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 1004 | if (DEBUG) Log.d(TAG, "notification is " + (isForCurrentUser ? "" : "not ") + "for you"); |
John Spurlock | 61e3683 | 2012-09-10 09:43:27 -0400 | [diff] [blame] | 1005 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1006 | // Restart the ticker if it's still running |
John Spurlock | 61e3683 | 2012-09-10 09:43:27 -0400 | [diff] [blame] | 1007 | if (updateTicker && isForCurrentUser) { |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1008 | haltTicker(); |
| 1009 | tick(key, notification, false); |
| 1010 | } |
| 1011 | |
| 1012 | // Recalculate the position of the sliding windows and the titles. |
| 1013 | setAreThereNotifications(); |
| 1014 | updateExpandedViewPos(EXPANDED_LEAVE_ALONE); |
Chris Wren | e03f4e1 | 2013-08-08 16:48:48 -0400 | [diff] [blame] | 1015 | } |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1016 | |
Chris Wren | e03f4e1 | 2013-08-08 16:48:48 -0400 | [diff] [blame] | 1017 | private void updateNotificationViews(NotificationData.Entry entry, |
| 1018 | StatusBarNotification notification) { |
| 1019 | final RemoteViews contentView = notification.getNotification().contentView; |
| 1020 | final RemoteViews bigContentView = notification.getNotification().bigContentView; |
| 1021 | // Reapply the RemoteViews |
| 1022 | contentView.reapply(mContext, entry.expanded, mOnClickHandler); |
| 1023 | if (bigContentView != null && entry.getBigContentView() != null) { |
| 1024 | bigContentView.reapply(mContext, entry.getBigContentView(), mOnClickHandler); |
| 1025 | } |
| 1026 | // update the contentIntent |
| 1027 | final PendingIntent contentIntent = notification.getNotification().contentIntent; |
| 1028 | if (contentIntent != null) { |
| 1029 | final View.OnClickListener listener = makeClicker(contentIntent, |
| 1030 | notification.getPackageName(), notification.getTag(), notification.getId()); |
| 1031 | entry.content.setOnClickListener(listener); |
| 1032 | } else { |
| 1033 | entry.content.setOnClickListener(null); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1034 | } |
| 1035 | } |
John Spurlock | 3623128 | 2012-06-23 17:11:27 -0400 | [diff] [blame] | 1036 | |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 1037 | protected void notifyHeadsUpScreenOn(boolean screenOn) { |
| 1038 | if (!screenOn && mInterruptingNotificationEntry != null) { |
| 1039 | mHandler.sendEmptyMessage(MSG_ESCALATE_HEADS_UP); |
| 1040 | } |
| 1041 | } |
| 1042 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1043 | protected boolean shouldInterrupt(StatusBarNotification sbn) { |
| 1044 | Notification notification = sbn.getNotification(); |
| 1045 | // some predicates to make the boolean logic legible |
| 1046 | boolean isNoisy = (notification.defaults & Notification.DEFAULT_SOUND) != 0 |
| 1047 | || (notification.defaults & Notification.DEFAULT_VIBRATE) != 0 |
| 1048 | || notification.sound != null |
| 1049 | || notification.vibrate != null; |
| 1050 | boolean isHighPriority = sbn.getScore() >= INTERRUPTION_THRESHOLD; |
| 1051 | boolean isFullscreen = notification.fullScreenIntent != null; |
| 1052 | boolean isAllowed = notification.extras.getInt(Notification.EXTRA_AS_HEADS_UP, |
| 1053 | Notification.HEADS_UP_ALLOWED) != Notification.HEADS_UP_NEVER; |
| 1054 | |
Jim Miller | a999d46 | 2013-10-30 13:58:11 -0700 | [diff] [blame] | 1055 | final KeyguardTouchDelegate keyguard = KeyguardTouchDelegate.getInstance(mContext); |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1056 | boolean interrupt = (isFullscreen || (isHighPriority && isNoisy)) |
| 1057 | && isAllowed |
| 1058 | && mPowerManager.isScreenOn() |
Jim Miller | a999d46 | 2013-10-30 13:58:11 -0700 | [diff] [blame] | 1059 | && !keyguard.isShowingAndNotHidden() |
| 1060 | && !keyguard.isInputRestricted(); |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 1061 | try { |
| 1062 | interrupt = interrupt && !mDreamManager.isDreaming(); |
| 1063 | } catch (RemoteException e) { |
| 1064 | Log.d(TAG, "failed to query dream manager", e); |
| 1065 | } |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1066 | if (DEBUG) Log.d(TAG, "interrupt: " + interrupt); |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 1067 | return interrupt; |
| 1068 | } |
| 1069 | |
John Spurlock | 3623128 | 2012-06-23 17:11:27 -0400 | [diff] [blame] | 1070 | // Q: What kinds of notifications should show during setup? |
| 1071 | // A: Almost none! Only things coming from the system (package is "android") that also |
| 1072 | // have special "kind" tags marking them as relevant for setup (see below). |
| 1073 | protected boolean showNotificationEvenIfUnprovisioned(StatusBarNotification sbn) { |
Daniel Sandler | 4f91efd | 2013-04-25 16:38:41 -0400 | [diff] [blame] | 1074 | if ("android".equals(sbn.getPackageName())) { |
Daniel Sandler | e6f7f2e | 2013-04-25 15:44:16 -0400 | [diff] [blame] | 1075 | if (sbn.getNotification().kind != null) { |
| 1076 | for (String aKind : sbn.getNotification().kind) { |
John Spurlock | 3623128 | 2012-06-23 17:11:27 -0400 | [diff] [blame] | 1077 | // IME switcher, created by InputMethodManagerService |
| 1078 | if ("android.system.imeswitcher".equals(aKind)) return true; |
| 1079 | // OTA availability & errors, created by SystemUpdateService |
| 1080 | if ("android.system.update".equals(aKind)) return true; |
| 1081 | } |
| 1082 | } |
| 1083 | } |
| 1084 | return false; |
| 1085 | } |
John Spurlock | 67ad368 | 2012-06-26 17:42:00 -0400 | [diff] [blame] | 1086 | |
| 1087 | public boolean inKeyguardRestrictedInputMode() { |
Jim Miller | a999d46 | 2013-10-30 13:58:11 -0700 | [diff] [blame] | 1088 | return KeyguardTouchDelegate.getInstance(mContext).isInputRestricted(); |
John Spurlock | 67ad368 | 2012-06-26 17:42:00 -0400 | [diff] [blame] | 1089 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1090 | |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 1091 | public void setInteracting(int barWindow, boolean interacting) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1092 | // hook for subclasses |
| 1093 | } |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 1094 | |
| 1095 | public void destroy() { |
| 1096 | if (mSearchPanelView != null) { |
| 1097 | mWindowManager.removeViewImmediate(mSearchPanelView); |
| 1098 | } |
| 1099 | mContext.unregisterReceiver(mBroadcastReceiver); |
| 1100 | } |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 1101 | } |