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 | |
Dan Sandler | 4247a5c | 2014-07-23 15:58:08 -0400 | [diff] [blame] | 19 | import android.animation.Animator; |
| 20 | import android.animation.AnimatorListenerAdapter; |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 21 | import android.app.ActivityManager; |
Jorim Jaggi | e6e108e | 2016-03-28 13:38:45 -0700 | [diff] [blame] | 22 | import android.app.ActivityManager.StackId; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 23 | import android.app.ActivityManagerNative; |
Jorim Jaggi | e6e108e | 2016-03-28 13:38:45 -0700 | [diff] [blame] | 24 | import android.app.ActivityOptions; |
Ricky Wai | 7fa0171 | 2016-03-16 12:13:54 +0000 | [diff] [blame] | 25 | import android.app.KeyguardManager; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 26 | import android.app.Notification; |
Chris Wren | cd8f4f7 | 2014-08-27 18:48:13 -0400 | [diff] [blame] | 27 | import android.app.NotificationManager; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 28 | import android.app.PendingIntent; |
Adrian Roos | 497ab02 | 2015-02-10 20:49:33 +0100 | [diff] [blame] | 29 | import android.app.RemoteInput; |
Adam Powell | 0fc5b2b | 2012-07-18 18:20:29 -0700 | [diff] [blame] | 30 | import android.app.TaskStackBuilder; |
Adrian Roos | bd3409c | 2014-08-12 18:21:09 +0200 | [diff] [blame] | 31 | import android.app.admin.DevicePolicyManager; |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 32 | import android.content.BroadcastReceiver; |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 33 | import android.content.ComponentName; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 34 | import android.content.Context; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 35 | import android.content.Intent; |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 36 | import android.content.IntentFilter; |
Ricky Wai | 7fa0171 | 2016-03-16 12:13:54 +0000 | [diff] [blame] | 37 | import android.content.IntentSender; |
Daniel Sandler | 96fd7c1 | 2012-03-30 16:37:36 -0400 | [diff] [blame] | 38 | import android.content.pm.ApplicationInfo; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 39 | import android.content.pm.PackageManager; |
Daniel Sandler | 96fd7c1 | 2012-03-30 16:37:36 -0400 | [diff] [blame] | 40 | import android.content.pm.PackageManager.NameNotFoundException; |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 41 | import android.content.pm.UserInfo; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 42 | import android.content.res.Configuration; |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 43 | import android.database.ContentObserver; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 44 | import android.graphics.Rect; |
Jorim Jaggi | 39fa59f | 2014-02-25 15:38:45 +0100 | [diff] [blame] | 45 | import android.graphics.drawable.Drawable; |
Dan Sandler | 3343981 | 2015-08-10 15:49:56 -0400 | [diff] [blame] | 46 | import android.graphics.drawable.Icon; |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 47 | import android.os.AsyncTask; |
Daniel Sandler | 96fd7c1 | 2012-03-30 16:37:36 -0400 | [diff] [blame] | 48 | import android.os.Build; |
Jorim Jaggi | 165ce06 | 2015-07-06 16:18:11 -0700 | [diff] [blame] | 49 | import android.os.Bundle; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 50 | import android.os.Handler; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 51 | import android.os.IBinder; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 52 | import android.os.Message; |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 53 | import android.os.PowerManager; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 54 | import android.os.RemoteException; |
| 55 | import android.os.ServiceManager; |
Adrian Roos | 497ab02 | 2015-02-10 20:49:33 +0100 | [diff] [blame] | 56 | import android.os.SystemProperties; |
Dianne Hackborn | f02b60a | 2012-08-16 10:48:27 -0700 | [diff] [blame] | 57 | import android.os.UserHandle; |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 58 | import android.os.UserManager; |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 59 | import android.provider.Settings; |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 60 | import android.service.dreams.DreamService; |
| 61 | import android.service.dreams.IDreamManager; |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 62 | import android.service.notification.NotificationListenerService; |
Christoph Studer | d0694b6 | 2014-06-04 16:36:01 +0200 | [diff] [blame] | 63 | import android.service.notification.NotificationListenerService.RankingMap; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 64 | import android.service.notification.StatusBarNotification; |
Dan Sandler | dc34df5 | 2016-04-07 21:04:46 -0400 | [diff] [blame] | 65 | import android.service.vr.IVrManager; |
| 66 | import android.service.vr.IVrStateCallbacks; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 67 | import android.text.TextUtils; |
Selim Cinek | 2d79f63 | 2015-11-02 15:13:29 -0800 | [diff] [blame] | 68 | import android.util.ArraySet; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 69 | import android.util.Log; |
Dan Sandler | e163a64 | 2015-03-01 22:58:32 -0500 | [diff] [blame] | 70 | import android.util.Slog; |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 71 | import android.util.SparseArray; |
Dan Sandler | fd16d56 | 2014-02-13 18:43:31 -0800 | [diff] [blame] | 72 | import android.util.SparseBooleanArray; |
Daniel Sandler | c638c1e | 2011-08-24 16:19:23 -0700 | [diff] [blame] | 73 | import android.view.Display; |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 74 | import android.view.IWindowManager; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 75 | import android.view.LayoutInflater; |
| 76 | import android.view.MotionEvent; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 77 | import android.view.View; |
Dan Sandler | 4247a5c | 2014-07-23 15:58:08 -0400 | [diff] [blame] | 78 | import android.view.ViewAnimationUtils; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 79 | import android.view.ViewGroup; |
Christoph Studer | 4da84cd | 2014-10-21 17:24:20 +0200 | [diff] [blame] | 80 | import android.view.ViewParent; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 81 | import android.view.WindowManager; |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 82 | import android.view.WindowManagerGlobal; |
Selim Cinek | a8fefa5 | 2014-09-08 16:10:50 +0200 | [diff] [blame] | 83 | import android.view.accessibility.AccessibilityManager; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 84 | import android.widget.ImageView; |
Michael Jurka | a600fd9 | 2012-06-25 15:57:05 -0700 | [diff] [blame] | 85 | import android.widget.RemoteViews; |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 86 | import android.widget.TextView; |
Kenny Guy | dae30d5 | 2015-04-01 19:11:35 +0100 | [diff] [blame] | 87 | import android.widget.Toast; |
Chris Wren | f6e9228b | 2016-01-26 18:04:35 -0500 | [diff] [blame] | 88 | |
Chris Wren | bd6b5fb | 2015-06-09 14:58:34 -0400 | [diff] [blame] | 89 | import com.android.internal.logging.MetricsLogger; |
Tamas Berghammer | cbd3f0c | 2016-06-22 15:21:38 +0100 | [diff] [blame^] | 90 | import com.android.internal.logging.nano.MetricsProto.MetricsEvent; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 91 | import com.android.internal.statusbar.IStatusBarService; |
| 92 | import com.android.internal.statusbar.StatusBarIcon; |
Chris Wren | cd8f4f7 | 2014-08-27 18:48:13 -0400 | [diff] [blame] | 93 | import com.android.internal.widget.LockPatternUtils; |
Mady Mellor | 97c8df4 | 2016-03-22 18:09:39 -0700 | [diff] [blame] | 94 | import com.android.keyguard.KeyguardHostView.OnDismissAction; |
Selim Cinek | fa760d4 | 2016-05-10 15:50:53 -0400 | [diff] [blame] | 95 | import com.android.keyguard.KeyguardUpdateMonitor; |
Jorim Jaggi | 5eb67c2 | 2015-08-19 19:50:49 -0700 | [diff] [blame] | 96 | import com.android.systemui.DejankUtils; |
Winson | c0d7058 | 2016-01-29 10:24:39 -0800 | [diff] [blame] | 97 | import com.android.systemui.Interpolators; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 98 | import com.android.systemui.R; |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 99 | import com.android.systemui.RecentsComponent; |
Dan Sandler | 4247a5c | 2014-07-23 15:58:08 -0400 | [diff] [blame] | 100 | import com.android.systemui.SwipeHelper; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 101 | import com.android.systemui.SystemUI; |
Jorim Jaggi | b835dd7 | 2015-06-08 12:28:42 -0700 | [diff] [blame] | 102 | import com.android.systemui.assist.AssistManager; |
Jorim Jaggi | d61f227 | 2014-12-19 20:35:35 +0100 | [diff] [blame] | 103 | import com.android.systemui.recents.Recents; |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 104 | import com.android.systemui.statusbar.NotificationData.Entry; |
Mady Mellor | 97c8df4 | 2016-03-22 18:09:39 -0700 | [diff] [blame] | 105 | import com.android.systemui.statusbar.NotificationGuts.OnGutsClosedListener; |
Selim Cinek | 92d892c | 2014-09-11 15:11:00 +0200 | [diff] [blame] | 106 | import com.android.systemui.statusbar.phone.NavigationBarView; |
Selim Cinek | 25fd4e2b | 2015-02-20 17:46:07 +0100 | [diff] [blame] | 107 | import com.android.systemui.statusbar.phone.NotificationGroupManager; |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 108 | import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 109 | import com.android.systemui.statusbar.policy.HeadsUpManager; |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 110 | import com.android.systemui.statusbar.policy.PreviewInflater; |
Adrian Roos | 497ab02 | 2015-02-10 20:49:33 +0100 | [diff] [blame] | 111 | import com.android.systemui.statusbar.policy.RemoteInputView; |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 112 | import com.android.systemui.statusbar.stack.NotificationStackScrollLayout; |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 113 | import com.android.systemui.statusbar.stack.StackStateAnimator; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 114 | |
Michael Jurka | a600fd9 | 2012-06-25 15:57:05 -0700 | [diff] [blame] | 115 | import java.util.ArrayList; |
Julia Reynolds | 98a4486 | 2016-09-12 08:53:47 -0400 | [diff] [blame] | 116 | import java.util.Collections; |
| 117 | import java.util.HashSet; |
Dan Sandler | f4db75c | 2014-09-03 18:02:31 +0200 | [diff] [blame] | 118 | import java.util.List; |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 119 | import java.util.Locale; |
Julia Reynolds | 98a4486 | 2016-09-12 08:53:47 -0400 | [diff] [blame] | 120 | import java.util.Set; |
Joe Onorato | 1c95ecb | 2010-06-28 17:19:12 -0400 | [diff] [blame] | 121 | |
Julia Reynolds | f0f629f | 2016-02-25 09:34:04 -0500 | [diff] [blame] | 122 | import static android.service.notification.NotificationListenerService.Ranking.IMPORTANCE_HIGH; |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 123 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 124 | public abstract class BaseStatusBar extends SystemUI implements |
Winson Chung | 9214eff | 2014-06-12 13:59:25 -0700 | [diff] [blame] | 125 | CommandQueue.Callbacks, ActivatableNotificationView.OnActivatedListener, |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 126 | ExpandableNotificationRow.ExpansionLogger, NotificationData.Environment, |
Mady Mellor | 97c8df4 | 2016-03-22 18:09:39 -0700 | [diff] [blame] | 127 | ExpandableNotificationRow.OnExpandClickListener, |
| 128 | OnGutsClosedListener { |
Daniel Sandler | 198a030 | 2012-08-17 16:04:31 -0400 | [diff] [blame] | 129 | public static final String TAG = "StatusBar"; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 130 | public static final boolean DEBUG = false; |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 131 | public static final boolean MULTIUSER_DEBUG = false; |
Joe Onorato | 1c95ecb | 2010-06-28 17:19:12 -0400 | [diff] [blame] | 132 | |
Adrian Roos | 497ab02 | 2015-02-10 20:49:33 +0100 | [diff] [blame] | 133 | public static final boolean ENABLE_REMOTE_INPUT = |
Adrian Roos | 9531c9b | 2015-11-03 17:43:01 -0800 | [diff] [blame] | 134 | SystemProperties.getBoolean("debug.enable_remote_input", true); |
Selim Cinek | 4041249 | 2015-12-08 18:03:22 -0800 | [diff] [blame] | 135 | public static final boolean ENABLE_CHILD_NOTIFICATIONS |
| 136 | = SystemProperties.getBoolean("debug.child_notifs", true); |
Adrian Roos | c0a579e | 2016-03-30 16:43:58 -0700 | [diff] [blame] | 137 | public static final boolean FORCE_REMOTE_INPUT_HISTORY = |
| 138 | SystemProperties.getBoolean("debug.force_remoteinput_history", false); |
Adrian Roos | b27d7a5 | 2016-06-16 13:04:47 -0700 | [diff] [blame] | 139 | private static boolean ENABLE_LOCK_SCREEN_ALLOW_REMOTE_INPUT = false; |
Adrian Roos | 497ab02 | 2015-02-10 20:49:33 +0100 | [diff] [blame] | 140 | |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 141 | protected static final int MSG_SHOW_RECENT_APPS = 1019; |
| 142 | protected static final int MSG_HIDE_RECENT_APPS = 1020; |
| 143 | protected static final int MSG_TOGGLE_RECENTS_APPS = 1021; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 144 | protected static final int MSG_PRELOAD_RECENT_APPS = 1022; |
| 145 | protected static final int MSG_CANCEL_PRELOAD_RECENT_APPS = 1023; |
Winson Chung | b1f7499 | 2014-08-08 12:53:09 -0700 | [diff] [blame] | 146 | protected static final int MSG_SHOW_NEXT_AFFILIATED_TASK = 1024; |
| 147 | protected static final int MSG_SHOW_PREV_AFFILIATED_TASK = 1025; |
Andrei Stingaceanu | c22ab79 | 2016-01-07 12:39:38 +0000 | [diff] [blame] | 148 | protected static final int MSG_TOGGLE_KEYBOARD_SHORTCUTS_MENU = 1026; |
Andrei Stingaceanu | 0bf096f | 2016-04-14 18:11:57 +0100 | [diff] [blame] | 149 | protected static final int MSG_DISMISS_KEYBOARD_SHORTCUTS_MENU = 1027; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 150 | |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 151 | protected static final boolean ENABLE_HEADS_UP = true; |
Chris Wren | 22ae46e | 2014-02-26 18:08:09 -0500 | [diff] [blame] | 152 | protected static final String SETTING_HEADS_UP_TICKER = "ticker_gets_heads_up"; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 153 | |
Ricky Wai | 7fa0171 | 2016-03-16 12:13:54 +0000 | [diff] [blame] | 154 | private static final String PERMISSION_SELF = "com.android.systemui.permission.SELF"; |
| 155 | |
Winson | d8b1d63 | 2016-01-04 17:51:18 -0800 | [diff] [blame] | 156 | // Should match the values in PhoneWindowManager |
Michael Jurka | 56a5783 | 2012-05-14 13:24:43 -0700 | [diff] [blame] | 157 | public static final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps"; |
Winson | d8b1d63 | 2016-01-04 17:51:18 -0800 | [diff] [blame] | 158 | public static final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey"; |
Michael Jurka | 56a5783 | 2012-05-14 13:24:43 -0700 | [diff] [blame] | 159 | |
Chris Wren | cd8f4f7 | 2014-08-27 18:48:13 -0400 | [diff] [blame] | 160 | private static final String BANNER_ACTION_CANCEL = |
| 161 | "com.android.systemui.statusbar.banner_action_cancel"; |
| 162 | private static final String BANNER_ACTION_SETUP = |
| 163 | "com.android.systemui.statusbar.banner_action_setup"; |
Ricky Wai | 7fa0171 | 2016-03-16 12:13:54 +0000 | [diff] [blame] | 164 | private static final String WORK_CHALLENGE_UNLOCKED_NOTIFICATION_ACTION |
| 165 | = "com.android.systemui.statusbar.work_challenge_unlocked_notification_action"; |
Chris Wren | cd8f4f7 | 2014-08-27 18:48:13 -0400 | [diff] [blame] | 166 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 167 | protected CommandQueue mCommandQueue; |
| 168 | protected IStatusBarService mBarService; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 169 | protected H mHandler = createHandler(); |
| 170 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 171 | // all notifications |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 172 | protected NotificationData mNotificationData; |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 173 | protected NotificationStackScrollLayout mStackScroller; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 174 | |
Selim Cinek | 25fd4e2b | 2015-02-20 17:46:07 +0100 | [diff] [blame] | 175 | protected NotificationGroupManager mGroupManager = new NotificationGroupManager(); |
| 176 | |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 177 | protected RemoteInputController mRemoteInputController; |
| 178 | |
Chris Wren | a4ef620 | 2014-06-09 18:07:30 -0400 | [diff] [blame] | 179 | // for heads up notifications |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 180 | protected HeadsUpManager mHeadsUpManager; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 181 | |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 182 | protected int mCurrentUserId = 0; |
Kenny Guy | 2a76494 | 2014-04-02 13:29:20 +0100 | [diff] [blame] | 183 | final protected SparseArray<UserInfo> mCurrentProfiles = new SparseArray<UserInfo>(); |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 184 | |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 185 | protected int mLayoutDirection = -1; // invalid |
Selim Cinek | a8fefa5 | 2014-09-08 16:10:50 +0200 | [diff] [blame] | 186 | protected AccessibilityManager mAccessibilityManager; |
Selim Cinek | 92d892c | 2014-09-11 15:11:00 +0200 | [diff] [blame] | 187 | |
| 188 | // on-screen navigation buttons |
| 189 | protected NavigationBarView mNavigationBarView = null; |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 190 | |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 191 | protected boolean mDeviceInteractive; |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 192 | |
| 193 | protected boolean mVisible; |
Selim Cinek | 2d79f63 | 2015-11-02 15:13:29 -0800 | [diff] [blame] | 194 | protected ArraySet<Entry> mHeadsUpEntriesToRemoveOnSwitch = new ArraySet<>(); |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 195 | protected ArraySet<Entry> mRemoteInputEntriesToRemoveOnCollapse = new ArraySet<>(); |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 196 | |
Adrian Roos | c0a579e | 2016-03-30 16:43:58 -0700 | [diff] [blame] | 197 | /** |
| 198 | * Notifications with keys in this set are not actually around anymore. We kept them around |
| 199 | * when they were canceled in response to a remote input interaction. This allows us to show |
| 200 | * what you replied and allows you to continue typing into it. |
| 201 | */ |
| 202 | protected ArraySet<String> mKeysKeptForRemoteInput = new ArraySet<>(); |
| 203 | |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 204 | // mScreenOnFromKeyguard && mVisible. |
| 205 | private boolean mVisibleToUser; |
| 206 | |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 207 | private Locale mLocale; |
Dan Sandler | 539aad4 | 2014-08-04 00:43:39 -0400 | [diff] [blame] | 208 | private float mFontScale; |
| 209 | |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 210 | protected boolean mUseHeadsUp = false; |
Chris Wren | 22ae46e | 2014-02-26 18:08:09 -0500 | [diff] [blame] | 211 | protected boolean mHeadsUpTicker = false; |
Jason Monk | f701954 | 2014-07-31 12:42:25 -0400 | [diff] [blame] | 212 | protected boolean mDisableNotificationAlerts = false; |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 213 | |
Adrian Roos | bd3409c | 2014-08-12 18:21:09 +0200 | [diff] [blame] | 214 | protected DevicePolicyManager mDevicePolicyManager; |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 215 | protected IDreamManager mDreamManager; |
Julia Reynolds | 0971cb0 | 2016-01-26 17:00:22 -0500 | [diff] [blame] | 216 | protected PowerManager mPowerManager; |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 217 | protected StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; |
Dan Sandler | fd16d56 | 2014-02-13 18:43:31 -0800 | [diff] [blame] | 218 | |
| 219 | // public mode, private notifications, etc |
| 220 | private boolean mLockscreenPublicMode = false; |
| 221 | private final SparseBooleanArray mUsersAllowingPrivateNotifications = new SparseBooleanArray(); |
Julia Reynolds | 26fa8a5 | 2016-02-24 08:31:22 -0500 | [diff] [blame] | 222 | private final SparseBooleanArray mUsersAllowingNotifications = new SparseBooleanArray(); |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 223 | |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 224 | private UserManager mUserManager; |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 225 | private int mDensity; |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 226 | |
Ricky Wai | 7fa0171 | 2016-03-16 12:13:54 +0000 | [diff] [blame] | 227 | private KeyguardManager mKeyguardManager; |
| 228 | private LockPatternUtils mLockPatternUtils; |
| 229 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 230 | // UI-specific methods |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 231 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 232 | /** |
| 233 | * Create all windows necessary for the status bar (including navigation, overlay panels, etc) |
| 234 | * and add them to the window manager. |
| 235 | */ |
| 236 | protected abstract void createAndAddWindows(); |
Joe Onorato | 1c95ecb | 2010-06-28 17:19:12 -0400 | [diff] [blame] | 237 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 238 | protected WindowManager mWindowManager; |
| 239 | protected IWindowManager mWindowManagerService; |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 240 | |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 241 | protected abstract void refreshLayout(int layoutDirection); |
| 242 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 243 | protected Display mDisplay; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 244 | |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 245 | private boolean mDeviceProvisioned = false; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 246 | |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 247 | protected RecentsComponent mRecents; |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 248 | |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 249 | protected int mZenMode; |
| 250 | |
Dan Sandler | 4247a5c | 2014-07-23 15:58:08 -0400 | [diff] [blame] | 251 | // which notification is currently being longpress-examined by the user |
Selim Cinek | 024ca59 | 2014-09-01 15:11:28 +0200 | [diff] [blame] | 252 | private NotificationGuts mNotificationGutsExposed; |
Dan Sandler | 4247a5c | 2014-07-23 15:58:08 -0400 | [diff] [blame] | 253 | |
Andrei Stingaceanu | 9d9294c | 2015-08-24 17:19:06 +0100 | [diff] [blame] | 254 | private KeyboardShortcuts mKeyboardShortcuts; |
| 255 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 256 | /** |
| 257 | * The {@link StatusBarState} of the status bar. |
| 258 | */ |
| 259 | protected int mState; |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 260 | protected boolean mBouncerShowing; |
John Spurlock | 4b3bda2 | 2014-05-22 14:32:20 -0400 | [diff] [blame] | 261 | protected boolean mShowLockscreenNotifications; |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 262 | protected boolean mAllowLockscreenRemoteInput; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 263 | |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 264 | protected NotificationOverflowContainer mKeyguardIconOverflowContainer; |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 265 | protected DismissView mDismissView; |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 266 | protected EmptyShadeView mEmptyShadeView; |
Jorim Jaggi | 649b708 | 2014-04-03 13:15:18 +0200 | [diff] [blame] | 267 | |
Chris Wren | 42d5dd4 | 2015-05-01 10:39:26 -0400 | [diff] [blame] | 268 | private NotificationClicker mNotificationClicker = new NotificationClicker(); |
| 269 | |
Jorim Jaggi | b835dd7 | 2015-06-08 12:28:42 -0700 | [diff] [blame] | 270 | protected AssistManager mAssistManager; |
| 271 | |
Dan Sandler | dc34df5 | 2016-04-07 21:04:46 -0400 | [diff] [blame] | 272 | protected boolean mVrMode; |
| 273 | |
Julia Reynolds | 98a4486 | 2016-09-12 08:53:47 -0400 | [diff] [blame] | 274 | private Set<String> mNonBlockablePkgs; |
| 275 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 276 | @Override // NotificationData.Environment |
Daniel Sandler | 3ffdcc7 | 2012-09-23 14:31:48 -0400 | [diff] [blame] | 277 | public boolean isDeviceProvisioned() { |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 278 | return mDeviceProvisioned; |
| 279 | } |
| 280 | |
Dan Sandler | dc34df5 | 2016-04-07 21:04:46 -0400 | [diff] [blame] | 281 | private final IVrStateCallbacks mVrStateCallbacks = new IVrStateCallbacks.Stub() { |
| 282 | @Override |
| 283 | public void onVrStateChanged(boolean enabled) { |
| 284 | mVrMode = enabled; |
| 285 | } |
| 286 | }; |
| 287 | |
| 288 | public boolean isDeviceInVrMode() { |
| 289 | return mVrMode; |
| 290 | } |
| 291 | |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 292 | protected final ContentObserver mSettingsObserver = new ContentObserver(mHandler) { |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 293 | @Override |
| 294 | public void onChange(boolean selfChange) { |
Jeff Brown | bf6f6f9 | 2012-09-25 15:03:20 -0700 | [diff] [blame] | 295 | final boolean provisioned = 0 != Settings.Global.getInt( |
| 296 | mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0); |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 297 | if (provisioned != mDeviceProvisioned) { |
| 298 | mDeviceProvisioned = provisioned; |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 299 | updateNotifications(); |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 300 | } |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 301 | final int mode = Settings.Global.getInt(mContext.getContentResolver(), |
| 302 | Settings.Global.ZEN_MODE, Settings.Global.ZEN_MODE_OFF); |
| 303 | setZenMode(mode); |
Dan Sandler | 52e5701e | 2014-07-22 23:14:54 -0400 | [diff] [blame] | 304 | |
| 305 | updateLockscreenNotificationSetting(); |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 306 | } |
| 307 | }; |
| 308 | |
Dan Sandler | fd16d56 | 2014-02-13 18:43:31 -0800 | [diff] [blame] | 309 | private final ContentObserver mLockscreenSettingsObserver = new ContentObserver(mHandler) { |
| 310 | @Override |
| 311 | public void onChange(boolean selfChange) { |
Daniel U | 5745487 | 2016-03-29 20:28:21 +0100 | [diff] [blame] | 312 | // We don't know which user changed LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS or |
| 313 | // LOCK_SCREEN_SHOW_NOTIFICATIONS, so we just dump our cache ... |
Dan Sandler | fd16d56 | 2014-02-13 18:43:31 -0800 | [diff] [blame] | 314 | mUsersAllowingPrivateNotifications.clear(); |
Daniel U | 5745487 | 2016-03-29 20:28:21 +0100 | [diff] [blame] | 315 | mUsersAllowingNotifications.clear(); |
Dan Sandler | fd16d56 | 2014-02-13 18:43:31 -0800 | [diff] [blame] | 316 | // ... and refresh all the notifications |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 317 | updateNotifications(); |
Dan Sandler | fd16d56 | 2014-02-13 18:43:31 -0800 | [diff] [blame] | 318 | } |
| 319 | }; |
| 320 | |
Dianne Hackborn | 1927ae8 | 2012-06-22 15:21:36 -0700 | [diff] [blame] | 321 | private RemoteViews.OnClickHandler mOnClickHandler = new RemoteViews.OnClickHandler() { |
| 322 | @Override |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 323 | public boolean onClickHandler( |
| 324 | final View view, final PendingIntent pendingIntent, final Intent fillInIntent) { |
Adrian Roos | fe84e1f | 2015-11-04 15:55:39 -0800 | [diff] [blame] | 325 | if (handleRemoteInput(view, pendingIntent, fillInIntent)) { |
| 326 | return true; |
| 327 | } |
| 328 | |
Daniel Sandler | 198a030 | 2012-08-17 16:04:31 -0400 | [diff] [blame] | 329 | if (DEBUG) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 330 | Log.v(TAG, "Notification click handler invoked for intent: " + pendingIntent); |
Daniel Sandler | 198a030 | 2012-08-17 16:04:31 -0400 | [diff] [blame] | 331 | } |
Christoph Studer | 4da84cd | 2014-10-21 17:24:20 +0200 | [diff] [blame] | 332 | logActionClick(view); |
Jorim Jaggi | 89f7f28 | 2014-10-17 19:54:15 +0200 | [diff] [blame] | 333 | // The intent we are sending is for the application, which |
| 334 | // won't have permission to immediately start an activity after |
| 335 | // the user switches to home. We know it is safe to do at this |
| 336 | // point, so make sure new activity switches are now allowed. |
| 337 | try { |
| 338 | ActivityManagerNative.getDefault().resumeAppSwitches(); |
| 339 | } catch (RemoteException e) { |
| 340 | } |
Dianne Hackborn | 1927ae8 | 2012-06-22 15:21:36 -0700 | [diff] [blame] | 341 | final boolean isActivity = pendingIntent.isActivity(); |
| 342 | if (isActivity) { |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 343 | final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing(); |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 344 | final boolean afterKeyguardGone = PreviewInflater.wouldLaunchResolverActivity( |
| 345 | mContext, pendingIntent.getIntent(), mCurrentUserId); |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 346 | dismissKeyguardThenExecute(new OnDismissAction() { |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 347 | @Override |
| 348 | public boolean onDismiss() { |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 349 | if (keyguardShowing && !afterKeyguardGone) { |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 350 | try { |
| 351 | ActivityManagerNative.getDefault() |
| 352 | .keyguardWaitingForActivityDrawn(); |
Jorim Jaggi | 91617a7 | 2015-06-25 15:01:29 -0700 | [diff] [blame] | 353 | ActivityManagerNative.getDefault().resumeAppSwitches(); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 354 | } catch (RemoteException e) { |
| 355 | } |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 356 | } |
Dianne Hackborn | 1927ae8 | 2012-06-22 15:21:36 -0700 | [diff] [blame] | 357 | |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 358 | boolean handled = superOnClickHandler(view, pendingIntent, fillInIntent); |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 359 | overrideActivityPendingAppTransition(keyguardShowing && !afterKeyguardGone); |
Dianne Hackborn | 1927ae8 | 2012-06-22 15:21:36 -0700 | [diff] [blame] | 360 | |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 361 | // close the shade if it was open |
| 362 | if (handled) { |
Jorim Jaggi | 4eedc1d | 2014-10-27 13:45:56 +0100 | [diff] [blame] | 363 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, |
| 364 | true /* force */); |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 365 | visibilityChanged(false); |
Jorim Jaggi | 91617a7 | 2015-06-25 15:01:29 -0700 | [diff] [blame] | 366 | mAssistManager.hideAssist(); |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 367 | } |
Jorim Jaggi | 91617a7 | 2015-06-25 15:01:29 -0700 | [diff] [blame] | 368 | |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 369 | // Wait for activity start. |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 370 | return handled; |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 371 | } |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 372 | }, afterKeyguardGone); |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 373 | return true; |
| 374 | } else { |
Jorim Jaggi | e6e108e | 2016-03-28 13:38:45 -0700 | [diff] [blame] | 375 | return superOnClickHandler(view, pendingIntent, fillInIntent); |
Dianne Hackborn | 1927ae8 | 2012-06-22 15:21:36 -0700 | [diff] [blame] | 376 | } |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 377 | } |
| 378 | |
Christoph Studer | 4da84cd | 2014-10-21 17:24:20 +0200 | [diff] [blame] | 379 | private void logActionClick(View view) { |
| 380 | ViewParent parent = view.getParent(); |
| 381 | String key = getNotificationKeyForParent(parent); |
| 382 | if (key == null) { |
| 383 | Log.w(TAG, "Couldn't determine notification for click."); |
| 384 | return; |
| 385 | } |
| 386 | int index = -1; |
| 387 | // If this is a default template, determine the index of the button. |
| 388 | if (view.getId() == com.android.internal.R.id.action0 && |
| 389 | parent != null && parent instanceof ViewGroup) { |
| 390 | ViewGroup actionGroup = (ViewGroup) parent; |
| 391 | index = actionGroup.indexOfChild(view); |
| 392 | } |
| 393 | try { |
| 394 | mBarService.onNotificationActionClick(key, index); |
| 395 | } catch (RemoteException e) { |
| 396 | // Ignore |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | private String getNotificationKeyForParent(ViewParent parent) { |
| 401 | while (parent != null) { |
| 402 | if (parent instanceof ExpandableNotificationRow) { |
| 403 | return ((ExpandableNotificationRow) parent).getStatusBarNotification().getKey(); |
| 404 | } |
| 405 | parent = parent.getParent(); |
| 406 | } |
| 407 | return null; |
| 408 | } |
| 409 | |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 410 | private boolean superOnClickHandler(View view, PendingIntent pendingIntent, |
| 411 | Intent fillInIntent) { |
Jorim Jaggi | e6e108e | 2016-03-28 13:38:45 -0700 | [diff] [blame] | 412 | return super.onClickHandler(view, pendingIntent, fillInIntent, |
| 413 | StackId.FULLSCREEN_WORKSPACE_STACK_ID); |
Dianne Hackborn | 1927ae8 | 2012-06-22 15:21:36 -0700 | [diff] [blame] | 414 | } |
Adrian Roos | fe84e1f | 2015-11-04 15:55:39 -0800 | [diff] [blame] | 415 | |
| 416 | private boolean handleRemoteInput(View view, PendingIntent pendingIntent, Intent fillInIntent) { |
| 417 | Object tag = view.getTag(com.android.internal.R.id.remote_input_tag); |
| 418 | RemoteInput[] inputs = null; |
| 419 | if (tag instanceof RemoteInput[]) { |
| 420 | inputs = (RemoteInput[]) tag; |
| 421 | } |
| 422 | |
| 423 | if (inputs == null) { |
| 424 | return false; |
| 425 | } |
| 426 | |
| 427 | RemoteInput input = null; |
| 428 | |
| 429 | for (RemoteInput i : inputs) { |
| 430 | if (i.getAllowFreeFormInput()) { |
| 431 | input = i; |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | if (input == null) { |
| 436 | return false; |
| 437 | } |
| 438 | |
| 439 | ViewParent p = view.getParent(); |
| 440 | RemoteInputView riv = null; |
| 441 | while (p != null) { |
| 442 | if (p instanceof View) { |
| 443 | View pv = (View) p; |
| 444 | if (pv.isRootNamespace()) { |
| 445 | riv = (RemoteInputView) pv.findViewWithTag(RemoteInputView.VIEW_TAG); |
| 446 | break; |
| 447 | } |
| 448 | } |
| 449 | p = p.getParent(); |
| 450 | } |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 451 | ExpandableNotificationRow row = null; |
| 452 | while (p != null) { |
| 453 | if (p instanceof ExpandableNotificationRow) { |
| 454 | row = (ExpandableNotificationRow) p; |
| 455 | break; |
| 456 | } |
| 457 | p = p.getParent(); |
| 458 | } |
Adrian Roos | fe84e1f | 2015-11-04 15:55:39 -0800 | [diff] [blame] | 459 | |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 460 | if (riv == null || row == null) { |
Adrian Roos | fe84e1f | 2015-11-04 15:55:39 -0800 | [diff] [blame] | 461 | return false; |
| 462 | } |
| 463 | |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 464 | row.setUserExpanded(true); |
| 465 | |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 466 | if (!mAllowLockscreenRemoteInput) { |
| 467 | if (isLockscreenPublicMode()) { |
| 468 | onLockedRemoteInput(row, view); |
| 469 | return true; |
| 470 | } |
| 471 | final int userId = pendingIntent.getCreatorUserHandle().getIdentifier(); |
| 472 | if (mUserManager.getUserInfo(userId).isManagedProfile() |
| 473 | && mKeyguardManager.isDeviceLocked(userId)) { |
| 474 | onLockedWorkRemoteInput(userId, row, view); |
| 475 | return true; |
| 476 | } |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 477 | } |
| 478 | |
Adrian Roos | af06bf2 | 2016-07-15 12:26:49 -0700 | [diff] [blame] | 479 | int width = view.getWidth(); |
| 480 | if (view instanceof TextView) { |
| 481 | // Center the reveal on the text which might be off-center from the TextView |
| 482 | TextView tv = (TextView) view; |
| 483 | if (tv.getLayout() != null) { |
| 484 | int innerWidth = (int) tv.getLayout().getLineWidth(0); |
| 485 | innerWidth += tv.getCompoundPaddingLeft() + tv.getCompoundPaddingRight(); |
| 486 | width = Math.min(width, innerWidth); |
| 487 | } |
| 488 | } |
| 489 | int cx = view.getLeft() + width / 2; |
Adrian Roos | fe84e1f | 2015-11-04 15:55:39 -0800 | [diff] [blame] | 490 | int cy = view.getTop() + view.getHeight() / 2; |
| 491 | int w = riv.getWidth(); |
| 492 | int h = riv.getHeight(); |
| 493 | int r = Math.max( |
| 494 | Math.max(cx + cy, cx + (h - cy)), |
| 495 | Math.max((w - cx) + cy, (w - cx) + (h - cy))); |
Adrian Roos | fe84e1f | 2015-11-04 15:55:39 -0800 | [diff] [blame] | 496 | |
Adrian Roos | af06bf2 | 2016-07-15 12:26:49 -0700 | [diff] [blame] | 497 | riv.setRevealParameters(cx, cy, r); |
Adrian Roos | fe84e1f | 2015-11-04 15:55:39 -0800 | [diff] [blame] | 498 | riv.setPendingIntent(pendingIntent); |
| 499 | riv.setRemoteInput(inputs, input); |
Adrian Roos | af06bf2 | 2016-07-15 12:26:49 -0700 | [diff] [blame] | 500 | riv.focusAnimated(); |
Adrian Roos | fe84e1f | 2015-11-04 15:55:39 -0800 | [diff] [blame] | 501 | |
| 502 | return true; |
| 503 | } |
| 504 | |
Dianne Hackborn | 1927ae8 | 2012-06-22 15:21:36 -0700 | [diff] [blame] | 505 | }; |
| 506 | |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 507 | private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { |
| 508 | @Override |
| 509 | public void onReceive(Context context, Intent intent) { |
| 510 | String action = intent.getAction(); |
| 511 | if (Intent.ACTION_USER_SWITCHED.equals(action)) { |
| 512 | mCurrentUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1); |
Kenny Guy | 2a76494 | 2014-04-02 13:29:20 +0100 | [diff] [blame] | 513 | updateCurrentProfilesCache(); |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 514 | if (true) Log.v(TAG, "userId " + mCurrentUserId + " is in the house"); |
Dan Sandler | 52e5701e | 2014-07-22 23:14:54 -0400 | [diff] [blame] | 515 | |
| 516 | updateLockscreenNotificationSetting(); |
| 517 | |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 518 | userSwitched(mCurrentUserId); |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 519 | } else if (Intent.ACTION_USER_ADDED.equals(action)) { |
Kenny Guy | 2a76494 | 2014-04-02 13:29:20 +0100 | [diff] [blame] | 520 | updateCurrentProfilesCache(); |
Kenny Guy | dae30d5 | 2015-04-01 19:11:35 +0100 | [diff] [blame] | 521 | } else if (Intent.ACTION_USER_PRESENT.equals(action)) { |
| 522 | List<ActivityManager.RecentTaskInfo> recentTask = null; |
| 523 | try { |
| 524 | recentTask = ActivityManagerNative.getDefault().getRecentTasks(1, |
| 525 | ActivityManager.RECENT_WITH_EXCLUDED |
| 526 | | ActivityManager.RECENT_INCLUDE_PROFILES, |
Jeff Sharkey | 479212c | 2016-06-29 16:00:55 -0600 | [diff] [blame] | 527 | mCurrentUserId).getList(); |
Kenny Guy | dae30d5 | 2015-04-01 19:11:35 +0100 | [diff] [blame] | 528 | } catch (RemoteException e) { |
| 529 | // Abandon hope activity manager not running. |
| 530 | } |
| 531 | if (recentTask != null && recentTask.size() > 0) { |
| 532 | UserInfo user = mUserManager.getUserInfo(recentTask.get(0).userId); |
| 533 | if (user != null && user.isManagedProfile()) { |
Kenny Guy | 63bf8ac | 2015-06-18 15:09:09 +0100 | [diff] [blame] | 534 | Toast toast = Toast.makeText(mContext, |
| 535 | R.string.managed_profile_foreground_toast, |
| 536 | Toast.LENGTH_SHORT); |
| 537 | TextView text = (TextView) toast.getView().findViewById( |
| 538 | android.R.id.message); |
| 539 | text.setCompoundDrawablesRelativeWithIntrinsicBounds( |
| 540 | R.drawable.stat_sys_managed_profile_status, 0, 0, 0); |
| 541 | int paddingPx = mContext.getResources().getDimensionPixelSize( |
| 542 | R.dimen.managed_profile_toast_padding); |
| 543 | text.setCompoundDrawablePadding(paddingPx); |
Kenny Guy | 540f7d2 | 2015-06-08 20:24:23 +0100 | [diff] [blame] | 544 | toast.show(); |
Kenny Guy | dae30d5 | 2015-04-01 19:11:35 +0100 | [diff] [blame] | 545 | } |
| 546 | } |
Chris Wren | cd8f4f7 | 2014-08-27 18:48:13 -0400 | [diff] [blame] | 547 | } else if (BANNER_ACTION_CANCEL.equals(action) || BANNER_ACTION_SETUP.equals(action)) { |
| 548 | NotificationManager noMan = (NotificationManager) |
| 549 | mContext.getSystemService(Context.NOTIFICATION_SERVICE); |
Chris Wren | d877510 | 2015-01-16 16:16:43 -0500 | [diff] [blame] | 550 | noMan.cancel(R.id.notification_hidden); |
Chris Wren | cd8f4f7 | 2014-08-27 18:48:13 -0400 | [diff] [blame] | 551 | |
| 552 | Settings.Secure.putInt(mContext.getContentResolver(), |
| 553 | Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING, 0); |
| 554 | if (BANNER_ACTION_SETUP.equals(action)) { |
Jorim Jaggi | 4eedc1d | 2014-10-27 13:45:56 +0100 | [diff] [blame] | 555 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, |
| 556 | true /* force */); |
Chris Wren | cd8f4f7 | 2014-08-27 18:48:13 -0400 | [diff] [blame] | 557 | mContext.startActivity(new Intent(Settings.ACTION_APP_NOTIFICATION_REDACTION) |
| 558 | .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) |
| 559 | |
| 560 | ); |
| 561 | } |
Ricky Wai | 7fa0171 | 2016-03-16 12:13:54 +0000 | [diff] [blame] | 562 | } else if (WORK_CHALLENGE_UNLOCKED_NOTIFICATION_ACTION.equals(action)) { |
Tony Mak | 646fe99 | 2016-04-21 16:43:08 +0100 | [diff] [blame] | 563 | final IntentSender intentSender = intent.getParcelableExtra(Intent.EXTRA_INTENT); |
Ricky Wai | 7fa0171 | 2016-03-16 12:13:54 +0000 | [diff] [blame] | 564 | final String notificationKey = intent.getStringExtra(Intent.EXTRA_INDEX); |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 565 | if (intentSender != null) { |
| 566 | try { |
| 567 | mContext.startIntentSender(intentSender, null, 0, 0, 0); |
| 568 | } catch (IntentSender.SendIntentException e) { |
| 569 | /* ignore */ |
| 570 | } |
Ricky Wai | 7fa0171 | 2016-03-16 12:13:54 +0000 | [diff] [blame] | 571 | } |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 572 | if (notificationKey != null) { |
| 573 | try { |
| 574 | mBarService.onNotificationClick(notificationKey); |
| 575 | } catch (RemoteException e) { |
| 576 | /* ignore */ |
| 577 | } |
Ricky Wai | 7fa0171 | 2016-03-16 12:13:54 +0000 | [diff] [blame] | 578 | } |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 579 | onWorkChallengeUnlocked(); |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 580 | } |
| 581 | } |
| 582 | }; |
| 583 | |
Kenny Guy | 0b7dd1e | 2015-03-12 17:14:38 +0000 | [diff] [blame] | 584 | private final BroadcastReceiver mAllUsersReceiver = new BroadcastReceiver() { |
| 585 | @Override |
| 586 | public void onReceive(Context context, Intent intent) { |
| 587 | String action = intent.getAction(); |
| 588 | if (DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED.equals(action) && |
| 589 | isCurrentProfile(getSendingUserId())) { |
| 590 | mUsersAllowingPrivateNotifications.clear(); |
| 591 | updateLockscreenNotificationSetting(); |
| 592 | updateNotifications(); |
| 593 | } |
| 594 | } |
| 595 | }; |
| 596 | |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 597 | private final NotificationListenerService mNotificationListener = |
| 598 | new NotificationListenerService() { |
| 599 | @Override |
| 600 | public void onListenerConnected() { |
| 601 | if (DEBUG) Log.d(TAG, "onListenerConnected"); |
| 602 | final StatusBarNotification[] notifications = getActiveNotifications(); |
Kent Persson | 185e9c2 | 2014-12-10 16:40:13 +0100 | [diff] [blame] | 603 | if (notifications == null) { |
| 604 | Log.w(TAG, "onListenerConnected unable to get active notifications."); |
| 605 | return; |
| 606 | } |
Christoph Studer | d0694b6 | 2014-06-04 16:36:01 +0200 | [diff] [blame] | 607 | final RankingMap currentRanking = getCurrentRanking(); |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 608 | mHandler.post(new Runnable() { |
| 609 | @Override |
| 610 | public void run() { |
| 611 | for (StatusBarNotification sbn : notifications) { |
Selim Cinek | 379ff8f | 2015-02-20 17:03:16 +0100 | [diff] [blame] | 612 | addNotification(sbn, currentRanking, null /* oldEntry */); |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 613 | } |
| 614 | } |
| 615 | }); |
| 616 | } |
| 617 | |
| 618 | @Override |
Christoph Studer | d0694b6 | 2014-06-04 16:36:01 +0200 | [diff] [blame] | 619 | public void onNotificationPosted(final StatusBarNotification sbn, |
| 620 | final RankingMap rankingMap) { |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 621 | if (DEBUG) Log.d(TAG, "onNotificationPosted: " + sbn); |
Chris Wren | 5691955 | 2015-02-24 15:56:34 -0500 | [diff] [blame] | 622 | if (sbn != null) { |
| 623 | mHandler.post(new Runnable() { |
| 624 | @Override |
| 625 | public void run() { |
Adrian Roos | 497ab02 | 2015-02-10 20:49:33 +0100 | [diff] [blame] | 626 | processForRemoteInput(sbn.getNotification()); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 627 | String key = sbn.getKey(); |
Adrian Roos | c0a579e | 2016-03-30 16:43:58 -0700 | [diff] [blame] | 628 | mKeysKeptForRemoteInput.remove(key); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 629 | boolean isUpdate = mNotificationData.get(key) != null; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 630 | // In case we don't allow child notifications, we ignore children of |
| 631 | // notifications that have a summary, since we're not going to show them |
| 632 | // anyway. This is true also when the summary is canceled, |
Chris Wren | 5691955 | 2015-02-24 15:56:34 -0500 | [diff] [blame] | 633 | // because children are automatically canceled by NoMan in that case. |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 634 | if (!ENABLE_CHILD_NOTIFICATIONS |
| 635 | && mGroupManager.isChildInGroupWithSummary(sbn)) { |
Chris Wren | 5691955 | 2015-02-24 15:56:34 -0500 | [diff] [blame] | 636 | if (DEBUG) { |
| 637 | Log.d(TAG, "Ignoring group child due to existing summary: " + sbn); |
| 638 | } |
| 639 | |
| 640 | // Remove existing notification to avoid stale data. |
| 641 | if (isUpdate) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 642 | removeNotification(key, rankingMap); |
Chris Wren | 5691955 | 2015-02-24 15:56:34 -0500 | [diff] [blame] | 643 | } else { |
| 644 | mNotificationData.updateRanking(rankingMap); |
| 645 | } |
| 646 | return; |
Christoph Studer | d722f27 | 2014-09-02 11:49:19 +0200 | [diff] [blame] | 647 | } |
Christoph Studer | d722f27 | 2014-09-02 11:49:19 +0200 | [diff] [blame] | 648 | if (isUpdate) { |
Chris Wren | 5691955 | 2015-02-24 15:56:34 -0500 | [diff] [blame] | 649 | updateNotification(sbn, rankingMap); |
Christoph Studer | d722f27 | 2014-09-02 11:49:19 +0200 | [diff] [blame] | 650 | } else { |
Selim Cinek | 379ff8f | 2015-02-20 17:03:16 +0100 | [diff] [blame] | 651 | addNotification(sbn, rankingMap, null /* oldEntry */); |
Christoph Studer | d722f27 | 2014-09-02 11:49:19 +0200 | [diff] [blame] | 652 | } |
Christoph Studer | d722f27 | 2014-09-02 11:49:19 +0200 | [diff] [blame] | 653 | } |
Chris Wren | 5691955 | 2015-02-24 15:56:34 -0500 | [diff] [blame] | 654 | }); |
| 655 | } |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 656 | } |
| 657 | |
| 658 | @Override |
Chris Wren | 5691955 | 2015-02-24 15:56:34 -0500 | [diff] [blame] | 659 | public void onNotificationRemoved(StatusBarNotification sbn, |
Christoph Studer | d0694b6 | 2014-06-04 16:36:01 +0200 | [diff] [blame] | 660 | final RankingMap rankingMap) { |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 661 | if (DEBUG) Log.d(TAG, "onNotificationRemoved: " + sbn); |
Chris Wren | 5691955 | 2015-02-24 15:56:34 -0500 | [diff] [blame] | 662 | if (sbn != null) { |
| 663 | final String key = sbn.getKey(); |
| 664 | mHandler.post(new Runnable() { |
| 665 | @Override |
| 666 | public void run() { |
| 667 | removeNotification(key, rankingMap); |
| 668 | } |
| 669 | }); |
| 670 | } |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 671 | } |
| 672 | |
| 673 | @Override |
Christoph Studer | d0694b6 | 2014-06-04 16:36:01 +0200 | [diff] [blame] | 674 | public void onNotificationRankingUpdate(final RankingMap rankingMap) { |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 675 | if (DEBUG) Log.d(TAG, "onRankingUpdate"); |
Chris Wren | 5691955 | 2015-02-24 15:56:34 -0500 | [diff] [blame] | 676 | if (rankingMap != null) { |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 677 | mHandler.post(new Runnable() { |
| 678 | @Override |
| 679 | public void run() { |
Christoph Studer | e71fefc | 2014-06-24 16:16:49 +0200 | [diff] [blame] | 680 | updateNotificationRanking(rankingMap); |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 681 | } |
| 682 | }); |
Chris Wren | 5691955 | 2015-02-24 15:56:34 -0500 | [diff] [blame] | 683 | } } |
Christoph Studer | 5b63826 | 2014-07-07 11:21:49 +0200 | [diff] [blame] | 684 | |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 685 | }; |
| 686 | |
Kenny Guy | 2a76494 | 2014-04-02 13:29:20 +0100 | [diff] [blame] | 687 | private void updateCurrentProfilesCache() { |
| 688 | synchronized (mCurrentProfiles) { |
| 689 | mCurrentProfiles.clear(); |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 690 | if (mUserManager != null) { |
Kenny Guy | 2a76494 | 2014-04-02 13:29:20 +0100 | [diff] [blame] | 691 | for (UserInfo user : mUserManager.getProfiles(mCurrentUserId)) { |
| 692 | mCurrentProfiles.put(user.id, user); |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 693 | } |
| 694 | } |
| 695 | } |
| 696 | } |
| 697 | |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 698 | public void start() { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 699 | mWindowManager = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); |
| 700 | mWindowManagerService = WindowManagerGlobal.getWindowManagerService(); |
| 701 | mDisplay = mWindowManager.getDefaultDisplay(); |
Adrian Roos | bd3409c | 2014-08-12 18:21:09 +0200 | [diff] [blame] | 702 | mDevicePolicyManager = (DevicePolicyManager)mContext.getSystemService( |
| 703 | Context.DEVICE_POLICY_SERVICE); |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 704 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 705 | mNotificationData = new NotificationData(this); |
| 706 | |
Selim Cinek | a8fefa5 | 2014-09-08 16:10:50 +0200 | [diff] [blame] | 707 | mAccessibilityManager = (AccessibilityManager) |
| 708 | mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); |
| 709 | |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 710 | mDreamManager = IDreamManager.Stub.asInterface( |
| 711 | ServiceManager.checkService(DreamService.DREAM_SERVICE)); |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 712 | mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); |
| 713 | |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 714 | mContext.getContentResolver().registerContentObserver( |
Jeff Brown | bf6f6f9 | 2012-09-25 15:03:20 -0700 | [diff] [blame] | 715 | Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED), true, |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 716 | mSettingsObserver); |
| 717 | mContext.getContentResolver().registerContentObserver( |
| 718 | Settings.Global.getUriFor(Settings.Global.ZEN_MODE), false, |
| 719 | mSettingsObserver); |
John Spurlock | 4b3bda2 | 2014-05-22 14:32:20 -0400 | [diff] [blame] | 720 | mContext.getContentResolver().registerContentObserver( |
Dan Sandler | 52e5701e | 2014-07-22 23:14:54 -0400 | [diff] [blame] | 721 | Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS), false, |
| 722 | mSettingsObserver, |
| 723 | UserHandle.USER_ALL); |
Adrian Roos | b27d7a5 | 2016-06-16 13:04:47 -0700 | [diff] [blame] | 724 | if (ENABLE_LOCK_SCREEN_ALLOW_REMOTE_INPUT) { |
| 725 | mContext.getContentResolver().registerContentObserver( |
| 726 | Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_ALLOW_REMOTE_INPUT), |
| 727 | false, |
| 728 | mSettingsObserver, |
| 729 | UserHandle.USER_ALL); |
| 730 | } |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 731 | |
Dan Sandler | fd16d56 | 2014-02-13 18:43:31 -0800 | [diff] [blame] | 732 | mContext.getContentResolver().registerContentObserver( |
| 733 | Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS), |
| 734 | true, |
| 735 | mLockscreenSettingsObserver, |
| 736 | UserHandle.USER_ALL); |
| 737 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 738 | mBarService = IStatusBarService.Stub.asInterface( |
| 739 | ServiceManager.getService(Context.STATUS_BAR_SERVICE)); |
Joe Onorato | 1c95ecb | 2010-06-28 17:19:12 -0400 | [diff] [blame] | 740 | |
Jorim Jaggi | d61f227 | 2014-12-19 20:35:35 +0100 | [diff] [blame] | 741 | mRecents = getComponent(Recents.class); |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 742 | |
Dan Sandler | 539aad4 | 2014-08-04 00:43:39 -0400 | [diff] [blame] | 743 | final Configuration currentConfig = mContext.getResources().getConfiguration(); |
| 744 | mLocale = currentConfig.locale; |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 745 | mLayoutDirection = TextUtils.getLayoutDirectionFromLocale(mLocale); |
Dan Sandler | 539aad4 | 2014-08-04 00:43:39 -0400 | [diff] [blame] | 746 | mFontScale = currentConfig.fontScale; |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 747 | mDensity = currentConfig.densityDpi; |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 748 | |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 749 | mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); |
Ricky Wai | 7fa0171 | 2016-03-16 12:13:54 +0000 | [diff] [blame] | 750 | mKeyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE); |
| 751 | mLockPatternUtils = new LockPatternUtils(mContext); |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 752 | |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 753 | // Connect in to the status bar manager service |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 754 | mCommandQueue = new CommandQueue(this); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 755 | |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 756 | int[] switches = new int[9]; |
satok | cd7cd29 | 2010-11-20 15:46:23 +0900 | [diff] [blame] | 757 | ArrayList<IBinder> binders = new ArrayList<IBinder>(); |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 758 | ArrayList<String> iconSlots = new ArrayList<>(); |
| 759 | ArrayList<StatusBarIcon> icons = new ArrayList<>(); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 760 | Rect fullscreenStackBounds = new Rect(); |
| 761 | Rect dockedStackBounds = new Rect(); |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 762 | try { |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 763 | mBarService.registerStatusBar(mCommandQueue, iconSlots, icons, switches, binders, |
| 764 | fullscreenStackBounds, dockedStackBounds); |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 765 | } catch (RemoteException ex) { |
| 766 | // If the system process isn't there we're doomed anyway. |
| 767 | } |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 768 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 769 | createAndAddWindows(); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 770 | |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 771 | mSettingsObserver.onChange(false); // set up |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 772 | disable(switches[0], switches[6], false /* animate */); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 773 | setSystemUiVisibility(switches[1], switches[7], switches[8], 0xffffffff, |
| 774 | fullscreenStackBounds, dockedStackBounds); |
Dianne Hackborn | 7d04932 | 2011-06-14 15:00:32 -0700 | [diff] [blame] | 775 | topAppWindowChanged(switches[2] != 0); |
satok | cd7cd29 | 2010-11-20 15:46:23 +0900 | [diff] [blame] | 776 | // StatusBarManagerService has a back up of IME token and it's restored here. |
Michael Wright | 665366a | 2014-08-07 15:44:40 -0700 | [diff] [blame] | 777 | setImeWindowStatus(binders.get(0), switches[3], switches[4], switches[5] != 0); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 778 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 779 | // Set up the initial icon state |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 780 | int N = iconSlots.size(); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 781 | int viewIndex = 0; |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 782 | for (int i=0; i < N; i++) { |
| 783 | setIcon(iconSlots.get(i), icons.get(i)); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 784 | } |
| 785 | |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 786 | // Set up the initial notification state. |
Christoph Studer | e71fefc | 2014-06-24 16:16:49 +0200 | [diff] [blame] | 787 | try { |
Christoph Studer | 4600f9b | 2014-07-22 22:44:43 +0200 | [diff] [blame] | 788 | mNotificationListener.registerAsSystemService(mContext, |
Christoph Studer | e71fefc | 2014-06-24 16:16:49 +0200 | [diff] [blame] | 789 | new ComponentName(mContext.getPackageName(), getClass().getCanonicalName()), |
| 790 | UserHandle.USER_ALL); |
| 791 | } catch (RemoteException e) { |
| 792 | Log.e(TAG, "Unable to register notification listener", e); |
Joe Onorato | 75199e3 | 2010-05-29 17:22:51 -0400 | [diff] [blame] | 793 | } |
| 794 | |
Christoph Studer | 60748e7 | 2014-05-22 16:51:41 +0200 | [diff] [blame] | 795 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 796 | if (DEBUG) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 797 | Log.d(TAG, String.format( |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 798 | "init: icons=%d disabled=0x%08x lights=0x%08x menu=0x%08x imeButton=0x%08x", |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 799 | icons.size(), |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 800 | switches[0], |
| 801 | switches[1], |
| 802 | switches[2], |
| 803 | switches[3] |
| 804 | )); |
Joe Onorato | 1c95ecb | 2010-06-28 17:19:12 -0400 | [diff] [blame] | 805 | } |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 806 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 807 | mCurrentUserId = ActivityManager.getCurrentUser(); |
Chris Wren | a6d4fb6 | 2014-11-20 14:46:23 -0500 | [diff] [blame] | 808 | setHeadsUpUser(mCurrentUserId); |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 809 | |
| 810 | IntentFilter filter = new IntentFilter(); |
| 811 | filter.addAction(Intent.ACTION_USER_SWITCHED); |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 812 | filter.addAction(Intent.ACTION_USER_ADDED); |
Kenny Guy | dae30d5 | 2015-04-01 19:11:35 +0100 | [diff] [blame] | 813 | filter.addAction(Intent.ACTION_USER_PRESENT); |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 814 | mContext.registerReceiver(mBroadcastReceiver, filter); |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 815 | |
Ricky Wai | 7fa0171 | 2016-03-16 12:13:54 +0000 | [diff] [blame] | 816 | IntentFilter internalFilter = new IntentFilter(); |
| 817 | internalFilter.addAction(WORK_CHALLENGE_UNLOCKED_NOTIFICATION_ACTION); |
| 818 | internalFilter.addAction(BANNER_ACTION_CANCEL); |
| 819 | internalFilter.addAction(BANNER_ACTION_SETUP); |
| 820 | mContext.registerReceiver(mBroadcastReceiver, internalFilter, PERMISSION_SELF, null); |
| 821 | |
Kenny Guy | 0b7dd1e | 2015-03-12 17:14:38 +0000 | [diff] [blame] | 822 | IntentFilter allUsersFilter = new IntentFilter(); |
| 823 | allUsersFilter.addAction( |
| 824 | DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED); |
| 825 | mContext.registerReceiverAsUser(mAllUsersReceiver, UserHandle.ALL, allUsersFilter, |
| 826 | null, null); |
Kenny Guy | 2a76494 | 2014-04-02 13:29:20 +0100 | [diff] [blame] | 827 | updateCurrentProfilesCache(); |
Dan Sandler | dc34df5 | 2016-04-07 21:04:46 -0400 | [diff] [blame] | 828 | |
| 829 | IVrManager vrManager = IVrManager.Stub.asInterface(ServiceManager.getService("vrmanager")); |
| 830 | try { |
| 831 | vrManager.registerListener(mVrStateCallbacks); |
| 832 | } catch (RemoteException e) { |
| 833 | Slog.e(TAG, "Failed to register VR mode state listener: " + e); |
| 834 | } |
| 835 | |
Dan Sandler | 028a60f | 2016-10-04 15:01:22 -0400 | [diff] [blame] | 836 | mNonBlockablePkgs = new ArraySet<String>(); |
Julia Reynolds | 98a4486 | 2016-09-12 08:53:47 -0400 | [diff] [blame] | 837 | Collections.addAll(mNonBlockablePkgs, mContext.getResources().getStringArray( |
| 838 | com.android.internal.R.array.config_nonBlockableNotificationPackages)); |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 839 | } |
| 840 | |
Chris Wren | cd8f4f7 | 2014-08-27 18:48:13 -0400 | [diff] [blame] | 841 | protected void notifyUserAboutHiddenNotifications() { |
| 842 | if (0 != Settings.Secure.getInt(mContext.getContentResolver(), |
| 843 | Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING, 1)) { |
| 844 | Log.d(TAG, "user hasn't seen notification about hidden notifications"); |
Ricky Wai | 7fa0171 | 2016-03-16 12:13:54 +0000 | [diff] [blame] | 845 | if (!mLockPatternUtils.isSecure(KeyguardUpdateMonitor.getCurrentUser())) { |
Chris Wren | cd8f4f7 | 2014-08-27 18:48:13 -0400 | [diff] [blame] | 846 | Log.d(TAG, "insecure lockscreen, skipping notification"); |
| 847 | Settings.Secure.putInt(mContext.getContentResolver(), |
| 848 | Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING, 0); |
| 849 | return; |
| 850 | } |
| 851 | Log.d(TAG, "disabling lockecreen notifications and alerting the user"); |
| 852 | // disable lockscreen notifications until user acts on the banner. |
| 853 | Settings.Secure.putInt(mContext.getContentResolver(), |
| 854 | Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0); |
Adrian Roos | aee7046 | 2014-09-03 16:27:39 +0200 | [diff] [blame] | 855 | Settings.Secure.putInt(mContext.getContentResolver(), |
| 856 | Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0); |
Chris Wren | cd8f4f7 | 2014-08-27 18:48:13 -0400 | [diff] [blame] | 857 | |
| 858 | final String packageName = mContext.getPackageName(); |
| 859 | PendingIntent cancelIntent = PendingIntent.getBroadcast(mContext, 0, |
| 860 | new Intent(BANNER_ACTION_CANCEL).setPackage(packageName), |
| 861 | PendingIntent.FLAG_CANCEL_CURRENT); |
| 862 | PendingIntent setupIntent = PendingIntent.getBroadcast(mContext, 0, |
| 863 | new Intent(BANNER_ACTION_SETUP).setPackage(packageName), |
| 864 | PendingIntent.FLAG_CANCEL_CURRENT); |
| 865 | |
Chris Wren | cd8f4f7 | 2014-08-27 18:48:13 -0400 | [diff] [blame] | 866 | final int colorRes = com.android.internal.R.color.system_notification_accent_color; |
| 867 | Notification.Builder note = new Notification.Builder(mContext) |
| 868 | .setSmallIcon(R.drawable.ic_android) |
| 869 | .setContentTitle(mContext.getString(R.string.hidden_notifications_title)) |
| 870 | .setContentText(mContext.getString(R.string.hidden_notifications_text)) |
| 871 | .setPriority(Notification.PRIORITY_HIGH) |
| 872 | .setOngoing(true) |
Alan Viverette | 4a357cd | 2015-03-18 18:37:18 -0700 | [diff] [blame] | 873 | .setColor(mContext.getColor(colorRes)) |
Chris Wren | cd8f4f7 | 2014-08-27 18:48:13 -0400 | [diff] [blame] | 874 | .setContentIntent(setupIntent) |
| 875 | .addAction(R.drawable.ic_close, |
| 876 | mContext.getString(R.string.hidden_notifications_cancel), |
| 877 | cancelIntent) |
| 878 | .addAction(R.drawable.ic_settings, |
| 879 | mContext.getString(R.string.hidden_notifications_setup), |
| 880 | setupIntent); |
Adrian Roos | e25c18d | 2016-06-17 15:59:49 -0700 | [diff] [blame] | 881 | overrideNotificationAppName(mContext, note); |
Chris Wren | cd8f4f7 | 2014-08-27 18:48:13 -0400 | [diff] [blame] | 882 | |
| 883 | NotificationManager noMan = |
| 884 | (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); |
Chris Wren | d877510 | 2015-01-16 16:16:43 -0500 | [diff] [blame] | 885 | noMan.notify(R.id.notification_hidden, note.build()); |
Chris Wren | cd8f4f7 | 2014-08-27 18:48:13 -0400 | [diff] [blame] | 886 | } |
| 887 | } |
| 888 | |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 889 | public void userSwitched(int newUserId) { |
Chris Wren | a6d4fb6 | 2014-11-20 14:46:23 -0500 | [diff] [blame] | 890 | setHeadsUpUser(newUserId); |
| 891 | } |
| 892 | |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 893 | protected abstract void setHeadsUpUser(int newUserId); |
Chris Wren | d04f6ce | 2014-06-11 17:37:28 -0400 | [diff] [blame] | 894 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 895 | @Override // NotificationData.Environment |
| 896 | public boolean isNotificationForCurrentProfiles(StatusBarNotification n) { |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 897 | final int thisUserId = mCurrentUserId; |
| 898 | final int notificationUserId = n.getUserId(); |
| 899 | if (DEBUG && MULTIUSER_DEBUG) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 900 | Log.v(TAG, String.format("%s: current userid: %d, notification userid: %d", |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 901 | n, thisUserId, notificationUserId)); |
| 902 | } |
Dan Sandler | e63ba4b | 2014-12-05 00:26:24 -0500 | [diff] [blame] | 903 | return isCurrentProfile(notificationUserId); |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 904 | } |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 905 | |
Amith Yamasani | f47e51e | 2015-04-17 10:02:15 -0700 | [diff] [blame] | 906 | protected void setNotificationShown(StatusBarNotification n) { |
Chris Wren | 2650558 | 2015-07-22 17:03:17 -0400 | [diff] [blame] | 907 | setNotificationsShown(new String[]{n.getKey()}); |
Amith Yamasani | f47e51e | 2015-04-17 10:02:15 -0700 | [diff] [blame] | 908 | } |
| 909 | |
| 910 | protected void setNotificationsShown(String[] keys) { |
Chris Wren | 2650558 | 2015-07-22 17:03:17 -0400 | [diff] [blame] | 911 | try { |
| 912 | mNotificationListener.setNotificationsShown(keys); |
| 913 | } catch (RuntimeException e) { |
| 914 | Log.d(TAG, "failed setNotificationsShown: ", e); |
| 915 | } |
Amith Yamasani | f47e51e | 2015-04-17 10:02:15 -0700 | [diff] [blame] | 916 | } |
| 917 | |
Kenny Guy | 44fc65f | 2014-11-28 22:18:14 +0000 | [diff] [blame] | 918 | protected boolean isCurrentProfile(int userId) { |
| 919 | synchronized (mCurrentProfiles) { |
Dan Sandler | e63ba4b | 2014-12-05 00:26:24 -0500 | [diff] [blame] | 920 | return userId == UserHandle.USER_ALL || mCurrentProfiles.get(userId) != null; |
Kenny Guy | 44fc65f | 2014-11-28 22:18:14 +0000 | [diff] [blame] | 921 | } |
| 922 | } |
| 923 | |
Christoph Studer | 2e731b5 | 2014-08-22 16:01:51 +0200 | [diff] [blame] | 924 | @Override |
| 925 | public String getCurrentMediaNotificationKey() { |
| 926 | return null; |
| 927 | } |
| 928 | |
Selim Cinek | 25fd4e2b | 2015-02-20 17:46:07 +0100 | [diff] [blame] | 929 | @Override |
| 930 | public NotificationGroupManager getGroupManager() { |
| 931 | return mGroupManager; |
| 932 | } |
| 933 | |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 934 | /** |
| 935 | * Takes the necessary steps to prepare the status bar for starting an activity, then starts it. |
| 936 | * @param action A dismiss action that is called if it's safe to start the activity. |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 937 | * @param afterKeyguardGone Whether the action should be executed after the Keyguard is gone. |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 938 | */ |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 939 | protected void dismissKeyguardThenExecute(OnDismissAction action, boolean afterKeyguardGone) { |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 940 | action.onDismiss(); |
| 941 | } |
| 942 | |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 943 | @Override |
| 944 | protected void onConfigurationChanged(Configuration newConfig) { |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 945 | final Locale locale = mContext.getResources().getConfiguration().locale; |
| 946 | final int ld = TextUtils.getLayoutDirectionFromLocale(locale); |
Dan Sandler | 539aad4 | 2014-08-04 00:43:39 -0400 | [diff] [blame] | 947 | final float fontScale = newConfig.fontScale; |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 948 | final int density = newConfig.densityDpi; |
| 949 | if (density != mDensity || mFontScale != fontScale) { |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 950 | onDensityOrFontScaleChanged(); |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 951 | mDensity = density; |
| 952 | mFontScale = fontScale; |
| 953 | } |
| 954 | if (! locale.equals(mLocale) || ld != mLayoutDirection) { |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 955 | if (DEBUG) { |
| 956 | Log.v(TAG, String.format( |
| 957 | "config changed locale/LD: %s (%d) -> %s (%d)", mLocale, mLayoutDirection, |
| 958 | locale, ld)); |
| 959 | } |
| 960 | mLocale = locale; |
| 961 | mLayoutDirection = ld; |
| 962 | refreshLayout(ld); |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 963 | } |
| 964 | } |
| 965 | |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 966 | protected void onDensityOrFontScaleChanged() { |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 967 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
| 968 | for (int i = 0; i < activeNotifications.size(); i++) { |
| 969 | Entry entry = activeNotifications.get(i); |
| 970 | boolean exposedGuts = entry.row.getGuts() == mNotificationGutsExposed; |
| 971 | entry.row.reInflateViews(); |
| 972 | if (exposedGuts) { |
| 973 | mNotificationGutsExposed = entry.row.getGuts(); |
| 974 | bindGuts(entry.row); |
| 975 | } |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 976 | inflateViews(entry, mStackScroller); |
| 977 | } |
| 978 | } |
| 979 | |
Selim Cinek | 9e624e7 | 2016-07-20 13:46:49 -0700 | [diff] [blame] | 980 | protected void bindDismissListener(final ExpandableNotificationRow row) { |
| 981 | row.setOnDismissListener(new View.OnClickListener() { |
Selim Cinek | 757d879 | 2016-01-28 16:21:08 -0800 | [diff] [blame] | 982 | public void onClick(View v) { |
| 983 | // Accessibility feedback |
| 984 | v.announceForAccessibility( |
| 985 | mContext.getString(R.string.accessibility_notification_dismissed)); |
Selim Cinek | 9e624e7 | 2016-07-20 13:46:49 -0700 | [diff] [blame] | 986 | performRemoveNotification(row.getStatusBarNotification(), false /* removeView */); |
Selim Cinek | 757d879 | 2016-01-28 16:21:08 -0800 | [diff] [blame] | 987 | } |
| 988 | }); |
Winson Chung | c57ccf0 | 2011-10-13 15:04:59 -0700 | [diff] [blame] | 989 | } |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 990 | |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 991 | protected void performRemoveNotification(StatusBarNotification n, boolean removeView) { |
Selim Cinek | 36b0223 | 2016-05-11 23:07:05 -0400 | [diff] [blame] | 992 | final String pkg = n.getPackageName(); |
| 993 | final String tag = n.getTag(); |
| 994 | final int id = n.getId(); |
| 995 | final int userId = n.getUserId(); |
| 996 | try { |
| 997 | mBarService.onNotificationClear(pkg, tag, id, userId); |
| 998 | if (FORCE_REMOTE_INPUT_HISTORY |
| 999 | && mKeysKeptForRemoteInput.contains(n.getKey())) { |
| 1000 | mKeysKeptForRemoteInput.remove(n.getKey()); |
| 1001 | removeView = true; |
| 1002 | } |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 1003 | if (mRemoteInputEntriesToRemoveOnCollapse.remove(mNotificationData.get(n.getKey()))) { |
| 1004 | removeView = true; |
| 1005 | } |
Selim Cinek | 36b0223 | 2016-05-11 23:07:05 -0400 | [diff] [blame] | 1006 | if (removeView) { |
| 1007 | removeNotification(n.getKey(), null); |
| 1008 | } |
| 1009 | |
| 1010 | } catch (RemoteException ex) { |
| 1011 | // system process is dead if we're here. |
| 1012 | } |
| 1013 | } |
| 1014 | |
Daniel Sandler | 96fd7c1 | 2012-03-30 16:37:36 -0400 | [diff] [blame] | 1015 | |
Christoph Studer | 13b89512 | 2014-08-26 15:42:12 +0200 | [diff] [blame] | 1016 | protected void applyColorsAndBackgrounds(StatusBarNotification sbn, |
Jorim Jaggi | 4673985 | 2014-04-15 09:58:24 +0200 | [diff] [blame] | 1017 | NotificationData.Entry entry) { |
Dan Sandler | fe266a3 | 2014-05-15 22:28:06 -0400 | [diff] [blame] | 1018 | |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1019 | if (entry.getContentView().getId() |
| 1020 | != com.android.internal.R.id.status_bar_latest_event_content) { |
Dan Sandler | fe266a3 | 2014-05-15 22:28:06 -0400 | [diff] [blame] | 1021 | // Using custom RemoteViews |
Jorim Jaggi | a1eeade | 2014-09-08 22:34:39 +0200 | [diff] [blame] | 1022 | if (entry.targetSdk >= Build.VERSION_CODES.GINGERBREAD |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 1023 | && entry.targetSdk < Build.VERSION_CODES.LOLLIPOP) { |
Selim Cinek | 697178b | 2014-07-02 19:40:30 +0200 | [diff] [blame] | 1024 | entry.row.setShowingLegacyBackground(true); |
Jorim Jaggi | 36b1523 | 2014-06-10 17:24:20 +0200 | [diff] [blame] | 1025 | entry.legacy = true; |
Daniel Sandler | 96fd7c1 | 2012-03-30 16:37:36 -0400 | [diff] [blame] | 1026 | } |
| 1027 | } |
Christoph Studer | 13b89512 | 2014-08-26 15:42:12 +0200 | [diff] [blame] | 1028 | |
| 1029 | if (entry.icon != null) { |
Jorim Jaggi | dd0107a | 2015-01-21 22:23:48 +0100 | [diff] [blame] | 1030 | entry.icon.setTag(R.id.icon_is_pre_L, entry.targetSdk < Build.VERSION_CODES.LOLLIPOP); |
Christoph Studer | 13b89512 | 2014-08-26 15:42:12 +0200 | [diff] [blame] | 1031 | } |
Daniel Sandler | 96fd7c1 | 2012-03-30 16:37:36 -0400 | [diff] [blame] | 1032 | } |
| 1033 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1034 | public boolean isMediaNotification(NotificationData.Entry entry) { |
Dan Sandler | 842dd77 | 2014-05-15 09:36:47 -0400 | [diff] [blame] | 1035 | // TODO: confirm that there's a valid media key |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1036 | return entry.getExpandedContentView() != null && |
| 1037 | entry.getExpandedContentView() |
| 1038 | .findViewById(com.android.internal.R.id.media_actions) != null; |
Dan Sandler | 842dd77 | 2014-05-15 09:36:47 -0400 | [diff] [blame] | 1039 | } |
| 1040 | |
Dan Sandler | f4db75c | 2014-09-03 18:02:31 +0200 | [diff] [blame] | 1041 | // The (i) button in the guts that links to the system notification settings for that app |
Jorim Jaggi | fb28c0e | 2014-08-22 16:28:42 +0200 | [diff] [blame] | 1042 | private void startAppNotificationSettingsActivity(String packageName, final int appUid) { |
| 1043 | final Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS); |
Dan Sandler | e9a4e90 | 2014-07-31 01:06:43 -0400 | [diff] [blame] | 1044 | intent.putExtra(Settings.EXTRA_APP_PACKAGE, packageName); |
| 1045 | intent.putExtra(Settings.EXTRA_APP_UID, appUid); |
Dan Sandler | f4db75c | 2014-09-03 18:02:31 +0200 | [diff] [blame] | 1046 | startNotificationGutsIntent(intent, appUid); |
| 1047 | } |
Jorim Jaggi | fb28c0e | 2014-08-22 16:28:42 +0200 | [diff] [blame] | 1048 | |
Dan Sandler | f4db75c | 2014-09-03 18:02:31 +0200 | [diff] [blame] | 1049 | private void startNotificationGutsIntent(final Intent intent, final int appUid) { |
Jorim Jaggi | fb28c0e | 2014-08-22 16:28:42 +0200 | [diff] [blame] | 1050 | final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing(); |
| 1051 | dismissKeyguardThenExecute(new OnDismissAction() { |
| 1052 | @Override |
| 1053 | public boolean onDismiss() { |
| 1054 | AsyncTask.execute(new Runnable() { |
| 1055 | public void run() { |
| 1056 | try { |
| 1057 | if (keyguardShowing) { |
| 1058 | ActivityManagerNative.getDefault() |
| 1059 | .keyguardWaitingForActivityDrawn(); |
| 1060 | } |
| 1061 | TaskStackBuilder.create(mContext) |
| 1062 | .addNextIntentWithParentStack(intent) |
Jorim Jaggi | e6e108e | 2016-03-28 13:38:45 -0700 | [diff] [blame] | 1063 | .startActivities(getActivityOptions(), |
Jorim Jaggi | fb28c0e | 2014-08-22 16:28:42 +0200 | [diff] [blame] | 1064 | new UserHandle(UserHandle.getUserId(appUid))); |
| 1065 | overrideActivityPendingAppTransition(keyguardShowing); |
| 1066 | } catch (RemoteException e) { |
| 1067 | } |
| 1068 | } |
| 1069 | }); |
Jorim Jaggi | 4eedc1d | 2014-10-27 13:45:56 +0100 | [diff] [blame] | 1070 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */); |
Jorim Jaggi | fb28c0e | 2014-08-22 16:28:42 +0200 | [diff] [blame] | 1071 | return true; |
| 1072 | } |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 1073 | }, false /* afterKeyguardGone */); |
Dan Sandler | 4247a5c | 2014-07-23 15:58:08 -0400 | [diff] [blame] | 1074 | } |
| 1075 | |
Mady Mellor | b53bc27 | 2016-02-11 18:28:23 -0800 | [diff] [blame] | 1076 | private void bindGuts(final ExpandableNotificationRow row) { |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 1077 | row.inflateGuts(); |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 1078 | final StatusBarNotification sbn = row.getStatusBarNotification(); |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 1079 | PackageManager pmUser = getPackageManagerForUser(mContext, sbn.getUser().getIdentifier()); |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 1080 | row.setTag(sbn.getPackageName()); |
Julia Reynolds | a07af88 | 2015-12-17 08:32:48 -0500 | [diff] [blame] | 1081 | final NotificationGuts guts = row.getGuts(); |
Mady Mellor | 97c8df4 | 2016-03-22 18:09:39 -0700 | [diff] [blame] | 1082 | guts.setClosedListener(this); |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 1083 | final String pkg = sbn.getPackageName(); |
| 1084 | String appname = pkg; |
| 1085 | Drawable pkgicon = null; |
| 1086 | int appUid = -1; |
| 1087 | try { |
| 1088 | final ApplicationInfo info = pmUser.getApplicationInfo(pkg, |
| 1089 | PackageManager.GET_UNINSTALLED_PACKAGES |
| 1090 | | PackageManager.GET_DISABLED_COMPONENTS); |
| 1091 | if (info != null) { |
| 1092 | appname = String.valueOf(pmUser.getApplicationLabel(info)); |
| 1093 | pkgicon = pmUser.getApplicationIcon(info); |
| 1094 | appUid = info.uid; |
| 1095 | } |
| 1096 | } catch (NameNotFoundException e) { |
| 1097 | // app is gone, just show package name and generic icon |
| 1098 | pkgicon = pmUser.getDefaultActivityIcon(); |
| 1099 | } |
Julia Reynolds | ead00aa | 2015-12-07 08:23:48 -0500 | [diff] [blame] | 1100 | |
Min Yun | 175559a | 2016-06-17 11:59:24 -0700 | [diff] [blame] | 1101 | ((ImageView) guts.findViewById(R.id.app_icon)).setImageDrawable(pkgicon); |
| 1102 | ((TextView) guts.findViewById(R.id.pkgname)).setText(appname); |
Julia Reynolds | ead00aa | 2015-12-07 08:23:48 -0500 | [diff] [blame] | 1103 | |
Min Yun | de383c7 | 2016-06-24 11:05:03 -0700 | [diff] [blame] | 1104 | final TextView settingsButton = (TextView) guts.findViewById(R.id.more_settings); |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 1105 | if (appUid >= 0) { |
| 1106 | final int appUidF = appUid; |
| 1107 | settingsButton.setOnClickListener(new View.OnClickListener() { |
| 1108 | public void onClick(View v) { |
Chris Wren | f6e9228b | 2016-01-26 18:04:35 -0500 | [diff] [blame] | 1109 | MetricsLogger.action(mContext, MetricsEvent.ACTION_NOTE_INFO); |
Mady Mellor | 97c8df4 | 2016-03-22 18:09:39 -0700 | [diff] [blame] | 1110 | guts.resetFalsingCheck(); |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 1111 | startAppNotificationSettingsActivity(pkg, appUidF); |
| 1112 | } |
| 1113 | }); |
Min Yun | de383c7 | 2016-06-24 11:05:03 -0700 | [diff] [blame] | 1114 | settingsButton.setText(R.string.notification_more_settings); |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 1115 | } else { |
| 1116 | settingsButton.setVisibility(View.GONE); |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 1117 | } |
| 1118 | |
Julia Reynolds | 98a4486 | 2016-09-12 08:53:47 -0400 | [diff] [blame] | 1119 | guts.bindImportance(pmUser, sbn, mNonBlockablePkgs, |
| 1120 | mNotificationData.getImportance(sbn.getKey())); |
Min Yun | 175559a | 2016-06-17 11:59:24 -0700 | [diff] [blame] | 1121 | |
Min Yun | de383c7 | 2016-06-24 11:05:03 -0700 | [diff] [blame] | 1122 | final TextView doneButton = (TextView) guts.findViewById(R.id.done); |
| 1123 | doneButton.setText(R.string.notification_done); |
| 1124 | doneButton.setOnClickListener(new View.OnClickListener() { |
Julia Reynolds | 5682192 | 2016-01-04 15:24:01 -0500 | [diff] [blame] | 1125 | @Override |
| 1126 | public void onClick(View v) { |
Mady Mellor | 8e8a69e | 2016-03-14 12:30:10 -0700 | [diff] [blame] | 1127 | // If the user has security enabled, show challenge if the setting is changed. |
| 1128 | if (guts.hasImportanceChanged() && isLockscreenPublicMode() && |
| 1129 | (mState == StatusBarState.KEYGUARD |
| 1130 | || mState == StatusBarState.SHADE_LOCKED)) { |
| 1131 | OnDismissAction dismissAction = new OnDismissAction() { |
| 1132 | @Override |
| 1133 | public boolean onDismiss() { |
| 1134 | saveImportanceCloseControls(sbn, row, guts, v); |
| 1135 | return true; |
| 1136 | } |
| 1137 | }; |
| 1138 | onLockedNotificationImportanceChange(dismissAction); |
| 1139 | } else { |
| 1140 | saveImportanceCloseControls(sbn, row, guts, v); |
| 1141 | } |
Julia Reynolds | 5682192 | 2016-01-04 15:24:01 -0500 | [diff] [blame] | 1142 | } |
| 1143 | }); |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 1144 | } |
| 1145 | |
Mady Mellor | 8e8a69e | 2016-03-14 12:30:10 -0700 | [diff] [blame] | 1146 | private void saveImportanceCloseControls(StatusBarNotification sbn, |
| 1147 | ExpandableNotificationRow row, NotificationGuts guts, View done) { |
Mady Mellor | 97c8df4 | 2016-03-22 18:09:39 -0700 | [diff] [blame] | 1148 | guts.resetFalsingCheck(); |
Mady Mellor | 8e8a69e | 2016-03-14 12:30:10 -0700 | [diff] [blame] | 1149 | guts.saveImportance(sbn); |
| 1150 | |
| 1151 | int[] rowLocation = new int[2]; |
| 1152 | int[] doneLocation = new int[2]; |
| 1153 | row.getLocationOnScreen(rowLocation); |
| 1154 | done.getLocationOnScreen(doneLocation); |
| 1155 | |
| 1156 | final int centerX = done.getWidth() / 2; |
| 1157 | final int centerY = done.getHeight() / 2; |
| 1158 | final int x = doneLocation[0] - rowLocation[0] + centerX; |
| 1159 | final int y = doneLocation[1] - rowLocation[1] + centerY; |
| 1160 | dismissPopups(x, y); |
| 1161 | } |
| 1162 | |
Dan Sandler | 4247a5c | 2014-07-23 15:58:08 -0400 | [diff] [blame] | 1163 | protected SwipeHelper.LongPressListener getNotificationLongClicker() { |
| 1164 | return new SwipeHelper.LongPressListener() { |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 1165 | @Override |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 1166 | public boolean onLongPress(View v, final int x, final int y) { |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 1167 | if (!(v instanceof ExpandableNotificationRow)) { |
| 1168 | return false; |
| 1169 | } |
Selim Cinek | abdc5a0 | 2014-09-02 13:46:00 +0200 | [diff] [blame] | 1170 | if (v.getWindowToken() == null) { |
| 1171 | Log.e(TAG, "Trying to show notification guts, but not attached to window"); |
| 1172 | return false; |
| 1173 | } |
Dan Sandler | 4247a5c | 2014-07-23 15:58:08 -0400 | [diff] [blame] | 1174 | |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1175 | final ExpandableNotificationRow row = (ExpandableNotificationRow) v; |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 1176 | bindGuts(row); |
Jorim Jaggi | b1cd3c1 | 2014-09-08 19:55:17 +0200 | [diff] [blame] | 1177 | |
Dan Sandler | 4247a5c | 2014-07-23 15:58:08 -0400 | [diff] [blame] | 1178 | // Assume we are a status_bar_notification_row |
Selim Cinek | ab29aeb | 2015-02-20 18:18:32 +0100 | [diff] [blame] | 1179 | final NotificationGuts guts = row.getGuts(); |
Selim Cinek | bdefcdf | 2014-09-11 12:41:47 +0200 | [diff] [blame] | 1180 | if (guts == null) { |
| 1181 | // This view has no guts. Examples are the more card or the dismiss all view |
| 1182 | return false; |
| 1183 | } |
Dan Sandler | 4247a5c | 2014-07-23 15:58:08 -0400 | [diff] [blame] | 1184 | |
| 1185 | // Already showing? |
Selim Cinek | abdc5a0 | 2014-09-02 13:46:00 +0200 | [diff] [blame] | 1186 | if (guts.getVisibility() == View.VISIBLE) { |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 1187 | dismissPopups(x, y); |
Selim Cinek | abdc5a0 | 2014-09-02 13:46:00 +0200 | [diff] [blame] | 1188 | return false; |
| 1189 | } |
Dan Sandler | 4247a5c | 2014-07-23 15:58:08 -0400 | [diff] [blame] | 1190 | |
Chris Wren | f6e9228b | 2016-01-26 18:04:35 -0500 | [diff] [blame] | 1191 | MetricsLogger.action(mContext, MetricsEvent.ACTION_NOTE_CONTROLS); |
Julia Reynolds | ead00aa | 2015-12-07 08:23:48 -0500 | [diff] [blame] | 1192 | |
Julia Reynolds | 4077945 | 2016-02-23 13:43:32 -0500 | [diff] [blame] | 1193 | // ensure that it's laid but not visible until actually laid out |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 1194 | guts.setVisibility(View.INVISIBLE); |
Julia Reynolds | 4077945 | 2016-02-23 13:43:32 -0500 | [diff] [blame] | 1195 | // Post to ensure the the guts are properly laid out. |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 1196 | guts.post(new Runnable() { |
| 1197 | public void run() { |
Mady Mellor | 7a9b2a6 | 2016-03-23 07:41:47 -0700 | [diff] [blame] | 1198 | dismissPopups(-1 /* x */, -1 /* y */, false /* resetGear */, |
| 1199 | false /* animate */); |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 1200 | guts.setVisibility(View.VISIBLE); |
| 1201 | final double horz = Math.max(guts.getWidth() - x, x); |
| 1202 | final double vert = Math.max(guts.getHeight() - y, y); |
| 1203 | final float r = (float) Math.hypot(horz, vert); |
| 1204 | final Animator a |
| 1205 | = ViewAnimationUtils.createCircularReveal(guts, x, y, 0, r); |
| 1206 | a.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD); |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 1207 | a.setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN); |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1208 | a.addListener(new AnimatorListenerAdapter() { |
| 1209 | @Override |
| 1210 | public void onAnimationEnd(Animator animation) { |
| 1211 | super.onAnimationEnd(animation); |
| 1212 | // Move the notification view back over the gear |
| 1213 | row.resetTranslation(); |
| 1214 | } |
| 1215 | }); |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 1216 | a.start(); |
Mady Mellor | 97c8df4 | 2016-03-22 18:09:39 -0700 | [diff] [blame] | 1217 | guts.setExposed(true /* exposed */, |
| 1218 | mState == StatusBarState.KEYGUARD /* needsFalsingProtection */); |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 1219 | row.closeRemoteInput(); |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 1220 | mStackScroller.onHeightChanged(null, true /* needsAnimation */); |
| 1221 | mNotificationGutsExposed = guts; |
| 1222 | } |
| 1223 | }); |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 1224 | return true; |
| 1225 | } |
| 1226 | }; |
| 1227 | } |
| 1228 | |
Mady Mellor | 7a9b2a6 | 2016-03-23 07:41:47 -0700 | [diff] [blame] | 1229 | /** |
| 1230 | * Returns the exposed NotificationGuts or null if none are exposed. |
| 1231 | */ |
| 1232 | public NotificationGuts getExposedGuts() { |
| 1233 | return mNotificationGutsExposed; |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1234 | } |
| 1235 | |
Daniel Sandler | 469e96e | 2012-05-04 15:56:19 -0400 | [diff] [blame] | 1236 | public void dismissPopups() { |
Mady Mellor | 7a9b2a6 | 2016-03-23 07:41:47 -0700 | [diff] [blame] | 1237 | dismissPopups(-1 /* x */, -1 /* y */, true /* resetGear */, false /* animate */); |
Selim Cinek | d84a593 | 2015-12-15 11:45:36 -0800 | [diff] [blame] | 1238 | } |
| 1239 | |
| 1240 | private void dismissPopups(int x, int y) { |
Mady Mellor | 7a9b2a6 | 2016-03-23 07:41:47 -0700 | [diff] [blame] | 1241 | dismissPopups(x, y, true /* resetGear */, false /* animate */); |
Mady Mellor | b53bc27 | 2016-02-11 18:28:23 -0800 | [diff] [blame] | 1242 | } |
| 1243 | |
Mady Mellor | 7a9b2a6 | 2016-03-23 07:41:47 -0700 | [diff] [blame] | 1244 | public void dismissPopups(int x, int y, boolean resetGear, boolean animate) { |
Dan Sandler | 4247a5c | 2014-07-23 15:58:08 -0400 | [diff] [blame] | 1245 | if (mNotificationGutsExposed != null) { |
Mady Mellor | 97c8df4 | 2016-03-22 18:09:39 -0700 | [diff] [blame] | 1246 | mNotificationGutsExposed.closeControls(x, y, true /* notify */); |
Daniel Sandler | 469e96e | 2012-05-04 15:56:19 -0400 | [diff] [blame] | 1247 | } |
Mady Mellor | 7a9b2a6 | 2016-03-23 07:41:47 -0700 | [diff] [blame] | 1248 | if (resetGear) { |
| 1249 | mStackScroller.resetExposedGearView(animate, true /* force */); |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 1250 | } |
Daniel Sandler | 469e96e | 2012-05-04 15:56:19 -0400 | [diff] [blame] | 1251 | } |
| 1252 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1253 | @Override |
Mady Mellor | 97c8df4 | 2016-03-22 18:09:39 -0700 | [diff] [blame] | 1254 | public void onGutsClosed(NotificationGuts guts) { |
| 1255 | mStackScroller.onHeightChanged(null, true /* needsAnimation */); |
| 1256 | mNotificationGutsExposed = null; |
| 1257 | } |
| 1258 | |
| 1259 | @Override |
Jorim Jaggi | 681fc7b | 2016-04-14 22:02:39 -0700 | [diff] [blame] | 1260 | public void showRecentApps(boolean triggeredFromAltTab, boolean fromHome) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 1261 | int msg = MSG_SHOW_RECENT_APPS; |
| 1262 | mHandler.removeMessages(msg); |
Jorim Jaggi | 681fc7b | 2016-04-14 22:02:39 -0700 | [diff] [blame] | 1263 | mHandler.obtainMessage(msg, triggeredFromAltTab ? 1 : 0, fromHome ? 1 : 0).sendToTarget(); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 1264 | } |
| 1265 | |
| 1266 | @Override |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame] | 1267 | public void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 1268 | int msg = MSG_HIDE_RECENT_APPS; |
| 1269 | mHandler.removeMessages(msg); |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame] | 1270 | mHandler.obtainMessage(msg, triggeredFromAltTab ? 1 : 0, |
| 1271 | triggeredFromHomeKey ? 1 : 0).sendToTarget(); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 1272 | } |
| 1273 | |
| 1274 | @Override |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1275 | public void toggleRecentApps() { |
Jorim Jaggi | 900fb48 | 2015-06-02 15:07:33 -0700 | [diff] [blame] | 1276 | toggleRecents(); |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1277 | } |
| 1278 | |
| 1279 | @Override |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1280 | public void toggleSplitScreen() { |
Jorim Jaggi | 29379ec | 2016-04-11 23:43:42 -0700 | [diff] [blame] | 1281 | toggleSplitScreenMode(-1 /* metricsDockAction */, -1 /* metricsUndockAction */); |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1282 | } |
| 1283 | |
| 1284 | @Override |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1285 | public void preloadRecentApps() { |
| 1286 | int msg = MSG_PRELOAD_RECENT_APPS; |
| 1287 | mHandler.removeMessages(msg); |
| 1288 | mHandler.sendEmptyMessage(msg); |
| 1289 | } |
| 1290 | |
| 1291 | @Override |
| 1292 | public void cancelPreloadRecentApps() { |
| 1293 | int msg = MSG_CANCEL_PRELOAD_RECENT_APPS; |
| 1294 | mHandler.removeMessages(msg); |
| 1295 | mHandler.sendEmptyMessage(msg); |
| 1296 | } |
| 1297 | |
Clara Bayarri | f2debb1 | 2015-07-10 14:47:17 +0100 | [diff] [blame] | 1298 | @Override |
Andrei Stingaceanu | 0bf096f | 2016-04-14 18:11:57 +0100 | [diff] [blame] | 1299 | public void dismissKeyboardShortcutsMenu() { |
| 1300 | int msg = MSG_DISMISS_KEYBOARD_SHORTCUTS_MENU; |
| 1301 | mHandler.removeMessages(msg); |
| 1302 | mHandler.sendEmptyMessage(msg); |
| 1303 | } |
| 1304 | |
| 1305 | @Override |
Clara Bayarri | 4e850ff | 2016-03-02 11:12:32 -0800 | [diff] [blame] | 1306 | public void toggleKeyboardShortcutsMenu(int deviceId) { |
Andrei Stingaceanu | c22ab79 | 2016-01-07 12:39:38 +0000 | [diff] [blame] | 1307 | int msg = MSG_TOGGLE_KEYBOARD_SHORTCUTS_MENU; |
Clara Bayarri | f2debb1 | 2015-07-10 14:47:17 +0100 | [diff] [blame] | 1308 | mHandler.removeMessages(msg); |
Clara Bayarri | 4e850ff | 2016-03-02 11:12:32 -0800 | [diff] [blame] | 1309 | mHandler.obtainMessage(msg, deviceId, 0).sendToTarget(); |
Clara Bayarri | f2debb1 | 2015-07-10 14:47:17 +0100 | [diff] [blame] | 1310 | } |
| 1311 | |
Winson Chung | b1f7499 | 2014-08-08 12:53:09 -0700 | [diff] [blame] | 1312 | /** Jumps to the next affiliated task in the group. */ |
| 1313 | public void showNextAffiliatedTask() { |
| 1314 | int msg = MSG_SHOW_NEXT_AFFILIATED_TASK; |
| 1315 | mHandler.removeMessages(msg); |
| 1316 | mHandler.sendEmptyMessage(msg); |
| 1317 | } |
| 1318 | |
| 1319 | /** Jumps to the previous affiliated task in the group. */ |
| 1320 | public void showPreviousAffiliatedTask() { |
| 1321 | int msg = MSG_SHOW_PREV_AFFILIATED_TASK; |
| 1322 | mHandler.removeMessages(msg); |
| 1323 | mHandler.sendEmptyMessage(msg); |
| 1324 | } |
| 1325 | |
Michael Jurka | ecc395a | 2012-03-30 05:31:46 -0700 | [diff] [blame] | 1326 | protected H createHandler() { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1327 | return new H(); |
| 1328 | } |
| 1329 | |
Andrei Stingaceanu | 9d9294c | 2015-08-24 17:19:06 +0100 | [diff] [blame] | 1330 | protected void sendCloseSystemWindows(String reason) { |
Michael Jurka | 56a5783 | 2012-05-14 13:24:43 -0700 | [diff] [blame] | 1331 | if (ActivityManagerNative.isSystemReady()) { |
| 1332 | try { |
| 1333 | ActivityManagerNative.getDefault().closeSystemDialogs(reason); |
| 1334 | } catch (RemoteException e) { |
| 1335 | } |
| 1336 | } |
| 1337 | } |
| 1338 | |
Michael Jurka | cb2522c | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 1339 | protected abstract View getStatusBarView(); |
| 1340 | |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 1341 | protected View.OnTouchListener mRecentsPreloadOnTouchListener = new View.OnTouchListener() { |
| 1342 | // additional optimization when we have software system buttons - start loading the recent |
| 1343 | // tasks on touch down |
| 1344 | @Override |
| 1345 | public boolean onTouch(View v, MotionEvent event) { |
| 1346 | int action = event.getAction() & MotionEvent.ACTION_MASK; |
| 1347 | if (action == MotionEvent.ACTION_DOWN) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 1348 | preloadRecents(); |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 1349 | } else if (action == MotionEvent.ACTION_CANCEL) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 1350 | cancelPreloadingRecents(); |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 1351 | } else if (action == MotionEvent.ACTION_UP) { |
| 1352 | if (!v.isPressed()) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 1353 | cancelPreloadingRecents(); |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 1354 | } |
| 1355 | |
| 1356 | } |
| 1357 | return false; |
| 1358 | } |
| 1359 | }; |
| 1360 | |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1361 | /** |
| 1362 | * Toggle docking the app window |
| 1363 | * |
Jorim Jaggi | 29379ec | 2016-04-11 23:43:42 -0700 | [diff] [blame] | 1364 | * @param metricsDockAction the action to log when docking is successful, or -1 to not log |
| 1365 | * anything on successful docking |
| 1366 | * @param metricsUndockAction the action to log when undocking, or -1 to not log anything when |
| 1367 | * undocking |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1368 | */ |
Jorim Jaggi | 29379ec | 2016-04-11 23:43:42 -0700 | [diff] [blame] | 1369 | protected abstract void toggleSplitScreenMode(int metricsDockAction, int metricsUndockAction); |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1370 | |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 1371 | /** Proxy for RecentsComponent */ |
| 1372 | |
Jorim Jaggi | 681fc7b | 2016-04-14 22:02:39 -0700 | [diff] [blame] | 1373 | protected void showRecents(boolean triggeredFromAltTab, boolean fromHome) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 1374 | if (mRecents != null) { |
Andrei Stingaceanu | 9d9294c | 2015-08-24 17:19:06 +0100 | [diff] [blame] | 1375 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_RECENT_APPS); |
Jorim Jaggi | db21bbd | 2016-04-18 15:32:07 -0700 | [diff] [blame] | 1376 | mRecents.showRecents(triggeredFromAltTab, fromHome); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 1377 | } |
| 1378 | } |
| 1379 | |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame] | 1380 | protected void hideRecents(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 1381 | if (mRecents != null) { |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame] | 1382 | mRecents.hideRecents(triggeredFromAltTab, triggeredFromHomeKey); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 1383 | } |
| 1384 | } |
| 1385 | |
| 1386 | protected void toggleRecents() { |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 1387 | if (mRecents != null) { |
Jorim Jaggi | db21bbd | 2016-04-18 15:32:07 -0700 | [diff] [blame] | 1388 | mRecents.toggleRecents(mDisplay); |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 1389 | } |
| 1390 | } |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 1391 | |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 1392 | protected void preloadRecents() { |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 1393 | if (mRecents != null) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 1394 | mRecents.preloadRecents(); |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 1395 | } |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 1396 | } |
| 1397 | |
Clara Bayarri | 4e850ff | 2016-03-02 11:12:32 -0800 | [diff] [blame] | 1398 | protected void toggleKeyboardShortcuts(int deviceId) { |
Andrei Stingaceanu | f86bc97 | 2016-04-12 15:29:25 +0100 | [diff] [blame] | 1399 | KeyboardShortcuts.toggle(mContext, deviceId); |
Clara Bayarri | f2debb1 | 2015-07-10 14:47:17 +0100 | [diff] [blame] | 1400 | } |
| 1401 | |
Andrei Stingaceanu | 0bf096f | 2016-04-14 18:11:57 +0100 | [diff] [blame] | 1402 | protected void dismissKeyboardShortcuts() { |
| 1403 | KeyboardShortcuts.dismiss(); |
| 1404 | } |
| 1405 | |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 1406 | protected void cancelPreloadingRecents() { |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 1407 | if (mRecents != null) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 1408 | mRecents.cancelPreloadingRecents(); |
John Spurlock | d08de37 | 2013-06-24 13:06:08 -0400 | [diff] [blame] | 1409 | } |
Michael Jurka | 80343f6 | 2012-10-18 13:13:46 +0200 | [diff] [blame] | 1410 | } |
| 1411 | |
Winson Chung | b1f7499 | 2014-08-08 12:53:09 -0700 | [diff] [blame] | 1412 | protected void showRecentsNextAffiliatedTask() { |
| 1413 | if (mRecents != null) { |
| 1414 | mRecents.showNextAffiliatedTask(); |
| 1415 | } |
| 1416 | } |
| 1417 | |
| 1418 | protected void showRecentsPreviousAffiliatedTask() { |
| 1419 | if (mRecents != null) { |
| 1420 | mRecents.showPrevAffiliatedTask(); |
| 1421 | } |
| 1422 | } |
| 1423 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1424 | /** |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1425 | * If there is an active heads-up notification and it has a fullscreen intent, fire it now. |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1426 | */ |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1427 | public abstract void maybeEscalateHeadsUp(); |
Chris Wren | a4ef620 | 2014-06-09 18:07:30 -0400 | [diff] [blame] | 1428 | |
Dan Sandler | fd16d56 | 2014-02-13 18:43:31 -0800 | [diff] [blame] | 1429 | /** |
| 1430 | * Save the current "public" (locked and secure) state of the lockscreen. |
| 1431 | */ |
| 1432 | public void setLockscreenPublicMode(boolean publicMode) { |
| 1433 | mLockscreenPublicMode = publicMode; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 1434 | } |
| 1435 | |
Dan Sandler | fd16d56 | 2014-02-13 18:43:31 -0800 | [diff] [blame] | 1436 | public boolean isLockscreenPublicMode() { |
| 1437 | return mLockscreenPublicMode; |
| 1438 | } |
| 1439 | |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 1440 | protected void onWorkChallengeUnlocked() {} |
| 1441 | |
Dan Sandler | fd16d56 | 2014-02-13 18:43:31 -0800 | [diff] [blame] | 1442 | /** |
Julia Reynolds | 26fa8a5 | 2016-02-24 08:31:22 -0500 | [diff] [blame] | 1443 | * Has the given user chosen to allow notifications to be shown even when the lockscreen is in |
| 1444 | * "public" (secure & locked) mode? |
| 1445 | */ |
| 1446 | public boolean userAllowsNotificationsInPublic(int userHandle) { |
| 1447 | if (userHandle == UserHandle.USER_ALL) { |
| 1448 | return true; |
| 1449 | } |
| 1450 | |
| 1451 | if (mUsersAllowingNotifications.indexOfKey(userHandle) < 0) { |
| 1452 | final boolean allowed = 0 != Settings.Secure.getIntForUser( |
| 1453 | mContext.getContentResolver(), |
| 1454 | Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0, userHandle); |
| 1455 | mUsersAllowingNotifications.append(userHandle, allowed); |
| 1456 | return allowed; |
| 1457 | } |
| 1458 | |
| 1459 | return mUsersAllowingNotifications.get(userHandle); |
| 1460 | } |
| 1461 | |
| 1462 | /** |
Dan Sandler | fd16d56 | 2014-02-13 18:43:31 -0800 | [diff] [blame] | 1463 | * Has the given user chosen to allow their private (full) notifications to be shown even |
| 1464 | * when the lockscreen is in "public" (secure & locked) mode? |
| 1465 | */ |
| 1466 | public boolean userAllowsPrivateNotificationsInPublic(int userHandle) { |
| 1467 | if (userHandle == UserHandle.USER_ALL) { |
| 1468 | return true; |
| 1469 | } |
| 1470 | |
| 1471 | if (mUsersAllowingPrivateNotifications.indexOfKey(userHandle) < 0) { |
Kenny Guy | b0d3ab2 | 2015-02-10 16:13:11 +0000 | [diff] [blame] | 1472 | final boolean allowedByUser = 0 != Settings.Secure.getIntForUser( |
Dan Sandler | fd16d56 | 2014-02-13 18:43:31 -0800 | [diff] [blame] | 1473 | mContext.getContentResolver(), |
| 1474 | Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0, userHandle); |
Sudheer Shanka | f5b850e | 2016-01-25 19:58:59 +0000 | [diff] [blame] | 1475 | final boolean allowedByDpm = adminAllowsUnredactedNotifications(userHandle); |
Kenny Guy | b0d3ab2 | 2015-02-10 16:13:11 +0000 | [diff] [blame] | 1476 | final boolean allowed = allowedByUser && allowedByDpm; |
| 1477 | mUsersAllowingPrivateNotifications.append(userHandle, allowed); |
Dan Sandler | fd16d56 | 2014-02-13 18:43:31 -0800 | [diff] [blame] | 1478 | return allowed; |
| 1479 | } |
| 1480 | |
| 1481 | return mUsersAllowingPrivateNotifications.get(userHandle); |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 1482 | } |
| 1483 | |
Sudheer Shanka | f5b850e | 2016-01-25 19:58:59 +0000 | [diff] [blame] | 1484 | private boolean adminAllowsUnredactedNotifications(int userHandle) { |
| 1485 | if (userHandle == UserHandle.USER_ALL) { |
| 1486 | return true; |
| 1487 | } |
| 1488 | final int dpmFlags = mDevicePolicyManager.getKeyguardDisabledFeatures(null /* admin */, |
| 1489 | userHandle); |
| 1490 | return (dpmFlags & DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS) == 0; |
| 1491 | } |
| 1492 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1493 | /** |
Julia Reynolds | 26fa8a5 | 2016-02-24 08:31:22 -0500 | [diff] [blame] | 1494 | * Returns true if we're on a secure lockscreen and the user wants to hide notification data. |
| 1495 | * If so, notifications should be hidden. |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1496 | */ |
| 1497 | @Override // NotificationData.Environment |
Julia Reynolds | 26fa8a5 | 2016-02-24 08:31:22 -0500 | [diff] [blame] | 1498 | public boolean shouldHideNotifications(int userid) { |
| 1499 | return isLockscreenPublicMode() && !userAllowsNotificationsInPublic(userid); |
| 1500 | } |
| 1501 | |
| 1502 | /** |
| 1503 | * Returns true if we're on a secure lockscreen and the user wants to hide notifications via |
| 1504 | * package-specific override. |
| 1505 | */ |
| 1506 | @Override // NotificationDate.Environment |
| 1507 | public boolean shouldHideNotifications(String key) { |
| 1508 | return isLockscreenPublicMode() |
| 1509 | && mNotificationData.getVisibilityOverride(key) == Notification.VISIBILITY_SECRET; |
| 1510 | } |
| 1511 | |
| 1512 | /** |
| 1513 | * Returns true if we're on a secure lockscreen. |
| 1514 | */ |
| 1515 | @Override // NotificationData.Environment |
| 1516 | public boolean onSecureLockScreen() { |
| 1517 | return isLockscreenPublicMode(); |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1518 | } |
| 1519 | |
Chris Wren | a4ef620 | 2014-06-09 18:07:30 -0400 | [diff] [blame] | 1520 | public void onNotificationClear(StatusBarNotification notification) { |
| 1521 | try { |
| 1522 | mBarService.onNotificationClear( |
| 1523 | notification.getPackageName(), |
| 1524 | notification.getTag(), |
| 1525 | notification.getId(), |
| 1526 | notification.getUserId()); |
| 1527 | } catch (android.os.RemoteException ex) { |
| 1528 | // oh well |
| 1529 | } |
| 1530 | } |
| 1531 | |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 1532 | /** |
Selim Cinek | 5fbc632 | 2016-01-15 17:17:58 -0800 | [diff] [blame] | 1533 | * Called when the notification panel layouts |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 1534 | */ |
Selim Cinek | 5fbc632 | 2016-01-15 17:17:58 -0800 | [diff] [blame] | 1535 | public void onPanelLaidOut() { |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 1536 | if (mState == StatusBarState.KEYGUARD) { |
| 1537 | // Since the number of notifications is determined based on the height of the view, we |
| 1538 | // need to update them. |
Selim Cinek | 5fbc632 | 2016-01-15 17:17:58 -0800 | [diff] [blame] | 1539 | int maxBefore = getMaxKeyguardNotifications(false /* recompute */); |
| 1540 | int maxNotifications = getMaxKeyguardNotifications(true /* recompute */); |
| 1541 | if (maxBefore != maxNotifications) { |
| 1542 | updateRowStates(); |
| 1543 | } |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 1544 | } |
| 1545 | } |
| 1546 | |
Mady Mellor | 8e8a69e | 2016-03-14 12:30:10 -0700 | [diff] [blame] | 1547 | protected void onLockedNotificationImportanceChange(OnDismissAction dismissAction) {} |
| 1548 | |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 1549 | protected void onLockedRemoteInput(ExpandableNotificationRow row, View clickedView) {} |
| 1550 | |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 1551 | protected void onLockedWorkRemoteInput(int userId, ExpandableNotificationRow row, |
| 1552 | View clicked) {} |
| 1553 | |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 1554 | @Override |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 1555 | public void onExpandClicked(Entry clickedEntry, boolean nowExpanded) { |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 1556 | } |
| 1557 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1558 | protected class H extends Handler { |
| 1559 | public void handleMessage(Message m) { |
| 1560 | switch (m.what) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 1561 | case MSG_SHOW_RECENT_APPS: |
Jorim Jaggi | 681fc7b | 2016-04-14 22:02:39 -0700 | [diff] [blame] | 1562 | showRecents(m.arg1 > 0, m.arg2 != 0); |
Michael Jurka | cb2522c | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 1563 | break; |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 1564 | case MSG_HIDE_RECENT_APPS: |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame] | 1565 | hideRecents(m.arg1 > 0, m.arg2 > 0); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 1566 | break; |
| 1567 | case MSG_TOGGLE_RECENTS_APPS: |
| 1568 | toggleRecents(); |
Michael Jurka | cb2522c | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 1569 | break; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1570 | case MSG_PRELOAD_RECENT_APPS: |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 1571 | preloadRecents(); |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1572 | break; |
| 1573 | case MSG_CANCEL_PRELOAD_RECENT_APPS: |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 1574 | cancelPreloadingRecents(); |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1575 | break; |
Winson Chung | b1f7499 | 2014-08-08 12:53:09 -0700 | [diff] [blame] | 1576 | case MSG_SHOW_NEXT_AFFILIATED_TASK: |
| 1577 | showRecentsNextAffiliatedTask(); |
| 1578 | break; |
| 1579 | case MSG_SHOW_PREV_AFFILIATED_TASK: |
| 1580 | showRecentsPreviousAffiliatedTask(); |
| 1581 | break; |
Andrei Stingaceanu | c22ab79 | 2016-01-07 12:39:38 +0000 | [diff] [blame] | 1582 | case MSG_TOGGLE_KEYBOARD_SHORTCUTS_MENU: |
Clara Bayarri | 4e850ff | 2016-03-02 11:12:32 -0800 | [diff] [blame] | 1583 | toggleKeyboardShortcuts(m.arg1); |
Clara Bayarri | f2debb1 | 2015-07-10 14:47:17 +0100 | [diff] [blame] | 1584 | break; |
Andrei Stingaceanu | 0bf096f | 2016-04-14 18:11:57 +0100 | [diff] [blame] | 1585 | case MSG_DISMISS_KEYBOARD_SHORTCUTS_MENU: |
| 1586 | dismissKeyboardShortcuts(); |
| 1587 | break; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1588 | } |
| 1589 | } |
| 1590 | } |
| 1591 | |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1592 | protected void workAroundBadLayerDrawableOpacity(View v) { |
| 1593 | } |
| 1594 | |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1595 | protected boolean inflateViews(Entry entry, ViewGroup parent) { |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 1596 | PackageManager pmUser = getPackageManagerForUser(mContext, |
Dan Sandler | e9a4e90 | 2014-07-31 01:06:43 -0400 | [diff] [blame] | 1597 | entry.notification.getUser().getIdentifier()); |
| 1598 | |
Dan Sandler | f4db75c | 2014-09-03 18:02:31 +0200 | [diff] [blame] | 1599 | final StatusBarNotification sbn = entry.notification; |
Adrian Roos | 95f8bea | 2016-07-27 15:49:03 -0700 | [diff] [blame] | 1600 | try { |
| 1601 | entry.cacheContentViews(mContext, null); |
| 1602 | } catch (RuntimeException e) { |
| 1603 | Log.e(TAG, "Unable to get notification remote views", e); |
| 1604 | return false; |
| 1605 | } |
Julia Reynolds | d9228f1 | 2015-10-20 10:37:27 -0400 | [diff] [blame] | 1606 | |
| 1607 | final RemoteViews contentView = entry.cachedContentView; |
| 1608 | final RemoteViews bigContentView = entry.cachedBigContentView; |
| 1609 | final RemoteViews headsUpContentView = entry.cachedHeadsUpContentView; |
| 1610 | final RemoteViews publicContentView = entry.cachedPublicContentView; |
Chris Wren | 8fd39ec | 2014-02-27 17:43:26 -0500 | [diff] [blame] | 1611 | |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 1612 | if (contentView == null) { |
Julia Reynolds | d9228f1 | 2015-10-20 10:37:27 -0400 | [diff] [blame] | 1613 | Log.v(TAG, "no contentView for: " + sbn.getNotification()); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1614 | return false; |
| 1615 | } |
| 1616 | |
Dan Sandler | f68448e | 2014-04-24 15:54:16 -0400 | [diff] [blame] | 1617 | if (DEBUG) { |
Julia Reynolds | d9228f1 | 2015-10-20 10:37:27 -0400 | [diff] [blame] | 1618 | Log.v(TAG, "publicContentView: " + publicContentView); |
Dan Sandler | f68448e | 2014-04-24 15:54:16 -0400 | [diff] [blame] | 1619 | } |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 1620 | |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 1621 | ExpandableNotificationRow row; |
| 1622 | |
| 1623 | // Stash away previous user expansion state so we can restore it at |
| 1624 | // the end. |
| 1625 | boolean hasUserChangedExpansion = false; |
| 1626 | boolean userExpanded = false; |
| 1627 | boolean userLocked = false; |
| 1628 | |
| 1629 | if (entry.row != null) { |
| 1630 | row = entry.row; |
| 1631 | hasUserChangedExpansion = row.hasUserChangedExpansion(); |
| 1632 | userExpanded = row.isUserExpanded(); |
| 1633 | userLocked = row.isUserLocked(); |
Christoph Studer | 22f2ee5 | 2014-07-29 22:57:21 +0200 | [diff] [blame] | 1634 | entry.reset(); |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 1635 | if (hasUserChangedExpansion) { |
| 1636 | row.setUserExpanded(userExpanded); |
| 1637 | } |
| 1638 | } else { |
| 1639 | // create the row view |
| 1640 | LayoutInflater inflater = (LayoutInflater) mContext.getSystemService( |
| 1641 | Context.LAYOUT_INFLATER_SERVICE); |
| 1642 | row = (ExpandableNotificationRow) inflater.inflate(R.layout.status_bar_notification_row, |
| 1643 | parent, false); |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 1644 | row.setExpansionLogger(this, entry.notification.getKey()); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1645 | row.setGroupManager(mGroupManager); |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 1646 | row.setHeadsUpManager(mHeadsUpManager); |
Adrian Roos | b88b1a1 | 2015-12-09 18:51:05 -0800 | [diff] [blame] | 1647 | row.setRemoteInputController(mRemoteInputController); |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 1648 | row.setOnExpandClickListener(this); |
Mady Mellor | 3fd273e | 2016-03-15 21:08:14 -0700 | [diff] [blame] | 1649 | |
Dan Sandler | 732bd6c | 2016-04-12 14:20:32 -0400 | [diff] [blame] | 1650 | // Get the app name. |
| 1651 | // Note that Notification.Builder#bindHeaderAppName has similar logic |
| 1652 | // but since this field is used in the guts, it must be accurate. |
| 1653 | // Therefore we will only show the application label, or, failing that, the |
| 1654 | // package name. No substitutions. |
Mady Mellor | 3fd273e | 2016-03-15 21:08:14 -0700 | [diff] [blame] | 1655 | final String pkg = sbn.getPackageName(); |
| 1656 | String appname = pkg; |
| 1657 | try { |
| 1658 | final ApplicationInfo info = pmUser.getApplicationInfo(pkg, |
| 1659 | PackageManager.GET_UNINSTALLED_PACKAGES |
| 1660 | | PackageManager.GET_DISABLED_COMPONENTS); |
| 1661 | if (info != null) { |
| 1662 | appname = String.valueOf(pmUser.getApplicationLabel(info)); |
| 1663 | } |
| 1664 | } catch (NameNotFoundException e) { |
| 1665 | // Do nothing |
| 1666 | } |
| 1667 | row.setAppName(appname); |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 1668 | } |
Daniel Sandler | bc5559f | 2012-04-19 01:08:15 -0400 | [diff] [blame] | 1669 | |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1670 | workAroundBadLayerDrawableOpacity(row); |
Selim Cinek | 9e624e7 | 2016-07-20 13:46:49 -0700 | [diff] [blame] | 1671 | bindDismissListener(row); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1672 | |
| 1673 | // NB: the large icon is now handled entirely by the template |
| 1674 | |
| 1675 | // bind the click event to the content area |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1676 | NotificationContentView contentContainer = row.getPrivateLayout(); |
| 1677 | NotificationContentView contentContainerPublic = row.getPublicLayout(); |
Daniel Sandler | bc5559f | 2012-04-19 01:08:15 -0400 | [diff] [blame] | 1678 | |
Jorim Jaggi | fe40f7d | 2014-04-28 15:20:04 +0200 | [diff] [blame] | 1679 | row.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); |
Adrian Roos | 497ab02 | 2015-02-10 20:49:33 +0100 | [diff] [blame] | 1680 | if (ENABLE_REMOTE_INPUT) { |
| 1681 | row.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS); |
| 1682 | } |
Daniel Sandler | bc5559f | 2012-04-19 01:08:15 -0400 | [diff] [blame] | 1683 | |
Chris Wren | 42d5dd4 | 2015-05-01 10:39:26 -0400 | [diff] [blame] | 1684 | mNotificationClicker.register(row, sbn); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1685 | |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 1686 | // set up the adaptive layout |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 1687 | View contentViewLocal = null; |
| 1688 | View bigContentViewLocal = null; |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1689 | View headsUpContentViewLocal = null; |
Selim Cinek | 624c02db | 2015-12-14 21:00:02 -0800 | [diff] [blame] | 1690 | View publicViewLocal = null; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1691 | try { |
Dan Sandler | 68079d5 | 2015-07-22 10:45:30 -0400 | [diff] [blame] | 1692 | contentViewLocal = contentView.apply( |
| 1693 | sbn.getPackageContext(mContext), |
| 1694 | contentContainer, |
Jorim Jaggi | 39fa59f | 2014-02-25 15:38:45 +0100 | [diff] [blame] | 1695 | mOnClickHandler); |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 1696 | if (bigContentView != null) { |
Dan Sandler | 68079d5 | 2015-07-22 10:45:30 -0400 | [diff] [blame] | 1697 | bigContentViewLocal = bigContentView.apply( |
| 1698 | sbn.getPackageContext(mContext), |
| 1699 | contentContainer, |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1700 | mOnClickHandler); |
| 1701 | } |
| 1702 | if (headsUpContentView != null) { |
Dan Sandler | 68079d5 | 2015-07-22 10:45:30 -0400 | [diff] [blame] | 1703 | headsUpContentViewLocal = headsUpContentView.apply( |
| 1704 | sbn.getPackageContext(mContext), |
| 1705 | contentContainer, |
Jorim Jaggi | 39fa59f | 2014-02-25 15:38:45 +0100 | [diff] [blame] | 1706 | mOnClickHandler); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1707 | } |
Selim Cinek | 624c02db | 2015-12-14 21:00:02 -0800 | [diff] [blame] | 1708 | if (publicContentView != null) { |
| 1709 | publicViewLocal = publicContentView.apply( |
| 1710 | sbn.getPackageContext(mContext), |
| 1711 | contentContainerPublic, mOnClickHandler); |
| 1712 | } |
dooyoung.hwang | 78c4114 | 2016-10-04 18:55:31 +0900 | [diff] [blame] | 1713 | |
| 1714 | if (contentViewLocal != null) { |
| 1715 | contentViewLocal.setIsRootNamespace(true); |
| 1716 | contentContainer.setContractedChild(contentViewLocal); |
| 1717 | } |
| 1718 | if (bigContentViewLocal != null) { |
| 1719 | bigContentViewLocal.setIsRootNamespace(true); |
| 1720 | contentContainer.setExpandedChild(bigContentViewLocal); |
| 1721 | } |
| 1722 | if (headsUpContentViewLocal != null) { |
| 1723 | headsUpContentViewLocal.setIsRootNamespace(true); |
| 1724 | contentContainer.setHeadsUpChild(headsUpContentViewLocal); |
| 1725 | } |
| 1726 | if (publicViewLocal != null) { |
| 1727 | publicViewLocal.setIsRootNamespace(true); |
| 1728 | contentContainerPublic.setContractedChild(publicViewLocal); |
| 1729 | } |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1730 | } |
| 1731 | catch (RuntimeException e) { |
Daniel Sandler | 4f91efd | 2013-04-25 16:38:41 -0400 | [diff] [blame] | 1732 | final String ident = sbn.getPackageName() + "/0x" + Integer.toHexString(sbn.getId()); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 1733 | Log.e(TAG, "couldn't inflate view for notification " + ident, e); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1734 | return false; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1735 | } |
| 1736 | |
Jorim Jaggi | a1eeade | 2014-09-08 22:34:39 +0200 | [diff] [blame] | 1737 | // Extract target SDK version. |
| 1738 | try { |
| 1739 | ApplicationInfo info = pmUser.getApplicationInfo(sbn.getPackageName(), 0); |
| 1740 | entry.targetSdk = info.targetSdkVersion; |
| 1741 | } catch (NameNotFoundException ex) { |
| 1742 | Log.e(TAG, "Failed looking up ApplicationInfo for " + sbn.getPackageName(), ex); |
| 1743 | } |
Selim Cinek | 624c02db | 2015-12-14 21:00:02 -0800 | [diff] [blame] | 1744 | entry.autoRedacted = entry.notification.getNotification().publicVersion == null; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 1745 | |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 1746 | if (MULTIUSER_DEBUG) { |
| 1747 | TextView debug = (TextView) row.findViewById(R.id.debug_info); |
| 1748 | if (debug != null) { |
| 1749 | debug.setVisibility(View.VISIBLE); |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 1750 | debug.setText("CU " + mCurrentUserId +" NU " + entry.notification.getUserId()); |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 1751 | } |
| 1752 | } |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1753 | entry.row = row; |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 1754 | entry.row.setOnActivatedListener(this); |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1755 | entry.row.setExpandable(bigContentViewLocal != null); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1756 | |
Christoph Studer | 13b89512 | 2014-08-26 15:42:12 +0200 | [diff] [blame] | 1757 | applyColorsAndBackgrounds(sbn, entry); |
Jorim Jaggi | 4673985 | 2014-04-15 09:58:24 +0200 | [diff] [blame] | 1758 | |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 1759 | // Restore previous flags. |
| 1760 | if (hasUserChangedExpansion) { |
| 1761 | // Note: setUserExpanded() conveniently ignores calls with |
| 1762 | // userExpanded=true if !isExpandable(). |
| 1763 | row.setUserExpanded(userExpanded); |
| 1764 | } |
| 1765 | row.setUserLocked(userLocked); |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 1766 | row.onNotificationUpdated(entry); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1767 | return true; |
| 1768 | } |
| 1769 | |
Adrian Roos | 497ab02 | 2015-02-10 20:49:33 +0100 | [diff] [blame] | 1770 | /** |
| 1771 | * Adds RemoteInput actions from the WearableExtender; to be removed once more apps support this |
| 1772 | * via first-class API. |
| 1773 | * |
| 1774 | * TODO: Remove once enough apps specify remote inputs on their own. |
| 1775 | */ |
| 1776 | private void processForRemoteInput(Notification n) { |
| 1777 | if (!ENABLE_REMOTE_INPUT) return; |
| 1778 | |
| 1779 | if (n.extras != null && n.extras.containsKey("android.wearable.EXTENSIONS") && |
| 1780 | (n.actions == null || n.actions.length == 0)) { |
| 1781 | Notification.Action viableAction = null; |
| 1782 | Notification.WearableExtender we = new Notification.WearableExtender(n); |
| 1783 | |
| 1784 | List<Notification.Action> actions = we.getActions(); |
| 1785 | final int numActions = actions.size(); |
| 1786 | |
| 1787 | for (int i = 0; i < numActions; i++) { |
| 1788 | Notification.Action action = actions.get(i); |
Adrian Roos | a3539cb | 2015-12-16 16:47:02 -0800 | [diff] [blame] | 1789 | if (action == null) { |
| 1790 | continue; |
| 1791 | } |
Adrian Roos | 497ab02 | 2015-02-10 20:49:33 +0100 | [diff] [blame] | 1792 | RemoteInput[] remoteInputs = action.getRemoteInputs(); |
Adrian Roos | a3539cb | 2015-12-16 16:47:02 -0800 | [diff] [blame] | 1793 | if (remoteInputs == null) { |
| 1794 | continue; |
| 1795 | } |
| 1796 | for (RemoteInput ri : remoteInputs) { |
Adrian Roos | 497ab02 | 2015-02-10 20:49:33 +0100 | [diff] [blame] | 1797 | if (ri.getAllowFreeFormInput()) { |
| 1798 | viableAction = action; |
| 1799 | break; |
| 1800 | } |
| 1801 | } |
| 1802 | if (viableAction != null) { |
| 1803 | break; |
| 1804 | } |
| 1805 | } |
| 1806 | |
| 1807 | if (viableAction != null) { |
Julia Reynolds | d9228f1 | 2015-10-20 10:37:27 -0400 | [diff] [blame] | 1808 | Notification.Builder rebuilder = Notification.Builder.recoverBuilder(mContext, n); |
| 1809 | rebuilder.setActions(viableAction); |
| 1810 | rebuilder.build(); // will rewrite n |
Adrian Roos | 497ab02 | 2015-02-10 20:49:33 +0100 | [diff] [blame] | 1811 | } |
| 1812 | } |
| 1813 | } |
| 1814 | |
Adrian Roos | 62692b2 | 2015-09-11 17:46:23 -0700 | [diff] [blame] | 1815 | public void startPendingIntentDismissingKeyguard(final PendingIntent intent) { |
| 1816 | if (!isDeviceProvisioned()) return; |
| 1817 | |
| 1818 | final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing(); |
| 1819 | final boolean afterKeyguardGone = intent.isActivity() |
| 1820 | && PreviewInflater.wouldLaunchResolverActivity(mContext, intent.getIntent(), |
| 1821 | mCurrentUserId); |
| 1822 | dismissKeyguardThenExecute(new OnDismissAction() { |
| 1823 | public boolean onDismiss() { |
| 1824 | new Thread() { |
| 1825 | @Override |
| 1826 | public void run() { |
| 1827 | try { |
| 1828 | if (keyguardShowing && !afterKeyguardGone) { |
| 1829 | ActivityManagerNative.getDefault() |
| 1830 | .keyguardWaitingForActivityDrawn(); |
| 1831 | } |
| 1832 | |
| 1833 | // The intent we are sending is for the application, which |
| 1834 | // won't have permission to immediately start an activity after |
| 1835 | // the user switches to home. We know it is safe to do at this |
| 1836 | // point, so make sure new activity switches are now allowed. |
| 1837 | ActivityManagerNative.getDefault().resumeAppSwitches(); |
| 1838 | } catch (RemoteException e) { |
| 1839 | } |
Adrian Roos | 62692b2 | 2015-09-11 17:46:23 -0700 | [diff] [blame] | 1840 | try { |
Jorim Jaggi | e6e108e | 2016-03-28 13:38:45 -0700 | [diff] [blame] | 1841 | intent.send(null, 0, null, null, null, null, getActivityOptions()); |
Adrian Roos | 62692b2 | 2015-09-11 17:46:23 -0700 | [diff] [blame] | 1842 | } catch (PendingIntent.CanceledException e) { |
| 1843 | // the stack trace isn't very helpful here. |
| 1844 | // Just log the exception message. |
| 1845 | Log.w(TAG, "Sending intent failed: " + e); |
| 1846 | |
| 1847 | // TODO: Dismiss Keyguard. |
| 1848 | } |
| 1849 | if (intent.isActivity()) { |
| 1850 | mAssistManager.hideAssist(); |
| 1851 | overrideActivityPendingAppTransition(keyguardShowing |
| 1852 | && !afterKeyguardGone); |
| 1853 | } |
| 1854 | } |
| 1855 | }.start(); |
| 1856 | |
| 1857 | // close the shade if it was open |
| 1858 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, |
| 1859 | true /* force */, true /* delayed */); |
| 1860 | visibilityChanged(false); |
| 1861 | |
| 1862 | return true; |
| 1863 | } |
| 1864 | }, afterKeyguardGone); |
| 1865 | } |
| 1866 | |
Selim Cinek | 36b0223 | 2016-05-11 23:07:05 -0400 | [diff] [blame] | 1867 | public void addPostCollapseAction(Runnable r) { |
| 1868 | } |
| 1869 | |
| 1870 | public boolean isCollapsing() { |
| 1871 | return false; |
| 1872 | } |
| 1873 | |
Chris Wren | 42d5dd4 | 2015-05-01 10:39:26 -0400 | [diff] [blame] | 1874 | private final class NotificationClicker implements View.OnClickListener { |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 1875 | public void onClick(final View v) { |
Chris Wren | 42d5dd4 | 2015-05-01 10:39:26 -0400 | [diff] [blame] | 1876 | if (!(v instanceof ExpandableNotificationRow)) { |
| 1877 | Log.e(TAG, "NotificationClicker called on a view that is not a notification row."); |
| 1878 | return; |
| 1879 | } |
| 1880 | |
| 1881 | final ExpandableNotificationRow row = (ExpandableNotificationRow) v; |
| 1882 | final StatusBarNotification sbn = row.getStatusBarNotification(); |
| 1883 | if (sbn == null) { |
| 1884 | Log.e(TAG, "NotificationClicker called on an unclickable notification,"); |
| 1885 | return; |
| 1886 | } |
| 1887 | |
Mady Mellor | f062580 | 2016-02-11 18:03:48 -0800 | [diff] [blame] | 1888 | // Check if the notification is displaying the gear, if so slide notification back |
| 1889 | if (row.getSettingsRow() != null && row.getSettingsRow().isVisible()) { |
| 1890 | row.animateTranslateNotification(0); |
| 1891 | return; |
| 1892 | } |
| 1893 | |
Selim Cinek | c6dd521 | 2015-11-02 14:51:54 -0800 | [diff] [blame] | 1894 | Notification notification = sbn.getNotification(); |
| 1895 | final PendingIntent intent = notification.contentIntent != null |
| 1896 | ? notification.contentIntent |
| 1897 | : notification.fullScreenIntent; |
Chris Wren | 42d5dd4 | 2015-05-01 10:39:26 -0400 | [diff] [blame] | 1898 | final String notificationKey = sbn.getKey(); |
| 1899 | |
Jorim Jaggi | 5eb67c2 | 2015-08-19 19:50:49 -0700 | [diff] [blame] | 1900 | // Mark notification for one frame. |
| 1901 | row.setJustClicked(true); |
| 1902 | DejankUtils.postAfterTraversal(new Runnable() { |
| 1903 | @Override |
| 1904 | public void run() { |
| 1905 | row.setJustClicked(false); |
| 1906 | } |
| 1907 | }); |
| 1908 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1909 | final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing(); |
Chris Wren | 42d5dd4 | 2015-05-01 10:39:26 -0400 | [diff] [blame] | 1910 | final boolean afterKeyguardGone = intent.isActivity() |
| 1911 | && PreviewInflater.wouldLaunchResolverActivity(mContext, intent.getIntent(), |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 1912 | mCurrentUserId); |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 1913 | dismissKeyguardThenExecute(new OnDismissAction() { |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 1914 | public boolean onDismiss() { |
Chris Wren | 42d5dd4 | 2015-05-01 10:39:26 -0400 | [diff] [blame] | 1915 | if (mHeadsUpManager != null && mHeadsUpManager.isHeadsUp(notificationKey)) { |
Christoph Studer | c6a656c | 2015-01-22 15:02:49 +0100 | [diff] [blame] | 1916 | // Release the HUN notification to the shade. |
Selim Cinek | f55f1bc | 2016-05-27 11:19:11 -0700 | [diff] [blame] | 1917 | |
| 1918 | if (isPanelFullyCollapsed()) { |
| 1919 | HeadsUpManager.setIsClickedNotification(row, true); |
| 1920 | } |
Christoph Studer | c6a656c | 2015-01-22 15:02:49 +0100 | [diff] [blame] | 1921 | // |
| 1922 | // In most cases, when FLAG_AUTO_CANCEL is set, the notification will |
| 1923 | // become canceled shortly by NoMan, but we can't assume that. |
Chris Wren | 42d5dd4 | 2015-05-01 10:39:26 -0400 | [diff] [blame] | 1924 | mHeadsUpManager.releaseImmediately(notificationKey); |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 1925 | } |
Selim Cinek | 36b0223 | 2016-05-11 23:07:05 -0400 | [diff] [blame] | 1926 | StatusBarNotification parentToCancel = null; |
| 1927 | if (shouldAutoCancel(sbn) && mGroupManager.isOnlyChildInGroup(sbn)) { |
| 1928 | StatusBarNotification summarySbn = mGroupManager.getLogicalGroupSummary(sbn) |
| 1929 | .getStatusBarNotification(); |
| 1930 | if (shouldAutoCancel(summarySbn)) { |
| 1931 | parentToCancel = summarySbn; |
| 1932 | } |
| 1933 | } |
| 1934 | final StatusBarNotification parentToCancelFinal = parentToCancel; |
Jorim Jaggi | 89f7f28 | 2014-10-17 19:54:15 +0200 | [diff] [blame] | 1935 | new Thread() { |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1936 | @Override |
| 1937 | public void run() { |
Jorim Jaggi | 89f7f28 | 2014-10-17 19:54:15 +0200 | [diff] [blame] | 1938 | try { |
| 1939 | if (keyguardShowing && !afterKeyguardGone) { |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1940 | ActivityManagerNative.getDefault() |
| 1941 | .keyguardWaitingForActivityDrawn(); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1942 | } |
Jorim Jaggi | 89f7f28 | 2014-10-17 19:54:15 +0200 | [diff] [blame] | 1943 | |
| 1944 | // The intent we are sending is for the application, which |
| 1945 | // won't have permission to immediately start an activity after |
| 1946 | // the user switches to home. We know it is safe to do at this |
| 1947 | // point, so make sure new activity switches are now allowed. |
| 1948 | ActivityManagerNative.getDefault().resumeAppSwitches(); |
| 1949 | } catch (RemoteException e) { |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1950 | } |
Chris Wren | 42d5dd4 | 2015-05-01 10:39:26 -0400 | [diff] [blame] | 1951 | if (intent != null) { |
Ricky Wai | 7fa0171 | 2016-03-16 12:13:54 +0000 | [diff] [blame] | 1952 | // If we are launching a work activity and require to launch |
| 1953 | // separate work challenge, we defer the activity action and cancel |
| 1954 | // notification until work challenge is unlocked. |
| 1955 | if (intent.isActivity()) { |
| 1956 | final int userId = intent.getCreatorUserHandle() |
| 1957 | .getIdentifier(); |
| 1958 | if (mLockPatternUtils.isSeparateProfileChallengeEnabled(userId) |
| 1959 | && mKeyguardManager.isDeviceLocked(userId)) { |
Rubin Xu | 89927b3 | 2016-07-28 14:34:26 +0100 | [diff] [blame] | 1960 | boolean canBypass = false; |
| 1961 | try { |
| 1962 | canBypass = ActivityManagerNative.getDefault() |
| 1963 | .canBypassWorkChallenge(intent); |
| 1964 | } catch (RemoteException e) { |
| 1965 | } |
| 1966 | // For direct-boot aware activities, they can be shown when |
| 1967 | // the device is still locked without triggering the work |
| 1968 | // challenge. |
| 1969 | if ((!canBypass) && startWorkChallengeIfNecessary(userId, |
| 1970 | intent.getIntentSender(), notificationKey)) { |
| 1971 | // Show work challenge, do not run PendingIntent and |
Ricky Wai | a8c37a1 | 2016-04-05 17:10:04 +0100 | [diff] [blame] | 1972 | // remove notification |
| 1973 | return; |
| 1974 | } |
Ricky Wai | 7fa0171 | 2016-03-16 12:13:54 +0000 | [diff] [blame] | 1975 | } |
| 1976 | } |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1977 | try { |
Jorim Jaggi | e6e108e | 2016-03-28 13:38:45 -0700 | [diff] [blame] | 1978 | intent.send(null, 0, null, null, null, null, |
| 1979 | getActivityOptions()); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1980 | } catch (PendingIntent.CanceledException e) { |
| 1981 | // the stack trace isn't very helpful here. |
| 1982 | // Just log the exception message. |
| 1983 | Log.w(TAG, "Sending contentIntent failed: " + e); |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 1984 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1985 | // TODO: Dismiss Keyguard. |
| 1986 | } |
Chris Wren | 42d5dd4 | 2015-05-01 10:39:26 -0400 | [diff] [blame] | 1987 | if (intent.isActivity()) { |
Jorim Jaggi | b835dd7 | 2015-06-08 12:28:42 -0700 | [diff] [blame] | 1988 | mAssistManager.hideAssist(); |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 1989 | overrideActivityPendingAppTransition(keyguardShowing |
| 1990 | && !afterKeyguardGone); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1991 | } |
| 1992 | } |
| 1993 | |
| 1994 | try { |
Chris Wren | 42d5dd4 | 2015-05-01 10:39:26 -0400 | [diff] [blame] | 1995 | mBarService.onNotificationClick(notificationKey); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1996 | } catch (RemoteException ex) { |
| 1997 | // system process is dead if we're here. |
| 1998 | } |
Selim Cinek | 36b0223 | 2016-05-11 23:07:05 -0400 | [diff] [blame] | 1999 | if (parentToCancelFinal != null) { |
| 2000 | // We have to post it to the UI thread for synchronization |
| 2001 | mHandler.post(new Runnable() { |
| 2002 | @Override |
| 2003 | public void run() { |
| 2004 | Runnable removeRunnable = new Runnable() { |
| 2005 | @Override |
| 2006 | public void run() { |
| 2007 | performRemoveNotification(parentToCancelFinal, |
| 2008 | true); |
| 2009 | } |
| 2010 | }; |
| 2011 | if (isCollapsing()) { |
| 2012 | // To avoid lags we're only performing the remove |
| 2013 | // after the shade was collapsed |
| 2014 | addPostCollapseAction(removeRunnable); |
| 2015 | } else { |
| 2016 | removeRunnable.run(); |
| 2017 | } |
| 2018 | } |
| 2019 | }); |
| 2020 | } |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 2021 | } |
Jorim Jaggi | 89f7f28 | 2014-10-17 19:54:15 +0200 | [diff] [blame] | 2022 | }.start(); |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 2023 | |
| 2024 | // close the shade if it was open |
Jorim Jaggi | 4eedc1d | 2014-10-27 13:45:56 +0100 | [diff] [blame] | 2025 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 2026 | true /* force */, true /* delayed */); |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 2027 | visibilityChanged(false); |
| 2028 | |
Jorim Jaggi | 8972c2a | 2015-06-05 16:05:54 -0700 | [diff] [blame] | 2029 | return true; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 2030 | } |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 2031 | }, afterKeyguardGone); |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 2032 | } |
Chris Wren | 42d5dd4 | 2015-05-01 10:39:26 -0400 | [diff] [blame] | 2033 | |
Selim Cinek | 36b0223 | 2016-05-11 23:07:05 -0400 | [diff] [blame] | 2034 | private boolean shouldAutoCancel(StatusBarNotification sbn) { |
| 2035 | int flags = sbn.getNotification().flags; |
| 2036 | if ((flags & Notification.FLAG_AUTO_CANCEL) != Notification.FLAG_AUTO_CANCEL) { |
| 2037 | return false; |
| 2038 | } |
| 2039 | if ((flags & Notification.FLAG_FOREGROUND_SERVICE) != 0) { |
| 2040 | return false; |
| 2041 | } |
| 2042 | return true; |
| 2043 | } |
| 2044 | |
Chris Wren | 42d5dd4 | 2015-05-01 10:39:26 -0400 | [diff] [blame] | 2045 | public void register(ExpandableNotificationRow row, StatusBarNotification sbn) { |
Selim Cinek | c6dd521 | 2015-11-02 14:51:54 -0800 | [diff] [blame] | 2046 | Notification notification = sbn.getNotification(); |
| 2047 | if (notification.contentIntent != null || notification.fullScreenIntent != null) { |
Chris Wren | 42d5dd4 | 2015-05-01 10:39:26 -0400 | [diff] [blame] | 2048 | row.setOnClickListener(this); |
| 2049 | } else { |
| 2050 | row.setOnClickListener(null); |
| 2051 | } |
| 2052 | } |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 2053 | } |
Chris Wren | f29c3b4 | 2013-11-27 16:30:30 -0500 | [diff] [blame] | 2054 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2055 | public void animateCollapsePanels(int flags, boolean force) { |
| 2056 | } |
| 2057 | |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 2058 | public void animateCollapsePanels(int flags, boolean force, boolean delayed) { |
| 2059 | } |
| 2060 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2061 | public void overrideActivityPendingAppTransition(boolean keyguardShowing) { |
| 2062 | if (keyguardShowing) { |
| 2063 | try { |
| 2064 | mWindowManagerService.overridePendingAppTransition(null, 0, 0, null); |
| 2065 | } catch (RemoteException e) { |
| 2066 | Log.w(TAG, "Error overriding app transition: " + e); |
| 2067 | } |
| 2068 | } |
| 2069 | } |
| 2070 | |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 2071 | protected boolean startWorkChallengeIfNecessary(int userId, IntentSender intendSender, |
| 2072 | String notificationKey) { |
| 2073 | final Intent newIntent = mKeyguardManager.createConfirmDeviceCredentialIntent(null, |
| 2074 | null, userId); |
| 2075 | if (newIntent == null) { |
| 2076 | return false; |
| 2077 | } |
| 2078 | final Intent callBackIntent = new Intent( |
| 2079 | WORK_CHALLENGE_UNLOCKED_NOTIFICATION_ACTION); |
| 2080 | callBackIntent.putExtra(Intent.EXTRA_INTENT, intendSender); |
| 2081 | callBackIntent.putExtra(Intent.EXTRA_INDEX, notificationKey); |
| 2082 | callBackIntent.setPackage(mContext.getPackageName()); |
| 2083 | |
| 2084 | PendingIntent callBackPendingIntent = PendingIntent.getBroadcast( |
| 2085 | mContext, |
| 2086 | 0, |
| 2087 | callBackIntent, |
| 2088 | PendingIntent.FLAG_CANCEL_CURRENT | |
| 2089 | PendingIntent.FLAG_ONE_SHOT | |
| 2090 | PendingIntent.FLAG_IMMUTABLE); |
| 2091 | newIntent.putExtra( |
| 2092 | Intent.EXTRA_INTENT, |
| 2093 | callBackPendingIntent.getIntentSender()); |
| 2094 | try { |
| 2095 | ActivityManagerNative.getDefault().startConfirmDeviceCredentialIntent(newIntent); |
| 2096 | } catch (RemoteException ex) { |
| 2097 | // ignore |
| 2098 | } |
| 2099 | return true; |
| 2100 | } |
| 2101 | |
Jorim Jaggi | e6e108e | 2016-03-28 13:38:45 -0700 | [diff] [blame] | 2102 | protected Bundle getActivityOptions() { |
| 2103 | // Anything launched from the notification shade should always go into the |
| 2104 | // fullscreen stack. |
| 2105 | ActivityOptions options = ActivityOptions.makeBasic(); |
| 2106 | options.setLaunchStackId(StackId.FULLSCREEN_WORKSPACE_STACK_ID); |
| 2107 | return options.toBundle(); |
| 2108 | } |
| 2109 | |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 2110 | protected void visibilityChanged(boolean visible) { |
| 2111 | if (mVisible != visible) { |
| 2112 | mVisible = visible; |
| 2113 | if (!visible) { |
| 2114 | dismissPopups(); |
| 2115 | } |
| 2116 | } |
| 2117 | updateVisibleToUser(); |
| 2118 | } |
| 2119 | |
| 2120 | protected void updateVisibleToUser() { |
| 2121 | boolean oldVisibleToUser = mVisibleToUser; |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 2122 | mVisibleToUser = mVisible && mDeviceInteractive; |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 2123 | |
| 2124 | if (oldVisibleToUser != mVisibleToUser) { |
| 2125 | handleVisibleToUserChanged(mVisibleToUser); |
| 2126 | } |
| 2127 | } |
| 2128 | |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 2129 | /** |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 2130 | * The LEDs are turned off when the notification panel is shown, even just a little bit. |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 2131 | * See also PhoneStatusBar.setPanelExpanded for another place where we attempt to do this. |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 2132 | */ |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 2133 | protected void handleVisibleToUserChanged(boolean visibleToUser) { |
| 2134 | try { |
| 2135 | if (visibleToUser) { |
Selim Cinek | 6577cae | 2015-08-31 16:15:49 -0700 | [diff] [blame] | 2136 | boolean pinnedHeadsUp = mHeadsUpManager.hasPinnedHeadsUp(); |
| 2137 | boolean clearNotificationEffects = |
Dan Sandler | cb01289 | 2016-03-01 00:45:06 -0500 | [diff] [blame] | 2138 | !isPanelFullyCollapsed() && |
| 2139 | (mState == StatusBarState.SHADE || mState == StatusBarState.SHADE_LOCKED); |
Chris Wren | b659c4f | 2015-06-25 17:12:27 -0400 | [diff] [blame] | 2140 | int notificationLoad = mNotificationData.getActiveNotifications().size(); |
Selim Cinek | 6577cae | 2015-08-31 16:15:49 -0700 | [diff] [blame] | 2141 | if (pinnedHeadsUp && isPanelFullyCollapsed()) { |
Chris Wren | b659c4f | 2015-06-25 17:12:27 -0400 | [diff] [blame] | 2142 | notificationLoad = 1; |
| 2143 | } else { |
| 2144 | MetricsLogger.histogram(mContext, "note_load", notificationLoad); |
| 2145 | } |
| 2146 | mBarService.onPanelRevealed(clearNotificationEffects, notificationLoad); |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 2147 | } else { |
| 2148 | mBarService.onPanelHidden(); |
Dan Sandler | 4247a5c | 2014-07-23 15:58:08 -0400 | [diff] [blame] | 2149 | } |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 2150 | } catch (RemoteException ex) { |
| 2151 | // Won't fail unless the world has ended. |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 2152 | } |
| 2153 | } |
| 2154 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2155 | /** |
Chris Wren | 1689594 | 2015-06-23 11:22:20 -0400 | [diff] [blame] | 2156 | * Clear Buzz/Beep/Blink. |
| 2157 | */ |
| 2158 | public void clearNotificationEffects() { |
| 2159 | try { |
| 2160 | mBarService.clearNotificationEffects(); |
| 2161 | } catch (RemoteException e) { |
| 2162 | // Won't fail unless the world has ended. |
| 2163 | } |
| 2164 | } |
| 2165 | |
Yorke Lee | e4ea6ab | 2016-03-03 14:51:49 -0800 | [diff] [blame] | 2166 | public abstract boolean isPanelFullyCollapsed(); |
Chris Wren | 1689594 | 2015-06-23 11:22:20 -0400 | [diff] [blame] | 2167 | |
| 2168 | /** |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2169 | * Cancel this notification and tell the StatusBarManagerService / NotificationManagerService |
| 2170 | * about the failure. |
| 2171 | * |
| 2172 | * WARNING: this will call back into us. Don't hold any locks. |
| 2173 | */ |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 2174 | void handleNotificationError(StatusBarNotification n, String message) { |
Christoph Studer | e71fefc | 2014-06-24 16:16:49 +0200 | [diff] [blame] | 2175 | removeNotification(n.getKey(), null); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2176 | try { |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 2177 | mBarService.onNotificationError(n.getPackageName(), n.getTag(), n.getId(), n.getUid(), |
| 2178 | n.getInitialPid(), message, n.getUserId()); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2179 | } catch (RemoteException ex) { |
| 2180 | // The end is nigh. |
| 2181 | } |
| 2182 | } |
| 2183 | |
Christoph Studer | d0694b6 | 2014-06-04 16:36:01 +0200 | [diff] [blame] | 2184 | protected StatusBarNotification removeNotificationViews(String key, RankingMap ranking) { |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 2185 | NotificationData.Entry entry = mNotificationData.remove(key, ranking); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2186 | if (entry == null) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2187 | Log.w(TAG, "removeNotification for unknown key: " + key); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2188 | return null; |
| 2189 | } |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 2190 | updateNotifications(); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2191 | return entry.notification; |
| 2192 | } |
| 2193 | |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 2194 | protected NotificationData.Entry createNotificationViews(StatusBarNotification sbn) { |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2195 | if (DEBUG) { |
Christoph Studer | a0506e7 | 2014-07-31 20:27:39 +0200 | [diff] [blame] | 2196 | Log.d(TAG, "createNotificationViews(notification=" + sbn); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2197 | } |
Selim Cinek | 379ff8f | 2015-02-20 17:03:16 +0100 | [diff] [blame] | 2198 | final StatusBarIconView iconView = createIcon(sbn); |
| 2199 | if (iconView == null) { |
| 2200 | return null; |
| 2201 | } |
| 2202 | |
| 2203 | // Construct the expanded view. |
| 2204 | NotificationData.Entry entry = new NotificationData.Entry(sbn, iconView); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 2205 | if (!inflateViews(entry, mStackScroller)) { |
Selim Cinek | 379ff8f | 2015-02-20 17:03:16 +0100 | [diff] [blame] | 2206 | handleNotificationError(sbn, "Couldn't expand RemoteViews for: " + sbn); |
| 2207 | return null; |
| 2208 | } |
| 2209 | return entry; |
| 2210 | } |
| 2211 | |
Xiaohui Chen | e90c2c5 | 2016-02-24 16:08:00 -0800 | [diff] [blame] | 2212 | public StatusBarIconView createIcon(StatusBarNotification sbn) { |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2213 | // Construct the icon. |
Christoph Studer | a0506e7 | 2014-07-31 20:27:39 +0200 | [diff] [blame] | 2214 | Notification n = sbn.getNotification(); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2215 | final StatusBarIconView iconView = new StatusBarIconView(mContext, |
Christoph Studer | a0506e7 | 2014-07-31 20:27:39 +0200 | [diff] [blame] | 2216 | sbn.getPackageName() + "/0x" + Integer.toHexString(sbn.getId()), n); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2217 | iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); |
| 2218 | |
Dan Sandler | 3343981 | 2015-08-10 15:49:56 -0400 | [diff] [blame] | 2219 | final Icon smallIcon = n.getSmallIcon(); |
| 2220 | if (smallIcon == null) { |
| 2221 | handleNotificationError(sbn, |
| 2222 | "No small icon in notification from " + sbn.getPackageName()); |
| 2223 | return null; |
| 2224 | } |
Dan Sandler | d63f932 | 2015-05-06 15:18:49 -0400 | [diff] [blame] | 2225 | final StatusBarIcon ic = new StatusBarIcon( |
Christoph Studer | a0506e7 | 2014-07-31 20:27:39 +0200 | [diff] [blame] | 2226 | sbn.getUser(), |
Dan Sandler | 4e78706 | 2015-06-17 15:09:48 -0400 | [diff] [blame] | 2227 | sbn.getPackageName(), |
Dan Sandler | 3343981 | 2015-08-10 15:49:56 -0400 | [diff] [blame] | 2228 | smallIcon, |
Dan Sandler | 4e78706 | 2015-06-17 15:09:48 -0400 | [diff] [blame] | 2229 | n.iconLevel, |
| 2230 | n.number, |
Adrian Roos | eba0582 | 2016-04-22 17:09:27 -0700 | [diff] [blame] | 2231 | StatusBarIconView.contentDescForNotification(mContext, n)); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2232 | if (!iconView.set(ic)) { |
Christoph Studer | a0506e7 | 2014-07-31 20:27:39 +0200 | [diff] [blame] | 2233 | handleNotificationError(sbn, "Couldn't create icon: " + ic); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2234 | return null; |
| 2235 | } |
Selim Cinek | 379ff8f | 2015-02-20 17:03:16 +0100 | [diff] [blame] | 2236 | return iconView; |
Chris Wren | f0048ce | 2013-08-07 16:43:43 -0400 | [diff] [blame] | 2237 | } |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2238 | |
Christoph Studer | d0694b6 | 2014-06-04 16:36:01 +0200 | [diff] [blame] | 2239 | protected void addNotificationViews(Entry entry, RankingMap ranking) { |
Raju Yadav | 5f33026 | 2014-03-24 10:44:00 +0100 | [diff] [blame] | 2240 | if (entry == null) { |
| 2241 | return; |
| 2242 | } |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2243 | // Add the expanded view and icon. |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 2244 | mNotificationData.add(entry, ranking); |
| 2245 | updateNotifications(); |
Selim Cinek | 8efa6dd | 2014-05-19 16:27:37 +0200 | [diff] [blame] | 2246 | } |
| 2247 | |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 2248 | /** |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 2249 | * @param recompute wheter the number should be recomputed |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 2250 | * @return The number of notifications we show on Keyguard. |
| 2251 | */ |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 2252 | protected abstract int getMaxKeyguardNotifications(boolean recompute); |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 2253 | |
| 2254 | /** |
Jorim Jaggi | 251957d | 2014-04-09 04:24:09 +0200 | [diff] [blame] | 2255 | * Updates expanded, dimmed and locked states of notification rows. |
| 2256 | */ |
| 2257 | protected void updateRowStates() { |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 2258 | mKeyguardIconOverflowContainer.getIconsView().removeAllViews(); |
| 2259 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 2260 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
| 2261 | final int N = activeNotifications.size(); |
| 2262 | |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 2263 | int visibleNotifications = 0; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 2264 | boolean onKeyguard = mState == StatusBarState.KEYGUARD; |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 2265 | int maxNotifications = 0; |
| 2266 | if (onKeyguard) { |
| 2267 | maxNotifications = getMaxKeyguardNotifications(true /* recompute */); |
| 2268 | } |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 2269 | for (int i = 0; i < N; i++) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 2270 | NotificationData.Entry entry = activeNotifications.get(i); |
Selim Cinek | 2a73934 | 2016-03-17 10:28:55 -0700 | [diff] [blame] | 2271 | boolean childNotification = mGroupManager.isChildInGroupWithSummary(entry.notification); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 2272 | if (onKeyguard) { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 2273 | entry.row.setOnKeyguard(true); |
Chris Wren | 3ddab0d | 2012-08-02 16:52:21 -0400 | [diff] [blame] | 2274 | } else { |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 2275 | entry.row.setOnKeyguard(false); |
Selim Cinek | 2a73934 | 2016-03-17 10:28:55 -0700 | [diff] [blame] | 2276 | entry.row.setSystemExpanded(visibleNotifications == 0 && !childNotification); |
Chris Wren | 8fd1265 | 2012-05-09 21:25:57 -0400 | [diff] [blame] | 2277 | } |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 2278 | boolean suppressedSummary = mGroupManager.isSummaryOfSuppressedGroup( |
| 2279 | entry.notification) && !entry.row.isRemoved(); |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 2280 | boolean childWithVisibleSummary = childNotification |
| 2281 | && mGroupManager.getGroupSummary(entry.notification).getVisibility() |
| 2282 | == View.VISIBLE; |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 2283 | boolean showOnKeyguard = shouldShowOnKeyguard(entry.notification); |
Selim Cinek | 2a73934 | 2016-03-17 10:28:55 -0700 | [diff] [blame] | 2284 | if (suppressedSummary || (isLockscreenPublicMode() && !mShowLockscreenNotifications) || |
Selim Cinek | 06416b9 | 2016-05-09 16:36:10 -0400 | [diff] [blame] | 2285 | (onKeyguard && !childWithVisibleSummary |
| 2286 | && (visibleNotifications >= maxNotifications || !showOnKeyguard))) { |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 2287 | entry.row.setVisibility(View.GONE); |
Selim Cinek | 2a73934 | 2016-03-17 10:28:55 -0700 | [diff] [blame] | 2288 | if (onKeyguard && showOnKeyguard && !childNotification && !suppressedSummary) { |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 2289 | mKeyguardIconOverflowContainer.getIconsView().addNotification(entry); |
| 2290 | } |
| 2291 | } else { |
| 2292 | boolean wasGone = entry.row.getVisibility() == View.GONE; |
| 2293 | entry.row.setVisibility(View.VISIBLE); |
Selim Cinek | fa760d4 | 2016-05-10 15:50:53 -0400 | [diff] [blame] | 2294 | if (!childNotification && !entry.row.isRemoved()) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 2295 | if (wasGone) { |
| 2296 | // notify the scroller of a child addition |
Selim Cinek | 2a73934 | 2016-03-17 10:28:55 -0700 | [diff] [blame] | 2297 | mStackScroller.generateAddAnimation(entry.row, |
| 2298 | !showOnKeyguard /* fromMoreCard */); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 2299 | } |
| 2300 | visibleNotifications++; |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 2301 | } |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 2302 | } |
Chris Wren | 8fd1265 | 2012-05-09 21:25:57 -0400 | [diff] [blame] | 2303 | } |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 2304 | |
Selim Cinek | 2cd45df | 2015-06-09 18:00:07 -0700 | [diff] [blame] | 2305 | mStackScroller.updateOverflowContainerVisibility(onKeyguard |
| 2306 | && mKeyguardIconOverflowContainer.getIconsView().getChildCount() > 0); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 2307 | |
Selim Cinek | 0cce531 | 2015-05-20 22:13:55 -0700 | [diff] [blame] | 2308 | mStackScroller.changeViewPosition(mDismissView, mStackScroller.getChildCount() - 1); |
| 2309 | mStackScroller.changeViewPosition(mEmptyShadeView, mStackScroller.getChildCount() - 2); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 2310 | mStackScroller.changeViewPosition(mKeyguardIconOverflowContainer, |
| 2311 | mStackScroller.getChildCount() - 3); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 2312 | } |
| 2313 | |
Selim Cinek | fa760d4 | 2016-05-10 15:50:53 -0400 | [diff] [blame] | 2314 | public boolean shouldShowOnKeyguard(StatusBarNotification sbn) { |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 2315 | return mShowLockscreenNotifications && !mNotificationData.isAmbient(sbn.getKey()); |
Chris Wren | 8fd1265 | 2012-05-09 21:25:57 -0400 | [diff] [blame] | 2316 | } |
| 2317 | |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 2318 | protected void setZenMode(int mode) { |
John Spurlock | 110e5b1 | 2014-02-27 13:09:35 -0500 | [diff] [blame] | 2319 | if (!isDeviceProvisioned()) return; |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 2320 | mZenMode = mode; |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 2321 | updateNotifications(); |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 2322 | } |
| 2323 | |
Dan Sandler | 52e5701e | 2014-07-22 23:14:54 -0400 | [diff] [blame] | 2324 | // extended in PhoneStatusBar |
| 2325 | protected void setShowLockscreenNotifications(boolean show) { |
| 2326 | mShowLockscreenNotifications = show; |
| 2327 | } |
| 2328 | |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 2329 | protected void setLockScreenAllowRemoteInput(boolean allowLockscreenRemoteInput) { |
| 2330 | mAllowLockscreenRemoteInput = allowLockscreenRemoteInput; |
| 2331 | } |
| 2332 | |
Dan Sandler | 52e5701e | 2014-07-22 23:14:54 -0400 | [diff] [blame] | 2333 | private void updateLockscreenNotificationSetting() { |
| 2334 | final boolean show = Settings.Secure.getIntForUser(mContext.getContentResolver(), |
| 2335 | Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, |
| 2336 | 1, |
| 2337 | mCurrentUserId) != 0; |
Adrian Roos | bd3409c | 2014-08-12 18:21:09 +0200 | [diff] [blame] | 2338 | final int dpmFlags = mDevicePolicyManager.getKeyguardDisabledFeatures( |
| 2339 | null /* admin */, mCurrentUserId); |
| 2340 | final boolean allowedByDpm = (dpmFlags |
| 2341 | & DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS) == 0; |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 2342 | |
Adrian Roos | bd3409c | 2014-08-12 18:21:09 +0200 | [diff] [blame] | 2343 | setShowLockscreenNotifications(show && allowedByDpm); |
Adrian Roos | b27d7a5 | 2016-06-16 13:04:47 -0700 | [diff] [blame] | 2344 | |
| 2345 | if (ENABLE_LOCK_SCREEN_ALLOW_REMOTE_INPUT) { |
| 2346 | final boolean remoteInput = Settings.Secure.getIntForUser(mContext.getContentResolver(), |
| 2347 | Settings.Secure.LOCK_SCREEN_ALLOW_REMOTE_INPUT, |
| 2348 | 0, |
| 2349 | mCurrentUserId) != 0; |
| 2350 | final boolean remoteInputDpm = |
| 2351 | (dpmFlags & DevicePolicyManager.KEYGUARD_DISABLE_REMOTE_INPUT) == 0; |
| 2352 | |
| 2353 | setLockScreenAllowRemoteInput(remoteInput && remoteInputDpm); |
| 2354 | } else { |
| 2355 | setLockScreenAllowRemoteInput(false); |
| 2356 | } |
Dan Sandler | 52e5701e | 2014-07-22 23:14:54 -0400 | [diff] [blame] | 2357 | } |
| 2358 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2359 | protected abstract void setAreThereNotifications(); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 2360 | protected abstract void updateNotifications(); |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 2361 | public abstract boolean shouldDisableNavbarGestures(); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2362 | |
Christoph Studer | e71fefc | 2014-06-24 16:16:49 +0200 | [diff] [blame] | 2363 | public abstract void addNotification(StatusBarNotification notification, |
Selim Cinek | 379ff8f | 2015-02-20 17:03:16 +0100 | [diff] [blame] | 2364 | RankingMap ranking, Entry oldEntry); |
Christoph Studer | e71fefc | 2014-06-24 16:16:49 +0200 | [diff] [blame] | 2365 | protected abstract void updateNotificationRanking(RankingMap ranking); |
| 2366 | public abstract void removeNotification(String key, RankingMap ranking); |
Christoph Studer | a7fe631 | 2014-06-27 19:32:44 +0200 | [diff] [blame] | 2367 | |
Christoph Studer | e71fefc | 2014-06-24 16:16:49 +0200 | [diff] [blame] | 2368 | public void updateNotification(StatusBarNotification notification, RankingMap ranking) { |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 2369 | if (DEBUG) Log.d(TAG, "updateNotification(" + notification + ")"); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2370 | |
Chris Wren | d04f6ce | 2014-06-11 17:37:28 -0400 | [diff] [blame] | 2371 | final String key = notification.getKey(); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2372 | Entry entry = mNotificationData.get(key); |
| 2373 | if (entry == null) { |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2374 | return; |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 2375 | } else { |
Selim Cinek | 2d79f63 | 2015-11-02 15:13:29 -0800 | [diff] [blame] | 2376 | mHeadsUpEntriesToRemoveOnSwitch.remove(entry); |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 2377 | mRemoteInputEntriesToRemoveOnCollapse.remove(entry); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2378 | } |
| 2379 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2380 | Notification n = notification.getNotification(); |
Julia Reynolds | f612869ae | 2015-11-05 16:48:55 -0500 | [diff] [blame] | 2381 | mNotificationData.updateRanking(ranking); |
Julia Reynolds | d9228f1 | 2015-10-20 10:37:27 -0400 | [diff] [blame] | 2382 | |
Adrian Roos | 95f8bea | 2016-07-27 15:49:03 -0700 | [diff] [blame] | 2383 | boolean applyInPlace; |
| 2384 | try { |
| 2385 | applyInPlace = entry.cacheContentViews(mContext, notification.getNotification()); |
| 2386 | } catch (RuntimeException e) { |
| 2387 | Log.e(TAG, "Unable to get notification remote views", e); |
| 2388 | applyInPlace = false; |
| 2389 | } |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 2390 | boolean shouldPeek = shouldPeek(entry, notification); |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2391 | boolean alertAgain = alertAgain(entry, n); |
Julia Reynolds | d9228f1 | 2015-10-20 10:37:27 -0400 | [diff] [blame] | 2392 | if (DEBUG) { |
| 2393 | Log.d(TAG, "applyInPlace=" + applyInPlace |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 2394 | + " shouldPeek=" + shouldPeek |
Julia Reynolds | d9228f1 | 2015-10-20 10:37:27 -0400 | [diff] [blame] | 2395 | + " alertAgain=" + alertAgain); |
| 2396 | } |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2397 | |
Dan Sandler | 24813b0 | 2016-01-14 15:49:36 -0500 | [diff] [blame] | 2398 | final StatusBarNotification oldNotification = entry.notification; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2399 | entry.notification = notification; |
Dan Sandler | 24813b0 | 2016-01-14 15:49:36 -0500 | [diff] [blame] | 2400 | mGroupManager.onEntryUpdated(entry, oldNotification); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2401 | |
| 2402 | boolean updateSuccessful = false; |
| 2403 | if (applyInPlace) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2404 | if (DEBUG) Log.d(TAG, "reusing notification for key: " + key); |
| 2405 | try { |
| 2406 | if (entry.icon != null) { |
| 2407 | // Update the icon |
Dan Sandler | d63f932 | 2015-05-06 15:18:49 -0400 | [diff] [blame] | 2408 | final StatusBarIcon ic = new StatusBarIcon( |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2409 | notification.getUser(), |
Dan Sandler | 4e78706 | 2015-06-17 15:09:48 -0400 | [diff] [blame] | 2410 | notification.getPackageName(), |
Dan Sandler | d63f932 | 2015-05-06 15:18:49 -0400 | [diff] [blame] | 2411 | n.getSmallIcon(), |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2412 | n.iconLevel, |
| 2413 | n.number, |
Adrian Roos | eba0582 | 2016-04-22 17:09:27 -0700 | [diff] [blame] | 2414 | StatusBarIconView.contentDescForNotification(mContext, n)); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2415 | entry.icon.setNotification(n); |
| 2416 | if (!entry.icon.set(ic)) { |
| 2417 | handleNotificationError(notification, "Couldn't update icon: " + ic); |
| 2418 | return; |
| 2419 | } |
| 2420 | } |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 2421 | updateNotificationViews(entry, notification); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2422 | updateSuccessful = true; |
| 2423 | } |
| 2424 | catch (RuntimeException e) { |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2425 | // It failed to apply cleanly. |
Adrian Roos | e458aa8 | 2015-12-08 16:17:19 -0800 | [diff] [blame] | 2426 | Log.w(TAG, "Couldn't reapply views for package " + |
| 2427 | notification.getPackageName(), e); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2428 | } |
| 2429 | } |
| 2430 | if (!updateSuccessful) { |
| 2431 | if (DEBUG) Log.d(TAG, "not reusing notification for key: " + key); |
Dan Sandler | d63f932 | 2015-05-06 15:18:49 -0400 | [diff] [blame] | 2432 | final StatusBarIcon ic = new StatusBarIcon( |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2433 | notification.getUser(), |
Dan Sandler | 4e78706 | 2015-06-17 15:09:48 -0400 | [diff] [blame] | 2434 | notification.getPackageName(), |
Dan Sandler | d63f932 | 2015-05-06 15:18:49 -0400 | [diff] [blame] | 2435 | n.getSmallIcon(), |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2436 | n.iconLevel, |
| 2437 | n.number, |
Adrian Roos | eba0582 | 2016-04-22 17:09:27 -0700 | [diff] [blame] | 2438 | StatusBarIconView.contentDescForNotification(mContext, n)); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2439 | entry.icon.setNotification(n); |
| 2440 | entry.icon.set(ic); |
Adrian Roos | 95f8bea | 2016-07-27 15:49:03 -0700 | [diff] [blame] | 2441 | if (!inflateViews(entry, mStackScroller)) { |
| 2442 | handleNotificationError(notification, "Couldn't update remote views for: " |
| 2443 | + notification); |
| 2444 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2445 | } |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 2446 | updateHeadsUp(key, entry, shouldPeek, alertAgain); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2447 | updateNotifications(); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2448 | |
dongwan0605.kim | 30637e4 | 2016-03-02 17:16:47 +0900 | [diff] [blame] | 2449 | if (!notification.isClearable()) { |
| 2450 | // The user may have performed a dismiss action on the notification, since it's |
| 2451 | // not clearable we should snap it back. |
| 2452 | mStackScroller.snapViewIfNeeded(entry.row); |
| 2453 | } |
| 2454 | |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2455 | if (DEBUG) { |
| 2456 | // Is this for you? |
| 2457 | boolean isForCurrentUser = isNotificationForCurrentProfiles(notification); |
| 2458 | Log.d(TAG, "notification is " + (isForCurrentUser ? "" : "not ") + "for you"); |
| 2459 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2460 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2461 | setAreThereNotifications(); |
| 2462 | } |
| 2463 | |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 2464 | protected abstract void updateHeadsUp(String key, Entry entry, boolean shouldPeek, |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 2465 | boolean alertAgain); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2466 | |
Julia Reynolds | d9228f1 | 2015-10-20 10:37:27 -0400 | [diff] [blame] | 2467 | private void updateNotificationViews(Entry entry, StatusBarNotification sbn) { |
| 2468 | final RemoteViews contentView = entry.cachedContentView; |
| 2469 | final RemoteViews bigContentView = entry.cachedBigContentView; |
| 2470 | final RemoteViews headsUpContentView = entry.cachedHeadsUpContentView; |
| 2471 | final RemoteViews publicContentView = entry.cachedPublicContentView; |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 2472 | |
Chris Wren | e03f4e1 | 2013-08-08 16:48:48 -0400 | [diff] [blame] | 2473 | // Reapply the RemoteViews |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2474 | contentView.reapply(mContext, entry.getContentView(), mOnClickHandler); |
| 2475 | if (bigContentView != null && entry.getExpandedContentView() != null) { |
Julia Reynolds | d9228f1 | 2015-10-20 10:37:27 -0400 | [diff] [blame] | 2476 | bigContentView.reapply(sbn.getPackageContext(mContext), |
Dan Sandler | 68079d5 | 2015-07-22 10:45:30 -0400 | [diff] [blame] | 2477 | entry.getExpandedContentView(), |
Jorim Jaggi | 39fa59f | 2014-02-25 15:38:45 +0100 | [diff] [blame] | 2478 | mOnClickHandler); |
Chris Wren | e03f4e1 | 2013-08-08 16:48:48 -0400 | [diff] [blame] | 2479 | } |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2480 | View headsUpChild = entry.getHeadsUpContentView(); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 2481 | if (headsUpContentView != null && headsUpChild != null) { |
Julia Reynolds | d9228f1 | 2015-10-20 10:37:27 -0400 | [diff] [blame] | 2482 | headsUpContentView.reapply(sbn.getPackageContext(mContext), |
Dan Sandler | 68079d5 | 2015-07-22 10:45:30 -0400 | [diff] [blame] | 2483 | headsUpChild, mOnClickHandler); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 2484 | } |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 2485 | if (publicContentView != null && entry.getPublicContentView() != null) { |
Julia Reynolds | d9228f1 | 2015-10-20 10:37:27 -0400 | [diff] [blame] | 2486 | publicContentView.reapply(sbn.getPackageContext(mContext), |
Dan Sandler | 68079d5 | 2015-07-22 10:45:30 -0400 | [diff] [blame] | 2487 | entry.getPublicContentView(), mOnClickHandler); |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 2488 | } |
Chris Wren | e03f4e1 | 2013-08-08 16:48:48 -0400 | [diff] [blame] | 2489 | // update the contentIntent |
Julia Reynolds | d9228f1 | 2015-10-20 10:37:27 -0400 | [diff] [blame] | 2490 | mNotificationClicker.register(entry.row, sbn); |
Chris Wren | 42d5dd4 | 2015-05-01 10:39:26 -0400 | [diff] [blame] | 2491 | |
Selim Cinek | da42d65 | 2015-12-04 15:51:16 -0800 | [diff] [blame] | 2492 | entry.row.onNotificationUpdated(entry); |
Selim Cinek | 51ae05d | 2014-09-09 15:51:38 +0200 | [diff] [blame] | 2493 | entry.row.resetHeight(); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2494 | } |
John Spurlock | 3623128 | 2012-06-23 17:11:27 -0400 | [diff] [blame] | 2495 | |
Sudheer Shanka | f5b850e | 2016-01-25 19:58:59 +0000 | [diff] [blame] | 2496 | protected void updatePublicContentView(Entry entry, |
| 2497 | StatusBarNotification sbn) { |
| 2498 | final RemoteViews publicContentView = entry.cachedPublicContentView; |
Selim Cinek | e4c068d | 2016-02-19 13:46:55 -0800 | [diff] [blame] | 2499 | View inflatedView = entry.getPublicContentView(); |
| 2500 | if (entry.autoRedacted && publicContentView != null && inflatedView != null) { |
Sudheer Shanka | f5b850e | 2016-01-25 19:58:59 +0000 | [diff] [blame] | 2501 | final boolean disabledByPolicy = |
| 2502 | !adminAllowsUnredactedNotifications(entry.notification.getUserId()); |
Selim Cinek | e4c068d | 2016-02-19 13:46:55 -0800 | [diff] [blame] | 2503 | String notificationHiddenText = mContext.getString(disabledByPolicy |
| 2504 | ? com.android.internal.R.string.notification_hidden_by_policy_text |
| 2505 | : com.android.internal.R.string.notification_hidden_text); |
| 2506 | TextView titleView = (TextView) inflatedView.findViewById(android.R.id.title); |
| 2507 | if (titleView != null |
| 2508 | && !titleView.getText().toString().equals(notificationHiddenText)) { |
| 2509 | publicContentView.setTextViewText(android.R.id.title, notificationHiddenText); |
| 2510 | publicContentView.reapply(sbn.getPackageContext(mContext), |
| 2511 | inflatedView, mOnClickHandler); |
| 2512 | entry.row.onNotificationUpdated(entry); |
| 2513 | } |
Sudheer Shanka | f5b850e | 2016-01-25 19:58:59 +0000 | [diff] [blame] | 2514 | } |
| 2515 | } |
| 2516 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2517 | protected void notifyHeadsUpScreenOff() { |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2518 | maybeEscalateHeadsUp(); |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2519 | } |
| 2520 | |
Chris Wren | d93d5ad | 2014-09-08 16:34:03 -0400 | [diff] [blame] | 2521 | private boolean alertAgain(Entry oldEntry, Notification newNotification) { |
| 2522 | return oldEntry == null || !oldEntry.hasInterrupted() |
| 2523 | || (newNotification.flags & Notification.FLAG_ONLY_ALERT_ONCE) == 0; |
Chris Wren | d04f6ce | 2014-06-11 17:37:28 -0400 | [diff] [blame] | 2524 | } |
| 2525 | |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 2526 | protected boolean shouldPeek(Entry entry) { |
| 2527 | return shouldPeek(entry, entry.notification); |
Chris Wren | 0c274b1 | 2015-07-17 10:34:53 -0400 | [diff] [blame] | 2528 | } |
| 2529 | |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 2530 | protected boolean shouldPeek(Entry entry, StatusBarNotification sbn) { |
Adrian Roos | f6967e06 | 2016-06-21 16:12:48 -0700 | [diff] [blame] | 2531 | if (!mUseHeadsUp || isDeviceInVrMode()) { |
Dan Sandler | dc34df5 | 2016-04-07 21:04:46 -0400 | [diff] [blame] | 2532 | return false; |
| 2533 | } |
| 2534 | |
Christoph Studer | 2f9dbba | 2014-09-03 17:35:54 +0200 | [diff] [blame] | 2535 | if (mNotificationData.shouldFilterOut(sbn)) { |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 2536 | if (DEBUG) Log.d(TAG, "No peeking: filtered notification: " + sbn.getKey()); |
Christoph Studer | 2f9dbba | 2014-09-03 17:35:54 +0200 | [diff] [blame] | 2537 | return false; |
| 2538 | } |
| 2539 | |
Selim Cinek | d592191 | 2016-02-09 10:33:01 -0800 | [diff] [blame] | 2540 | boolean inUse = mPowerManager.isScreenOn() |
| 2541 | && (!mStatusBarKeyguardViewManager.isShowing() |
Selim Cinek | 2dabc82 | 2016-08-09 16:28:17 -0700 | [diff] [blame] | 2542 | || mStatusBarKeyguardViewManager.isOccluded()); |
Selim Cinek | d592191 | 2016-02-09 10:33:01 -0800 | [diff] [blame] | 2543 | try { |
| 2544 | inUse = inUse && !mDreamManager.isDreaming(); |
| 2545 | } catch (RemoteException e) { |
| 2546 | Log.d(TAG, "failed to query dream manager", e); |
| 2547 | } |
| 2548 | |
| 2549 | if (!inUse) { |
| 2550 | if (DEBUG) { |
| 2551 | Log.d(TAG, "No peeking: not in use: " + sbn.getKey()); |
| 2552 | } |
| 2553 | return false; |
| 2554 | } |
| 2555 | |
| 2556 | if (mNotificationData.shouldSuppressScreenOn(sbn.getKey())) { |
| 2557 | if (DEBUG) Log.d(TAG, "No peeking: suppressed by DND: " + sbn.getKey()); |
Chris Wren | a6d4fb6 | 2014-11-20 14:46:23 -0500 | [diff] [blame] | 2558 | return false; |
| 2559 | } |
| 2560 | |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 2561 | if (entry.hasJustLaunchedFullScreenIntent()) { |
| 2562 | if (DEBUG) Log.d(TAG, "No peeking: recent fullscreen: " + sbn.getKey()); |
| 2563 | return false; |
| 2564 | } |
| 2565 | |
Julia Reynolds | f0f629f | 2016-02-25 09:34:04 -0500 | [diff] [blame] | 2566 | if (isSnoozedPackage(sbn)) { |
| 2567 | if (DEBUG) Log.d(TAG, "No peeking: snoozed package: " + sbn.getKey()); |
| 2568 | return false; |
| 2569 | } |
| 2570 | |
| 2571 | if (mNotificationData.getImportance(sbn.getKey()) < IMPORTANCE_HIGH) { |
| 2572 | if (DEBUG) Log.d(TAG, "No peeking: unimportant notification: " + sbn.getKey()); |
| 2573 | return false; |
| 2574 | } |
| 2575 | |
Selim Cinek | d592191 | 2016-02-09 10:33:01 -0800 | [diff] [blame] | 2576 | if (sbn.getNotification().fullScreenIntent != null) { |
| 2577 | if (mAccessibilityManager.isTouchExplorationEnabled()) { |
| 2578 | if (DEBUG) Log.d(TAG, "No peeking: accessible fullscreen: " + sbn.getKey()); |
| 2579 | return false; |
| 2580 | } else { |
| 2581 | return true; |
| 2582 | } |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 2583 | } |
| 2584 | |
Selim Cinek | d592191 | 2016-02-09 10:33:01 -0800 | [diff] [blame] | 2585 | return true; |
Chris Wren | 157026f | 2013-06-28 16:54:01 -0400 | [diff] [blame] | 2586 | } |
| 2587 | |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 2588 | protected abstract boolean isSnoozedPackage(StatusBarNotification sbn); |
| 2589 | |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 2590 | public void setInteracting(int barWindow, boolean interacting) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2591 | // hook for subclasses |
| 2592 | } |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 2593 | |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 2594 | public void setBouncerShowing(boolean bouncerShowing) { |
| 2595 | mBouncerShowing = bouncerShowing; |
| 2596 | } |
| 2597 | |
| 2598 | /** |
| 2599 | * @return Whether the security bouncer from Keyguard is showing. |
| 2600 | */ |
| 2601 | public boolean isBouncerShowing() { |
| 2602 | return mBouncerShowing; |
| 2603 | } |
| 2604 | |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 2605 | public void destroy() { |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 2606 | mContext.unregisterReceiver(mBroadcastReceiver); |
Christoph Studer | e71fefc | 2014-06-24 16:16:49 +0200 | [diff] [blame] | 2607 | try { |
| 2608 | mNotificationListener.unregisterAsSystemService(); |
| 2609 | } catch (RemoteException e) { |
| 2610 | // Ignore. |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 2611 | } |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 2612 | } |
Kenny Guy | 4dcb0dc | 2014-07-15 12:41:24 +0100 | [diff] [blame] | 2613 | |
| 2614 | /** |
| 2615 | * @return a PackageManger for userId or if userId is < 0 (USER_ALL etc) then |
| 2616 | * return PackageManager for mContext |
| 2617 | */ |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 2618 | public static PackageManager getPackageManagerForUser(Context context, int userId) { |
| 2619 | Context contextForUser = context; |
Kenny Guy | 4dcb0dc | 2014-07-15 12:41:24 +0100 | [diff] [blame] | 2620 | // UserHandle defines special userId as negative values, e.g. USER_ALL |
| 2621 | if (userId >= 0) { |
| 2622 | try { |
| 2623 | // Create a context for the correct user so if a package isn't installed |
| 2624 | // for user 0 we can still load information about the package. |
| 2625 | contextForUser = |
Selim Cinek | eef8428 | 2015-10-30 16:28:00 -0700 | [diff] [blame] | 2626 | context.createPackageContextAsUser(context.getPackageName(), |
Kenny Guy | 4dcb0dc | 2014-07-15 12:41:24 +0100 | [diff] [blame] | 2627 | Context.CONTEXT_RESTRICTED, |
| 2628 | new UserHandle(userId)); |
| 2629 | } catch (NameNotFoundException e) { |
| 2630 | // Shouldn't fail to find the package name for system ui. |
| 2631 | } |
| 2632 | } |
| 2633 | return contextForUser.getPackageManager(); |
| 2634 | } |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 2635 | |
| 2636 | @Override |
| 2637 | public void logNotificationExpansion(String key, boolean userAction, boolean expanded) { |
| 2638 | try { |
| 2639 | mBarService.onNotificationExpansionChanged(key, userAction, expanded); |
| 2640 | } catch (RemoteException e) { |
| 2641 | // Ignore. |
| 2642 | } |
| 2643 | } |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 2644 | |
| 2645 | public boolean isKeyguardSecure() { |
Dan Sandler | e163a64 | 2015-03-01 22:58:32 -0500 | [diff] [blame] | 2646 | if (mStatusBarKeyguardViewManager == null) { |
| 2647 | // startKeyguard() hasn't been called yet, so we don't know. |
| 2648 | // Make sure anything that needs to know isKeyguardSecure() checks and re-checks this |
| 2649 | // value onVisibilityChanged(). |
| 2650 | Slog.w(TAG, "isKeyguardSecure() called before startKeyguard(), returning false", |
| 2651 | new Throwable()); |
| 2652 | return false; |
| 2653 | } |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 2654 | return mStatusBarKeyguardViewManager.isSecure(); |
| 2655 | } |
Adrian Roos | 4f43dc0 | 2015-06-17 16:43:38 -0700 | [diff] [blame] | 2656 | |
| 2657 | @Override |
| 2658 | public void showAssistDisclosure() { |
| 2659 | if (mAssistManager != null) { |
| 2660 | mAssistManager.showDisclosure(); |
| 2661 | } |
| 2662 | } |
Jorim Jaggi | 165ce06 | 2015-07-06 16:18:11 -0700 | [diff] [blame] | 2663 | |
| 2664 | @Override |
| 2665 | public void startAssist(Bundle args) { |
| 2666 | if (mAssistManager != null) { |
| 2667 | mAssistManager.startAssist(args); |
| 2668 | } |
| 2669 | } |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 2670 | } |