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; |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 25 | import android.content.ComponentName; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 26 | import android.content.Context; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 27 | import android.content.Intent; |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 28 | import android.content.IntentFilter; |
Daniel Sandler | 96fd7c1 | 2012-03-30 16:37:36 -0400 | [diff] [blame] | 29 | import android.content.pm.ApplicationInfo; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 30 | import android.content.pm.PackageManager; |
Daniel Sandler | 96fd7c1 | 2012-03-30 16:37:36 -0400 | [diff] [blame] | 31 | import android.content.pm.PackageManager.NameNotFoundException; |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 32 | import android.content.pm.UserInfo; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 33 | import android.content.res.Configuration; |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 34 | import android.database.ContentObserver; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 35 | import android.graphics.Rect; |
Jorim Jaggi | 39fa59f | 2014-02-25 15:38:45 +0100 | [diff] [blame] | 36 | import android.graphics.drawable.Drawable; |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 37 | import android.net.Uri; |
Daniel Sandler | 96fd7c1 | 2012-03-30 16:37:36 -0400 | [diff] [blame] | 38 | import android.os.Build; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 39 | import android.os.Handler; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 40 | import android.os.IBinder; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 41 | import android.os.Message; |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 42 | import android.os.PowerManager; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 43 | import android.os.RemoteException; |
| 44 | import android.os.ServiceManager; |
Dianne Hackborn | f02b60a | 2012-08-16 10:48:27 -0700 | [diff] [blame] | 45 | import android.os.UserHandle; |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 46 | import android.os.UserManager; |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 47 | import android.provider.Settings; |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 48 | import android.service.dreams.DreamService; |
| 49 | import android.service.dreams.IDreamManager; |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 50 | import android.service.notification.NotificationListenerService; |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 51 | import android.service.notification.NotificationListenerService.Ranking; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 52 | import android.service.notification.StatusBarNotification; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 53 | import android.text.TextUtils; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 54 | import android.util.Log; |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 55 | import android.util.SparseArray; |
Dan Sandler | fd16d56 | 2014-02-13 18:43:31 -0800 | [diff] [blame] | 56 | import android.util.SparseBooleanArray; |
Daniel Sandler | c638c1e | 2011-08-24 16:19:23 -0700 | [diff] [blame] | 57 | import android.view.Display; |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 58 | import android.view.IWindowManager; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 59 | import android.view.LayoutInflater; |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 60 | import android.view.MenuItem; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 61 | import android.view.MotionEvent; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 62 | import android.view.View; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 63 | import android.view.ViewGroup; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 64 | import android.view.ViewGroup.LayoutParams; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 65 | import android.view.WindowManager; |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 66 | import android.view.WindowManagerGlobal; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 67 | import android.widget.ImageView; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 68 | import android.widget.LinearLayout; |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 69 | import android.widget.PopupMenu; |
Michael Jurka | a600fd9 | 2012-06-25 15:57:05 -0700 | [diff] [blame] | 70 | import android.widget.RemoteViews; |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 71 | import android.widget.TextView; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 72 | |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 73 | import com.android.internal.statusbar.IStatusBarService; |
| 74 | import com.android.internal.statusbar.StatusBarIcon; |
| 75 | import com.android.internal.statusbar.StatusBarIconList; |
Dan Sandler | 26e81cf | 2014-05-06 10:01:27 -0400 | [diff] [blame] | 76 | import com.android.internal.util.NotificationColorUtil; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 77 | import com.android.systemui.R; |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 78 | import com.android.systemui.RecentsComponent; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 79 | import com.android.systemui.SearchPanelView; |
| 80 | import com.android.systemui.SystemUI; |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 81 | import com.android.systemui.statusbar.NotificationData.Entry; |
Jim Miller | a999d46 | 2013-10-30 13:58:11 -0700 | [diff] [blame] | 82 | import com.android.systemui.statusbar.phone.KeyguardTouchDelegate; |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 83 | import com.android.systemui.statusbar.stack.NotificationStackScrollLayout; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 84 | |
Michael Jurka | a600fd9 | 2012-06-25 15:57:05 -0700 | [diff] [blame] | 85 | import java.util.ArrayList; |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 86 | import java.util.Arrays; |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 87 | import java.util.Collections; |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 88 | import java.util.Locale; |
Joe Onorato | 1c95ecb | 2010-06-28 17:19:12 -0400 | [diff] [blame] | 89 | |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 90 | import static com.android.keyguard.KeyguardHostView.OnDismissAction; |
| 91 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 92 | public abstract class BaseStatusBar extends SystemUI implements |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 93 | CommandQueue.Callbacks, ActivatableNotificationView.OnActivatedListener { |
Daniel Sandler | 198a030 | 2012-08-17 16:04:31 -0400 | [diff] [blame] | 94 | public static final String TAG = "StatusBar"; |
| 95 | public static final boolean DEBUG = false; |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 96 | public static final boolean MULTIUSER_DEBUG = false; |
Christoph Studer | c288514 | 2014-05-28 14:48:15 +0200 | [diff] [blame] | 97 | private static final boolean USE_NOTIFICATION_LISTENER = true; |
Joe Onorato | 1c95ecb | 2010-06-28 17:19:12 -0400 | [diff] [blame] | 98 | |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 99 | protected static final int MSG_SHOW_RECENT_APPS = 1019; |
| 100 | protected static final int MSG_HIDE_RECENT_APPS = 1020; |
| 101 | protected static final int MSG_TOGGLE_RECENTS_APPS = 1021; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 102 | protected static final int MSG_PRELOAD_RECENT_APPS = 1022; |
| 103 | protected static final int MSG_CANCEL_PRELOAD_RECENT_APPS = 1023; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 104 | protected static final int MSG_OPEN_SEARCH_PANEL = 1024; |
| 105 | protected static final int MSG_CLOSE_SEARCH_PANEL = 1025; |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 106 | protected static final int MSG_SHOW_HEADS_UP = 1026; |
| 107 | protected static final int MSG_HIDE_HEADS_UP = 1027; |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 108 | protected static final int MSG_ESCALATE_HEADS_UP = 1028; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 109 | |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 110 | protected static final boolean ENABLE_HEADS_UP = true; |
| 111 | // scores above this threshold should be displayed in heads up mode. |
Chris Wren | 5d9b153 | 2014-03-21 14:31:05 -0400 | [diff] [blame] | 112 | protected static final int INTERRUPTION_THRESHOLD = 10; |
Chris Wren | 22ae46e | 2014-02-26 18:08:09 -0500 | [diff] [blame] | 113 | protected static final String SETTING_HEADS_UP_TICKER = "ticker_gets_heads_up"; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 114 | |
Michael Jurka | 56a5783 | 2012-05-14 13:24:43 -0700 | [diff] [blame] | 115 | // Should match the value in PhoneWindowManager |
| 116 | public static final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps"; |
| 117 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 118 | public static final int EXPANDED_LEAVE_ALONE = -10000; |
| 119 | public static final int EXPANDED_FULL_OPEN = -10001; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 120 | |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 121 | /** If true, delays dismissing the Keyguard until the ActivityManager calls back. */ |
| 122 | protected static final boolean DELAY_DISMISS_TO_ACTIVITY_LAUNCH = false; |
| 123 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 124 | protected CommandQueue mCommandQueue; |
| 125 | protected IStatusBarService mBarService; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 126 | protected H mHandler = createHandler(); |
| 127 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 128 | // all notifications |
| 129 | protected NotificationData mNotificationData = new NotificationData(); |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 130 | protected NotificationStackScrollLayout mStackScroller; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 131 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 132 | protected NotificationData.Entry mInterruptingNotificationEntry; |
| 133 | protected long mInterruptingNotificationTime; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 134 | |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 135 | // used to notify status bar for suppressing notification LED |
| 136 | protected boolean mPanelSlightlyVisible; |
| 137 | |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 138 | // Search panel |
| 139 | protected SearchPanelView mSearchPanelView; |
| 140 | |
Daniel Sandler | 469e96e | 2012-05-04 15:56:19 -0400 | [diff] [blame] | 141 | protected PopupMenu mNotificationBlamePopup; |
| 142 | |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 143 | protected int mCurrentUserId = 0; |
Kenny Guy | 2a76494 | 2014-04-02 13:29:20 +0100 | [diff] [blame] | 144 | final protected SparseArray<UserInfo> mCurrentProfiles = new SparseArray<UserInfo>(); |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 145 | |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 146 | protected int mLayoutDirection = -1; // invalid |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 147 | private Locale mLocale; |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 148 | protected boolean mUseHeadsUp = false; |
Chris Wren | 22ae46e | 2014-02-26 18:08:09 -0500 | [diff] [blame] | 149 | protected boolean mHeadsUpTicker = false; |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 150 | |
| 151 | protected IDreamManager mDreamManager; |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 152 | PowerManager mPowerManager; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 153 | protected int mRowMinHeight; |
| 154 | protected int mRowMaxHeight; |
Dan Sandler | fd16d56 | 2014-02-13 18:43:31 -0800 | [diff] [blame] | 155 | |
| 156 | // public mode, private notifications, etc |
| 157 | private boolean mLockscreenPublicMode = false; |
| 158 | private final SparseBooleanArray mUsersAllowingPrivateNotifications = new SparseBooleanArray(); |
Dan Sandler | 26e81cf | 2014-05-06 10:01:27 -0400 | [diff] [blame] | 159 | private NotificationColorUtil mNotificationColorUtil = NotificationColorUtil.getInstance(); |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 160 | |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 161 | private UserManager mUserManager; |
| 162 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 163 | // UI-specific methods |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 164 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 165 | /** |
| 166 | * Create all windows necessary for the status bar (including navigation, overlay panels, etc) |
| 167 | * and add them to the window manager. |
| 168 | */ |
| 169 | protected abstract void createAndAddWindows(); |
Joe Onorato | 1c95ecb | 2010-06-28 17:19:12 -0400 | [diff] [blame] | 170 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 171 | protected WindowManager mWindowManager; |
| 172 | protected IWindowManager mWindowManagerService; |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 173 | |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 174 | protected abstract void refreshLayout(int layoutDirection); |
| 175 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 176 | protected Display mDisplay; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 177 | |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 178 | private boolean mDeviceProvisioned = false; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 179 | |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 180 | private RecentsComponent mRecents; |
| 181 | |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 182 | protected int mZenMode; |
| 183 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 184 | /** |
| 185 | * The {@link StatusBarState} of the status bar. |
| 186 | */ |
| 187 | protected int mState; |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 188 | protected boolean mBouncerShowing; |
John Spurlock | 4b3bda2 | 2014-05-22 14:32:20 -0400 | [diff] [blame] | 189 | protected boolean mShowLockscreenNotifications; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 190 | |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 191 | protected NotificationOverflowContainer mKeyguardIconOverflowContainer; |
Jorim Jaggi | 649b708 | 2014-04-03 13:15:18 +0200 | [diff] [blame] | 192 | |
Daniel Sandler | 3ffdcc7 | 2012-09-23 14:31:48 -0400 | [diff] [blame] | 193 | public boolean isDeviceProvisioned() { |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 194 | return mDeviceProvisioned; |
| 195 | } |
| 196 | |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 197 | protected final ContentObserver mSettingsObserver = new ContentObserver(mHandler) { |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 198 | @Override |
| 199 | public void onChange(boolean selfChange) { |
Jeff Brown | bf6f6f9 | 2012-09-25 15:03:20 -0700 | [diff] [blame] | 200 | final boolean provisioned = 0 != Settings.Global.getInt( |
| 201 | mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0); |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 202 | if (provisioned != mDeviceProvisioned) { |
| 203 | mDeviceProvisioned = provisioned; |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 204 | updateNotifications(); |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 205 | } |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 206 | final int mode = Settings.Global.getInt(mContext.getContentResolver(), |
| 207 | Settings.Global.ZEN_MODE, Settings.Global.ZEN_MODE_OFF); |
| 208 | setZenMode(mode); |
John Spurlock | 4b3bda2 | 2014-05-22 14:32:20 -0400 | [diff] [blame] | 209 | final boolean show = Settings.Global.getInt(mContext.getContentResolver(), |
| 210 | Settings.Global.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1) != 0; |
| 211 | setShowLockscreenNotifications(show); |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 212 | } |
| 213 | }; |
| 214 | |
Dan Sandler | fd16d56 | 2014-02-13 18:43:31 -0800 | [diff] [blame] | 215 | private final ContentObserver mLockscreenSettingsObserver = new ContentObserver(mHandler) { |
| 216 | @Override |
| 217 | public void onChange(boolean selfChange) { |
| 218 | // We don't know which user changed LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, |
| 219 | // so we just dump our cache ... |
| 220 | mUsersAllowingPrivateNotifications.clear(); |
| 221 | // ... and refresh all the notifications |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 222 | updateNotifications(); |
Dan Sandler | fd16d56 | 2014-02-13 18:43:31 -0800 | [diff] [blame] | 223 | } |
| 224 | }; |
| 225 | |
Dianne Hackborn | 1927ae8 | 2012-06-22 15:21:36 -0700 | [diff] [blame] | 226 | private RemoteViews.OnClickHandler mOnClickHandler = new RemoteViews.OnClickHandler() { |
| 227 | @Override |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 228 | public boolean onClickHandler( |
| 229 | final View view, final PendingIntent pendingIntent, final Intent fillInIntent) { |
Daniel Sandler | 198a030 | 2012-08-17 16:04:31 -0400 | [diff] [blame] | 230 | if (DEBUG) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 231 | Log.v(TAG, "Notification click handler invoked for intent: " + pendingIntent); |
Daniel Sandler | 198a030 | 2012-08-17 16:04:31 -0400 | [diff] [blame] | 232 | } |
Dianne Hackborn | 1927ae8 | 2012-06-22 15:21:36 -0700 | [diff] [blame] | 233 | final boolean isActivity = pendingIntent.isActivity(); |
| 234 | if (isActivity) { |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 235 | dismissKeyguardThenExecute(new OnDismissAction() { |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 236 | @Override |
| 237 | public boolean onDismiss() { |
| 238 | try { |
| 239 | // The intent we are sending is for the application, which |
| 240 | // won't have permission to immediately start an activity after |
| 241 | // the user switches to home. We know it is safe to do at this |
| 242 | // point, so make sure new activity switches are now allowed. |
| 243 | ActivityManagerNative.getDefault().resumeAppSwitches(); |
| 244 | // Also, notifications can be launched from the lock screen, |
| 245 | // so dismiss the lock screen when the activity starts. |
| 246 | ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity(); |
| 247 | } catch (RemoteException e) { |
| 248 | } |
Dianne Hackborn | 1927ae8 | 2012-06-22 15:21:36 -0700 | [diff] [blame] | 249 | |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 250 | boolean handled = superOnClickHandler(view, pendingIntent, fillInIntent); |
Dianne Hackborn | 1927ae8 | 2012-06-22 15:21:36 -0700 | [diff] [blame] | 251 | |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 252 | // close the shade if it was open |
| 253 | if (handled) { |
| 254 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
| 255 | visibilityChanged(false); |
| 256 | } |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 257 | // Wait for activity start. |
| 258 | return handled && DELAY_DISMISS_TO_ACTIVITY_LAUNCH; |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 259 | } |
| 260 | }); |
| 261 | return true; |
| 262 | } else { |
| 263 | return super.onClickHandler(view, pendingIntent, fillInIntent); |
Dianne Hackborn | 1927ae8 | 2012-06-22 15:21:36 -0700 | [diff] [blame] | 264 | } |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | private boolean superOnClickHandler(View view, PendingIntent pendingIntent, |
| 268 | Intent fillInIntent) { |
| 269 | return super.onClickHandler(view, pendingIntent, fillInIntent); |
Dianne Hackborn | 1927ae8 | 2012-06-22 15:21:36 -0700 | [diff] [blame] | 270 | } |
| 271 | }; |
| 272 | |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 273 | private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { |
| 274 | @Override |
| 275 | public void onReceive(Context context, Intent intent) { |
| 276 | String action = intent.getAction(); |
| 277 | if (Intent.ACTION_USER_SWITCHED.equals(action)) { |
| 278 | mCurrentUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1); |
Kenny Guy | 2a76494 | 2014-04-02 13:29:20 +0100 | [diff] [blame] | 279 | updateCurrentProfilesCache(); |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 280 | if (true) Log.v(TAG, "userId " + mCurrentUserId + " is in the house"); |
| 281 | userSwitched(mCurrentUserId); |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 282 | } else if (Intent.ACTION_USER_ADDED.equals(action)) { |
Kenny Guy | 2a76494 | 2014-04-02 13:29:20 +0100 | [diff] [blame] | 283 | updateCurrentProfilesCache(); |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 284 | } |
| 285 | } |
| 286 | }; |
| 287 | |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 288 | private final NotificationListenerService mNotificationListener = |
| 289 | new NotificationListenerService() { |
| 290 | @Override |
| 291 | public void onListenerConnected() { |
| 292 | if (DEBUG) Log.d(TAG, "onListenerConnected"); |
| 293 | final StatusBarNotification[] notifications = getActiveNotifications(); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 294 | final Ranking currentRanking = getCurrentRanking(); |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 295 | mHandler.post(new Runnable() { |
| 296 | @Override |
| 297 | public void run() { |
| 298 | for (StatusBarNotification sbn : notifications) { |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 299 | addNotificationInternal(sbn, currentRanking); |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 300 | } |
| 301 | } |
| 302 | }); |
| 303 | } |
| 304 | |
| 305 | @Override |
| 306 | public void onNotificationPosted(final StatusBarNotification sbn) { |
| 307 | if (DEBUG) Log.d(TAG, "onNotificationPosted: " + sbn); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 308 | final Ranking currentRanking = getCurrentRanking(); |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 309 | mHandler.post(new Runnable() { |
| 310 | @Override |
| 311 | public void run() { |
| 312 | if (mNotificationData.findByKey(sbn.getKey()) != null) { |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 313 | updateNotificationInternal(sbn, currentRanking); |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 314 | } else { |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 315 | addNotificationInternal(sbn, currentRanking); |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 316 | } |
| 317 | } |
| 318 | }); |
| 319 | } |
| 320 | |
| 321 | @Override |
| 322 | public void onNotificationRemoved(final StatusBarNotification sbn) { |
| 323 | if (DEBUG) Log.d(TAG, "onNotificationRemoved: " + sbn); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 324 | final Ranking currentRanking = getCurrentRanking(); |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 325 | mHandler.post(new Runnable() { |
| 326 | @Override |
| 327 | public void run() { |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 328 | removeNotificationInternal(sbn.getKey(), currentRanking); |
| 329 | } |
| 330 | }); |
| 331 | } |
| 332 | |
| 333 | @Override |
| 334 | public void onNotificationRankingUpdate() { |
| 335 | if (DEBUG) Log.d(TAG, "onRankingUpdate"); |
| 336 | final Ranking currentRanking = getCurrentRanking(); |
| 337 | mHandler.post(new Runnable() { |
| 338 | @Override |
| 339 | public void run() { |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 340 | updateRankingInternal(currentRanking); |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 341 | } |
| 342 | }); |
| 343 | } |
| 344 | }; |
| 345 | |
Kenny Guy | 2a76494 | 2014-04-02 13:29:20 +0100 | [diff] [blame] | 346 | private void updateCurrentProfilesCache() { |
| 347 | synchronized (mCurrentProfiles) { |
| 348 | mCurrentProfiles.clear(); |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 349 | if (mUserManager != null) { |
Kenny Guy | 2a76494 | 2014-04-02 13:29:20 +0100 | [diff] [blame] | 350 | for (UserInfo user : mUserManager.getProfiles(mCurrentUserId)) { |
| 351 | mCurrentProfiles.put(user.id, user); |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 352 | } |
| 353 | } |
| 354 | } |
| 355 | } |
| 356 | |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 357 | public void start() { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 358 | mWindowManager = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); |
| 359 | mWindowManagerService = WindowManagerGlobal.getWindowManagerService(); |
| 360 | mDisplay = mWindowManager.getDefaultDisplay(); |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 361 | |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 362 | mDreamManager = IDreamManager.Stub.asInterface( |
| 363 | ServiceManager.checkService(DreamService.DREAM_SERVICE)); |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 364 | mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); |
| 365 | |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 366 | mSettingsObserver.onChange(false); // set up |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 367 | mContext.getContentResolver().registerContentObserver( |
Jeff Brown | bf6f6f9 | 2012-09-25 15:03:20 -0700 | [diff] [blame] | 368 | Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED), true, |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 369 | mSettingsObserver); |
| 370 | mContext.getContentResolver().registerContentObserver( |
| 371 | Settings.Global.getUriFor(Settings.Global.ZEN_MODE), false, |
| 372 | mSettingsObserver); |
John Spurlock | 4b3bda2 | 2014-05-22 14:32:20 -0400 | [diff] [blame] | 373 | mContext.getContentResolver().registerContentObserver( |
| 374 | Settings.Global.getUriFor(Settings.Global.LOCK_SCREEN_SHOW_NOTIFICATIONS), false, |
| 375 | mSettingsObserver); |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 376 | |
Dan Sandler | fd16d56 | 2014-02-13 18:43:31 -0800 | [diff] [blame] | 377 | mContext.getContentResolver().registerContentObserver( |
| 378 | Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS), |
| 379 | true, |
| 380 | mLockscreenSettingsObserver, |
| 381 | UserHandle.USER_ALL); |
| 382 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 383 | mBarService = IStatusBarService.Stub.asInterface( |
| 384 | ServiceManager.getService(Context.STATUS_BAR_SERVICE)); |
Joe Onorato | 1c95ecb | 2010-06-28 17:19:12 -0400 | [diff] [blame] | 385 | |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 386 | mRecents = getComponent(RecentsComponent.class); |
| 387 | |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 388 | mLocale = mContext.getResources().getConfiguration().locale; |
| 389 | mLayoutDirection = TextUtils.getLayoutDirectionFromLocale(mLocale); |
| 390 | |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 391 | mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); |
| 392 | |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 393 | // Connect in to the status bar manager service |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 394 | StatusBarIconList iconList = new StatusBarIconList(); |
Joe Onorato | 75199e3 | 2010-05-29 17:22:51 -0400 | [diff] [blame] | 395 | ArrayList<StatusBarNotification> notifications = new ArrayList<StatusBarNotification>(); |
Joe Onorato | 66d7d01 | 2010-05-14 10:05:10 -0700 | [diff] [blame] | 396 | mCommandQueue = new CommandQueue(this, iconList); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 397 | |
Jason Monk | b605fec | 2014-05-02 17:04:10 -0400 | [diff] [blame] | 398 | int[] switches = new int[8]; |
satok | cd7cd29 | 2010-11-20 15:46:23 +0900 | [diff] [blame] | 399 | ArrayList<IBinder> binders = new ArrayList<IBinder>(); |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 400 | try { |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 401 | mBarService.registerStatusBar(mCommandQueue, iconList, notifications, |
satok | cd7cd29 | 2010-11-20 15:46:23 +0900 | [diff] [blame] | 402 | switches, binders); |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 403 | } catch (RemoteException ex) { |
| 404 | // If the system process isn't there we're doomed anyway. |
| 405 | } |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 406 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 407 | createAndAddWindows(); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 408 | |
Joe Onorato | e4c7b3f | 2010-10-30 12:15:03 -0700 | [diff] [blame] | 409 | disable(switches[0]); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 410 | setSystemUiVisibility(switches[1], 0xffffffff); |
Dianne Hackborn | 7d04932 | 2011-06-14 15:00:32 -0700 | [diff] [blame] | 411 | topAppWindowChanged(switches[2] != 0); |
satok | cd7cd29 | 2010-11-20 15:46:23 +0900 | [diff] [blame] | 412 | // StatusBarManagerService has a back up of IME token and it's restored here. |
Jason Monk | b605fec | 2014-05-02 17:04:10 -0400 | [diff] [blame] | 413 | setImeWindowStatus(binders.get(0), switches[3], switches[4], switches[7] != 0); |
Jeff Brown | 2992ea7 | 2011-01-28 22:04:14 -0800 | [diff] [blame] | 414 | setHardKeyboardStatus(switches[5] != 0, switches[6] != 0); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 415 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 416 | // Set up the initial icon state |
Joe Onorato | 75199e3 | 2010-05-29 17:22:51 -0400 | [diff] [blame] | 417 | int N = iconList.size(); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 418 | int viewIndex = 0; |
| 419 | for (int i=0; i<N; i++) { |
| 420 | StatusBarIcon icon = iconList.getIcon(i); |
| 421 | if (icon != null) { |
| 422 | addIcon(iconList.getSlot(i), i, viewIndex, icon); |
| 423 | viewIndex++; |
| 424 | } |
| 425 | } |
| 426 | |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 427 | // Set up the initial notification state. |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 428 | if (USE_NOTIFICATION_LISTENER) { |
| 429 | try { |
| 430 | mNotificationListener.registerAsSystemService( |
| 431 | new ComponentName(mContext.getPackageName(), getClass().getCanonicalName()), |
| 432 | UserHandle.USER_ALL); |
| 433 | } catch (RemoteException e) { |
| 434 | Log.e(TAG, "Unable to register notification listener", e); |
| 435 | } |
| 436 | } else { |
| 437 | N = notifications.size(); |
| 438 | for (int i=0; i<N; i++) { |
| 439 | addNotification(notifications.get(i)); |
| 440 | } |
Joe Onorato | 75199e3 | 2010-05-29 17:22:51 -0400 | [diff] [blame] | 441 | } |
| 442 | |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 443 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 444 | if (DEBUG) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 445 | Log.d(TAG, String.format( |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 446 | "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] | 447 | iconList.size(), |
| 448 | switches[0], |
| 449 | switches[1], |
| 450 | switches[2], |
| 451 | switches[3] |
| 452 | )); |
Joe Onorato | 1c95ecb | 2010-06-28 17:19:12 -0400 | [diff] [blame] | 453 | } |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 454 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 455 | mCurrentUserId = ActivityManager.getCurrentUser(); |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 456 | |
| 457 | IntentFilter filter = new IntentFilter(); |
| 458 | filter.addAction(Intent.ACTION_USER_SWITCHED); |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 459 | filter.addAction(Intent.ACTION_USER_ADDED); |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 460 | mContext.registerReceiver(mBroadcastReceiver, filter); |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 461 | |
Kenny Guy | 2a76494 | 2014-04-02 13:29:20 +0100 | [diff] [blame] | 462 | updateCurrentProfilesCache(); |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | public void userSwitched(int newUserId) { |
| 466 | // should be overridden |
| 467 | } |
| 468 | |
Kenny Guy | 2a76494 | 2014-04-02 13:29:20 +0100 | [diff] [blame] | 469 | public boolean notificationIsForCurrentProfiles(StatusBarNotification n) { |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 470 | final int thisUserId = mCurrentUserId; |
| 471 | final int notificationUserId = n.getUserId(); |
| 472 | if (DEBUG && MULTIUSER_DEBUG) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 473 | Log.v(TAG, String.format("%s: current userid: %d, notification userid: %d", |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 474 | n, thisUserId, notificationUserId)); |
| 475 | } |
Kenny Guy | 2a76494 | 2014-04-02 13:29:20 +0100 | [diff] [blame] | 476 | synchronized (mCurrentProfiles) { |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 477 | return notificationUserId == UserHandle.USER_ALL |
Kenny Guy | 2a76494 | 2014-04-02 13:29:20 +0100 | [diff] [blame] | 478 | || mCurrentProfiles.get(notificationUserId) != null; |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 479 | } |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 480 | } |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 481 | |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 482 | /** |
| 483 | * Takes the necessary steps to prepare the status bar for starting an activity, then starts it. |
| 484 | * @param action A dismiss action that is called if it's safe to start the activity. |
| 485 | */ |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 486 | protected void dismissKeyguardThenExecute(OnDismissAction action) { |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 487 | action.onDismiss(); |
| 488 | } |
| 489 | |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 490 | @Override |
| 491 | protected void onConfigurationChanged(Configuration newConfig) { |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 492 | final Locale locale = mContext.getResources().getConfiguration().locale; |
| 493 | final int ld = TextUtils.getLayoutDirectionFromLocale(locale); |
| 494 | if (! locale.equals(mLocale) || ld != mLayoutDirection) { |
| 495 | if (DEBUG) { |
| 496 | Log.v(TAG, String.format( |
| 497 | "config changed locale/LD: %s (%d) -> %s (%d)", mLocale, mLayoutDirection, |
| 498 | locale, ld)); |
| 499 | } |
| 500 | mLocale = locale; |
| 501 | mLayoutDirection = ld; |
| 502 | refreshLayout(ld); |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 503 | } |
| 504 | } |
| 505 | |
Winson Chung | c57ccf0 | 2011-10-13 15:04:59 -0700 | [diff] [blame] | 506 | protected View updateNotificationVetoButton(View row, StatusBarNotification n) { |
| 507 | View vetoButton = row.findViewById(R.id.veto); |
Chris Wren | 6d15a36 | 2013-08-20 18:46:29 -0400 | [diff] [blame] | 508 | if (n.isClearable() || (mInterruptingNotificationEntry != null |
| 509 | && mInterruptingNotificationEntry.row == row)) { |
Daniel Sandler | 4f91efd | 2013-04-25 16:38:41 -0400 | [diff] [blame] | 510 | final String _pkg = n.getPackageName(); |
Daniel Sandler | e6f7f2e | 2013-04-25 15:44:16 -0400 | [diff] [blame] | 511 | final String _tag = n.getTag(); |
| 512 | final int _id = n.getId(); |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 513 | final int _userId = n.getUserId(); |
Winson Chung | c57ccf0 | 2011-10-13 15:04:59 -0700 | [diff] [blame] | 514 | vetoButton.setOnClickListener(new View.OnClickListener() { |
| 515 | public void onClick(View v) { |
Casey Burkhardt | bac221f | 2012-10-03 18:13:58 -0700 | [diff] [blame] | 516 | // Accessibility feedback |
| 517 | v.announceForAccessibility( |
| 518 | mContext.getString(R.string.accessibility_notification_dismissed)); |
Winson Chung | c57ccf0 | 2011-10-13 15:04:59 -0700 | [diff] [blame] | 519 | try { |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 520 | mBarService.onNotificationClear(_pkg, _tag, _id, _userId); |
Casey Burkhardt | bac221f | 2012-10-03 18:13:58 -0700 | [diff] [blame] | 521 | |
Winson Chung | c57ccf0 | 2011-10-13 15:04:59 -0700 | [diff] [blame] | 522 | } catch (RemoteException ex) { |
| 523 | // system process is dead if we're here. |
| 524 | } |
| 525 | } |
| 526 | }); |
| 527 | vetoButton.setVisibility(View.VISIBLE); |
| 528 | } else { |
| 529 | vetoButton.setVisibility(View.GONE); |
| 530 | } |
Casey Burkhardt | bac221f | 2012-10-03 18:13:58 -0700 | [diff] [blame] | 531 | vetoButton.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO); |
Winson Chung | c57ccf0 | 2011-10-13 15:04:59 -0700 | [diff] [blame] | 532 | return vetoButton; |
| 533 | } |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 534 | |
Daniel Sandler | 96fd7c1 | 2012-03-30 16:37:36 -0400 | [diff] [blame] | 535 | |
Jorim Jaggi | 4673985 | 2014-04-15 09:58:24 +0200 | [diff] [blame] | 536 | protected void applyLegacyRowBackground(StatusBarNotification sbn, |
| 537 | NotificationData.Entry entry) { |
Dan Sandler | fe266a3 | 2014-05-15 22:28:06 -0400 | [diff] [blame] | 538 | int version = 0; |
| 539 | try { |
| 540 | ApplicationInfo info = mContext.getPackageManager().getApplicationInfo(sbn.getPackageName(), 0); |
| 541 | version = info.targetSdkVersion; |
| 542 | } catch (NameNotFoundException ex) { |
| 543 | Log.e(TAG, "Failed looking up ApplicationInfo for " + sbn.getPackageName(), ex); |
| 544 | } |
| 545 | |
Jorim Jaggi | 4673985 | 2014-04-15 09:58:24 +0200 | [diff] [blame] | 546 | if (entry.expanded.getId() != com.android.internal.R.id.status_bar_latest_event_content) { |
Dan Sandler | fe266a3 | 2014-05-15 22:28:06 -0400 | [diff] [blame] | 547 | // Using custom RemoteViews |
Daniel Sandler | 96fd7c1 | 2012-03-30 16:37:36 -0400 | [diff] [blame] | 548 | if (version > 0 && version < Build.VERSION_CODES.GINGERBREAD) { |
Jorim Jaggi | 4673985 | 2014-04-15 09:58:24 +0200 | [diff] [blame] | 549 | entry.row.setBackgroundResource(R.drawable.notification_row_legacy_bg); |
| 550 | } else if (version < Build.VERSION_CODES.L) { |
| 551 | entry.row.setBackgroundResourceIds( |
| 552 | com.android.internal.R.drawable.notification_bg, |
| 553 | com.android.internal.R.drawable.notification_bg_dim); |
Daniel Sandler | 96fd7c1 | 2012-03-30 16:37:36 -0400 | [diff] [blame] | 554 | } |
Dan Sandler | 842dd77 | 2014-05-15 09:36:47 -0400 | [diff] [blame] | 555 | } else { |
| 556 | // Using platform templates |
| 557 | final int color = sbn.getNotification().color; |
| 558 | if (isMediaNotification(entry)) { |
| 559 | entry.row.setBackgroundResourceIds( |
| 560 | com.android.internal.R.drawable.notification_quantum_bg, |
| 561 | color, |
| 562 | com.android.internal.R.drawable.notification_quantum_bg_dim, |
| 563 | color); |
| 564 | } |
Daniel Sandler | 96fd7c1 | 2012-03-30 16:37:36 -0400 | [diff] [blame] | 565 | } |
| 566 | } |
| 567 | |
Dan Sandler | 842dd77 | 2014-05-15 09:36:47 -0400 | [diff] [blame] | 568 | private boolean isMediaNotification(NotificationData.Entry entry) { |
| 569 | // TODO: confirm that there's a valid media key |
| 570 | return entry.expandedBig != null && |
| 571 | entry.expandedBig.findViewById(com.android.internal.R.id.media_action_area) != null; |
| 572 | } |
| 573 | |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 574 | private void startApplicationDetailsActivity(String packageName) { |
| 575 | Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, |
| 576 | Uri.fromParts("package", packageName, null)); |
Adam Powell | 0fc5b2b | 2012-07-18 18:20:29 -0700 | [diff] [blame] | 577 | intent.setComponent(intent.resolveActivity(mContext.getPackageManager())); |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 578 | TaskStackBuilder.create(mContext).addNextIntentWithParentStack(intent).startActivities( |
| 579 | null, UserHandle.CURRENT); |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 580 | } |
| 581 | |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 582 | protected View.OnLongClickListener getNotificationLongClicker() { |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 583 | return new View.OnLongClickListener() { |
| 584 | @Override |
| 585 | public boolean onLongClick(View v) { |
| 586 | final String packageNameF = (String) v.getTag(); |
| 587 | if (packageNameF == null) return false; |
Jeff Sharkey | af232ed | 2012-04-30 15:19:39 -0700 | [diff] [blame] | 588 | if (v.getWindowToken() == null) return false; |
Daniel Sandler | 469e96e | 2012-05-04 15:56:19 -0400 | [diff] [blame] | 589 | mNotificationBlamePopup = new PopupMenu(mContext, v); |
| 590 | mNotificationBlamePopup.getMenuInflater().inflate( |
| 591 | R.menu.notification_popup_menu, |
| 592 | mNotificationBlamePopup.getMenu()); |
| 593 | mNotificationBlamePopup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 594 | public boolean onMenuItemClick(MenuItem item) { |
| 595 | if (item.getItemId() == R.id.notification_inspect_item) { |
| 596 | startApplicationDetailsActivity(packageNameF); |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 597 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 598 | } else { |
| 599 | return false; |
| 600 | } |
| 601 | return true; |
| 602 | } |
| 603 | }); |
Daniel Sandler | 469e96e | 2012-05-04 15:56:19 -0400 | [diff] [blame] | 604 | mNotificationBlamePopup.show(); |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 605 | |
| 606 | return true; |
| 607 | } |
| 608 | }; |
| 609 | } |
| 610 | |
Daniel Sandler | 469e96e | 2012-05-04 15:56:19 -0400 | [diff] [blame] | 611 | public void dismissPopups() { |
| 612 | if (mNotificationBlamePopup != null) { |
| 613 | mNotificationBlamePopup.dismiss(); |
| 614 | mNotificationBlamePopup = null; |
| 615 | } |
| 616 | } |
| 617 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 618 | public void onHeadsUpDismissed() { |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 619 | } |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 620 | |
| 621 | @Override |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 622 | public void showRecentApps(boolean triggeredFromAltTab) { |
| 623 | int msg = MSG_SHOW_RECENT_APPS; |
| 624 | mHandler.removeMessages(msg); |
| 625 | mHandler.obtainMessage(msg, triggeredFromAltTab ? 1 : 0, 0).sendToTarget(); |
| 626 | } |
| 627 | |
| 628 | @Override |
Winson Chung | 6cb485f | 2014-05-19 10:30:43 -0700 | [diff] [blame] | 629 | public void hideRecentApps(boolean triggeredFromAltTab) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 630 | int msg = MSG_HIDE_RECENT_APPS; |
| 631 | mHandler.removeMessages(msg); |
Winson Chung | 6cb485f | 2014-05-19 10:30:43 -0700 | [diff] [blame] | 632 | mHandler.obtainMessage(msg, triggeredFromAltTab ? 1 : 0, 0).sendToTarget(); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 633 | } |
| 634 | |
| 635 | @Override |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 636 | public void toggleRecentApps() { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 637 | int msg = MSG_TOGGLE_RECENTS_APPS; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 638 | mHandler.removeMessages(msg); |
| 639 | mHandler.sendEmptyMessage(msg); |
| 640 | } |
| 641 | |
| 642 | @Override |
| 643 | public void preloadRecentApps() { |
| 644 | int msg = MSG_PRELOAD_RECENT_APPS; |
| 645 | mHandler.removeMessages(msg); |
| 646 | mHandler.sendEmptyMessage(msg); |
| 647 | } |
| 648 | |
| 649 | @Override |
| 650 | public void cancelPreloadRecentApps() { |
| 651 | int msg = MSG_CANCEL_PRELOAD_RECENT_APPS; |
| 652 | mHandler.removeMessages(msg); |
| 653 | mHandler.sendEmptyMessage(msg); |
| 654 | } |
| 655 | |
| 656 | @Override |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 657 | public void showSearchPanel() { |
| 658 | int msg = MSG_OPEN_SEARCH_PANEL; |
| 659 | mHandler.removeMessages(msg); |
| 660 | mHandler.sendEmptyMessage(msg); |
| 661 | } |
| 662 | |
| 663 | @Override |
| 664 | public void hideSearchPanel() { |
| 665 | int msg = MSG_CLOSE_SEARCH_PANEL; |
| 666 | mHandler.removeMessages(msg); |
| 667 | mHandler.sendEmptyMessage(msg); |
| 668 | } |
| 669 | |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 670 | protected abstract WindowManager.LayoutParams getSearchLayoutParams( |
| 671 | LayoutParams layoutParams); |
| 672 | |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 673 | protected void updateSearchPanel() { |
| 674 | // Search Panel |
| 675 | boolean visible = false; |
| 676 | if (mSearchPanelView != null) { |
| 677 | visible = mSearchPanelView.isShowing(); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 678 | mWindowManager.removeView(mSearchPanelView); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 679 | } |
| 680 | |
| 681 | // Provide SearchPanel with a temporary parent to allow layout params to work. |
| 682 | LinearLayout tmpRoot = new LinearLayout(mContext); |
| 683 | mSearchPanelView = (SearchPanelView) LayoutInflater.from(mContext).inflate( |
| 684 | R.layout.status_bar_search_panel, tmpRoot, false); |
| 685 | mSearchPanelView.setOnTouchListener( |
| 686 | new TouchOutsideListener(MSG_CLOSE_SEARCH_PANEL, mSearchPanelView)); |
| 687 | mSearchPanelView.setVisibility(View.GONE); |
| 688 | |
| 689 | WindowManager.LayoutParams lp = getSearchLayoutParams(mSearchPanelView.getLayoutParams()); |
| 690 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 691 | mWindowManager.addView(mSearchPanelView, lp); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 692 | mSearchPanelView.setBar(this); |
| 693 | if (visible) { |
| 694 | mSearchPanelView.show(true, false); |
| 695 | } |
| 696 | } |
| 697 | |
Michael Jurka | ecc395a | 2012-03-30 05:31:46 -0700 | [diff] [blame] | 698 | protected H createHandler() { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 699 | return new H(); |
| 700 | } |
| 701 | |
Michael Jurka | 56a5783 | 2012-05-14 13:24:43 -0700 | [diff] [blame] | 702 | static void sendCloseSystemWindows(Context context, String reason) { |
| 703 | if (ActivityManagerNative.isSystemReady()) { |
| 704 | try { |
| 705 | ActivityManagerNative.getDefault().closeSystemDialogs(reason); |
| 706 | } catch (RemoteException e) { |
| 707 | } |
| 708 | } |
| 709 | } |
| 710 | |
Michael Jurka | cb2522c | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 711 | protected abstract View getStatusBarView(); |
| 712 | |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 713 | protected View.OnTouchListener mRecentsPreloadOnTouchListener = new View.OnTouchListener() { |
| 714 | // additional optimization when we have software system buttons - start loading the recent |
| 715 | // tasks on touch down |
| 716 | @Override |
| 717 | public boolean onTouch(View v, MotionEvent event) { |
| 718 | int action = event.getAction() & MotionEvent.ACTION_MASK; |
| 719 | if (action == MotionEvent.ACTION_DOWN) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 720 | preloadRecents(); |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 721 | } else if (action == MotionEvent.ACTION_CANCEL) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 722 | cancelPreloadingRecents(); |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 723 | } else if (action == MotionEvent.ACTION_UP) { |
| 724 | if (!v.isPressed()) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 725 | cancelPreloadingRecents(); |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 726 | } |
| 727 | |
| 728 | } |
| 729 | return false; |
| 730 | } |
| 731 | }; |
| 732 | |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 733 | /** Proxy for RecentsComponent */ |
| 734 | |
| 735 | protected void showRecents(boolean triggeredFromAltTab) { |
| 736 | if (mRecents != null) { |
| 737 | sendCloseSystemWindows(mContext, SYSTEM_DIALOG_REASON_RECENT_APPS); |
| 738 | mRecents.showRecents(triggeredFromAltTab, getStatusBarView()); |
| 739 | } |
| 740 | } |
| 741 | |
Winson Chung | 6cb485f | 2014-05-19 10:30:43 -0700 | [diff] [blame] | 742 | protected void hideRecents(boolean triggeredFromAltTab) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 743 | if (mRecents != null) { |
Winson Chung | 6cb485f | 2014-05-19 10:30:43 -0700 | [diff] [blame] | 744 | mRecents.hideRecents(triggeredFromAltTab); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 745 | } |
| 746 | } |
| 747 | |
| 748 | protected void toggleRecents() { |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 749 | if (mRecents != null) { |
Winson Chung | 4c71aef | 2014-03-21 15:15:11 -0700 | [diff] [blame] | 750 | sendCloseSystemWindows(mContext, SYSTEM_DIALOG_REASON_RECENT_APPS); |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 751 | mRecents.toggleRecents(mDisplay, mLayoutDirection, getStatusBarView()); |
| 752 | } |
| 753 | } |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 754 | |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 755 | protected void preloadRecents() { |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 756 | if (mRecents != null) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 757 | mRecents.preloadRecents(); |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 758 | } |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 759 | } |
| 760 | |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 761 | protected void cancelPreloadingRecents() { |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 762 | if (mRecents != null) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 763 | mRecents.cancelPreloadingRecents(); |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 764 | } |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 765 | } |
| 766 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 767 | public abstract void resetHeadsUpDecayTimer(); |
| 768 | |
Dan Sandler | fd16d56 | 2014-02-13 18:43:31 -0800 | [diff] [blame] | 769 | /** |
| 770 | * Save the current "public" (locked and secure) state of the lockscreen. |
| 771 | */ |
| 772 | public void setLockscreenPublicMode(boolean publicMode) { |
| 773 | mLockscreenPublicMode = publicMode; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 774 | } |
| 775 | |
Dan Sandler | fd16d56 | 2014-02-13 18:43:31 -0800 | [diff] [blame] | 776 | public boolean isLockscreenPublicMode() { |
| 777 | return mLockscreenPublicMode; |
| 778 | } |
| 779 | |
| 780 | /** |
| 781 | * Has the given user chosen to allow their private (full) notifications to be shown even |
| 782 | * when the lockscreen is in "public" (secure & locked) mode? |
| 783 | */ |
| 784 | public boolean userAllowsPrivateNotificationsInPublic(int userHandle) { |
| 785 | if (userHandle == UserHandle.USER_ALL) { |
| 786 | return true; |
| 787 | } |
| 788 | |
| 789 | if (mUsersAllowingPrivateNotifications.indexOfKey(userHandle) < 0) { |
| 790 | final boolean allowed = 0 != Settings.Secure.getIntForUser( |
| 791 | mContext.getContentResolver(), |
| 792 | Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0, userHandle); |
| 793 | mUsersAllowingPrivateNotifications.append(userHandle, allowed); |
| 794 | return allowed; |
| 795 | } |
| 796 | |
| 797 | return mUsersAllowingPrivateNotifications.get(userHandle); |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 798 | } |
| 799 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 800 | protected class H extends Handler { |
| 801 | public void handleMessage(Message m) { |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 802 | Intent intent; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 803 | switch (m.what) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 804 | case MSG_SHOW_RECENT_APPS: |
| 805 | showRecents(m.arg1 > 0); |
Michael Jurka | cb2522c | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 806 | break; |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 807 | case MSG_HIDE_RECENT_APPS: |
Winson Chung | 6cb485f | 2014-05-19 10:30:43 -0700 | [diff] [blame] | 808 | hideRecents(m.arg1 > 0); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 809 | break; |
| 810 | case MSG_TOGGLE_RECENTS_APPS: |
| 811 | toggleRecents(); |
Michael Jurka | cb2522c | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 812 | break; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 813 | case MSG_PRELOAD_RECENT_APPS: |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 814 | preloadRecents(); |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 815 | break; |
| 816 | case MSG_CANCEL_PRELOAD_RECENT_APPS: |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 817 | cancelPreloadingRecents(); |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 818 | break; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 819 | case MSG_OPEN_SEARCH_PANEL: |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 820 | if (DEBUG) Log.d(TAG, "opening search panel"); |
Jim Miller | 0799440 | 2012-05-02 14:22:27 -0700 | [diff] [blame] | 821 | if (mSearchPanelView != null && mSearchPanelView.isAssistantAvailable()) { |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 822 | mSearchPanelView.show(true, true); |
Jim Miller | ad178a4 | 2013-10-08 20:03:38 -0700 | [diff] [blame] | 823 | onShowSearchPanel(); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 824 | } |
| 825 | break; |
| 826 | case MSG_CLOSE_SEARCH_PANEL: |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 827 | if (DEBUG) Log.d(TAG, "closing search panel"); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 828 | if (mSearchPanelView != null && mSearchPanelView.isShowing()) { |
| 829 | mSearchPanelView.show(false, true); |
Jim Miller | ad178a4 | 2013-10-08 20:03:38 -0700 | [diff] [blame] | 830 | onHideSearchPanel(); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 831 | } |
| 832 | break; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 833 | } |
| 834 | } |
| 835 | } |
| 836 | |
| 837 | public class TouchOutsideListener implements View.OnTouchListener { |
| 838 | private int mMsg; |
| 839 | private StatusBarPanel mPanel; |
| 840 | |
| 841 | public TouchOutsideListener(int msg, StatusBarPanel panel) { |
| 842 | mMsg = msg; |
| 843 | mPanel = panel; |
| 844 | } |
| 845 | |
| 846 | public boolean onTouch(View v, MotionEvent ev) { |
| 847 | final int action = ev.getAction(); |
| 848 | if (action == MotionEvent.ACTION_OUTSIDE |
| 849 | || (action == MotionEvent.ACTION_DOWN |
| 850 | && !mPanel.isInContentArea((int)ev.getX(), (int)ev.getY()))) { |
| 851 | mHandler.removeMessages(mMsg); |
| 852 | mHandler.sendEmptyMessage(mMsg); |
| 853 | return true; |
| 854 | } |
| 855 | return false; |
| 856 | } |
| 857 | } |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 858 | |
| 859 | protected void workAroundBadLayerDrawableOpacity(View v) { |
| 860 | } |
| 861 | |
Jim Miller | ad178a4 | 2013-10-08 20:03:38 -0700 | [diff] [blame] | 862 | protected void onHideSearchPanel() { |
| 863 | } |
| 864 | |
| 865 | protected void onShowSearchPanel() { |
| 866 | } |
| 867 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 868 | public boolean inflateViews(NotificationData.Entry entry, ViewGroup parent) { |
Chris Wren | f29c3b4 | 2013-11-27 16:30:30 -0500 | [diff] [blame] | 869 | return inflateViews(entry, parent, false); |
| 870 | } |
| 871 | |
| 872 | public boolean inflateViewsForHeadsUp(NotificationData.Entry entry, ViewGroup parent) { |
| 873 | return inflateViews(entry, parent, true); |
| 874 | } |
| 875 | |
| 876 | public boolean inflateViews(NotificationData.Entry entry, ViewGroup parent, boolean isHeadsUp) { |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 877 | int minHeight = |
| 878 | mContext.getResources().getDimensionPixelSize(R.dimen.notification_min_height); |
| 879 | int maxHeight = |
| 880 | mContext.getResources().getDimensionPixelSize(R.dimen.notification_max_height); |
| 881 | StatusBarNotification sbn = entry.notification; |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 882 | RemoteViews contentView = sbn.getNotification().contentView; |
| 883 | RemoteViews bigContentView = sbn.getNotification().bigContentView; |
Chris Wren | 8fd39ec | 2014-02-27 17:43:26 -0500 | [diff] [blame] | 884 | |
| 885 | if (isHeadsUp) { |
| 886 | maxHeight = |
| 887 | mContext.getResources().getDimensionPixelSize(R.dimen.notification_mid_height); |
| 888 | bigContentView = sbn.getNotification().headsUpContentView; |
| 889 | } |
| 890 | |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 891 | if (contentView == null) { |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 892 | return false; |
| 893 | } |
| 894 | |
Dan Sandler | f68448e | 2014-04-24 15:54:16 -0400 | [diff] [blame] | 895 | if (DEBUG) { |
| 896 | Log.v(TAG, "publicNotification: " + sbn.getNotification().publicVersion); |
| 897 | } |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 898 | |
| 899 | Notification publicNotification = sbn.getNotification().publicVersion; |
| 900 | |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 901 | // create the row view |
| 902 | LayoutInflater inflater = (LayoutInflater)mContext.getSystemService( |
| 903 | Context.LAYOUT_INFLATER_SERVICE); |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 904 | ExpandableNotificationRow row = (ExpandableNotificationRow) inflater.inflate( |
| 905 | R.layout.status_bar_notification_row, parent, false); |
Daniel Sandler | bc5559f | 2012-04-19 01:08:15 -0400 | [diff] [blame] | 906 | |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 907 | // for blaming (see SwipeHelper.setLongPressListener) |
Daniel Sandler | 4f91efd | 2013-04-25 16:38:41 -0400 | [diff] [blame] | 908 | row.setTag(sbn.getPackageName()); |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 909 | |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 910 | workAroundBadLayerDrawableOpacity(row); |
| 911 | View vetoButton = updateNotificationVetoButton(row, sbn); |
| 912 | vetoButton.setContentDescription(mContext.getString( |
| 913 | R.string.accessibility_remove_notification)); |
| 914 | |
| 915 | // NB: the large icon is now handled entirely by the template |
| 916 | |
| 917 | // bind the click event to the content area |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 918 | NotificationContentView expanded = |
| 919 | (NotificationContentView) row.findViewById(R.id.expanded); |
| 920 | NotificationContentView expandedPublic = |
| 921 | (NotificationContentView) row.findViewById(R.id.expandedPublic); |
Daniel Sandler | bc5559f | 2012-04-19 01:08:15 -0400 | [diff] [blame] | 922 | |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 923 | row.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); |
Daniel Sandler | bc5559f | 2012-04-19 01:08:15 -0400 | [diff] [blame] | 924 | |
Daniel Sandler | e6f7f2e | 2013-04-25 15:44:16 -0400 | [diff] [blame] | 925 | PendingIntent contentIntent = sbn.getNotification().contentIntent; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 926 | if (contentIntent != null) { |
Christoph Studer | 03b87a2 | 2014-04-30 17:33:27 +0200 | [diff] [blame] | 927 | final View.OnClickListener listener = makeClicker(contentIntent, sbn.getKey(), |
| 928 | isHeadsUp); |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 929 | row.setOnClickListener(listener); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 930 | } else { |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 931 | row.setOnClickListener(null); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 932 | } |
| 933 | |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 934 | // set up the adaptive layout |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 935 | View contentViewLocal = null; |
| 936 | View bigContentViewLocal = null; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 937 | try { |
Jorim Jaggi | 5c2d846 | 2014-03-21 17:37:00 +0100 | [diff] [blame] | 938 | contentViewLocal = contentView.apply(mContext, expanded, |
Jorim Jaggi | 39fa59f | 2014-02-25 15:38:45 +0100 | [diff] [blame] | 939 | mOnClickHandler); |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 940 | if (bigContentView != null) { |
Jorim Jaggi | 5c2d846 | 2014-03-21 17:37:00 +0100 | [diff] [blame] | 941 | bigContentViewLocal = bigContentView.apply(mContext, expanded, |
Jorim Jaggi | 39fa59f | 2014-02-25 15:38:45 +0100 | [diff] [blame] | 942 | mOnClickHandler); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 943 | } |
| 944 | } |
| 945 | catch (RuntimeException e) { |
Daniel Sandler | 4f91efd | 2013-04-25 16:38:41 -0400 | [diff] [blame] | 946 | final String ident = sbn.getPackageName() + "/0x" + Integer.toHexString(sbn.getId()); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 947 | Log.e(TAG, "couldn't inflate view for notification " + ident, e); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 948 | return false; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 949 | } |
| 950 | |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 951 | if (contentViewLocal != null) { |
Dan Sandler | 6d94aa7 | 2014-03-12 00:53:21 -0400 | [diff] [blame] | 952 | contentViewLocal.setIsRootNamespace(true); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 953 | expanded.setContractedChild(contentViewLocal); |
Daniel Sandler | 8680bf8 | 2012-05-15 16:52:52 -0400 | [diff] [blame] | 954 | } |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 955 | if (bigContentViewLocal != null) { |
Dan Sandler | 6d94aa7 | 2014-03-12 00:53:21 -0400 | [diff] [blame] | 956 | bigContentViewLocal.setIsRootNamespace(true); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 957 | expanded.setExpandedChild(bigContentViewLocal); |
Daniel Sandler | 8680bf8 | 2012-05-15 16:52:52 -0400 | [diff] [blame] | 958 | } |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 959 | |
| 960 | PackageManager pm = mContext.getPackageManager(); |
| 961 | |
| 962 | // now the public version |
| 963 | View publicViewLocal = null; |
| 964 | if (publicNotification != null) { |
| 965 | try { |
Jorim Jaggi | 5c2d846 | 2014-03-21 17:37:00 +0100 | [diff] [blame] | 966 | publicViewLocal = publicNotification.contentView.apply(mContext, expandedPublic, |
| 967 | mOnClickHandler); |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 968 | |
| 969 | if (publicViewLocal != null) { |
Dan Sandler | 6d94aa7 | 2014-03-12 00:53:21 -0400 | [diff] [blame] | 970 | publicViewLocal.setIsRootNamespace(true); |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 971 | expandedPublic.setContractedChild(publicViewLocal); |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 972 | } |
| 973 | } |
| 974 | catch (RuntimeException e) { |
| 975 | final String ident = sbn.getPackageName() + "/0x" + Integer.toHexString(sbn.getId()); |
| 976 | Log.e(TAG, "couldn't inflate public view for notification " + ident, e); |
| 977 | publicViewLocal = null; |
| 978 | } |
| 979 | } |
| 980 | |
| 981 | if (publicViewLocal == null) { |
| 982 | // Add a basic notification template |
| 983 | publicViewLocal = LayoutInflater.from(mContext).inflate( |
Jorim Jaggi | 5c2d846 | 2014-03-21 17:37:00 +0100 | [diff] [blame] | 984 | com.android.internal.R.layout.notification_template_quantum_base, |
| 985 | expandedPublic, true); |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 986 | |
| 987 | final TextView title = (TextView) publicViewLocal.findViewById(com.android.internal.R.id.title); |
| 988 | try { |
| 989 | title.setText(pm.getApplicationLabel( |
| 990 | pm.getApplicationInfo(entry.notification.getPackageName(), 0))); |
| 991 | } catch (NameNotFoundException e) { |
| 992 | title.setText(entry.notification.getPackageName()); |
| 993 | } |
| 994 | |
| 995 | final ImageView icon = (ImageView) publicViewLocal.findViewById(com.android.internal.R.id.icon); |
| 996 | |
| 997 | final StatusBarIcon ic = new StatusBarIcon(entry.notification.getPackageName(), |
| 998 | entry.notification.getUser(), |
| 999 | entry.notification.getNotification().icon, |
| 1000 | entry.notification.getNotification().iconLevel, |
| 1001 | entry.notification.getNotification().number, |
| 1002 | entry.notification.getNotification().tickerText); |
| 1003 | |
Jorim Jaggi | 5c2d846 | 2014-03-21 17:37:00 +0100 | [diff] [blame] | 1004 | Drawable iconDrawable = StatusBarIconView.getIcon(mContext, ic); |
| 1005 | icon.setImageDrawable(iconDrawable); |
Dan Sandler | 26e81cf | 2014-05-06 10:01:27 -0400 | [diff] [blame] | 1006 | if (mNotificationColorUtil.isGrayscale(iconDrawable)) { |
Jorim Jaggi | 5c2d846 | 2014-03-21 17:37:00 +0100 | [diff] [blame] | 1007 | icon.setBackgroundResource( |
| 1008 | com.android.internal.R.drawable.notification_icon_legacy_bg_inset); |
| 1009 | } |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 1010 | |
| 1011 | final TextView text = (TextView) publicViewLocal.findViewById(com.android.internal.R.id.text); |
| 1012 | text.setText("Unlock your device to see this notification."); |
| 1013 | |
| 1014 | // TODO: fill out "time" as well |
| 1015 | } |
| 1016 | |
Daniel Sandler | 8680bf8 | 2012-05-15 16:52:52 -0400 | [diff] [blame] | 1017 | row.setDrawingCacheEnabled(true); |
| 1018 | |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 1019 | if (MULTIUSER_DEBUG) { |
| 1020 | TextView debug = (TextView) row.findViewById(R.id.debug_info); |
| 1021 | if (debug != null) { |
| 1022 | debug.setVisibility(View.VISIBLE); |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 1023 | debug.setText("CU " + mCurrentUserId +" NU " + entry.notification.getUserId()); |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 1024 | } |
| 1025 | } |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1026 | entry.row = row; |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1027 | entry.row.setHeightRange(mRowMinHeight, mRowMaxHeight); |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 1028 | entry.row.setOnActivatedListener(this); |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 1029 | entry.row.setIsBelowSpeedBump(isBelowSpeedBump(entry.notification)); |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 1030 | entry.expanded = contentViewLocal; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 1031 | entry.expandedPublic = publicViewLocal; |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 1032 | entry.setBigContentView(bigContentViewLocal); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1033 | |
Jorim Jaggi | 4673985 | 2014-04-15 09:58:24 +0200 | [diff] [blame] | 1034 | applyLegacyRowBackground(sbn, entry); |
| 1035 | |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1036 | return true; |
| 1037 | } |
| 1038 | |
Christoph Studer | 03b87a2 | 2014-04-30 17:33:27 +0200 | [diff] [blame] | 1039 | public NotificationClicker makeClicker(PendingIntent intent, String notificationKey, |
| 1040 | boolean forHun) { |
| 1041 | return new NotificationClicker(intent, notificationKey, forHun); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1042 | } |
| 1043 | |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 1044 | protected class NotificationClicker implements View.OnClickListener { |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1045 | private PendingIntent mIntent; |
Christoph Studer | 03b87a2 | 2014-04-30 17:33:27 +0200 | [diff] [blame] | 1046 | private final String mNotificationKey; |
Chris Wren | f29c3b4 | 2013-11-27 16:30:30 -0500 | [diff] [blame] | 1047 | private boolean mIsHeadsUp; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1048 | |
Christoph Studer | 03b87a2 | 2014-04-30 17:33:27 +0200 | [diff] [blame] | 1049 | public NotificationClicker(PendingIntent intent, String notificationKey, boolean forHun) { |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1050 | mIntent = intent; |
Christoph Studer | 03b87a2 | 2014-04-30 17:33:27 +0200 | [diff] [blame] | 1051 | mNotificationKey = notificationKey; |
Chris Wren | f29c3b4 | 2013-11-27 16:30:30 -0500 | [diff] [blame] | 1052 | mIsHeadsUp = forHun; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1053 | } |
| 1054 | |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 1055 | public void onClick(final View v) { |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 1056 | dismissKeyguardThenExecute(new OnDismissAction() { |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 1057 | public boolean onDismiss() { |
| 1058 | try { |
| 1059 | // The intent we are sending is for the application, which |
| 1060 | // won't have permission to immediately start an activity after |
| 1061 | // the user switches to home. We know it is safe to do at this |
| 1062 | // point, so make sure new activity switches are now allowed. |
| 1063 | ActivityManagerNative.getDefault().resumeAppSwitches(); |
| 1064 | // Also, notifications can be launched from the lock screen, |
| 1065 | // so dismiss the lock screen when the activity starts. |
| 1066 | ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity(); |
| 1067 | } catch (RemoteException e) { |
| 1068 | } |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1069 | |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 1070 | boolean sent = false; |
| 1071 | if (mIntent != null) { |
| 1072 | int[] pos = new int[2]; |
| 1073 | v.getLocationOnScreen(pos); |
| 1074 | Intent overlay = new Intent(); |
| 1075 | overlay.setSourceBounds(new Rect(pos[0], pos[1], |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 1076 | pos[0] + v.getWidth(), pos[1] + v.getHeight())); |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 1077 | try { |
| 1078 | mIntent.send(mContext, 0, overlay); |
| 1079 | sent = true; |
| 1080 | } catch (PendingIntent.CanceledException e) { |
| 1081 | // the stack trace isn't very helpful here. |
| 1082 | // Just log the exception message. |
| 1083 | Log.w(TAG, "Sending contentIntent failed: " + e); |
| 1084 | } |
| 1085 | } |
| 1086 | |
| 1087 | try { |
| 1088 | if (mIsHeadsUp) { |
| 1089 | mHandler.sendEmptyMessage(MSG_HIDE_HEADS_UP); |
| 1090 | } |
| 1091 | mBarService.onNotificationClick(mNotificationKey); |
| 1092 | } catch (RemoteException ex) { |
| 1093 | // system process is dead if we're here. |
| 1094 | } |
| 1095 | |
| 1096 | // close the shade if it was open |
| 1097 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
| 1098 | visibilityChanged(false); |
| 1099 | |
| 1100 | boolean waitForActivityLaunch = sent && mIntent.isActivity(); |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 1101 | return waitForActivityLaunch && DELAY_DISMISS_TO_ACTIVITY_LAUNCH; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1102 | } |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 1103 | }); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1104 | } |
| 1105 | } |
Chris Wren | f29c3b4 | 2013-11-27 16:30:30 -0500 | [diff] [blame] | 1106 | |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1107 | /** |
| 1108 | * The LEDs are turned o)ff when the notification panel is shown, even just a little bit. |
| 1109 | * This was added last-minute and is inconsistent with the way the rest of the notifications |
| 1110 | * are handled, because the notification isn't really cancelled. The lights are just |
| 1111 | * turned off. If any other notifications happen, the lights will turn back on. Steve says |
| 1112 | * this is what he wants. (see bug 1131461) |
| 1113 | */ |
| 1114 | protected void visibilityChanged(boolean visible) { |
| 1115 | if (mPanelSlightlyVisible != visible) { |
| 1116 | mPanelSlightlyVisible = visible; |
| 1117 | try { |
Christoph Studer | 760ea55 | 2014-03-21 13:10:21 +0100 | [diff] [blame] | 1118 | if (visible) { |
| 1119 | mBarService.onPanelRevealed(); |
| 1120 | } else { |
| 1121 | mBarService.onPanelHidden(); |
| 1122 | } |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1123 | } catch (RemoteException ex) { |
| 1124 | // Won't fail unless the world has ended. |
| 1125 | } |
| 1126 | } |
| 1127 | } |
| 1128 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1129 | /** |
| 1130 | * Cancel this notification and tell the StatusBarManagerService / NotificationManagerService |
| 1131 | * about the failure. |
| 1132 | * |
| 1133 | * WARNING: this will call back into us. Don't hold any locks. |
| 1134 | */ |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 1135 | void handleNotificationError(StatusBarNotification n, String message) { |
| 1136 | removeNotification(n.getKey()); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1137 | try { |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 1138 | mBarService.onNotificationError(n.getPackageName(), n.getTag(), n.getId(), n.getUid(), |
| 1139 | n.getInitialPid(), message, n.getUserId()); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1140 | } catch (RemoteException ex) { |
| 1141 | // The end is nigh. |
| 1142 | } |
| 1143 | } |
| 1144 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1145 | protected StatusBarNotification removeNotificationViews(String key, Ranking ranking) { |
| 1146 | NotificationData.Entry entry = mNotificationData.remove(key, ranking); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1147 | if (entry == null) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 1148 | Log.w(TAG, "removeNotification for unknown key: " + key); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1149 | return null; |
| 1150 | } |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1151 | updateNotifications(); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1152 | return entry.notification; |
| 1153 | } |
| 1154 | |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 1155 | protected NotificationData.Entry createNotificationViews(StatusBarNotification notification) { |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1156 | if (DEBUG) { |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 1157 | Log.d(TAG, "createNotificationViews(notification=" + notification); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1158 | } |
| 1159 | // Construct the icon. |
| 1160 | final StatusBarIconView iconView = new StatusBarIconView(mContext, |
Daniel Sandler | 4f91efd | 2013-04-25 16:38:41 -0400 | [diff] [blame] | 1161 | notification.getPackageName() + "/0x" + Integer.toHexString(notification.getId()), |
John Spurlock | e6f0a71 | 2013-09-03 16:23:49 -0400 | [diff] [blame] | 1162 | notification.getNotification()); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1163 | iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); |
| 1164 | |
Daniel Sandler | 4f91efd | 2013-04-25 16:38:41 -0400 | [diff] [blame] | 1165 | final StatusBarIcon ic = new StatusBarIcon(notification.getPackageName(), |
Daniel Sandler | e6f7f2e | 2013-04-25 15:44:16 -0400 | [diff] [blame] | 1166 | notification.getUser(), |
| 1167 | notification.getNotification().icon, |
| 1168 | notification.getNotification().iconLevel, |
| 1169 | notification.getNotification().number, |
| 1170 | notification.getNotification().tickerText); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1171 | if (!iconView.set(ic)) { |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 1172 | handleNotificationError(notification, "Couldn't create icon: " + ic); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1173 | return null; |
| 1174 | } |
| 1175 | // Construct the expanded view. |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 1176 | NotificationData.Entry entry = new NotificationData.Entry(notification, iconView); |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 1177 | if (!inflateViews(entry, mStackScroller)) { |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 1178 | handleNotificationError(notification, "Couldn't expand RemoteViews for: " |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1179 | + notification); |
| 1180 | return null; |
| 1181 | } |
Chris Wren | f0048ce | 2013-08-07 16:43:43 -0400 | [diff] [blame] | 1182 | return entry; |
| 1183 | } |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1184 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1185 | protected void addNotificationViews(Entry entry, Ranking ranking) { |
Raju Yadav | 5f33026 | 2014-03-24 10:44:00 +0100 | [diff] [blame] | 1186 | if (entry == null) { |
| 1187 | return; |
| 1188 | } |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1189 | // Add the expanded view and icon. |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1190 | mNotificationData.add(entry, ranking); |
| 1191 | updateNotifications(); |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 1192 | } |
| 1193 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1194 | private void addNotificationViews(StatusBarNotification notification, Ranking ranking) { |
| 1195 | addNotificationViews(createNotificationViews(notification), ranking); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1196 | } |
| 1197 | |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 1198 | /** |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 1199 | * @return The number of notifications we show on Keyguard. |
| 1200 | */ |
| 1201 | protected abstract int getMaxKeyguardNotifications(); |
| 1202 | |
| 1203 | /** |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 1204 | * Updates expanded, dimmed and locked states of notification rows. |
| 1205 | */ |
| 1206 | protected void updateRowStates() { |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 1207 | int maxKeyguardNotifications = getMaxKeyguardNotifications(); |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 1208 | mKeyguardIconOverflowContainer.getIconsView().removeAllViews(); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1209 | final int N = mNotificationData.size(); |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 1210 | int visibleNotifications = 0; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 1211 | boolean onKeyguard = mState == StatusBarState.KEYGUARD; |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1212 | for (int i = 0; i < N; i++) { |
Chris Wren | 8fd1265 | 2012-05-09 21:25:57 -0400 | [diff] [blame] | 1213 | NotificationData.Entry entry = mNotificationData.get(i); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 1214 | if (onKeyguard) { |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 1215 | entry.row.setExpansionDisabled(true); |
Chris Wren | 3ddab0d | 2012-08-02 16:52:21 -0400 | [diff] [blame] | 1216 | } else { |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 1217 | entry.row.setExpansionDisabled(false); |
Jorim Jaggi | 649b708 | 2014-04-03 13:15:18 +0200 | [diff] [blame] | 1218 | if (!entry.row.isUserLocked()) { |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1219 | boolean top = (i == 0); |
Jorim Jaggi | dce3c4c | 2014-04-29 23:12:24 +0200 | [diff] [blame] | 1220 | entry.row.setSystemExpanded(top); |
Jorim Jaggi | 649b708 | 2014-04-03 13:15:18 +0200 | [diff] [blame] | 1221 | } |
Chris Wren | 8fd1265 | 2012-05-09 21:25:57 -0400 | [diff] [blame] | 1222 | } |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 1223 | boolean showOnKeyguard = shouldShowOnKeyguard(entry.notification); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 1224 | if (onKeyguard && (visibleNotifications >= maxKeyguardNotifications |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 1225 | || !showOnKeyguard)) { |
| 1226 | entry.row.setVisibility(View.GONE); |
| 1227 | if (showOnKeyguard) { |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 1228 | mKeyguardIconOverflowContainer.getIconsView().addNotification(entry); |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 1229 | } |
| 1230 | } else { |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 1231 | boolean wasGone = entry.row.getVisibility() == View.GONE; |
| 1232 | entry.row.setVisibility(View.VISIBLE); |
| 1233 | if (wasGone) { |
Selim Cinek | 572bbd4 | 2014-04-25 16:43:27 +0200 | [diff] [blame] | 1234 | // notify the scroller of a child addition |
| 1235 | mStackScroller.generateAddAnimation(entry.row); |
| 1236 | } |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 1237 | visibleNotifications++; |
| 1238 | } |
Chris Wren | 8fd1265 | 2012-05-09 21:25:57 -0400 | [diff] [blame] | 1239 | } |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 1240 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 1241 | if (onKeyguard && mKeyguardIconOverflowContainer.getIconsView().getChildCount() > 0) { |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 1242 | mKeyguardIconOverflowContainer.setVisibility(View.VISIBLE); |
| 1243 | } else { |
| 1244 | mKeyguardIconOverflowContainer.setVisibility(View.GONE); |
| 1245 | } |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1246 | // Move overflow container to last position. |
| 1247 | mStackScroller.changeViewPosition(mKeyguardIconOverflowContainer, |
| 1248 | mStackScroller.getChildCount() - 1); |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 1249 | } |
| 1250 | |
| 1251 | private boolean shouldShowOnKeyguard(StatusBarNotification sbn) { |
| 1252 | return sbn.getNotification().priority >= Notification.PRIORITY_LOW; |
Chris Wren | 8fd1265 | 2012-05-09 21:25:57 -0400 | [diff] [blame] | 1253 | } |
| 1254 | |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 1255 | protected void setZenMode(int mode) { |
John Spurlock | 110e5b1 | 2014-02-27 13:09:35 -0500 | [diff] [blame] | 1256 | if (!isDeviceProvisioned()) return; |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 1257 | mZenMode = mode; |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1258 | updateNotifications(); |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 1259 | } |
| 1260 | |
John Spurlock | 4b3bda2 | 2014-05-22 14:32:20 -0400 | [diff] [blame] | 1261 | protected void setShowLockscreenNotifications(boolean show) { |
| 1262 | mShowLockscreenNotifications = show; |
| 1263 | } |
| 1264 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1265 | protected abstract void haltTicker(); |
| 1266 | protected abstract void setAreThereNotifications(); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1267 | protected abstract void updateNotifications(); |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 1268 | protected abstract void tick(StatusBarNotification n, boolean firstTime); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1269 | protected abstract void updateExpandedViewPos(int expandedPosition); |
Jim Miller | b4238e0 | 2012-05-14 15:26:20 -0700 | [diff] [blame] | 1270 | protected abstract boolean shouldDisableNavbarGestures(); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1271 | |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 1272 | @Override |
| 1273 | public void addNotification(StatusBarNotification notification) { |
| 1274 | if (!USE_NOTIFICATION_LISTENER) { |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1275 | addNotificationInternal(notification, null); |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 1276 | } |
| 1277 | } |
| 1278 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1279 | public abstract void addNotificationInternal(StatusBarNotification notification, |
| 1280 | Ranking ranking); |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 1281 | |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 1282 | protected abstract void updateRankingInternal(Ranking ranking); |
| 1283 | |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 1284 | @Override |
| 1285 | public void removeNotification(String key) { |
| 1286 | if (!USE_NOTIFICATION_LISTENER) { |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1287 | removeNotificationInternal(key, null); |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 1288 | } |
| 1289 | } |
| 1290 | |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 1291 | public abstract void removeNotificationInternal(String key, Ranking ranking); |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 1292 | |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 1293 | public void updateNotification(StatusBarNotification notification) { |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 1294 | if (!USE_NOTIFICATION_LISTENER) { |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1295 | updateNotificationInternal(notification, null); |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 1296 | } |
| 1297 | } |
| 1298 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1299 | public void updateNotificationInternal(StatusBarNotification notification, Ranking ranking) { |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 1300 | if (DEBUG) Log.d(TAG, "updateNotification(" + notification + ")"); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1301 | |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 1302 | final NotificationData.Entry oldEntry = mNotificationData.findByKey(notification.getKey()); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1303 | if (oldEntry == null) { |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 1304 | Log.w(TAG, "updateNotification for unknown key: " + notification.getKey()); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1305 | return; |
| 1306 | } |
| 1307 | |
| 1308 | final StatusBarNotification oldNotification = oldEntry.notification; |
| 1309 | |
| 1310 | // 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] | 1311 | final RemoteViews oldContentView = oldNotification.getNotification().contentView; |
| 1312 | final RemoteViews contentView = notification.getNotification().contentView; |
| 1313 | final RemoteViews oldBigContentView = oldNotification.getNotification().bigContentView; |
| 1314 | final RemoteViews bigContentView = notification.getNotification().bigContentView; |
Chris Wren | 8fd39ec | 2014-02-27 17:43:26 -0500 | [diff] [blame] | 1315 | final RemoteViews oldHeadsUpContentView = oldNotification.getNotification().headsUpContentView; |
| 1316 | final RemoteViews headsUpContentView = notification.getNotification().headsUpContentView; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 1317 | final Notification oldPublicNotification = oldNotification.getNotification().publicVersion; |
| 1318 | final RemoteViews oldPublicContentView = oldPublicNotification != null |
| 1319 | ? oldPublicNotification.contentView : null; |
| 1320 | final Notification publicNotification = notification.getNotification().publicVersion; |
| 1321 | final RemoteViews publicContentView = publicNotification != null |
| 1322 | ? publicNotification.contentView : null; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1323 | |
| 1324 | if (DEBUG) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 1325 | Log.d(TAG, "old notification: when=" + oldNotification.getNotification().when |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1326 | + " ongoing=" + oldNotification.isOngoing() |
| 1327 | + " expanded=" + oldEntry.expanded |
| 1328 | + " contentView=" + oldContentView |
Chris Wren | e9e3772 | 2012-05-11 17:40:14 -0400 | [diff] [blame] | 1329 | + " bigContentView=" + oldBigContentView |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 1330 | + " publicView=" + oldPublicContentView |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1331 | + " rowParent=" + oldEntry.row.getParent()); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 1332 | Log.d(TAG, "new notification: when=" + notification.getNotification().when |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1333 | + " ongoing=" + oldNotification.isOngoing() |
Chris Wren | e9e3772 | 2012-05-11 17:40:14 -0400 | [diff] [blame] | 1334 | + " contentView=" + contentView |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 1335 | + " bigContentView=" + bigContentView |
| 1336 | + " publicView=" + publicContentView); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1337 | } |
| 1338 | |
| 1339 | // Can we just reapply the RemoteViews in place? If when didn't change, the order |
| 1340 | // didn't change. |
Chris Wren | e9e3772 | 2012-05-11 17:40:14 -0400 | [diff] [blame] | 1341 | |
| 1342 | // 1U is never null |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1343 | boolean contentsUnchanged = oldEntry.expanded != null |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1344 | && contentView.getPackage() != null |
| 1345 | && oldContentView.getPackage() != null |
| 1346 | && oldContentView.getPackage().equals(contentView.getPackage()) |
| 1347 | && oldContentView.getLayoutId() == contentView.getLayoutId(); |
Chris Wren | e9e3772 | 2012-05-11 17:40:14 -0400 | [diff] [blame] | 1348 | // large view may be null |
| 1349 | boolean bigContentsUnchanged = |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 1350 | (oldEntry.getBigContentView() == null && bigContentView == null) |
| 1351 | || ((oldEntry.getBigContentView() != null && bigContentView != null) |
Chris Wren | e9e3772 | 2012-05-11 17:40:14 -0400 | [diff] [blame] | 1352 | && bigContentView.getPackage() != null |
| 1353 | && oldBigContentView.getPackage() != null |
| 1354 | && oldBigContentView.getPackage().equals(bigContentView.getPackage()) |
| 1355 | && oldBigContentView.getLayoutId() == bigContentView.getLayoutId()); |
Chris Wren | 8fd39ec | 2014-02-27 17:43:26 -0500 | [diff] [blame] | 1356 | boolean headsUpContentsUnchanged = |
| 1357 | (oldHeadsUpContentView == null && headsUpContentView == null) |
| 1358 | || ((oldHeadsUpContentView != null && headsUpContentView != null) |
| 1359 | && headsUpContentView.getPackage() != null |
| 1360 | && oldHeadsUpContentView.getPackage() != null |
| 1361 | && oldHeadsUpContentView.getPackage().equals(headsUpContentView.getPackage()) |
| 1362 | && oldHeadsUpContentView.getLayoutId() == headsUpContentView.getLayoutId()); |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 1363 | boolean publicUnchanged = |
| 1364 | (oldPublicContentView == null && publicContentView == null) |
| 1365 | || ((oldPublicContentView != null && publicContentView != null) |
| 1366 | && publicContentView.getPackage() != null |
| 1367 | && oldPublicContentView.getPackage() != null |
| 1368 | && oldPublicContentView.getPackage().equals(publicContentView.getPackage()) |
| 1369 | && oldPublicContentView.getLayoutId() == publicContentView.getLayoutId()); |
| 1370 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1371 | |
Daniel Sandler | e6f7f2e | 2013-04-25 15:44:16 -0400 | [diff] [blame] | 1372 | boolean updateTicker = notification.getNotification().tickerText != null |
| 1373 | && !TextUtils.equals(notification.getNotification().tickerText, |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 1374 | oldEntry.notification.getNotification().tickerText); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1375 | if (contentsUnchanged && bigContentsUnchanged && headsUpContentsUnchanged |
| 1376 | && publicUnchanged) { |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 1377 | if (DEBUG) Log.d(TAG, "reusing notification for key: " + notification.getKey()); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1378 | oldEntry.notification = notification; |
| 1379 | try { |
Chris Wren | e03f4e1 | 2013-08-08 16:48:48 -0400 | [diff] [blame] | 1380 | updateNotificationViews(oldEntry, notification); |
| 1381 | |
| 1382 | if (ENABLE_HEADS_UP && mInterruptingNotificationEntry != null |
| 1383 | && oldNotification == mInterruptingNotificationEntry.notification) { |
| 1384 | if (!shouldInterrupt(notification)) { |
| 1385 | if (DEBUG) Log.d(TAG, "no longer interrupts!"); |
| 1386 | mHandler.sendEmptyMessage(MSG_HIDE_HEADS_UP); |
| 1387 | } else { |
| 1388 | if (DEBUG) Log.d(TAG, "updating the current heads up:" + notification); |
| 1389 | mInterruptingNotificationEntry.notification = notification; |
Chris Wren | f29c3b4 | 2013-11-27 16:30:30 -0500 | [diff] [blame] | 1390 | updateHeadsUpViews(mInterruptingNotificationEntry, notification); |
Chris Wren | e03f4e1 | 2013-08-08 16:48:48 -0400 | [diff] [blame] | 1391 | } |
Chris Wren | e9e3772 | 2012-05-11 17:40:14 -0400 | [diff] [blame] | 1392 | } |
Chris Wren | e03f4e1 | 2013-08-08 16:48:48 -0400 | [diff] [blame] | 1393 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1394 | // Update the icon. |
Daniel Sandler | 4f91efd | 2013-04-25 16:38:41 -0400 | [diff] [blame] | 1395 | final StatusBarIcon ic = new StatusBarIcon(notification.getPackageName(), |
Daniel Sandler | e6f7f2e | 2013-04-25 15:44:16 -0400 | [diff] [blame] | 1396 | notification.getUser(), |
| 1397 | notification.getNotification().icon, notification.getNotification().iconLevel, |
| 1398 | notification.getNotification().number, |
| 1399 | notification.getNotification().tickerText); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1400 | if (!oldEntry.icon.set(ic)) { |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 1401 | handleNotificationError(notification, "Couldn't update icon: " + ic); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1402 | return; |
| 1403 | } |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1404 | mNotificationData.updateRanking(ranking); |
| 1405 | updateNotifications(); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1406 | } |
| 1407 | catch (RuntimeException e) { |
| 1408 | // 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] | 1409 | Log.w(TAG, "Couldn't reapply views for package " + contentView.getPackage(), e); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1410 | removeNotificationViews(notification.getKey(), ranking); |
| 1411 | addNotificationViews(notification, ranking); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1412 | } |
| 1413 | } else { |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 1414 | if (DEBUG) Log.d(TAG, "not reusing notification for key: " + notification.getKey()); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 1415 | if (DEBUG) Log.d(TAG, "contents was " + (contentsUnchanged ? "unchanged" : "changed")); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1416 | removeNotificationViews(notification.getKey(), ranking); |
| 1417 | addNotificationViews(notification, ranking); // will also replace the heads up |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 1418 | final NotificationData.Entry newEntry = mNotificationData.findByKey( |
| 1419 | notification.getKey()); |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1420 | final boolean userChangedExpansion = oldEntry.row.hasUserChangedExpansion(); |
| 1421 | if (userChangedExpansion) { |
| 1422 | boolean userExpanded = oldEntry.row.isUserExpanded(); |
Selim Cinek | 1685e63 | 2014-04-08 02:27:49 +0200 | [diff] [blame] | 1423 | newEntry.row.setUserExpanded(userExpanded); |
Jorim Jaggi | 9cbadd3 | 2014-05-01 20:18:31 +0200 | [diff] [blame] | 1424 | newEntry.row.notifyHeightChanged(); |
Chris Wren | c9433ecb | 2012-06-27 17:37:03 -0400 | [diff] [blame] | 1425 | } |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1426 | } |
| 1427 | |
| 1428 | // Update the veto button accordingly (and as a result, whether this row is |
| 1429 | // swipe-dismissable) |
| 1430 | updateNotificationVetoButton(oldEntry.row, notification); |
| 1431 | |
John Spurlock | 61e3683 | 2012-09-10 09:43:27 -0400 | [diff] [blame] | 1432 | // Is this for you? |
Kenny Guy | 2a76494 | 2014-04-02 13:29:20 +0100 | [diff] [blame] | 1433 | boolean isForCurrentUser = notificationIsForCurrentProfiles(notification); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 1434 | if (DEBUG) Log.d(TAG, "notification is " + (isForCurrentUser ? "" : "not ") + "for you"); |
John Spurlock | 61e3683 | 2012-09-10 09:43:27 -0400 | [diff] [blame] | 1435 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1436 | // Restart the ticker if it's still running |
John Spurlock | 61e3683 | 2012-09-10 09:43:27 -0400 | [diff] [blame] | 1437 | if (updateTicker && isForCurrentUser) { |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1438 | haltTicker(); |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 1439 | tick(notification, false); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1440 | } |
| 1441 | |
| 1442 | // Recalculate the position of the sliding windows and the titles. |
| 1443 | setAreThereNotifications(); |
| 1444 | updateExpandedViewPos(EXPANDED_LEAVE_ALONE); |
Chris Wren | e03f4e1 | 2013-08-08 16:48:48 -0400 | [diff] [blame] | 1445 | } |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1446 | |
Chris Wren | e03f4e1 | 2013-08-08 16:48:48 -0400 | [diff] [blame] | 1447 | private void updateNotificationViews(NotificationData.Entry entry, |
| 1448 | StatusBarNotification notification) { |
Chris Wren | f29c3b4 | 2013-11-27 16:30:30 -0500 | [diff] [blame] | 1449 | updateNotificationViews(entry, notification, false); |
| 1450 | } |
| 1451 | |
| 1452 | private void updateHeadsUpViews(NotificationData.Entry entry, |
| 1453 | StatusBarNotification notification) { |
| 1454 | updateNotificationViews(entry, notification, true); |
| 1455 | } |
| 1456 | |
| 1457 | private void updateNotificationViews(NotificationData.Entry entry, |
| 1458 | StatusBarNotification notification, boolean isHeadsUp) { |
Chris Wren | e03f4e1 | 2013-08-08 16:48:48 -0400 | [diff] [blame] | 1459 | final RemoteViews contentView = notification.getNotification().contentView; |
Chris Wren | 8fd39ec | 2014-02-27 17:43:26 -0500 | [diff] [blame] | 1460 | final RemoteViews bigContentView = isHeadsUp |
| 1461 | ? notification.getNotification().headsUpContentView |
| 1462 | : notification.getNotification().bigContentView; |
John Spurlock | 70cf4c1 | 2014-02-13 09:39:14 -0500 | [diff] [blame] | 1463 | final Notification publicVersion = notification.getNotification().publicVersion; |
| 1464 | final RemoteViews publicContentView = publicVersion != null ? publicVersion.contentView |
| 1465 | : null; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 1466 | |
Chris Wren | e03f4e1 | 2013-08-08 16:48:48 -0400 | [diff] [blame] | 1467 | // Reapply the RemoteViews |
Jorim Jaggi | 5c2d846 | 2014-03-21 17:37:00 +0100 | [diff] [blame] | 1468 | contentView.reapply(mContext, entry.expanded, mOnClickHandler); |
Chris Wren | e03f4e1 | 2013-08-08 16:48:48 -0400 | [diff] [blame] | 1469 | if (bigContentView != null && entry.getBigContentView() != null) { |
Jorim Jaggi | 5c2d846 | 2014-03-21 17:37:00 +0100 | [diff] [blame] | 1470 | bigContentView.reapply(mContext, entry.getBigContentView(), |
Jorim Jaggi | 39fa59f | 2014-02-25 15:38:45 +0100 | [diff] [blame] | 1471 | mOnClickHandler); |
Chris Wren | e03f4e1 | 2013-08-08 16:48:48 -0400 | [diff] [blame] | 1472 | } |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 1473 | if (publicContentView != null && entry.getPublicContentView() != null) { |
Jorim Jaggi | 5c2d846 | 2014-03-21 17:37:00 +0100 | [diff] [blame] | 1474 | publicContentView.reapply(mContext, entry.getPublicContentView(), mOnClickHandler); |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 1475 | } |
Chris Wren | e03f4e1 | 2013-08-08 16:48:48 -0400 | [diff] [blame] | 1476 | // update the contentIntent |
| 1477 | final PendingIntent contentIntent = notification.getNotification().contentIntent; |
| 1478 | if (contentIntent != null) { |
Christoph Studer | 03b87a2 | 2014-04-30 17:33:27 +0200 | [diff] [blame] | 1479 | final View.OnClickListener listener = makeClicker(contentIntent, notification.getKey(), |
| 1480 | isHeadsUp); |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 1481 | entry.row.setOnClickListener(listener); |
Chris Wren | e03f4e1 | 2013-08-08 16:48:48 -0400 | [diff] [blame] | 1482 | } else { |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 1483 | entry.row.setOnClickListener(null); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1484 | } |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 1485 | boolean wasBelow = entry.row.isBelowSpeedBump(); |
| 1486 | boolean nowBelow = isBelowSpeedBump(notification); |
| 1487 | if (wasBelow != nowBelow) { |
| 1488 | entry.row.setIsBelowSpeedBump(nowBelow); |
| 1489 | } |
Jorim Jaggi | be565df | 2014-04-28 17:51:23 +0200 | [diff] [blame] | 1490 | entry.row.notifyContentUpdated(); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1491 | } |
John Spurlock | 3623128 | 2012-06-23 17:11:27 -0400 | [diff] [blame] | 1492 | |
Selim Cinek | c27437b | 2014-05-14 10:23:33 +0200 | [diff] [blame] | 1493 | private boolean isBelowSpeedBump(StatusBarNotification notification) { |
| 1494 | return notification.getNotification().priority == |
| 1495 | Notification.PRIORITY_MIN; |
| 1496 | } |
| 1497 | |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 1498 | protected void notifyHeadsUpScreenOn(boolean screenOn) { |
| 1499 | if (!screenOn && mInterruptingNotificationEntry != null) { |
| 1500 | mHandler.sendEmptyMessage(MSG_ESCALATE_HEADS_UP); |
| 1501 | } |
| 1502 | } |
| 1503 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1504 | protected boolean shouldInterrupt(StatusBarNotification sbn) { |
| 1505 | Notification notification = sbn.getNotification(); |
| 1506 | // some predicates to make the boolean logic legible |
| 1507 | boolean isNoisy = (notification.defaults & Notification.DEFAULT_SOUND) != 0 |
| 1508 | || (notification.defaults & Notification.DEFAULT_VIBRATE) != 0 |
| 1509 | || notification.sound != null |
| 1510 | || notification.vibrate != null; |
| 1511 | boolean isHighPriority = sbn.getScore() >= INTERRUPTION_THRESHOLD; |
| 1512 | boolean isFullscreen = notification.fullScreenIntent != null; |
Chris Wren | 22ae46e | 2014-02-26 18:08:09 -0500 | [diff] [blame] | 1513 | boolean hasTicker = mHeadsUpTicker && !TextUtils.isEmpty(notification.tickerText); |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1514 | boolean isAllowed = notification.extras.getInt(Notification.EXTRA_AS_HEADS_UP, |
| 1515 | Notification.HEADS_UP_ALLOWED) != Notification.HEADS_UP_NEVER; |
| 1516 | |
Jim Miller | a999d46 | 2013-10-30 13:58:11 -0700 | [diff] [blame] | 1517 | final KeyguardTouchDelegate keyguard = KeyguardTouchDelegate.getInstance(mContext); |
Chris Wren | 22ae46e | 2014-02-26 18:08:09 -0500 | [diff] [blame] | 1518 | boolean interrupt = (isFullscreen || (isHighPriority && (isNoisy || hasTicker))) |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1519 | && isAllowed |
| 1520 | && mPowerManager.isScreenOn() |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1521 | && !keyguard.isShowingAndNotOccluded() |
Jim Miller | a999d46 | 2013-10-30 13:58:11 -0700 | [diff] [blame] | 1522 | && !keyguard.isInputRestricted(); |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 1523 | try { |
| 1524 | interrupt = interrupt && !mDreamManager.isDreaming(); |
| 1525 | } catch (RemoteException e) { |
| 1526 | Log.d(TAG, "failed to query dream manager", e); |
| 1527 | } |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1528 | if (DEBUG) Log.d(TAG, "interrupt: " + interrupt); |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 1529 | return interrupt; |
| 1530 | } |
| 1531 | |
John Spurlock | 3623128 | 2012-06-23 17:11:27 -0400 | [diff] [blame] | 1532 | // Q: What kinds of notifications should show during setup? |
| 1533 | // A: Almost none! Only things coming from the system (package is "android") that also |
| 1534 | // have special "kind" tags marking them as relevant for setup (see below). |
| 1535 | protected boolean showNotificationEvenIfUnprovisioned(StatusBarNotification sbn) { |
John Spurlock | fd7f1e0 | 2014-03-18 16:41:57 -0400 | [diff] [blame] | 1536 | return "android".equals(sbn.getPackageName()) |
| 1537 | && sbn.getNotification().extras.getBoolean(Notification.EXTRA_ALLOW_DURING_SETUP); |
John Spurlock | 3623128 | 2012-06-23 17:11:27 -0400 | [diff] [blame] | 1538 | } |
John Spurlock | 67ad368 | 2012-06-26 17:42:00 -0400 | [diff] [blame] | 1539 | |
| 1540 | public boolean inKeyguardRestrictedInputMode() { |
Jim Miller | a999d46 | 2013-10-30 13:58:11 -0700 | [diff] [blame] | 1541 | return KeyguardTouchDelegate.getInstance(mContext).isInputRestricted(); |
John Spurlock | 67ad368 | 2012-06-26 17:42:00 -0400 | [diff] [blame] | 1542 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1543 | |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 1544 | public void setInteracting(int barWindow, boolean interacting) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1545 | // hook for subclasses |
| 1546 | } |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 1547 | |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 1548 | public void setBouncerShowing(boolean bouncerShowing) { |
| 1549 | mBouncerShowing = bouncerShowing; |
| 1550 | } |
| 1551 | |
| 1552 | /** |
| 1553 | * @return Whether the security bouncer from Keyguard is showing. |
| 1554 | */ |
| 1555 | public boolean isBouncerShowing() { |
| 1556 | return mBouncerShowing; |
| 1557 | } |
| 1558 | |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 1559 | public void destroy() { |
| 1560 | if (mSearchPanelView != null) { |
| 1561 | mWindowManager.removeViewImmediate(mSearchPanelView); |
| 1562 | } |
| 1563 | mContext.unregisterReceiver(mBroadcastReceiver); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1564 | if (USE_NOTIFICATION_LISTENER) { |
| 1565 | try { |
| 1566 | mNotificationListener.unregisterAsSystemService(); |
| 1567 | } catch (RemoteException e) { |
| 1568 | // Ignore. |
| 1569 | } |
| 1570 | } |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 1571 | } |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 1572 | } |