Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [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 | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 17 | package com.android.systemui.statusbar.phone; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 18 | |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 19 | |
Selim Cinek | 64be772 | 2016-07-22 13:28:16 -0700 | [diff] [blame] | 20 | import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_ALT; |
| 21 | import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SHOWN; |
| 22 | import static android.app.StatusBarManager.WINDOW_STATE_HIDDEN; |
| 23 | import static android.app.StatusBarManager.WINDOW_STATE_SHOWING; |
| 24 | import static android.app.StatusBarManager.windowStateToString; |
| 25 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT; |
| 26 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT_TRANSPARENT; |
| 27 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_OPAQUE; |
| 28 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_SEMI_TRANSPARENT; |
| 29 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSLUCENT; |
| 30 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARENT; |
| 31 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_WARNING; |
| 32 | |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 33 | import android.animation.Animator; |
| 34 | import android.animation.AnimatorListenerAdapter; |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 35 | import android.annotation.NonNull; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 36 | import android.app.ActivityManager; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 37 | import android.app.ActivityManagerNative; |
Robert Carr | fd10cd1 | 2016-06-29 16:41:50 -0700 | [diff] [blame] | 38 | import android.app.ActivityOptions; |
phweiss | 923d2cc | 2016-12-14 21:37:48 +0100 | [diff] [blame] | 39 | import android.app.admin.DevicePolicyManager; |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 40 | import android.app.IActivityManager; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 41 | import android.app.Notification; |
| 42 | import android.app.PendingIntent; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 43 | import android.app.StatusBarManager; |
| 44 | import android.content.BroadcastReceiver; |
Jorim Jaggi | 786afcb | 2014-09-25 02:41:29 +0200 | [diff] [blame] | 45 | import android.content.ComponentCallbacks2; |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 46 | import android.content.ComponentName; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 47 | import android.content.Context; |
| 48 | import android.content.Intent; |
| 49 | import android.content.IntentFilter; |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 50 | import android.content.IntentSender; |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 51 | import android.content.pm.IPackageManager; |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 52 | import android.content.pm.PackageManager; |
Tony Mak | 92c989d | 2016-04-19 14:02:44 +0100 | [diff] [blame] | 53 | import android.content.pm.UserInfo; |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 54 | import android.content.res.Configuration; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 55 | import android.content.res.Resources; |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 56 | import android.database.ContentObserver; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 57 | import android.graphics.Bitmap; |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 58 | import android.graphics.Canvas; |
| 59 | import android.graphics.ColorFilter; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 60 | import android.graphics.PixelFormat; |
Daniel Sandler | e680f54 | 2012-09-28 12:22:27 -0400 | [diff] [blame] | 61 | import android.graphics.Point; |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 62 | import android.graphics.PointF; |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 63 | import android.graphics.PorterDuff; |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 64 | import android.graphics.PorterDuffXfermode; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 65 | import android.graphics.Rect; |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 66 | import android.graphics.drawable.BitmapDrawable; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 67 | import android.graphics.drawable.ColorDrawable; |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 68 | import android.graphics.drawable.Drawable; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 69 | import android.inputmethodservice.InputMethodService; |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 70 | import android.media.AudioAttributes; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 71 | import android.media.MediaMetadata; |
| 72 | import android.media.session.MediaController; |
| 73 | import android.media.session.MediaSession; |
| 74 | import android.media.session.MediaSessionManager; |
| 75 | import android.media.session.PlaybackState; |
Adrian Roos | 7bb38a9 | 2016-07-21 11:44:01 -0700 | [diff] [blame] | 76 | import android.net.Uri; |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 77 | import android.os.AsyncTask; |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 78 | import android.os.Bundle; |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 79 | import android.os.Handler; |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 80 | import android.os.HandlerThread; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 81 | import android.os.IBinder; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 82 | import android.os.Message; |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 83 | import android.os.PowerManager; |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 84 | import android.os.Process; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 85 | import android.os.RemoteException; |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 86 | import android.os.ServiceManager; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 87 | import android.os.SystemClock; |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 88 | import android.os.Trace; |
Adrian Roos | 7bb38a9 | 2016-07-21 11:44:01 -0700 | [diff] [blame] | 89 | import android.os.SystemProperties; |
Dianne Hackborn | f02b60a | 2012-08-16 10:48:27 -0700 | [diff] [blame] | 90 | import android.os.UserHandle; |
Adrian Roos | 2b154a9 | 2014-11-17 15:18:39 +0100 | [diff] [blame] | 91 | import android.os.UserManager; |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 92 | import android.os.Vibrator; |
Daniel Sandler | d309056 | 2011-08-09 00:28:44 -0400 | [diff] [blame] | 93 | import android.provider.Settings; |
Chris Wren | 3ad4e3a | 2014-09-02 17:23:51 -0400 | [diff] [blame] | 94 | import android.service.notification.NotificationListenerService; |
Christoph Studer | d0694b6 | 2014-06-04 16:36:01 +0200 | [diff] [blame] | 95 | import android.service.notification.NotificationListenerService.RankingMap; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 96 | import android.service.notification.StatusBarNotification; |
Selim Cinek | 64be772 | 2016-07-22 13:28:16 -0700 | [diff] [blame] | 97 | import android.telecom.TelecomManager; |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 98 | import android.util.ArraySet; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 99 | import android.util.DisplayMetrics; |
Chris Wren | 64161cc | 2012-12-17 16:49:30 -0500 | [diff] [blame] | 100 | import android.util.EventLog; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 101 | import android.util.Log; |
| 102 | import android.view.Display; |
Adrian Roos | a98b32c | 2016-08-11 10:41:08 -0700 | [diff] [blame] | 103 | import android.view.IRotationWatcher; |
Jorim Jaggi | df99351 | 2014-05-13 23:06:35 +0200 | [diff] [blame] | 104 | import android.view.KeyEvent; |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 105 | import android.view.LayoutInflater; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 106 | import android.view.MotionEvent; |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 107 | import android.view.ThreadedRenderer; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 108 | import android.view.View; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 109 | import android.view.ViewGroup; |
Jim Miller | f2a16b2 | 2011-07-06 17:32:48 -0700 | [diff] [blame] | 110 | import android.view.ViewGroup.LayoutParams; |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 111 | import android.view.ViewParent; |
Dan Sandler | 44c0dfd | 2014-06-09 11:26:16 -0400 | [diff] [blame] | 112 | import android.view.ViewStub; |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 113 | import android.view.ViewTreeObserver; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 114 | import android.view.WindowManager; |
Jorim Jaggi | 786afcb | 2014-09-25 02:41:29 +0200 | [diff] [blame] | 115 | import android.view.WindowManagerGlobal; |
Jorim Jaggi | 4e723e6 | 2016-12-14 11:02:39 -0800 | [diff] [blame] | 116 | import android.view.accessibility.AccessibilityEvent; |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 117 | import android.view.animation.AccelerateInterpolator; |
Jorim Jaggi | b13d36d | 2014-06-06 18:03:52 +0200 | [diff] [blame] | 118 | import android.view.animation.Interpolator; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 119 | import android.widget.ImageView; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 120 | import android.widget.TextView; |
Selim Cinek | 64be772 | 2016-07-22 13:28:16 -0700 | [diff] [blame] | 121 | |
Chris Wren | 9763d42 | 2015-04-30 15:24:05 -0400 | [diff] [blame] | 122 | import com.android.internal.logging.MetricsLogger; |
Chris Wren | f6e9228b | 2016-01-26 18:04:35 -0500 | [diff] [blame] | 123 | import com.android.internal.logging.MetricsProto.MetricsEvent; |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 124 | import com.android.internal.statusbar.NotificationVisibility; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 125 | import com.android.internal.statusbar.StatusBarIcon; |
Jorim Jaggi | 6b88cdf | 2014-12-22 20:56:50 +0100 | [diff] [blame] | 126 | import com.android.keyguard.KeyguardHostView.OnDismissAction; |
Jason Monk | ab52527 | 2015-07-13 17:02:49 -0400 | [diff] [blame] | 127 | import com.android.keyguard.KeyguardUpdateMonitor; |
Jorim Jaggi | 007f0e8 | 2015-08-14 13:56:01 -0700 | [diff] [blame] | 128 | import com.android.keyguard.KeyguardUpdateMonitorCallback; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 129 | import com.android.keyguard.ViewMediatorCallback; |
Clara Bayarri | 9b1fdff | 2016-04-21 14:28:47 +0100 | [diff] [blame] | 130 | import com.android.systemui.AutoReinflateContainer; |
| 131 | import com.android.systemui.AutoReinflateContainer.InflateListener; |
Jorim Jaggi | 708f772 | 2014-08-20 17:30:38 +0200 | [diff] [blame] | 132 | import com.android.systemui.BatteryMeterView; |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 133 | import com.android.systemui.DemoMode; |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 134 | import com.android.systemui.EventLogConstants; |
Chris Wren | 64161cc | 2012-12-17 16:49:30 -0500 | [diff] [blame] | 135 | import com.android.systemui.EventLogTags; |
Winson | c0d7058 | 2016-01-29 10:24:39 -0800 | [diff] [blame] | 136 | import com.android.systemui.Interpolators; |
Andrew Flynn | 8286257 | 2015-04-01 14:22:37 -0400 | [diff] [blame] | 137 | import com.android.systemui.Prefs; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 138 | import com.android.systemui.R; |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 139 | import com.android.systemui.SystemUIFactory; |
Adrian Roos | 401caae | 2016-03-04 13:35:21 -0800 | [diff] [blame] | 140 | import com.android.systemui.classifier.FalsingLog; |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 141 | import com.android.systemui.classifier.FalsingManager; |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 142 | import com.android.systemui.doze.DozeHost; |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 143 | import com.android.systemui.doze.DozeLog; |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 144 | import com.android.systemui.keyguard.KeyguardViewMediator; |
Jason Monk | 162011e | 2016-02-19 08:11:55 -0500 | [diff] [blame] | 145 | import com.android.systemui.qs.QSContainer; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 146 | import com.android.systemui.qs.QSPanel; |
Jorim Jaggi | d61f227 | 2014-12-19 20:35:35 +0100 | [diff] [blame] | 147 | import com.android.systemui.recents.ScreenPinningRequest; |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 148 | import com.android.systemui.recents.events.EventBus; |
Jorim Jaggi | 2adba07 | 2016-03-03 13:43:39 +0100 | [diff] [blame] | 149 | import com.android.systemui.recents.events.activity.AppTransitionFinishedEvent; |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 150 | import com.android.systemui.recents.events.activity.UndockingTaskEvent; |
Jorim Jaggi | dd98d41 | 2015-11-18 15:57:38 -0800 | [diff] [blame] | 151 | import com.android.systemui.stackdivider.Divider; |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 152 | import com.android.systemui.stackdivider.WindowManagerProxy; |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 153 | import com.android.systemui.statusbar.ActivatableNotificationView; |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 154 | import com.android.systemui.statusbar.BackDropView; |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 155 | import com.android.systemui.statusbar.BaseStatusBar; |
Michael Jurka | a600fd9 | 2012-06-25 15:57:05 -0700 | [diff] [blame] | 156 | import com.android.systemui.statusbar.CommandQueue; |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 157 | import com.android.systemui.statusbar.DismissView; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 158 | import com.android.systemui.statusbar.DragDownHelper; |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 159 | import com.android.systemui.statusbar.EmptyShadeView; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 160 | import com.android.systemui.statusbar.ExpandableNotificationRow; |
Daniel Sandler | 3380534 | 2012-07-23 15:45:12 -0400 | [diff] [blame] | 161 | import com.android.systemui.statusbar.GestureRecorder; |
Andrei Stingaceanu | f86bc97 | 2016-04-12 15:29:25 +0100 | [diff] [blame] | 162 | import com.android.systemui.statusbar.KeyboardShortcuts; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 163 | import com.android.systemui.statusbar.KeyguardIndicationController; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 164 | import com.android.systemui.statusbar.NotificationData; |
Daniel Sandler | 58b173b | 2012-05-03 11:25:29 -0400 | [diff] [blame] | 165 | import com.android.systemui.statusbar.NotificationData.Entry; |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 166 | import com.android.systemui.statusbar.NotificationOverflowContainer; |
Adrian Roos | 1c0ca50 | 2015-10-07 12:20:42 -0700 | [diff] [blame] | 167 | import com.android.systemui.statusbar.RemoteInputController; |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 168 | import com.android.systemui.statusbar.ScrimView; |
Christian Robertson | 2e34742 | 2011-08-11 14:01:04 -0700 | [diff] [blame] | 169 | import com.android.systemui.statusbar.SignalClusterView; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 170 | import com.android.systemui.statusbar.StatusBarState; |
Selim Cinek | add9526 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 171 | import com.android.systemui.statusbar.notification.VisualStabilityManager; |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 172 | import com.android.systemui.statusbar.phone.UnlockMethodCache.OnUnlockMethodChangedListener; |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 173 | import com.android.systemui.statusbar.policy.AccessibilityController; |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 174 | import com.android.systemui.statusbar.policy.BatteryController; |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 175 | import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback; |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 176 | import com.android.systemui.statusbar.policy.BatteryControllerImpl; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 177 | import com.android.systemui.statusbar.policy.BluetoothControllerImpl; |
Adrian Roos | 5fd872e | 2014-08-12 17:28:58 +0200 | [diff] [blame] | 178 | import com.android.systemui.statusbar.policy.BrightnessMirrorController; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 179 | import com.android.systemui.statusbar.policy.CastControllerImpl; |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 180 | import com.android.systemui.statusbar.policy.EncryptionHelper; |
Adrian Roos | b83777b | 2014-06-30 15:11:53 +0200 | [diff] [blame] | 181 | import com.android.systemui.statusbar.policy.FlashlightController; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 182 | import com.android.systemui.statusbar.policy.HeadsUpManager; |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 183 | import com.android.systemui.statusbar.policy.HotspotControllerImpl; |
Jorim Jaggi | 4e723e6 | 2016-12-14 11:02:39 -0800 | [diff] [blame] | 184 | import com.android.systemui.statusbar.policy.KeyButtonView; |
John Spurlock | 657c62c | 2014-07-22 12:18:09 -0400 | [diff] [blame] | 185 | import com.android.systemui.statusbar.policy.KeyguardMonitor; |
Adrian Roos | 8ddb2da | 2014-06-16 18:56:22 -0700 | [diff] [blame] | 186 | import com.android.systemui.statusbar.policy.KeyguardUserSwitcher; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 187 | import com.android.systemui.statusbar.policy.LocationControllerImpl; |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 188 | import com.android.systemui.statusbar.policy.NetworkController; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 189 | import com.android.systemui.statusbar.policy.NetworkControllerImpl; |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 190 | import com.android.systemui.statusbar.policy.NextAlarmController; |
Selim Cinek | add9526 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 191 | import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener; |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 192 | import com.android.systemui.statusbar.policy.PreviewInflater; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 193 | import com.android.systemui.statusbar.policy.RotationLockControllerImpl; |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 194 | import com.android.systemui.statusbar.policy.SecurityControllerImpl; |
| 195 | import com.android.systemui.statusbar.policy.UserInfoController; |
Adrian Roos | 00a0b1f | 2014-07-16 16:44:49 +0200 | [diff] [blame] | 196 | import com.android.systemui.statusbar.policy.UserSwitcherController; |
John Spurlock | 8600534 | 2014-05-23 11:58:00 -0400 | [diff] [blame] | 197 | import com.android.systemui.statusbar.policy.ZenModeController; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 198 | import com.android.systemui.statusbar.stack.NotificationStackScrollLayout; |
Selim Cinek | 64be772 | 2016-07-22 13:28:16 -0700 | [diff] [blame] | 199 | import com.android.systemui.statusbar.stack.NotificationStackScrollLayout |
| 200 | .OnChildLocationsChangedListener; |
Jorim Jaggi | 37c1180 | 2015-08-18 20:27:54 -0700 | [diff] [blame] | 201 | import com.android.systemui.statusbar.stack.StackStateAnimator; |
John Spurlock | 8600534 | 2014-05-23 11:58:00 -0400 | [diff] [blame] | 202 | import com.android.systemui.volume.VolumeComponent; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 203 | |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 204 | import java.io.FileDescriptor; |
| 205 | import java.io.PrintWriter; |
Adrian Roos | 7bb38a9 | 2016-07-21 11:44:01 -0700 | [diff] [blame] | 206 | import java.io.StringWriter; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 207 | import java.util.ArrayList; |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 208 | import java.util.Collection; |
| 209 | import java.util.Collections; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 210 | import java.util.HashMap; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 211 | import java.util.List; |
John Spurlock | 7bbb9f6 | 2014-10-21 12:15:28 -0400 | [diff] [blame] | 212 | import java.util.Map; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 213 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 214 | public class PhoneStatusBar extends BaseStatusBar implements DemoMode, |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 215 | DragDownHelper.DragDownCallback, ActivityStarter, OnUnlockMethodChangedListener, |
Selim Cinek | add9526 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 216 | OnHeadsUpChangedListener, VisualStabilityManager.Callback { |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 217 | static final String TAG = "PhoneStatusBar"; |
Daniel Sandler | 198a030 | 2012-08-17 16:04:31 -0400 | [diff] [blame] | 218 | public static final boolean DEBUG = BaseStatusBar.DEBUG; |
Chris Wren | 6d15a36 | 2013-08-20 18:46:29 -0400 | [diff] [blame] | 219 | public static final boolean SPEW = false; |
Daniel Sandler | 7579bca | 2011-08-18 15:47:26 -0400 | [diff] [blame] | 220 | public static final boolean DUMPTRUCK = true; // extra dumpsys info |
Daniel Sandler | fa027f5 | 2013-04-11 22:01:47 -0400 | [diff] [blame] | 221 | public static final boolean DEBUG_GESTURES = false; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 222 | public static final boolean DEBUG_MEDIA = false; |
| 223 | public static final boolean DEBUG_MEDIA_FAKE_ARTWORK = false; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 224 | |
John Spurlock | 342cad7 | 2013-10-08 09:36:50 -0400 | [diff] [blame] | 225 | public static final boolean DEBUG_WINDOW_STATE = false; |
Daniel Sandler | b17a726 | 2012-10-05 14:32:50 -0400 | [diff] [blame] | 226 | |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 227 | // additional instrumentation for testing purposes; intended to be left on during development |
Daniel Sandler | 7c35174 | 2011-10-17 10:48:06 -0400 | [diff] [blame] | 228 | public static final boolean CHATTY = DEBUG; |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 229 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 230 | public static final boolean SHOW_LOCKSCREEN_MEDIA_ARTWORK = true; |
| 231 | |
Adrian Roos | 8e3e836 | 2015-07-16 19:42:22 -0700 | [diff] [blame] | 232 | public static final String ACTION_FAKE_ARTWORK = "fake_artwork"; |
| 233 | |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 234 | private static final int MSG_OPEN_NOTIFICATION_PANEL = 1000; |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 235 | private static final int MSG_CLOSE_PANELS = 1001; |
| 236 | private static final int MSG_OPEN_SETTINGS_PANEL = 1002; |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 237 | private static final int MSG_LAUNCH_TRANSITION_TIMEOUT = 1003; |
Winson Chung | b1f7499 | 2014-08-08 12:53:09 -0700 | [diff] [blame] | 238 | // 1020-1040 reserved for BaseStatusBar |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 239 | |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 240 | // Time after we abort the launch transition. |
| 241 | private static final long LAUNCH_TRANSITION_TIMEOUT_MS = 5000; |
| 242 | |
Daniel Sandler | 8cc36e5 | 2011-10-17 14:18:46 -0400 | [diff] [blame] | 243 | private static final boolean CLOSE_PANEL_WHEN_EMPTIED = true; |
| 244 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 245 | private static final int STATUS_OR_NAV_TRANSIENT = |
| 246 | View.STATUS_BAR_TRANSIENT | View.NAVIGATION_BAR_TRANSIENT; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 247 | private static final long AUTOHIDE_TIMEOUT_MS = 3000; |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 248 | |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 249 | /** The minimum delay in ms between reports of notification visibility. */ |
| 250 | private static final int VISIBILITY_REPORT_MIN_DELAY_MS = 500; |
| 251 | |
Jorim Jaggi | 93a2bb2 | 2014-06-02 19:57:28 +0200 | [diff] [blame] | 252 | /** |
| 253 | * The delay to reset the hint text when the hint animation is finished running. |
| 254 | */ |
| 255 | private static final int HINT_RESET_DELAY_MS = 1200; |
| 256 | |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 257 | private static final AudioAttributes VIBRATION_ATTRIBUTES = new AudioAttributes.Builder() |
| 258 | .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) |
| 259 | .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) |
| 260 | .build(); |
| 261 | |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 262 | public static final int FADE_KEYGUARD_START_DELAY = 100; |
| 263 | public static final int FADE_KEYGUARD_DURATION = 300; |
Jorim Jaggi | 9097885 | 2015-08-18 19:55:53 -0700 | [diff] [blame] | 264 | public static final int FADE_KEYGUARD_DURATION_PULSING = 96; |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 265 | |
Jason Monk | 815e057 | 2014-08-12 17:26:36 -0400 | [diff] [blame] | 266 | /** Allow some time inbetween the long press for back and recents. */ |
| 267 | private static final int LOCK_TO_APP_GESTURE_TOLERENCE = 200; |
| 268 | |
Adrian Roos | 2f2bd9a | 2015-06-04 18:11:14 -0700 | [diff] [blame] | 269 | /** If true, the system is in the half-boot-to-decryption-screen state. |
| 270 | * Prudently disable QS and notifications. */ |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 271 | private static final boolean ONLY_CORE_APPS; |
| 272 | |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 273 | /** If true, the lockscreen will show a distinct wallpaper */ |
Adrian Roos | e381c16 | 2016-02-11 15:26:42 -0800 | [diff] [blame] | 274 | private static final boolean ENABLE_LOCKSCREEN_WALLPAPER = true; |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 275 | |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 276 | /* If true, the device supports freeform window management. |
| 277 | * This affects the status bar UI. */ |
| 278 | private static final boolean FREEFORM_WINDOW_MANAGEMENT; |
| 279 | |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 280 | /** |
| 281 | * How long to wait before auto-dismissing a notification that was kept for remote input, and |
| 282 | * has now sent a remote input. We auto-dismiss, because the app may not see a reason to cancel |
| 283 | * these given that they technically don't exist anymore. We wait a bit in case the app issues |
| 284 | * an update. |
| 285 | */ |
| 286 | private static final int REMOTE_INPUT_KEPT_ENTRY_AUTO_CANCEL_DELAY = 200; |
| 287 | |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 288 | /** |
| 289 | * Never let the alpha become zero for surfaces that draw with SRC - otherwise the RenderNode |
| 290 | * won't draw anything and uninitialized memory will show through |
| 291 | * if mScrimSrcModeEnabled. Note that 0.001 is rounded down to 0 in |
| 292 | * libhwui. |
| 293 | */ |
| 294 | private static final float SRC_MIN_ALPHA = 0.002f; |
| 295 | |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 296 | static { |
| 297 | boolean onlyCoreApps; |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 298 | boolean freeformWindowManagement; |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 299 | try { |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 300 | IPackageManager packageManager = |
| 301 | IPackageManager.Stub.asInterface(ServiceManager.getService("package")); |
| 302 | onlyCoreApps = packageManager.isOnlyCoreApps(); |
| 303 | freeformWindowManagement = packageManager.hasSystemFeature( |
Jeff Sharkey | 115d2c1 | 2016-02-15 17:25:57 -0700 | [diff] [blame] | 304 | PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT, 0); |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 305 | } catch (RemoteException e) { |
| 306 | onlyCoreApps = false; |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 307 | freeformWindowManagement = false; |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 308 | } |
| 309 | ONLY_CORE_APPS = onlyCoreApps; |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 310 | FREEFORM_WINDOW_MANAGEMENT = freeformWindowManagement; |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 311 | } |
| 312 | |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 313 | PhoneStatusBarPolicy mIconPolicy; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 314 | |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 315 | // These are no longer handled by the policy, because we need custom strategies for them |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 316 | BluetoothControllerImpl mBluetoothController; |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 317 | SecurityControllerImpl mSecurityController; |
Xiaohui Chen | 8bdcd1f | 2016-01-19 13:52:07 -0800 | [diff] [blame] | 318 | protected BatteryController mBatteryController; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 319 | LocationControllerImpl mLocationController; |
| 320 | NetworkControllerImpl mNetworkController; |
Jason Monk | 51e4dc0 | 2014-07-22 12:00:47 -0400 | [diff] [blame] | 321 | HotspotControllerImpl mHotspotController; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 322 | RotationLockControllerImpl mRotationLockController; |
Jorim Jaggi | 3d878be | 2014-05-10 03:22:32 +0200 | [diff] [blame] | 323 | UserInfoController mUserInfoController; |
Muyuan Li | 40e1135 | 2016-03-23 11:43:58 -0700 | [diff] [blame] | 324 | protected ZenModeController mZenModeController; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 325 | CastControllerImpl mCastController; |
John Spurlock | 8600534 | 2014-05-23 11:58:00 -0400 | [diff] [blame] | 326 | VolumeComponent mVolumeComponent; |
Adrian Roos | 8ddb2da | 2014-06-16 18:56:22 -0700 | [diff] [blame] | 327 | KeyguardUserSwitcher mKeyguardUserSwitcher; |
Adrian Roos | b83777b | 2014-06-30 15:11:53 +0200 | [diff] [blame] | 328 | FlashlightController mFlashlightController; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 329 | protected UserSwitcherController mUserSwitcherController; |
Jorim Jaggi | c7dea6e | 2014-07-26 14:36:57 +0200 | [diff] [blame] | 330 | NextAlarmController mNextAlarmController; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 331 | protected KeyguardMonitor mKeyguardMonitor; |
Adrian Roos | 5fd872e | 2014-08-12 17:28:58 +0200 | [diff] [blame] | 332 | BrightnessMirrorController mBrightnessMirrorController; |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 333 | AccessibilityController mAccessibilityController; |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 334 | FingerprintUnlockController mFingerprintUnlockController; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 335 | LightStatusBarController mLightStatusBarController; |
Vadim Tryshev | 12a30e8 | 2016-02-12 15:39:28 -0800 | [diff] [blame] | 336 | protected LockscreenWallpaper mLockscreenWallpaper; |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 337 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 338 | int mNaturalBarHeight = -1; |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 339 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 340 | Display mDisplay; |
Daniel Sandler | e680f54 | 2012-09-28 12:22:27 -0400 | [diff] [blame] | 341 | Point mCurrentDisplaySize = new Point(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 342 | |
Xiaohui Chen | d839d1a | 2016-01-21 13:05:02 -0800 | [diff] [blame] | 343 | protected StatusBarWindowView mStatusBarWindow; |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 344 | protected PhoneStatusBarView mStatusBarView; |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 345 | private int mStatusBarWindowState = WINDOW_STATE_SHOWING; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 346 | protected StatusBarWindowManager mStatusBarWindowManager; |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 347 | private UnlockMethodCache mUnlockMethodCache; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 348 | private DozeServiceHost mDozeServiceHost; |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 349 | private boolean mWakeUpComingFromTouch; |
| 350 | private PointF mWakeUpTouchLocation; |
Selim Cinek | 1b6f819 | 2015-09-03 16:01:53 -0700 | [diff] [blame] | 351 | private boolean mScreenTurningOn; |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 352 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 353 | int mPixelFormat; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 354 | Object mQueueLock = new Object(); |
| 355 | |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 356 | protected StatusBarIconController mIconController; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 357 | |
| 358 | // expanded notifications |
Xiaohui Chen | ea4b6ba | 2016-02-18 10:53:17 -0800 | [diff] [blame] | 359 | protected NotificationPanelView mNotificationPanel; // the sliding/resizing panel within the notification window |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 360 | View mExpandedContents; |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 361 | TextView mNotificationPanelDebugText; |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 362 | |
Daniel Sandler | 8e72c9e | 2012-08-15 00:09:26 -0400 | [diff] [blame] | 363 | // settings |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 364 | private QSPanel mQSPanel; |
Daniel Sandler | 8e72c9e | 2012-08-15 00:09:26 -0400 | [diff] [blame] | 365 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 366 | // top bar |
Jason Monk | 0e1101d | 2015-10-07 13:06:09 -0400 | [diff] [blame] | 367 | BaseStatusBarHeader mHeader; |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 368 | protected KeyguardStatusBarView mKeyguardStatusBar; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 369 | View mKeyguardStatusView; |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 370 | KeyguardBottomAreaView mKeyguardBottomArea; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 371 | boolean mLeaveOpenOnKeyguardHide; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 372 | KeyguardIndicationController mKeyguardIndicationController; |
Jorim Jaggi | e70d31f | 2014-04-24 22:08:30 +0200 | [diff] [blame] | 373 | |
Adrian Roos | 46df1ca | 2015-09-11 12:38:43 -0700 | [diff] [blame] | 374 | // Keyguard is going away soon. |
| 375 | private boolean mKeyguardGoingAway; |
| 376 | // Keyguard is actually fading away now. |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 377 | private boolean mKeyguardFadingAway; |
| 378 | private long mKeyguardFadingAwayDelay; |
| 379 | private long mKeyguardFadingAwayDuration; |
| 380 | |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 381 | // RemoteInputView to be activated after unlock |
| 382 | private View mPendingRemoteInputView; |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 383 | private View mPendingWorkRemoteInputView; |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 384 | |
Adrian Roos | 7bb38a9 | 2016-07-21 11:44:01 -0700 | [diff] [blame] | 385 | private View mReportRejectedTouch; |
| 386 | |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 387 | int mMaxAllowedKeyguardNotifications; |
Daniel Sandler | d309056 | 2011-08-09 00:28:44 -0400 | [diff] [blame] | 388 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 389 | boolean mExpandedVisible; |
| 390 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 391 | private int mNavigationBarWindowState = WINDOW_STATE_SHOWING; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 392 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 393 | // the tracker view |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 394 | int mTrackingPosition; // the position of the top of the tracking view. |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 395 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 396 | // Tracking finger for opening/closing. |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 397 | boolean mTracking; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 398 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 399 | int[] mAbsPos = new int[2]; |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 400 | ArrayList<Runnable> mPostCollapseRunnables = new ArrayList<>(); |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 401 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 402 | // for disabling the status bar |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 403 | int mDisabled1 = 0; |
| 404 | int mDisabled2 = 0; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 405 | |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 406 | // tracking calls to View.setSystemUiVisibility() |
| 407 | int mSystemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 408 | private final Rect mLastFullscreenStackBounds = new Rect(); |
| 409 | private final Rect mLastDockedStackBounds = new Rect(); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 410 | |
Adrian Roos | 389beec | 2015-05-12 13:33:25 -0700 | [diff] [blame] | 411 | // last value sent to window manager |
| 412 | private int mLastDispatchedSystemUiVisibility = ~View.SYSTEM_UI_FLAG_VISIBLE; |
| 413 | |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 414 | DisplayMetrics mDisplayMetrics = new DisplayMetrics(); |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 415 | |
Daniel Sandler | 3380534 | 2012-07-23 15:45:12 -0400 | [diff] [blame] | 416 | // XXX: gesture research |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 417 | private final GestureRecorder mGestureRec = DEBUG_GESTURES |
John Spurlock | 209bede | 2013-07-17 12:23:27 -0400 | [diff] [blame] | 418 | ? new GestureRecorder("/sdcard/statusbar_gestures.dat") |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 419 | : null; |
Daniel Sandler | 3380534 | 2012-07-23 15:45:12 -0400 | [diff] [blame] | 420 | |
Jason Monk | 18f99d9 | 2014-09-11 13:36:42 -0400 | [diff] [blame] | 421 | private ScreenPinningRequest mScreenPinningRequest; |
| 422 | |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 423 | private int mNavigationIconHints = 0; |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 424 | private HandlerThread mHandlerThread; |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 425 | |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 426 | // ensure quick settings is disabled until the current user makes it through the setup wizard |
| 427 | private boolean mUserSetup = false; |
| 428 | private ContentObserver mUserSetupObserver = new ContentObserver(new Handler()) { |
| 429 | @Override |
| 430 | public void onChange(boolean selfChange) { |
| 431 | final boolean userSetup = 0 != Settings.Secure.getIntForUser( |
| 432 | mContext.getContentResolver(), |
| 433 | Settings.Secure.USER_SETUP_COMPLETE, |
| 434 | 0 /*default */, |
| 435 | mCurrentUserId); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 436 | if (MULTIUSER_DEBUG) Log.d(TAG, String.format("User setup changed: " + |
John Spurlock | e4e8c56 | 2012-10-04 09:55:01 -0400 | [diff] [blame] | 437 | "selfChange=%s userSetup=%s mUserSetup=%s", |
| 438 | selfChange, userSetup, mUserSetup)); |
John Spurlock | 73203eb | 2014-04-15 16:14:46 -0400 | [diff] [blame] | 439 | |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 440 | if (userSetup != mUserSetup) { |
| 441 | mUserSetup = userSetup; |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 442 | if (!mUserSetup && mStatusBarView != null) |
| 443 | animateCollapseQuickSettings(); |
Adrian Roos | a4eba9f | 2015-07-22 18:13:04 -0700 | [diff] [blame] | 444 | if (mKeyguardBottomArea != null) { |
| 445 | mKeyguardBottomArea.setUserSetupComplete(mUserSetup); |
| 446 | } |
Jason Monk | fd57ea7 | 2016-04-29 13:37:58 -0400 | [diff] [blame] | 447 | if (mNetworkController != null) { |
| 448 | mNetworkController.setUserSetupComplete(mUserSetup); |
| 449 | } |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 450 | } |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 451 | if (mIconPolicy != null) { |
| 452 | mIconPolicy.setCurrentUserSetup(mUserSetup); |
| 453 | } |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 454 | } |
| 455 | }; |
| 456 | |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 457 | final private ContentObserver mHeadsUpObserver = new ContentObserver(mHandler) { |
| 458 | @Override |
| 459 | public void onChange(boolean selfChange) { |
| 460 | boolean wasUsing = mUseHeadsUp; |
Jason Monk | f701954 | 2014-07-31 12:42:25 -0400 | [diff] [blame] | 461 | mUseHeadsUp = ENABLE_HEADS_UP && !mDisableNotificationAlerts |
| 462 | && Settings.Global.HEADS_UP_OFF != Settings.Global.getInt( |
Chris Wren | 10d82df | 2014-03-01 10:34:51 -0500 | [diff] [blame] | 463 | mContext.getContentResolver(), Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED, |
Chris Wren | 7bd24123 | 2014-02-28 16:25:05 -0500 | [diff] [blame] | 464 | Settings.Global.HEADS_UP_OFF); |
Chris Wren | 22ae46e | 2014-02-26 18:08:09 -0500 | [diff] [blame] | 465 | mHeadsUpTicker = mUseHeadsUp && 0 != Settings.Global.getInt( |
| 466 | mContext.getContentResolver(), SETTING_HEADS_UP_TICKER, 0); |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 467 | Log.d(TAG, "heads up is " + (mUseHeadsUp ? "enabled" : "disabled")); |
| 468 | if (wasUsing != mUseHeadsUp) { |
| 469 | if (!mUseHeadsUp) { |
| 470 | Log.d(TAG, "dismissing any existing heads up notification on disable event"); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 471 | mHeadsUpManager.releaseAllImmediately(); |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 472 | } |
| 473 | } |
| 474 | } |
| 475 | }; |
| 476 | |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 477 | private int mInteractingWindows; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 478 | private boolean mAutohideSuspended; |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 479 | private int mStatusBarMode; |
| 480 | private int mNavigationBarMode; |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 481 | private int mMaxKeyguardNotifications; |
Jorim Jaggi | d41083a | 2014-09-12 02:54:40 +0200 | [diff] [blame] | 482 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 483 | private ViewMediatorCallback mKeyguardViewMediatorCallback; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 484 | protected ScrimController mScrimController; |
| 485 | protected DozeScrimController mDozeScrimController; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 486 | |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 487 | private final Runnable mAutohide = new Runnable() { |
| 488 | @Override |
| 489 | public void run() { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 490 | int requested = mSystemUiVisibility & ~STATUS_OR_NAV_TRANSIENT; |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 491 | if (mSystemUiVisibility != requested) { |
| 492 | notifyUiVisibilityChanged(requested); |
| 493 | } |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 494 | }}; |
| 495 | |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 496 | private boolean mWaitingForKeyguardExit; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 497 | private boolean mDozing; |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 498 | private boolean mDozingRequested; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 499 | protected boolean mScrimSrcModeEnabled; |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 500 | |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 501 | public static final Interpolator ALPHA_IN = Interpolators.ALPHA_IN; |
| 502 | public static final Interpolator ALPHA_OUT = Interpolators.ALPHA_OUT; |
Jorim Jaggi | b13d36d | 2014-06-06 18:03:52 +0200 | [diff] [blame] | 503 | |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 504 | private BackDropView mBackdrop; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 505 | private ImageView mBackdropFront, mBackdropBack; |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 506 | private PorterDuffXfermode mSrcXferMode = new PorterDuffXfermode(PorterDuff.Mode.SRC); |
| 507 | private PorterDuffXfermode mSrcOverXferMode = new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 508 | |
| 509 | private MediaSessionManager mMediaSessionManager; |
| 510 | private MediaController mMediaController; |
| 511 | private String mMediaNotificationKey; |
| 512 | private MediaMetadata mMediaMetadata; |
| 513 | private MediaController.Callback mMediaListener |
| 514 | = new MediaController.Callback() { |
| 515 | @Override |
| 516 | public void onPlaybackStateChanged(PlaybackState state) { |
| 517 | super.onPlaybackStateChanged(state); |
| 518 | if (DEBUG_MEDIA) Log.v(TAG, "DEBUG_MEDIA: onPlaybackStateChanged: " + state); |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 519 | if (state != null) { |
| 520 | if (!isPlaybackActive(state.getState())) { |
| 521 | clearCurrentMediaNotification(); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 522 | updateMediaMetaData(true, true); |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 523 | } |
| 524 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 525 | } |
| 526 | |
| 527 | @Override |
| 528 | public void onMetadataChanged(MediaMetadata metadata) { |
| 529 | super.onMetadataChanged(metadata); |
| 530 | if (DEBUG_MEDIA) Log.v(TAG, "DEBUG_MEDIA: onMetadataChanged: " + metadata); |
| 531 | mMediaMetadata = metadata; |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 532 | updateMediaMetaData(true, true); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 533 | } |
| 534 | }; |
| 535 | |
| 536 | private final OnChildLocationsChangedListener mOnChildLocationsChangedListener = |
| 537 | new OnChildLocationsChangedListener() { |
| 538 | @Override |
| 539 | public void onChildLocationsChanged(NotificationStackScrollLayout stackScrollLayout) { |
| 540 | userActivity(); |
| 541 | } |
| 542 | }; |
| 543 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 544 | private int mDisabledUnmodified1; |
| 545 | private int mDisabledUnmodified2; |
Jorim Jaggi | b13d36d | 2014-06-06 18:03:52 +0200 | [diff] [blame] | 546 | |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 547 | /** Keys of notifications currently visible to the user. */ |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 548 | private final ArraySet<NotificationVisibility> mCurrentlyVisibleNotifications = |
| 549 | new ArraySet<>(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 550 | private long mLastVisibilityReportUptimeMs; |
| 551 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 552 | private final ShadeUpdates mShadeUpdates = new ShadeUpdates(); |
| 553 | |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 554 | private Runnable mLaunchTransitionEndRunnable; |
| 555 | private boolean mLaunchTransitionFadingAway; |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 556 | private ExpandableNotificationRow mDraggedDownRow; |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 557 | private boolean mLaunchCameraOnScreenTurningOn; |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 558 | private boolean mLaunchCameraOnFinishedGoingToSleep; |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 559 | private int mLastCameraLaunchSource; |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 560 | private PowerManager.WakeLock mGestureWakeLock; |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 561 | private Vibrator mVibrator; |
Jorim Jaggi | 362dd6d | 2014-07-09 19:04:07 +0200 | [diff] [blame] | 562 | |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 563 | // Fingerprint (as computed by getLoggingFingerprint() of the last logged state. |
| 564 | private int mLastLoggedStateFingerprint; |
| 565 | |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 566 | /** |
| 567 | * If set, the device has started going to sleep but isn't fully non-interactive yet. |
| 568 | */ |
| 569 | protected boolean mStartedGoingToSleep; |
| 570 | |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 571 | private final OnChildLocationsChangedListener mNotificationLocationsChangedListener = |
| 572 | new OnChildLocationsChangedListener() { |
| 573 | @Override |
| 574 | public void onChildLocationsChanged( |
| 575 | NotificationStackScrollLayout stackScrollLayout) { |
| 576 | if (mHandler.hasCallbacks(mVisibilityReporter)) { |
| 577 | // Visibilities will be reported when the existing |
| 578 | // callback is executed. |
| 579 | return; |
| 580 | } |
| 581 | // Calculate when we're allowed to run the visibility |
| 582 | // reporter. Note that this timestamp might already have |
| 583 | // passed. That's OK, the callback will just be executed |
| 584 | // ASAP. |
| 585 | long nextReportUptimeMs = |
| 586 | mLastVisibilityReportUptimeMs + VISIBILITY_REPORT_MIN_DELAY_MS; |
| 587 | mHandler.postAtTime(mVisibilityReporter, nextReportUptimeMs); |
| 588 | } |
| 589 | }; |
| 590 | |
| 591 | // Tracks notifications currently visible in mNotificationStackScroller and |
| 592 | // emits visibility events via NoMan on changes. |
| 593 | private final Runnable mVisibilityReporter = new Runnable() { |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 594 | private final ArraySet<NotificationVisibility> mTmpNewlyVisibleNotifications = |
| 595 | new ArraySet<>(); |
| 596 | private final ArraySet<NotificationVisibility> mTmpCurrentlyVisibleNotifications = |
| 597 | new ArraySet<>(); |
| 598 | private final ArraySet<NotificationVisibility> mTmpNoLongerVisibleNotifications = |
| 599 | new ArraySet<>(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 600 | |
| 601 | @Override |
| 602 | public void run() { |
| 603 | mLastVisibilityReportUptimeMs = SystemClock.uptimeMillis(); |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 604 | final String mediaKey = getCurrentMediaNotificationKey(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 605 | |
| 606 | // 1. Loop over mNotificationData entries: |
| 607 | // A. Keep list of visible notifications. |
| 608 | // B. Keep list of previously hidden, now visible notifications. |
| 609 | // 2. Compute no-longer visible notifications by removing currently |
| 610 | // visible notifications from the set of previously visible |
| 611 | // notifications. |
| 612 | // 3. Report newly visible and no-longer visible notifications. |
| 613 | // 4. Keep currently visible notifications for next report. |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 614 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
| 615 | int N = activeNotifications.size(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 616 | for (int i = 0; i < N; i++) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 617 | Entry entry = activeNotifications.get(i); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 618 | String key = entry.notification.getKey(); |
Selim Cinek | add9526 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 619 | boolean isVisible = mStackScroller.isInVisibleLocation(entry.row); |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 620 | NotificationVisibility visObj = NotificationVisibility.obtain(key, i, isVisible); |
| 621 | boolean previouslyVisible = mCurrentlyVisibleNotifications.contains(visObj); |
| 622 | if (isVisible) { |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 623 | // Build new set of visible notifications. |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 624 | mTmpCurrentlyVisibleNotifications.add(visObj); |
| 625 | if (!previouslyVisible) { |
| 626 | mTmpNewlyVisibleNotifications.add(visObj); |
| 627 | } |
| 628 | } else { |
| 629 | // release object |
| 630 | visObj.recycle(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 631 | } |
| 632 | } |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 633 | mTmpNoLongerVisibleNotifications.addAll(mCurrentlyVisibleNotifications); |
| 634 | mTmpNoLongerVisibleNotifications.removeAll(mTmpCurrentlyVisibleNotifications); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 635 | |
| 636 | logNotificationVisibilityChanges( |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 637 | mTmpNewlyVisibleNotifications, mTmpNoLongerVisibleNotifications); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 638 | |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 639 | recycleAllVisibilityObjects(mCurrentlyVisibleNotifications); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 640 | mCurrentlyVisibleNotifications.addAll(mTmpCurrentlyVisibleNotifications); |
| 641 | |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 642 | recycleAllVisibilityObjects(mTmpNoLongerVisibleNotifications); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 643 | mTmpCurrentlyVisibleNotifications.clear(); |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 644 | mTmpNewlyVisibleNotifications.clear(); |
| 645 | mTmpNoLongerVisibleNotifications.clear(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 646 | } |
| 647 | }; |
| 648 | |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 649 | private void recycleAllVisibilityObjects(ArraySet<NotificationVisibility> array) { |
| 650 | final int N = array.size(); |
| 651 | for (int i = 0 ; i < N; i++) { |
| 652 | array.valueAt(i).recycle(); |
| 653 | } |
| 654 | array.clear(); |
| 655 | } |
| 656 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 657 | private final View.OnClickListener mOverflowClickListener = new View.OnClickListener() { |
| 658 | @Override |
| 659 | public void onClick(View v) { |
| 660 | goToLockedShade(null); |
| 661 | } |
| 662 | }; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 663 | private HashMap<ExpandableNotificationRow, List<ExpandableNotificationRow>> mTmpChildOrderMap |
| 664 | = new HashMap<>(); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 665 | private RankingMap mLatestRankingMap; |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 666 | private boolean mNoAnimationOnNextBarModeChange; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 667 | private FalsingManager mFalsingManager; |
Jorim Jaggi | 4e723e6 | 2016-12-14 11:02:39 -0800 | [diff] [blame] | 668 | private long mLastLockToAppLongPress; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 669 | |
Selim Cinek | 9941539 | 2016-09-09 14:58:41 -0700 | [diff] [blame] | 670 | private KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() { |
| 671 | @Override |
| 672 | public void onDreamingStateChanged(boolean dreaming) { |
| 673 | if (dreaming) { |
| 674 | maybeEscalateHeadsUp(); |
| 675 | } |
| 676 | } |
| 677 | }; |
| 678 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 679 | @Override |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 680 | public void start() { |
| 681 | mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)) |
| 682 | .getDefaultDisplay(); |
Daniel Sandler | 7e8ae50 | 2013-10-10 23:38:19 -0400 | [diff] [blame] | 683 | updateDisplaySize(); |
Jorim Jaggi | 0e66439 | 2014-09-27 01:30:22 +0200 | [diff] [blame] | 684 | mScrimSrcModeEnabled = mContext.getResources().getBoolean( |
| 685 | R.bool.config_status_bar_scrim_behind_use_src); |
Adrian Roos | 75fa385 | 2015-01-27 20:21:44 +0100 | [diff] [blame] | 686 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 687 | super.start(); // calls createAndAddWindows() |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 688 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 689 | mMediaSessionManager |
| 690 | = (MediaSessionManager) mContext.getSystemService(Context.MEDIA_SESSION_SERVICE); |
| 691 | // TODO: use MediaSessionManager.SessionListener to hook us up to future updates |
| 692 | // in session state |
| 693 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 694 | addNavigationBar(); |
| 695 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 696 | // Lastly, call to the icon policy to install/update all the icons. |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 697 | mIconPolicy = new PhoneStatusBarPolicy(mContext, mIconController, mCastController, |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 698 | mHotspotController, mUserInfoController, mBluetoothController, |
Jason Monk | f23aa99 | 2016-01-22 16:45:21 -0500 | [diff] [blame] | 699 | mRotationLockController, mNetworkController.getDataSaverController()); |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 700 | mIconPolicy.setCurrentUserSetup(mUserSetup); |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 701 | mSettingsObserver.onChange(false); // set up |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 702 | |
| 703 | mHeadsUpObserver.onChange(true); // set up |
| 704 | if (ENABLE_HEADS_UP) { |
| 705 | mContext.getContentResolver().registerContentObserver( |
Chris Wren | 10d82df | 2014-03-01 10:34:51 -0500 | [diff] [blame] | 706 | Settings.Global.getUriFor(Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED), true, |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 707 | mHeadsUpObserver); |
Chris Wren | 22ae46e | 2014-02-26 18:08:09 -0500 | [diff] [blame] | 708 | mContext.getContentResolver().registerContentObserver( |
| 709 | Settings.Global.getUriFor(SETTING_HEADS_UP_TICKER), true, |
| 710 | mHeadsUpObserver); |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 711 | } |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 712 | mUnlockMethodCache = UnlockMethodCache.getInstance(mContext); |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 713 | mUnlockMethodCache.addListener(this); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 714 | startKeyguard(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 715 | |
Selim Cinek | 9941539 | 2016-09-09 14:58:41 -0700 | [diff] [blame] | 716 | KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateCallback); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 717 | mDozeServiceHost = new DozeServiceHost(); |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 718 | putComponent(DozeHost.class, mDozeServiceHost); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 719 | putComponent(PhoneStatusBar.class, this); |
John Spurlock | 89f060a | 2014-07-16 21:03:15 -0400 | [diff] [blame] | 720 | |
| 721 | setControllerUsers(); |
Chris Wren | cd8f4f7 | 2014-08-27 18:48:13 -0400 | [diff] [blame] | 722 | |
| 723 | notifyUserAboutHiddenNotifications(); |
Jason Monk | 18f99d9 | 2014-09-11 13:36:42 -0400 | [diff] [blame] | 724 | |
| 725 | mScreenPinningRequest = new ScreenPinningRequest(mContext); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 726 | mFalsingManager = FalsingManager.getInstance(mContext); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 727 | } |
| 728 | |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 729 | protected void createIconController() { |
| 730 | mIconController = new StatusBarIconController( |
| 731 | mContext, mStatusBarView, mKeyguardStatusBar, this); |
| 732 | } |
| 733 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 734 | // ================================================================================ |
| 735 | // Constructing the view |
| 736 | // ================================================================================ |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 737 | protected PhoneStatusBarView makeStatusBarView() { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 738 | final Context context = mContext; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 739 | |
Daniel Sandler | 6e8db88 | 2011-10-26 15:40:51 -0400 | [diff] [blame] | 740 | updateDisplaySize(); // populates mDisplayMetrics |
Jorim Jaggi | 2e115c5 | 2014-07-01 21:27:58 +0200 | [diff] [blame] | 741 | updateResources(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 742 | |
Xiaohui Chen | d839d1a | 2016-01-21 13:05:02 -0800 | [diff] [blame] | 743 | inflateStatusBarWindow(context); |
Selim Cinek | 4e6b2d3 | 2015-06-25 20:15:33 -0400 | [diff] [blame] | 744 | mStatusBarWindow.setService(this); |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 745 | mStatusBarWindow.setOnTouchListener(new View.OnTouchListener() { |
| 746 | @Override |
| 747 | public boolean onTouch(View v, MotionEvent event) { |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 748 | checkUserAutohide(v, event); |
Adrian Roos | 6d53de6 | 2016-12-19 16:17:50 -0800 | [diff] [blame] | 749 | checkRemoteInputOutside(event); |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 750 | if (event.getAction() == MotionEvent.ACTION_DOWN) { |
Daniel Sandler | 37a38aa | 2013-02-13 17:15:57 -0500 | [diff] [blame] | 751 | if (mExpandedVisible) { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 752 | animateCollapsePanels(); |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 753 | } |
| 754 | } |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame] | 755 | return mStatusBarWindow.onTouchEvent(event); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 756 | } |
| 757 | }); |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 758 | |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 759 | mNotificationPanel = (NotificationPanelView) mStatusBarWindow.findViewById( |
| 760 | R.id.notification_panel); |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 761 | mNotificationPanel.setStatusBar(this); |
Selim Cinek | 53f8e7d | 2016-03-25 02:28:01 -0700 | [diff] [blame] | 762 | mNotificationPanel.setGroupManager(mGroupManager); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 763 | |
Xiaohui Chen | 9f96711 | 2016-01-07 14:14:06 -0800 | [diff] [blame] | 764 | mStatusBarView = (PhoneStatusBarView) mStatusBarWindow.findViewById(R.id.status_bar); |
| 765 | mStatusBarView.setBar(this); |
| 766 | mStatusBarView.setPanel(mNotificationPanel); |
| 767 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 768 | if (!ActivityManager.isHighEndGfx()) { |
Romain Guy | 328b358 | 2012-05-08 15:30:57 -0700 | [diff] [blame] | 769 | mStatusBarWindow.setBackground(null); |
Alan Viverette | 4a357cd | 2015-03-18 18:37:18 -0700 | [diff] [blame] | 770 | mNotificationPanel.setBackground(new FastColorDrawable(context.getColor( |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 771 | R.color.notification_panel_solid_background))); |
Romain Guy | 328b358 | 2012-05-08 15:30:57 -0700 | [diff] [blame] | 772 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 773 | |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 774 | mHeadsUpManager = new HeadsUpManager(context, mStatusBarWindow, mGroupManager); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 775 | mHeadsUpManager.setBar(this); |
| 776 | mHeadsUpManager.addListener(this); |
| 777 | mHeadsUpManager.addListener(mNotificationPanel); |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 778 | mHeadsUpManager.addListener(mGroupManager); |
Selim Cinek | add9526 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 779 | mHeadsUpManager.addListener(mVisualStabilityManager); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 780 | mNotificationPanel.setHeadsUpManager(mHeadsUpManager); |
Selim Cinek | fbe9a44 | 2015-04-13 16:09:49 -0700 | [diff] [blame] | 781 | mNotificationData.setHeadsUpManager(mHeadsUpManager); |
Selim Cinek | 967ed2a | 2016-04-08 18:29:11 -0700 | [diff] [blame] | 782 | mGroupManager.setHeadsUpManager(mHeadsUpManager); |
Selim Cinek | add9526 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 783 | mHeadsUpManager.setVisualStabilityManager(mVisualStabilityManager); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 784 | |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 785 | if (MULTIUSER_DEBUG) { |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 786 | mNotificationPanelDebugText = (TextView) mNotificationPanel.findViewById( |
| 787 | R.id.header_debug_info); |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 788 | mNotificationPanelDebugText.setVisibility(View.VISIBLE); |
| 789 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 790 | |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 791 | try { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 792 | boolean showNav = mWindowManagerService.hasNavigationBar(); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 793 | if (DEBUG) Log.v(TAG, "hasNavigationBar=" + showNav); |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 794 | if (showNav) { |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 795 | createNavigationBarView(context); |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 796 | } |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 797 | } catch (RemoteException ex) { |
| 798 | // no window manager? good luck with that |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 799 | } |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 800 | |
Annie Chin | 937a991 | 2016-05-31 10:14:23 -0700 | [diff] [blame] | 801 | mAssistManager = SystemUIFactory.getInstance().createAssistManager(this, context); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 802 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 803 | // figure out which pixel-format to use for the status bar. |
Daniel Sandler | f733c2a | 2011-09-25 15:03:40 -0400 | [diff] [blame] | 804 | mPixelFormat = PixelFormat.OPAQUE; |
Daniel Sandler | 173bae2 | 2012-09-25 14:37:42 -0400 | [diff] [blame] | 805 | |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 806 | mStackScroller = (NotificationStackScrollLayout) mStatusBarWindow.findViewById( |
| 807 | R.id.notification_stack_scroller); |
| 808 | mStackScroller.setLongPressListener(getNotificationLongClicker()); |
Selim Cinek | 19c8c70 | 2014-08-25 22:09:19 +0200 | [diff] [blame] | 809 | mStackScroller.setPhoneStatusBar(this); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 810 | mStackScroller.setGroupManager(mGroupManager); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 811 | mStackScroller.setHeadsUpManager(mHeadsUpManager); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 812 | mGroupManager.setOnGroupChangeListener(mStackScroller); |
Selim Cinek | add9526 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 813 | mVisualStabilityManager.setVisibilityLocationProvider(mStackScroller); |
Selim Cinek | 80a14e5 | 2014-03-27 16:58:04 +0100 | [diff] [blame] | 814 | |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 815 | inflateOverflowContainer(); |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 816 | inflateEmptyShadeView(); |
| 817 | inflateDismissView(); |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 818 | mExpandedContents = mStackScroller; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 819 | |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 820 | mBackdrop = (BackDropView) mStatusBarWindow.findViewById(R.id.backdrop); |
| 821 | mBackdropFront = (ImageView) mBackdrop.findViewById(R.id.backdrop_front); |
| 822 | mBackdropBack = (ImageView) mBackdrop.findViewById(R.id.backdrop_back); |
| 823 | |
Jorim Jaggi | e31f6b8 | 2016-07-01 16:15:09 -0700 | [diff] [blame] | 824 | if (ENABLE_LOCKSCREEN_WALLPAPER) { |
| 825 | mLockscreenWallpaper = new LockscreenWallpaper(mContext, this, mHandler); |
| 826 | } |
| 827 | |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 828 | ScrimView scrimBehind = (ScrimView) mStatusBarWindow.findViewById(R.id.scrim_behind); |
| 829 | ScrimView scrimInFront = (ScrimView) mStatusBarWindow.findViewById(R.id.scrim_in_front); |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 830 | View headsUpScrim = mStatusBarWindow.findViewById(R.id.heads_up_scrim); |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 831 | mScrimController = SystemUIFactory.getInstance().createScrimController( |
Jorim Jaggi | e31f6b8 | 2016-07-01 16:15:09 -0700 | [diff] [blame] | 832 | scrimBehind, scrimInFront, headsUpScrim, mLockscreenWallpaper); |
Selim Cinek | 2550325 | 2016-03-03 15:31:43 -0800 | [diff] [blame] | 833 | if (mScrimSrcModeEnabled) { |
| 834 | Runnable runnable = new Runnable() { |
| 835 | @Override |
| 836 | public void run() { |
| 837 | boolean asSrc = mBackdrop.getVisibility() != View.VISIBLE; |
| 838 | mScrimController.setDrawBehindAsSrc(asSrc); |
| 839 | mStackScroller.setDrawBackgroundAsSrc(asSrc); |
| 840 | } |
| 841 | }; |
| 842 | mBackdrop.setOnVisibilityChangedRunnable(runnable); |
| 843 | runnable.run(); |
| 844 | } |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 845 | mHeadsUpManager.addListener(mScrimController); |
| 846 | mStackScroller.setScrimController(mScrimController); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 847 | mStatusBarView.setScrimController(mScrimController); |
Jorim Jaggi | 048af1f | 2014-11-11 22:51:10 +0100 | [diff] [blame] | 848 | mDozeScrimController = new DozeScrimController(mScrimController, context); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 849 | |
Jorim Jaggi | 4538027d | 2014-07-30 15:43:13 +0200 | [diff] [blame] | 850 | mKeyguardStatusBar = (KeyguardStatusBarView) mStatusBarWindow.findViewById(R.id.keyguard_header); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 851 | mKeyguardStatusView = mStatusBarWindow.findViewById(R.id.keyguard_status_view); |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 852 | mKeyguardBottomArea = |
| 853 | (KeyguardBottomAreaView) mStatusBarWindow.findViewById(R.id.keyguard_bottom_area); |
| 854 | mKeyguardBottomArea.setActivityStarter(this); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 855 | mKeyguardBottomArea.setAssistManager(mAssistManager); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 856 | mKeyguardIndicationController = new KeyguardIndicationController(mContext, |
| 857 | (KeyguardIndicationTextView) mStatusBarWindow.findViewById( |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 858 | R.id.keyguard_indication_text), |
| 859 | mKeyguardBottomArea.getLockIcon()); |
Adrian Roos | 4ebcdfd | 2014-08-12 23:33:49 +0200 | [diff] [blame] | 860 | mKeyguardBottomArea.setKeyguardIndicationController(mKeyguardIndicationController); |
Daniel Sandler | e111ad3 | 2012-10-13 15:17:45 -0400 | [diff] [blame] | 861 | |
Xiaohui Chen | f43491f | 2016-02-01 12:19:35 -0800 | [diff] [blame] | 862 | // set the initial view visibility |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 863 | setAreThereNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 864 | |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 865 | createIconController(); |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 866 | |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 867 | // Background thread for any controllers that need it. |
| 868 | mHandlerThread = new HandlerThread(TAG, Process.THREAD_PRIORITY_BACKGROUND); |
| 869 | mHandlerThread.start(); |
| 870 | |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 871 | // Other icons |
Jason Monk | 05b86bc | 2015-05-19 14:21:28 -0400 | [diff] [blame] | 872 | mLocationController = new LocationControllerImpl(mContext, |
| 873 | mHandlerThread.getLooper()); // will post a notification |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 874 | mBatteryController = createBatteryController(); |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 875 | mBatteryController.addStateChangedCallback(new BatteryStateChangeCallback() { |
| 876 | @Override |
Jason Monk | c06fbb1 | 2016-01-08 14:12:18 -0500 | [diff] [blame] | 877 | public void onPowerSaveChanged(boolean isPowerSave) { |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 878 | mHandler.post(mCheckBarModes); |
John Spurlock | d96179e | 2014-08-21 16:43:45 -0400 | [diff] [blame] | 879 | if (mDozeServiceHost != null) { |
Jason Monk | c06fbb1 | 2016-01-08 14:12:18 -0500 | [diff] [blame] | 880 | mDozeServiceHost.firePowerSaveChanged(isPowerSave); |
John Spurlock | d96179e | 2014-08-21 16:43:45 -0400 | [diff] [blame] | 881 | } |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 882 | } |
| 883 | @Override |
| 884 | public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) { |
| 885 | // noop |
| 886 | } |
| 887 | }); |
Jason Monk | 30d8004 | 2015-05-08 16:54:18 -0400 | [diff] [blame] | 888 | mNetworkController = new NetworkControllerImpl(mContext, mHandlerThread.getLooper()); |
Jason Monk | fd57ea7 | 2016-04-29 13:37:58 -0400 | [diff] [blame] | 889 | mNetworkController.setUserSetupComplete(mUserSetup); |
Jason Monk | 51e4dc0 | 2014-07-22 12:00:47 -0400 | [diff] [blame] | 890 | mHotspotController = new HotspotControllerImpl(mContext); |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 891 | mBluetoothController = new BluetoothControllerImpl(mContext, mHandlerThread.getLooper()); |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 892 | mSecurityController = new SecurityControllerImpl(mContext); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 893 | if (mContext.getResources().getBoolean(R.bool.config_showRotationLock)) { |
| 894 | mRotationLockController = new RotationLockControllerImpl(mContext); |
John Spurlock | 8ab172e | 2013-12-19 16:39:23 -0500 | [diff] [blame] | 895 | } |
Jorim Jaggi | 3d878be | 2014-05-10 03:22:32 +0200 | [diff] [blame] | 896 | mUserInfoController = new UserInfoController(mContext); |
John Spurlock | 8600534 | 2014-05-23 11:58:00 -0400 | [diff] [blame] | 897 | mVolumeComponent = getComponent(VolumeComponent.class); |
John Spurlock | f2565a8 | 2014-10-23 20:16:22 -0400 | [diff] [blame] | 898 | if (mVolumeComponent != null) { |
| 899 | mZenModeController = mVolumeComponent.getZenController(); |
| 900 | } |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 901 | mCastController = new CastControllerImpl(mContext); |
Xiaohui Chen | 1094230 | 2015-12-16 16:38:13 -0800 | [diff] [blame] | 902 | |
| 903 | initSignalCluster(mStatusBarView); |
| 904 | initSignalCluster(mKeyguardStatusBar); |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 905 | initEmergencyCryptkeeperText(); |
Daniel Sandler | dd4ef49 | 2012-07-27 11:19:52 -0400 | [diff] [blame] | 906 | |
Adrian Roos | b83777b | 2014-06-30 15:11:53 +0200 | [diff] [blame] | 907 | mFlashlightController = new FlashlightController(mContext); |
Adrian Roos | 1e1d6ac | 2014-07-22 17:18:55 +0200 | [diff] [blame] | 908 | mKeyguardBottomArea.setFlashlightController(mFlashlightController); |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 909 | mKeyguardBottomArea.setPhoneStatusBar(this); |
Adrian Roos | a4eba9f | 2015-07-22 18:13:04 -0700 | [diff] [blame] | 910 | mKeyguardBottomArea.setUserSetupComplete(mUserSetup); |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 911 | mAccessibilityController = new AccessibilityController(mContext); |
| 912 | mKeyguardBottomArea.setAccessibilityController(mAccessibilityController); |
Jorim Jaggi | c7dea6e | 2014-07-26 14:36:57 +0200 | [diff] [blame] | 913 | mNextAlarmController = new NextAlarmController(mContext); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 914 | mLightStatusBarController = new LightStatusBarController(mIconController, |
| 915 | mBatteryController); |
Jason Monk | 8a3a964 | 2015-06-05 11:01:30 -0400 | [diff] [blame] | 916 | mKeyguardMonitor = new KeyguardMonitor(mContext); |
Amith Yamasani | 6947636 | 2016-07-13 11:59:16 -0700 | [diff] [blame] | 917 | mUserSwitcherController = new UserSwitcherController(mContext, mKeyguardMonitor, |
| 918 | mHandler, this); |
Fyodor Kupolov | cd86ebf | 2015-09-29 17:06:50 -0700 | [diff] [blame] | 919 | if (UserManager.get(mContext).isUserSwitcherEnabled()) { |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 920 | createUserSwitcher(); |
Adrian Roos | 2b154a9 | 2014-11-17 15:18:39 +0100 | [diff] [blame] | 921 | } |
Adrian Roos | 723632e | 2014-07-23 21:13:21 +0200 | [diff] [blame] | 922 | |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 923 | // Set up the quick settings tile panel |
Clara Bayarri | 9b1fdff | 2016-04-21 14:28:47 +0100 | [diff] [blame] | 924 | AutoReinflateContainer container = (AutoReinflateContainer) mStatusBarWindow.findViewById( |
| 925 | R.id.qs_auto_reinflate_container); |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 926 | if (container != null) { |
Xiaohui Chen | 311b98e | 2016-03-30 11:55:54 -0700 | [diff] [blame] | 927 | final QSTileHost qsh = SystemUIFactory.getInstance().createQSTileHost(mContext, this, |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 928 | mBluetoothController, mLocationController, mRotationLockController, |
Jason Monk | 51e4dc0 | 2014-07-22 12:00:47 -0400 | [diff] [blame] | 929 | mNetworkController, mZenModeController, mHotspotController, |
John Spurlock | 657c62c | 2014-07-22 12:18:09 -0400 | [diff] [blame] | 930 | mCastController, mFlashlightController, |
Jason Monk | abe1974 | 2015-09-29 09:47:06 -0400 | [diff] [blame] | 931 | mUserSwitcherController, mUserInfoController, mKeyguardMonitor, |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 932 | mSecurityController, mBatteryController, mIconController, |
| 933 | mNextAlarmController); |
Adrian Roos | 5fd872e | 2014-08-12 17:28:58 +0200 | [diff] [blame] | 934 | mBrightnessMirrorController = new BrightnessMirrorController(mStatusBarWindow); |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 935 | container.addInflateListener(new InflateListener() { |
John Spurlock | bceed06 | 2014-08-10 18:04:16 -0400 | [diff] [blame] | 936 | @Override |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 937 | public void onInflated(View v) { |
| 938 | QSContainer qsContainer = (QSContainer) v.findViewById( |
| 939 | R.id.quick_settings_container); |
| 940 | qsContainer.setHost(qsh); |
| 941 | mQSPanel = qsContainer.getQsPanel(); |
| 942 | mQSPanel.setBrightnessMirror(mBrightnessMirrorController); |
Kaori Katou | ccf08d7 | 2015-05-26 16:25:04 +0900 | [diff] [blame] | 943 | mKeyguardStatusBar.setQSPanel(mQSPanel); |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 944 | mHeader = qsContainer.getHeader(); |
| 945 | initSignalCluster(mHeader); |
| 946 | mHeader.setActivityStarter(PhoneStatusBar.this); |
John Spurlock | bceed06 | 2014-08-10 18:04:16 -0400 | [diff] [blame] | 947 | } |
| 948 | }); |
Siva Velusamy | 537421b | 2012-09-14 14:45:02 -0700 | [diff] [blame] | 949 | } |
| 950 | |
Jorim Jaggi | 3d878be | 2014-05-10 03:22:32 +0200 | [diff] [blame] | 951 | // User info. Trigger first load. |
Jorim Jaggi | 4538027d | 2014-07-30 15:43:13 +0200 | [diff] [blame] | 952 | mKeyguardStatusBar.setUserInfoController(mUserInfoController); |
Adrian Roos | ffc9097 | 2015-06-09 18:09:49 -0700 | [diff] [blame] | 953 | mKeyguardStatusBar.setUserSwitcherController(mUserSwitcherController); |
Jorim Jaggi | 3d878be | 2014-05-10 03:22:32 +0200 | [diff] [blame] | 954 | mUserInfoController.reloadUserInfo(); |
| 955 | |
Jorim Jaggi | 708f772 | 2014-08-20 17:30:38 +0200 | [diff] [blame] | 956 | ((BatteryMeterView) mStatusBarView.findViewById(R.id.battery)).setBatteryController( |
| 957 | mBatteryController); |
Jorim Jaggi | 4538027d | 2014-07-30 15:43:13 +0200 | [diff] [blame] | 958 | mKeyguardStatusBar.setBatteryController(mBatteryController); |
Jorim Jaggi | 853b070 | 2014-07-05 04:31:14 +0200 | [diff] [blame] | 959 | |
Adrian Roos | 7bb38a9 | 2016-07-21 11:44:01 -0700 | [diff] [blame] | 960 | mReportRejectedTouch = mStatusBarWindow.findViewById(R.id.report_rejected_touch); |
| 961 | if (mReportRejectedTouch != null) { |
| 962 | updateReportRejectedTouchVisibility(); |
| 963 | mReportRejectedTouch.setOnClickListener(v -> { |
| 964 | Uri session = mFalsingManager.reportRejectedTouch(); |
| 965 | if (session == null) { return; } |
| 966 | |
| 967 | StringWriter message = new StringWriter(); |
| 968 | message.write("Build info: "); |
| 969 | message.write(SystemProperties.get("ro.build.description")); |
| 970 | message.write("\nSerial number: "); |
| 971 | message.write(SystemProperties.get("ro.serialno")); |
| 972 | message.write("\n"); |
| 973 | |
| 974 | PrintWriter falsingPw = new PrintWriter(message); |
| 975 | FalsingLog.dump(falsingPw); |
| 976 | falsingPw.flush(); |
| 977 | |
| 978 | startActivityDismissingKeyguard(Intent.createChooser(new Intent(Intent.ACTION_SEND) |
| 979 | .setType("*/*") |
| 980 | .putExtra(Intent.EXTRA_SUBJECT, "Rejected touch report") |
| 981 | .putExtra(Intent.EXTRA_STREAM, session) |
| 982 | .putExtra(Intent.EXTRA_TEXT, message.toString()), |
| 983 | "Share rejected touch report") |
| 984 | .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), |
| 985 | true /* onlyProvisioned */, true /* dismissShade */); |
| 986 | }); |
| 987 | } |
| 988 | |
| 989 | |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 990 | PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); |
| 991 | mBroadcastReceiver.onReceive(mContext, |
| 992 | new Intent(pm.isScreenOn() ? Intent.ACTION_SCREEN_ON : Intent.ACTION_SCREEN_OFF)); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 993 | mGestureWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, |
| 994 | "GestureWakeLock"); |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 995 | mVibrator = mContext.getSystemService(Vibrator.class); |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 996 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 997 | // receive broadcasts |
| 998 | IntentFilter filter = new IntentFilter(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 999 | filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); |
| 1000 | filter.addAction(Intent.ACTION_SCREEN_OFF); |
Daniel Sandler | 7f3cf95 | 2012-08-31 14:57:09 -0400 | [diff] [blame] | 1001 | filter.addAction(Intent.ACTION_SCREEN_ON); |
phweiss | 923d2cc | 2016-12-14 21:37:48 +0100 | [diff] [blame] | 1002 | filter.addAction(DevicePolicyManager.ACTION_SHOW_DEVICE_MONITORING_DIALOG); |
Kenny Guy | 44fc65f | 2014-11-28 22:18:14 +0000 | [diff] [blame] | 1003 | context.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1004 | |
Adrian Roos | 8e3e836 | 2015-07-16 19:42:22 -0700 | [diff] [blame] | 1005 | IntentFilter demoFilter = new IntentFilter(); |
| 1006 | if (DEBUG_MEDIA_FAKE_ARTWORK) { |
| 1007 | demoFilter.addAction(ACTION_FAKE_ARTWORK); |
| 1008 | } |
| 1009 | demoFilter.addAction(ACTION_DEMO); |
| 1010 | context.registerReceiverAsUser(mDemoReceiver, UserHandle.ALL, demoFilter, |
| 1011 | android.Manifest.permission.DUMP, null); |
| 1012 | |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 1013 | // listen for USER_SETUP_COMPLETE setting (per-user) |
| 1014 | resetUserSetupObserver(); |
| 1015 | |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 1016 | // disable profiling bars, since they overlap and clutter the output on app windows |
| 1017 | ThreadedRenderer.overrideProperty("disableProfileBars", "true"); |
| 1018 | |
| 1019 | // Private API call to make the shadows look better for Recents |
| 1020 | ThreadedRenderer.overrideProperty("ambientRatio", String.valueOf(1.5f)); |
| 1021 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1022 | return mStatusBarView; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1023 | } |
| 1024 | |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 1025 | private void initEmergencyCryptkeeperText() { |
| 1026 | View emergencyViewStub = mStatusBarWindow.findViewById(R.id.emergency_cryptkeeper_text); |
| 1027 | if (mNetworkController.hasEmergencyCryptKeeperText()) { |
| 1028 | if (emergencyViewStub != null) { |
| 1029 | ((ViewStub) emergencyViewStub).inflate(); |
| 1030 | } |
| 1031 | mNetworkController.addSignalCallback(new NetworkController.SignalCallback() { |
| 1032 | @Override |
| 1033 | public void setIsAirplaneMode(NetworkController.IconState icon) { |
| 1034 | recomputeDisableFlags(true /* animate */); |
| 1035 | } |
| 1036 | }); |
| 1037 | } else if (emergencyViewStub != null) { |
| 1038 | ViewGroup parent = (ViewGroup) emergencyViewStub.getParent(); |
| 1039 | parent.removeView(emergencyViewStub); |
| 1040 | } |
| 1041 | } |
| 1042 | |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 1043 | protected BatteryController createBatteryController() { |
| 1044 | return new BatteryControllerImpl(mContext); |
| 1045 | } |
| 1046 | |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 1047 | private void inflateOverflowContainer() { |
| 1048 | mKeyguardIconOverflowContainer = |
| 1049 | (NotificationOverflowContainer) LayoutInflater.from(mContext).inflate( |
| 1050 | R.layout.status_bar_notification_keyguard_overflow, mStackScroller, false); |
| 1051 | mKeyguardIconOverflowContainer.setOnActivatedListener(this); |
| 1052 | mKeyguardIconOverflowContainer.setOnClickListener(mOverflowClickListener); |
| 1053 | mStackScroller.setOverflowContainer(mKeyguardIconOverflowContainer); |
| 1054 | } |
| 1055 | |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 1056 | @Override |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 1057 | protected void onDensityOrFontScaleChanged() { |
| 1058 | super.onDensityOrFontScaleChanged(); |
| 1059 | mScrimController.onDensityOrFontScaleChanged(); |
| 1060 | mStatusBarView.onDensityOrFontScaleChanged(); |
Adrian Roos | d390b89 | 2016-05-05 10:50:49 -0400 | [diff] [blame] | 1061 | if (mBrightnessMirrorController != null) { |
| 1062 | mBrightnessMirrorController.onDensityOrFontScaleChanged(); |
| 1063 | } |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 1064 | inflateSignalClusters(); |
| 1065 | mIconController.onDensityOrFontScaleChanged(); |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 1066 | inflateDismissView(); |
| 1067 | updateClearAll(); |
| 1068 | inflateEmptyShadeView(); |
| 1069 | updateEmptyShadeView(); |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 1070 | inflateOverflowContainer(); |
Selim Cinek | aa8bbf1 | 2016-05-04 14:13:20 -0700 | [diff] [blame] | 1071 | mStatusBarKeyguardViewManager.onDensityOrFontScaleChanged(); |
Adrian Roos | d390b89 | 2016-05-05 10:50:49 -0400 | [diff] [blame] | 1072 | mUserInfoController.onDensityOrFontScaleChanged(); |
| 1073 | if (mUserSwitcherController != null) { |
| 1074 | mUserSwitcherController.onDensityOrFontScaleChanged(); |
| 1075 | } |
| 1076 | if (mKeyguardUserSwitcher != null) { |
| 1077 | mKeyguardUserSwitcher.onDensityOrFontScaleChanged(); |
| 1078 | } |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 1079 | } |
| 1080 | |
| 1081 | private void inflateSignalClusters() { |
| 1082 | SignalClusterView signalClusterView = reinflateSignalCluster(mStatusBarView); |
| 1083 | mIconController.setSignalCluster(signalClusterView); |
Selim Cinek | 6ebba59 | 2016-05-31 15:28:28 -0700 | [diff] [blame] | 1084 | reinflateSignalCluster(mKeyguardStatusBar); |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 1085 | } |
| 1086 | |
| 1087 | private SignalClusterView reinflateSignalCluster(View view) { |
| 1088 | SignalClusterView signalCluster = |
| 1089 | (SignalClusterView) view.findViewById(R.id.signal_cluster); |
| 1090 | if (signalCluster != null) { |
| 1091 | ViewParent parent = signalCluster.getParent(); |
| 1092 | if (parent instanceof ViewGroup) { |
| 1093 | ViewGroup viewParent = (ViewGroup) parent; |
| 1094 | int index = viewParent.indexOfChild(signalCluster); |
| 1095 | viewParent.removeView(signalCluster); |
| 1096 | SignalClusterView newCluster = (SignalClusterView) LayoutInflater.from(mContext) |
| 1097 | .inflate(R.layout.signal_cluster_view, viewParent, false); |
| 1098 | ViewGroup.MarginLayoutParams layoutParams = |
| 1099 | (ViewGroup.MarginLayoutParams) viewParent.getLayoutParams(); |
| 1100 | layoutParams.setMarginsRelative( |
| 1101 | mContext.getResources().getDimensionPixelSize( |
| 1102 | R.dimen.signal_cluster_margin_start), |
| 1103 | 0, 0, 0); |
| 1104 | newCluster.setLayoutParams(layoutParams); |
| 1105 | newCluster.setSecurityController(mSecurityController); |
| 1106 | newCluster.setNetworkController(mNetworkController); |
| 1107 | viewParent.addView(newCluster, index); |
| 1108 | return newCluster; |
| 1109 | } |
| 1110 | return signalCluster; |
| 1111 | } |
| 1112 | return null; |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 1113 | } |
| 1114 | |
| 1115 | private void inflateEmptyShadeView() { |
| 1116 | mEmptyShadeView = (EmptyShadeView) LayoutInflater.from(mContext).inflate( |
| 1117 | R.layout.status_bar_no_notifications, mStackScroller, false); |
| 1118 | mStackScroller.setEmptyShadeView(mEmptyShadeView); |
| 1119 | } |
| 1120 | |
| 1121 | private void inflateDismissView() { |
| 1122 | mDismissView = (DismissView) LayoutInflater.from(mContext).inflate( |
| 1123 | R.layout.status_bar_notification_dismiss_all, mStackScroller, false); |
| 1124 | mDismissView.setOnButtonClickListener(new View.OnClickListener() { |
| 1125 | @Override |
| 1126 | public void onClick(View v) { |
| 1127 | MetricsLogger.action(mContext, MetricsEvent.ACTION_DISMISS_ALL_NOTES); |
| 1128 | clearAllNotifications(); |
| 1129 | } |
| 1130 | }); |
| 1131 | mStackScroller.setDismissView(mDismissView); |
| 1132 | } |
| 1133 | |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 1134 | protected void createUserSwitcher() { |
| 1135 | mKeyguardUserSwitcher = new KeyguardUserSwitcher(mContext, |
| 1136 | (ViewStub) mStatusBarWindow.findViewById(R.id.keyguard_user_switcher), |
| 1137 | mKeyguardStatusBar, mNotificationPanel, mUserSwitcherController); |
| 1138 | } |
| 1139 | |
Xiaohui Chen | d839d1a | 2016-01-21 13:05:02 -0800 | [diff] [blame] | 1140 | protected void inflateStatusBarWindow(Context context) { |
| 1141 | mStatusBarWindow = (StatusBarWindowView) View.inflate(context, |
| 1142 | R.layout.super_status_bar, null); |
| 1143 | } |
| 1144 | |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 1145 | protected void createNavigationBarView(Context context) { |
Xiaohui Chen | 8bdcd1f | 2016-01-19 13:52:07 -0800 | [diff] [blame] | 1146 | inflateNavigationBarView(context); |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 1147 | mNavigationBarView.setDisabledFlags(mDisabled1); |
| 1148 | mNavigationBarView.setComponents(mRecents, getComponent(Divider.class)); |
| 1149 | mNavigationBarView.setOnVerticalChangedListener( |
| 1150 | new NavigationBarView.OnVerticalChangedListener() { |
| 1151 | @Override |
| 1152 | public void onVerticalChanged(boolean isVertical) { |
| 1153 | if (mAssistManager != null) { |
| 1154 | mAssistManager.onConfigurationChanged(); |
| 1155 | } |
| 1156 | mNotificationPanel.setQsScrimEnabled(!isVertical); |
| 1157 | } |
| 1158 | }); |
| 1159 | mNavigationBarView.setOnTouchListener(new View.OnTouchListener() { |
| 1160 | @Override |
| 1161 | public boolean onTouch(View v, MotionEvent event) { |
| 1162 | checkUserAutohide(v, event); |
| 1163 | return false; |
| 1164 | }}); |
| 1165 | } |
| 1166 | |
Xiaohui Chen | 8bdcd1f | 2016-01-19 13:52:07 -0800 | [diff] [blame] | 1167 | protected void inflateNavigationBarView(Context context) { |
Jason Monk | 4f878ef | 2016-01-23 14:37:38 -0500 | [diff] [blame] | 1168 | mNavigationBarView = (NavigationBarView) View.inflate( |
| 1169 | context, R.layout.navigation_bar, null); |
Xiaohui Chen | 8bdcd1f | 2016-01-19 13:52:07 -0800 | [diff] [blame] | 1170 | } |
| 1171 | |
| 1172 | protected void initSignalCluster(View containerView) { |
Xiaohui Chen | 1094230 | 2015-12-16 16:38:13 -0800 | [diff] [blame] | 1173 | SignalClusterView signalCluster = |
| 1174 | (SignalClusterView) containerView.findViewById(R.id.signal_cluster); |
| 1175 | if (signalCluster != null) { |
Xiaohui Chen | 1094230 | 2015-12-16 16:38:13 -0800 | [diff] [blame] | 1176 | signalCluster.setSecurityController(mSecurityController); |
| 1177 | signalCluster.setNetworkController(mNetworkController); |
| 1178 | } |
| 1179 | } |
| 1180 | |
Muyuan Li | c510b5e | 2016-03-09 17:15:05 -0800 | [diff] [blame] | 1181 | public void clearAllNotifications() { |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1182 | |
| 1183 | // animate-swipe all dismissable notifications, then animate the shade closed |
| 1184 | int numChildren = mStackScroller.getChildCount(); |
| 1185 | |
| 1186 | final ArrayList<View> viewsToHide = new ArrayList<View>(numChildren); |
| 1187 | for (int i = 0; i < numChildren; i++) { |
| 1188 | final View child = mStackScroller.getChildAt(i); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1189 | if (child instanceof ExpandableNotificationRow) { |
| 1190 | if (mStackScroller.canChildBeDismissed(child)) { |
| 1191 | if (child.getVisibility() == View.VISIBLE) { |
| 1192 | viewsToHide.add(child); |
| 1193 | } |
| 1194 | } |
| 1195 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
| 1196 | List<ExpandableNotificationRow> children = row.getNotificationChildren(); |
| 1197 | if (row.areChildrenExpanded() && children != null) { |
| 1198 | for (ExpandableNotificationRow childRow : children) { |
Selim Cinek | 1d35979 | 2017-01-13 14:43:43 -0800 | [diff] [blame] | 1199 | if (mStackScroller.canChildBeDismissed(childRow)) { |
| 1200 | if (childRow.getVisibility() == View.VISIBLE) { |
| 1201 | viewsToHide.add(childRow); |
| 1202 | } |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1203 | } |
| 1204 | } |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1205 | } |
| 1206 | } |
| 1207 | } |
| 1208 | if (viewsToHide.isEmpty()) { |
| 1209 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
| 1210 | return; |
| 1211 | } |
| 1212 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1213 | addPostCollapseAction(new Runnable() { |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1214 | @Override |
| 1215 | public void run() { |
Selim Cinek | 9c17b77 | 2015-07-07 20:37:09 -0700 | [diff] [blame] | 1216 | mStackScroller.setDismissAllInProgress(false); |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1217 | try { |
| 1218 | mBarService.onClearAllNotifications(mCurrentUserId); |
| 1219 | } catch (Exception ex) { } |
| 1220 | } |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1221 | }); |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1222 | |
| 1223 | performDismissAllAnimations(viewsToHide); |
| 1224 | |
| 1225 | } |
| 1226 | |
| 1227 | private void performDismissAllAnimations(ArrayList<View> hideAnimatedList) { |
| 1228 | Runnable animationFinishAction = new Runnable() { |
| 1229 | @Override |
| 1230 | public void run() { |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1231 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
| 1232 | } |
| 1233 | }; |
| 1234 | |
| 1235 | // let's disable our normal animations |
| 1236 | mStackScroller.setDismissAllInProgress(true); |
| 1237 | |
| 1238 | // Decrease the delay for every row we animate to give the sense of |
| 1239 | // accelerating the swipes |
| 1240 | int rowDelayDecrement = 10; |
| 1241 | int currentDelay = 140; |
Selim Cinek | 7d5f374 | 2014-11-07 18:07:49 +0100 | [diff] [blame] | 1242 | int totalDelay = 180; |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1243 | int numItems = hideAnimatedList.size(); |
Selim Cinek | 7d5f374 | 2014-11-07 18:07:49 +0100 | [diff] [blame] | 1244 | for (int i = numItems - 1; i >= 0; i--) { |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1245 | View view = hideAnimatedList.get(i); |
| 1246 | Runnable endRunnable = null; |
Selim Cinek | 7d5f374 | 2014-11-07 18:07:49 +0100 | [diff] [blame] | 1247 | if (i == 0) { |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1248 | endRunnable = animationFinishAction; |
| 1249 | } |
| 1250 | mStackScroller.dismissViewAnimated(view, endRunnable, totalDelay, 260); |
| 1251 | currentDelay = Math.max(50, currentDelay - rowDelayDecrement); |
| 1252 | totalDelay += currentDelay; |
| 1253 | } |
| 1254 | } |
| 1255 | |
John Spurlock | ae641c9 | 2014-06-30 18:11:40 -0400 | [diff] [blame] | 1256 | @Override |
| 1257 | protected void setZenMode(int mode) { |
| 1258 | super.setZenMode(mode); |
| 1259 | if (mIconPolicy != null) { |
| 1260 | mIconPolicy.setZenMode(mode); |
| 1261 | } |
| 1262 | } |
| 1263 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 1264 | protected void startKeyguard() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1265 | Trace.beginSection("PhoneStatusBar#startKeyguard"); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 1266 | KeyguardViewMediator keyguardViewMediator = getComponent(KeyguardViewMediator.class); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 1267 | mFingerprintUnlockController = new FingerprintUnlockController(mContext, |
| 1268 | mStatusBarWindowManager, mDozeScrimController, keyguardViewMediator, |
| 1269 | mScrimController, this); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 1270 | mStatusBarKeyguardViewManager = keyguardViewMediator.registerStatusBar(this, |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 1271 | getBouncerContainer(), mStatusBarWindowManager, mScrimController, |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 1272 | mFingerprintUnlockController); |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 1273 | mKeyguardIndicationController.setStatusBarKeyguardViewManager( |
| 1274 | mStatusBarKeyguardViewManager); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 1275 | mFingerprintUnlockController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager); |
Nicolas Prevot | 1dbbe7d | 2016-05-17 12:52:54 +0100 | [diff] [blame] | 1276 | mIconPolicy.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager); |
Adrian Roos | d28ccd7 | 2016-01-06 15:23:14 +0100 | [diff] [blame] | 1277 | mRemoteInputController.addCallback(mStatusBarKeyguardViewManager); |
Adrian Roos | c0a579e | 2016-03-30 16:43:58 -0700 | [diff] [blame] | 1278 | |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 1279 | mRemoteInputController.addCallback(new RemoteInputController.Callback() { |
| 1280 | @Override |
| 1281 | public void onRemoteInputSent(Entry entry) { |
| 1282 | if (FORCE_REMOTE_INPUT_HISTORY && mKeysKeptForRemoteInput.contains(entry.key)) { |
| 1283 | removeNotification(entry.key, null); |
| 1284 | } else if (mRemoteInputEntriesToRemoveOnCollapse.contains(entry)) { |
| 1285 | // We're currently holding onto this notification, but from the apps point of |
| 1286 | // view it is already canceled, so we'll need to cancel it on the apps behalf |
| 1287 | // after sending - unless the app posts an update in the mean time, so wait a |
| 1288 | // bit. |
| 1289 | mHandler.postDelayed(() -> { |
| 1290 | if (mRemoteInputEntriesToRemoveOnCollapse.remove(entry)) { |
| 1291 | removeNotification(entry.key, null); |
| 1292 | } |
| 1293 | }, REMOTE_INPUT_KEPT_ENTRY_AUTO_CANCEL_DELAY); |
Adrian Roos | c0a579e | 2016-03-30 16:43:58 -0700 | [diff] [blame] | 1294 | } |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 1295 | } |
| 1296 | }); |
Adrian Roos | c0a579e | 2016-03-30 16:43:58 -0700 | [diff] [blame] | 1297 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 1298 | mKeyguardViewMediatorCallback = keyguardViewMediator.getViewMediatorCallback(); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 1299 | mLightStatusBarController.setFingerprintUnlockController(mFingerprintUnlockController); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1300 | Trace.endSection(); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1301 | } |
| 1302 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1303 | @Override |
Michael Jurka | cb2522c | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 1304 | protected View getStatusBarView() { |
| 1305 | return mStatusBarView; |
| 1306 | } |
| 1307 | |
Jorim Jaggi | 0a27be8 | 2014-06-11 03:22:39 +0200 | [diff] [blame] | 1308 | public StatusBarWindowView getStatusBarWindow() { |
| 1309 | return mStatusBarWindow; |
| 1310 | } |
| 1311 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 1312 | protected ViewGroup getBouncerContainer() { |
| 1313 | return mStatusBarWindow; |
| 1314 | } |
| 1315 | |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 1316 | public int getStatusBarHeight() { |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1317 | if (mNaturalBarHeight < 0) { |
| 1318 | final Resources res = mContext.getResources(); |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 1319 | mNaturalBarHeight = |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1320 | res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); |
| 1321 | } |
| 1322 | return mNaturalBarHeight; |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 1323 | } |
| 1324 | |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1325 | private View.OnClickListener mRecentsClickListener = new View.OnClickListener() { |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 1326 | @Override |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1327 | public void onClick(View v) { |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 1328 | awakenDreams(); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1329 | toggleRecentApps(); |
| 1330 | } |
| 1331 | }; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1332 | |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1333 | @Override |
Jorim Jaggi | 29379ec | 2016-04-11 23:43:42 -0700 | [diff] [blame] | 1334 | protected void toggleSplitScreenMode(int metricsDockAction, int metricsUndockAction) { |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1335 | if (mRecents == null) { |
Jorim Jaggi | 29379ec | 2016-04-11 23:43:42 -0700 | [diff] [blame] | 1336 | return; |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1337 | } |
| 1338 | int dockSide = WindowManagerProxy.getInstance().getDockSide(); |
| 1339 | if (dockSide == WindowManager.DOCKED_INVALID) { |
Jorim Jaggi | 29379ec | 2016-04-11 23:43:42 -0700 | [diff] [blame] | 1340 | mRecents.dockTopTask(NavigationBarGestureHelper.DRAG_MODE_NONE, |
| 1341 | ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT, null, metricsDockAction); |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1342 | } else { |
| 1343 | EventBus.getDefault().send(new UndockingTaskEvent()); |
Jorim Jaggi | 29379ec | 2016-04-11 23:43:42 -0700 | [diff] [blame] | 1344 | if (metricsUndockAction != -1) { |
| 1345 | MetricsLogger.action(mContext, metricsUndockAction); |
| 1346 | } |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1347 | } |
| 1348 | } |
| 1349 | |
Jorim Jaggi | 7e6571f | 2015-06-25 11:52:48 -0700 | [diff] [blame] | 1350 | private final View.OnLongClickListener mLongPressHomeListener |
| 1351 | = new View.OnLongClickListener() { |
| 1352 | @Override |
| 1353 | public boolean onLongClick(View v) { |
| 1354 | if (shouldDisableNavbarGestures()) { |
| 1355 | return false; |
| 1356 | } |
Chris Wren | f6e9228b | 2016-01-26 18:04:35 -0500 | [diff] [blame] | 1357 | MetricsLogger.action(mContext, MetricsEvent.ACTION_ASSIST_LONG_PRESS); |
Jorim Jaggi | 165ce06 | 2015-07-06 16:18:11 -0700 | [diff] [blame] | 1358 | mAssistManager.startAssist(new Bundle() /* args */); |
Daniel Sandler | a2fbe53 | 2012-08-10 01:19:03 -0400 | [diff] [blame] | 1359 | awakenDreams(); |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 1360 | if (mNavigationBarView != null) { |
Xiyuan Xia | ee7dd05 | 2015-05-15 09:46:27 -0700 | [diff] [blame] | 1361 | mNavigationBarView.abortCurrentGesture(); |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 1362 | } |
Jorim Jaggi | 7e6571f | 2015-06-25 11:52:48 -0700 | [diff] [blame] | 1363 | return true; |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 1364 | } |
| 1365 | }; |
| 1366 | |
Jorim Jaggi | 7e6571f | 2015-06-25 11:52:48 -0700 | [diff] [blame] | 1367 | private final View.OnTouchListener mHomeActionListener = new View.OnTouchListener() { |
Selim Cinek | 64be772 | 2016-07-22 13:28:16 -0700 | [diff] [blame] | 1368 | public boolean mBlockedThisTouch; |
| 1369 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 1370 | @Override |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 1371 | public boolean onTouch(View v, MotionEvent event) { |
Selim Cinek | 64be772 | 2016-07-22 13:28:16 -0700 | [diff] [blame] | 1372 | if (mBlockedThisTouch && event.getActionMasked() != MotionEvent.ACTION_DOWN) { |
| 1373 | return true; |
| 1374 | } |
| 1375 | // If an incoming call is ringing, HOME is totally disabled. |
| 1376 | // (The user is already on the InCallUI at this point, |
| 1377 | // and his ONLY options are to answer or reject the call.) |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 1378 | switch (event.getAction()) { |
Selim Cinek | 64be772 | 2016-07-22 13:28:16 -0700 | [diff] [blame] | 1379 | case MotionEvent.ACTION_DOWN: |
| 1380 | mBlockedThisTouch = false; |
| 1381 | TelecomManager telecomManager = mContext.getSystemService(TelecomManager.class); |
| 1382 | if (telecomManager != null && telecomManager.isRinging()) { |
| 1383 | if (mStatusBarKeyguardViewManager.isShowing()) { |
| 1384 | Log.i(TAG, "Ignoring HOME; there's a ringing incoming call. " + |
| 1385 | "No heads up"); |
| 1386 | mBlockedThisTouch = true; |
| 1387 | return true; |
| 1388 | } |
| 1389 | } |
| 1390 | break; |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 1391 | case MotionEvent.ACTION_UP: |
| 1392 | case MotionEvent.ACTION_CANCEL: |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 1393 | awakenDreams(); |
| 1394 | break; |
| 1395 | } |
| 1396 | return false; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 1397 | } |
| 1398 | }; |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1399 | |
Daniel Sandler | a2fbe53 | 2012-08-10 01:19:03 -0400 | [diff] [blame] | 1400 | private void awakenDreams() { |
| 1401 | if (mDreamManager != null) { |
| 1402 | try { |
| 1403 | mDreamManager.awaken(); |
| 1404 | } catch (RemoteException e) { |
| 1405 | // fine, stay asleep then |
| 1406 | } |
| 1407 | } |
| 1408 | } |
| 1409 | |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 1410 | private void prepareNavigationBarView() { |
| 1411 | mNavigationBarView.reorient(); |
| 1412 | |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 1413 | ButtonDispatcher recentsButton = mNavigationBarView.getRecentsButton(); |
| 1414 | recentsButton.setOnClickListener(mRecentsClickListener); |
| 1415 | recentsButton.setOnTouchListener(mRecentsPreloadOnTouchListener); |
| 1416 | recentsButton.setLongClickable(true); |
Jorim Jaggi | 4e723e6 | 2016-12-14 11:02:39 -0800 | [diff] [blame] | 1417 | recentsButton.setOnLongClickListener(this::handleLongPressBackRecents); |
Anthony Chen | ada1304 | 2016-01-19 16:57:20 -0800 | [diff] [blame] | 1418 | |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 1419 | ButtonDispatcher backButton = mNavigationBarView.getBackButton(); |
| 1420 | backButton.setLongClickable(true); |
Jorim Jaggi | 4e723e6 | 2016-12-14 11:02:39 -0800 | [diff] [blame] | 1421 | backButton.setOnLongClickListener(this::handleLongPressBackRecents); |
Anthony Chen | ada1304 | 2016-01-19 16:57:20 -0800 | [diff] [blame] | 1422 | |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 1423 | ButtonDispatcher homeButton = mNavigationBarView.getHomeButton(); |
| 1424 | homeButton.setOnTouchListener(mHomeActionListener); |
| 1425 | homeButton.setOnLongClickListener(mLongPressHomeListener); |
Anthony Chen | ada1304 | 2016-01-19 16:57:20 -0800 | [diff] [blame] | 1426 | |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 1427 | mAssistManager.onConfigurationChanged(); |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 1428 | } |
| 1429 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1430 | // For small-screen devices (read: phones) that lack hardware navigation buttons |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 1431 | protected void addNavigationBar() { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 1432 | if (DEBUG) Log.v(TAG, "addNavigationBar: about to add " + mNavigationBarView); |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 1433 | if (mNavigationBarView == null) return; |
Jim Miller | 17dfec7 | 2011-07-08 19:09:55 -0700 | [diff] [blame] | 1434 | |
Adrian Roos | a98b32c | 2016-08-11 10:41:08 -0700 | [diff] [blame] | 1435 | try { |
| 1436 | WindowManagerGlobal.getWindowManagerService() |
| 1437 | .watchRotation(new IRotationWatcher.Stub() { |
| 1438 | @Override |
| 1439 | public void onRotationChanged(int rotation) throws RemoteException { |
| 1440 | // We need this to be scheduled as early as possible to beat the redrawing of |
| 1441 | // window in response to the orientation change. |
| 1442 | Message msg = Message.obtain(mHandler, () -> { |
| 1443 | if (mNavigationBarView != null |
| 1444 | && mNavigationBarView.needsReorient(rotation)) { |
| 1445 | repositionNavigationBar(); |
| 1446 | } |
| 1447 | }); |
| 1448 | msg.setAsynchronous(true); |
| 1449 | mHandler.sendMessageAtFrontOfQueue(msg); |
| 1450 | } |
| 1451 | }); |
| 1452 | } catch (RemoteException e) { |
| 1453 | throw e.rethrowFromSystemServer(); |
| 1454 | } |
| 1455 | |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 1456 | prepareNavigationBarView(); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1457 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1458 | mWindowManager.addView(mNavigationBarView, getNavigationBarLayoutParams()); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1459 | } |
| 1460 | |
Victor Chan | ecdb8b0 | 2016-01-07 18:32:43 -0800 | [diff] [blame] | 1461 | protected void repositionNavigationBar() { |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 1462 | if (mNavigationBarView == null || !mNavigationBarView.isAttachedToWindow()) return; |
Jim Miller | 17dfec7 | 2011-07-08 19:09:55 -0700 | [diff] [blame] | 1463 | |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 1464 | prepareNavigationBarView(); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1465 | |
Jorim Jaggi | 90dfb89 | 2016-07-25 15:57:36 +0200 | [diff] [blame] | 1466 | mWindowManager.updateViewLayout(mNavigationBarView, mNavigationBarView.getLayoutParams()); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1467 | } |
| 1468 | |
John Spurlock | 1bbd49d | 2012-10-19 11:09:32 -0400 | [diff] [blame] | 1469 | private void notifyNavigationBarScreenOn(boolean screenOn) { |
| 1470 | if (mNavigationBarView == null) return; |
| 1471 | mNavigationBarView.notifyScreenOn(screenOn); |
| 1472 | } |
| 1473 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1474 | private WindowManager.LayoutParams getNavigationBarLayoutParams() { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1475 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1476 | LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1477 | WindowManager.LayoutParams.TYPE_NAVIGATION_BAR, |
| 1478 | 0 |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1479 | | WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING |
| 1480 | | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 1481 | | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
Daniel Sandler | c26185b | 2012-08-29 15:49:53 -0400 | [diff] [blame] | 1482 | | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
Jorim Jaggi | c59a23f | 2016-05-24 14:53:36 -0700 | [diff] [blame] | 1483 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH |
| 1484 | | WindowManager.LayoutParams.FLAG_SLIPPERY, |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1485 | PixelFormat.TRANSLUCENT); |
Daniel Sandler | c638c1e | 2011-08-24 16:19:23 -0700 | [diff] [blame] | 1486 | // this will allow the navbar to run in an overlay on devices that support this |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1487 | if (ActivityManager.isHighEndGfx()) { |
Daniel Sandler | c638c1e | 2011-08-24 16:19:23 -0700 | [diff] [blame] | 1488 | lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
| 1489 | } |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1490 | |
| 1491 | lp.setTitle("NavigationBar"); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1492 | lp.windowAnimations = 0; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1493 | return lp; |
| 1494 | } |
| 1495 | |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 1496 | @Override |
| 1497 | public void setIcon(String slot, StatusBarIcon icon) { |
| 1498 | mIconController.setIcon(slot, icon); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1499 | } |
| 1500 | |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 1501 | @Override |
| 1502 | public void removeIcon(String slot) { |
| 1503 | mIconController.removeIcon(slot); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1504 | } |
| 1505 | |
John Spurlock | bf20eab | 2014-04-09 16:40:39 -0400 | [diff] [blame] | 1506 | public UserHandle getCurrentUserHandle() { |
| 1507 | return new UserHandle(mCurrentUserId); |
| 1508 | } |
| 1509 | |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 1510 | @Override |
Selim Cinek | 379ff8f | 2015-02-20 17:03:16 +0100 | [diff] [blame] | 1511 | public void addNotification(StatusBarNotification notification, RankingMap ranking, |
| 1512 | Entry oldEntry) { |
Chris Wren | aaa58d1 | 2014-06-03 14:29:12 -0400 | [diff] [blame] | 1513 | if (DEBUG) Log.d(TAG, "addNotification key=" + notification.getKey()); |
Chris Wren | d4db6cb | 2013-08-07 16:05:23 -0400 | [diff] [blame] | 1514 | |
Julia Reynolds | f612869ae | 2015-11-05 16:48:55 -0500 | [diff] [blame] | 1515 | mNotificationData.updateRanking(ranking); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1516 | Entry shadeEntry = createNotificationViews(notification); |
Chris Wren | a4ef620 | 2014-06-09 18:07:30 -0400 | [diff] [blame] | 1517 | if (shadeEntry == null) { |
| 1518 | return; |
| 1519 | } |
Adrian Roos | f6967e06 | 2016-06-21 16:12:48 -0700 | [diff] [blame] | 1520 | boolean isHeadsUped = shouldPeek(shadeEntry); |
Selim Cinek | 31d9ef7 | 2015-04-15 19:29:49 -0700 | [diff] [blame] | 1521 | if (isHeadsUped) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1522 | mHeadsUpManager.showNotification(shadeEntry); |
Amith Yamasani | f47e51e | 2015-04-17 10:02:15 -0700 | [diff] [blame] | 1523 | // Mark as seen immediately |
| 1524 | setNotificationShown(notification); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1525 | } |
Chris Wren | a4ef620 | 2014-06-09 18:07:30 -0400 | [diff] [blame] | 1526 | |
Selim Cinek | 31d9ef7 | 2015-04-15 19:29:49 -0700 | [diff] [blame] | 1527 | if (!isHeadsUped && notification.getNotification().fullScreenIntent != null) { |
Julia Reynolds | d560729 | 2016-02-05 15:25:58 -0500 | [diff] [blame] | 1528 | if (shouldSuppressFullScreenIntent(notification.getKey())) { |
Julia Reynolds | 6172158 | 2016-01-05 08:35:25 -0500 | [diff] [blame] | 1529 | if (DEBUG) { |
| 1530 | Log.d(TAG, "No Fullscreen intent: suppressed by DND: " + notification.getKey()); |
| 1531 | } |
Julia Reynolds | f0f629f | 2016-02-25 09:34:04 -0500 | [diff] [blame] | 1532 | } else if (mNotificationData.getImportance(notification.getKey()) |
| 1533 | < NotificationListenerService.Ranking.IMPORTANCE_MAX) { |
| 1534 | if (DEBUG) { |
| 1535 | Log.d(TAG, "No Fullscreen intent: not important enough: " |
| 1536 | + notification.getKey()); |
| 1537 | } |
Julia Reynolds | 6172158 | 2016-01-05 08:35:25 -0500 | [diff] [blame] | 1538 | } else { |
| 1539 | // Stop screensaver if the notification has a full-screen intent. |
| 1540 | // (like an incoming phone call) |
| 1541 | awakenDreams(); |
Daniel Sandler | c9ce0ab | 2012-09-04 13:27:09 -0400 | [diff] [blame] | 1542 | |
Julia Reynolds | 6172158 | 2016-01-05 08:35:25 -0500 | [diff] [blame] | 1543 | // not immersive & a full-screen alert should be shown |
| 1544 | if (DEBUG) |
| 1545 | Log.d(TAG, "Notification has fullScreenIntent; sending fullScreenIntent"); |
| 1546 | try { |
| 1547 | EventLog.writeEvent(EventLogTags.SYSUI_FULLSCREEN_NOTIFICATION, |
| 1548 | notification.getKey()); |
| 1549 | notification.getNotification().fullScreenIntent.send(); |
| 1550 | shadeEntry.notifyFullScreenIntentLaunched(); |
| 1551 | MetricsLogger.count(mContext, "note_fullscreen", 1); |
| 1552 | } catch (PendingIntent.CanceledException e) { |
| 1553 | } |
John Spurlock | bf20eab | 2014-04-09 16:40:39 -0400 | [diff] [blame] | 1554 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1555 | } |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1556 | addNotificationViews(shadeEntry, ranking); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1557 | // Recalculate the position of the sliding windows and the titles. |
| 1558 | setAreThereNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1559 | } |
| 1560 | |
Julia Reynolds | d560729 | 2016-02-05 15:25:58 -0500 | [diff] [blame] | 1561 | private boolean shouldSuppressFullScreenIntent(String key) { |
Dan Sandler | dc34df5 | 2016-04-07 21:04:46 -0400 | [diff] [blame] | 1562 | if (isDeviceInVrMode()) { |
| 1563 | return true; |
| 1564 | } |
| 1565 | |
Julia Reynolds | 0971cb0 | 2016-01-26 17:00:22 -0500 | [diff] [blame] | 1566 | if (mPowerManager.isInteractive()) { |
Julia Reynolds | 0971cb0 | 2016-01-26 17:00:22 -0500 | [diff] [blame] | 1567 | return mNotificationData.shouldSuppressScreenOn(key); |
Julia Reynolds | d560729 | 2016-02-05 15:25:58 -0500 | [diff] [blame] | 1568 | } else { |
| 1569 | return mNotificationData.shouldSuppressScreenOff(key); |
Julia Reynolds | 0971cb0 | 2016-01-26 17:00:22 -0500 | [diff] [blame] | 1570 | } |
| 1571 | } |
| 1572 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1573 | @Override |
Christoph Studer | e71fefc | 2014-06-24 16:16:49 +0200 | [diff] [blame] | 1574 | protected void updateNotificationRanking(RankingMap ranking) { |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 1575 | mNotificationData.updateRanking(ranking); |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 1576 | updateNotifications(); |
| 1577 | } |
| 1578 | |
| 1579 | @Override |
Christoph Studer | e71fefc | 2014-06-24 16:16:49 +0200 | [diff] [blame] | 1580 | public void removeNotification(String key, RankingMap ranking) { |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1581 | boolean deferRemoval = false; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1582 | if (mHeadsUpManager.isHeadsUp(key)) { |
Adrian Roos | c721fcc5 | 2016-04-29 11:28:37 -0700 | [diff] [blame] | 1583 | // A cancel() in repsonse to a remote input shouldn't be delayed, as it makes the |
| 1584 | // sending look longer than it takes. |
| 1585 | boolean ignoreEarliestRemovalTime = mRemoteInputController.isSpinning(key) |
| 1586 | && !FORCE_REMOTE_INPUT_HISTORY; |
| 1587 | deferRemoval = !mHeadsUpManager.removeNotification(key, ignoreEarliestRemovalTime); |
Chris Wren | a4ef620 | 2014-06-09 18:07:30 -0400 | [diff] [blame] | 1588 | } |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1589 | if (key.equals(mMediaNotificationKey)) { |
| 1590 | clearCurrentMediaNotification(); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 1591 | updateMediaMetaData(true, true); |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1592 | } |
Adrian Roos | c0a579e | 2016-03-30 16:43:58 -0700 | [diff] [blame] | 1593 | if (FORCE_REMOTE_INPUT_HISTORY && mRemoteInputController.isSpinning(key)) { |
| 1594 | Entry entry = mNotificationData.get(key); |
| 1595 | StatusBarNotification sbn = entry.notification; |
| 1596 | |
| 1597 | Notification.Builder b = Notification.Builder |
| 1598 | .recoverBuilder(mContext, sbn.getNotification().clone()); |
| 1599 | CharSequence[] oldHistory = sbn.getNotification().extras |
| 1600 | .getCharSequenceArray(Notification.EXTRA_REMOTE_INPUT_HISTORY); |
| 1601 | CharSequence[] newHistory; |
| 1602 | if (oldHistory == null) { |
| 1603 | newHistory = new CharSequence[1]; |
| 1604 | } else { |
| 1605 | newHistory = new CharSequence[oldHistory.length + 1]; |
| 1606 | for (int i = 0; i < oldHistory.length; i++) { |
| 1607 | newHistory[i + 1] = oldHistory[i]; |
| 1608 | } |
| 1609 | } |
| 1610 | newHistory[0] = String.valueOf(entry.remoteInputText); |
| 1611 | b.setRemoteInputHistory(newHistory); |
| 1612 | |
| 1613 | Notification newNotification = b.build(); |
| 1614 | |
| 1615 | // Undo any compatibility view inflation |
| 1616 | newNotification.contentView = sbn.getNotification().contentView; |
| 1617 | newNotification.bigContentView = sbn.getNotification().bigContentView; |
| 1618 | newNotification.headsUpContentView = sbn.getNotification().headsUpContentView; |
| 1619 | |
| 1620 | StatusBarNotification newSbn = new StatusBarNotification(sbn.getPackageName(), |
| 1621 | sbn.getOpPkg(), |
| 1622 | sbn.getId(), sbn.getTag(), sbn.getUid(), sbn.getInitialPid(), |
| 1623 | 0, newNotification, sbn.getUser(), sbn.getPostTime()); |
| 1624 | |
| 1625 | updateNotification(newSbn, null); |
| 1626 | mKeysKeptForRemoteInput.add(entry.key); |
| 1627 | return; |
| 1628 | } |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1629 | if (deferRemoval) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1630 | mLatestRankingMap = ranking; |
| 1631 | mHeadsUpEntriesToRemoveOnSwitch.add(mHeadsUpManager.getEntry(key)); |
| 1632 | return; |
| 1633 | } |
Selim Cinek | a570318 | 2016-05-11 21:23:16 -0400 | [diff] [blame] | 1634 | Entry entry = mNotificationData.get(key); |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 1635 | |
Adrian Roos | 9550f2e | 2016-08-23 18:23:01 +0200 | [diff] [blame] | 1636 | if (entry != null && mRemoteInputController.isRemoteInputActive(entry) |
| 1637 | && (entry.row != null && !entry.row.isDismissed())) { |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 1638 | mLatestRankingMap = ranking; |
| 1639 | mRemoteInputEntriesToRemoveOnCollapse.add(entry); |
| 1640 | return; |
| 1641 | } |
| 1642 | |
Selim Cinek | a570318 | 2016-05-11 21:23:16 -0400 | [diff] [blame] | 1643 | if (entry != null && entry.row != null) { |
Adrian Roos | d009ab1 | 2016-05-20 17:58:53 -0700 | [diff] [blame] | 1644 | entry.row.setRemoved(); |
Selim Cinek | a570318 | 2016-05-11 21:23:16 -0400 | [diff] [blame] | 1645 | } |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1646 | // Let's remove the children if this was a summary |
| 1647 | handleGroupSummaryRemoved(key, ranking); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1648 | StatusBarNotification old = removeNotificationViews(key, ranking); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 1649 | if (SPEW) Log.d(TAG, "removeNotification key=" + key + " old=" + old); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1650 | |
| 1651 | if (old != null) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1652 | if (CLOSE_PANEL_WHEN_EMPTIED && !hasActiveNotifications() |
Jorim Jaggi | ba94f88 | 2014-08-20 19:23:55 +0200 | [diff] [blame] | 1653 | && !mNotificationPanel.isTracking() && !mNotificationPanel.isQsExpanded()) { |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 1654 | if (mState == StatusBarState.SHADE) { |
| 1655 | animateCollapsePanels(); |
Selim Cinek | 61b350c | 2016-08-05 14:26:51 -0700 | [diff] [blame] | 1656 | } else if (mState == StatusBarState.SHADE_LOCKED && !isCollapsing()) { |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 1657 | goToKeyguard(); |
| 1658 | } |
Daniel Sandler | 8cc36e5 | 2011-10-17 14:18:46 -0400 | [diff] [blame] | 1659 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1660 | } |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 1661 | setAreThereNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1662 | } |
| 1663 | |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1664 | /** |
| 1665 | * Ensures that the group children are cancelled immediately when the group summary is cancelled |
| 1666 | * instead of waiting for the notification manager to send all cancels. Otherwise this could |
| 1667 | * lead to flickers. |
| 1668 | * |
| 1669 | * This also ensures that the animation looks nice and only consists of a single disappear |
| 1670 | * animation instead of multiple. |
| 1671 | * |
| 1672 | * @param key the key of the notification was removed |
| 1673 | * @param ranking the current ranking |
| 1674 | */ |
| 1675 | private void handleGroupSummaryRemoved(String key, |
| 1676 | RankingMap ranking) { |
| 1677 | Entry entry = mNotificationData.get(key); |
| 1678 | if (entry != null && entry.row != null |
| 1679 | && entry.row.isSummaryWithChildren()) { |
| 1680 | if (entry.notification.getOverrideGroupKey() != null && !entry.row.isDismissed()) { |
| 1681 | // We don't want to remove children for autobundled notifications as they are not |
| 1682 | // always cancelled. We only remove them if they were dismissed by the user. |
| 1683 | return; |
| 1684 | } |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1685 | List<ExpandableNotificationRow> notificationChildren = |
| 1686 | entry.row.getNotificationChildren(); |
Selim Cinek | 1d35979 | 2017-01-13 14:43:43 -0800 | [diff] [blame] | 1687 | ArrayList<ExpandableNotificationRow> toRemove = new ArrayList<>(); |
| 1688 | for (int i = 0; i < notificationChildren.size(); i++) { |
| 1689 | ExpandableNotificationRow row = notificationChildren.get(i); |
| 1690 | if ((row.getStatusBarNotification().getNotification().flags |
| 1691 | & Notification.FLAG_FOREGROUND_SERVICE) != 0) { |
| 1692 | // the child is a forground service notification which we can't remove! |
| 1693 | continue; |
| 1694 | } |
| 1695 | toRemove.add(row); |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1696 | toRemove.get(i).setKeepInParent(true); |
Selim Cinek | a570318 | 2016-05-11 21:23:16 -0400 | [diff] [blame] | 1697 | // we need to set this state earlier as otherwise we might generate some weird |
| 1698 | // animations |
Adrian Roos | d009ab1 | 2016-05-20 17:58:53 -0700 | [diff] [blame] | 1699 | toRemove.get(i).setRemoved(); |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1700 | } |
| 1701 | for (int i = 0; i < toRemove.size(); i++) { |
| 1702 | removeNotification(toRemove.get(i).getStatusBarNotification().getKey(), ranking); |
Selim Cinek | 7103fd4 | 2016-05-09 22:22:33 -0400 | [diff] [blame] | 1703 | // we need to ensure that the view is actually properly removed from the viewstate |
| 1704 | // as this won't happen anymore when kept in the parent. |
| 1705 | mStackScroller.removeViewStateForView(toRemove.get(i)); |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1706 | } |
| 1707 | } |
| 1708 | } |
| 1709 | |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 1710 | @Override |
Selim Cinek | 5e01820 | 2016-12-15 14:44:36 -0800 | [diff] [blame] | 1711 | protected void performRemoveNotification(StatusBarNotification n) { |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 1712 | Entry entry = mNotificationData.get(n.getKey()); |
| 1713 | if (mRemoteInputController.isRemoteInputActive(entry)) { |
Adrian Roos | 7813dd7 | 2016-09-23 17:12:17 -0700 | [diff] [blame] | 1714 | mRemoteInputController.removeRemoteInput(entry, null); |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 1715 | } |
Selim Cinek | 5e01820 | 2016-12-15 14:44:36 -0800 | [diff] [blame] | 1716 | super.performRemoveNotification(n); |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 1717 | } |
| 1718 | |
| 1719 | @Override |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 1720 | protected void refreshLayout(int layoutDirection) { |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 1721 | if (mNavigationBarView != null) { |
| 1722 | mNavigationBarView.setLayoutDirection(layoutDirection); |
| 1723 | } |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 1724 | } |
| 1725 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1726 | private void updateNotificationShade() { |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 1727 | if (mStackScroller == null) return; |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 1728 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1729 | // Do not modify the notifications during collapse. |
| 1730 | if (isCollapsing()) { |
| 1731 | addPostCollapseAction(new Runnable() { |
| 1732 | @Override |
| 1733 | public void run() { |
| 1734 | updateNotificationShade(); |
| 1735 | } |
| 1736 | }); |
| 1737 | return; |
| 1738 | } |
| 1739 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1740 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1741 | ArrayList<ExpandableNotificationRow> toShow = new ArrayList<>(activeNotifications.size()); |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1742 | final int N = activeNotifications.size(); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1743 | for (int i=0; i<N; i++) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1744 | Entry ent = activeNotifications.get(i); |
Selim Cinek | add9526 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 1745 | if (ent.row.isDismissed() || ent.row.isRemoved()) { |
| 1746 | // we don't want to update removed notifications because they could |
| 1747 | // temporarily become children if they were isolated before. |
| 1748 | continue; |
| 1749 | } |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1750 | int vis = ent.notification.getNotification().visibility; |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 1751 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1752 | // Display public version of the notification if we need to redact. |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1753 | final boolean hideSensitive = |
| 1754 | !userAllowsPrivateNotificationsInPublic(ent.notification.getUserId()); |
Chris Wren | 3ad4e3a | 2014-09-02 17:23:51 -0400 | [diff] [blame] | 1755 | boolean sensitiveNote = vis == Notification.VISIBILITY_PRIVATE; |
| 1756 | boolean sensitivePackage = packageHasVisibilityOverride(ent.notification.getKey()); |
| 1757 | boolean sensitive = (sensitiveNote && hideSensitive) || sensitivePackage; |
| 1758 | boolean showingPublic = sensitive && isLockscreenPublicMode(); |
Sudheer Shanka | f5b850e | 2016-01-25 19:58:59 +0000 | [diff] [blame] | 1759 | if (showingPublic) { |
| 1760 | updatePublicContentView(ent, ent.notification); |
| 1761 | } |
Selim Cinek | 3c76d50 | 2016-02-19 15:16:33 -0800 | [diff] [blame] | 1762 | ent.row.setSensitive(sensitive, hideSensitive); |
Dan Sandler | 1b71878 | 2014-07-18 12:43:45 -0400 | [diff] [blame] | 1763 | if (ent.autoRedacted && ent.legacy) { |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1764 | // TODO: Also fade this? Or, maybe easier (and better), provide a dark redacted form |
| 1765 | // for legacy auto redacted notifications. |
Dan Sandler | 1b71878 | 2014-07-18 12:43:45 -0400 | [diff] [blame] | 1766 | if (showingPublic) { |
| 1767 | ent.row.setShowingLegacyBackground(false); |
| 1768 | } else { |
| 1769 | ent.row.setShowingLegacyBackground(true); |
| 1770 | } |
| 1771 | } |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1772 | if (mGroupManager.isChildInGroupWithSummary(ent.row.getStatusBarNotification())) { |
| 1773 | ExpandableNotificationRow summary = mGroupManager.getGroupSummary( |
| 1774 | ent.row.getStatusBarNotification()); |
| 1775 | List<ExpandableNotificationRow> orderedChildren = |
| 1776 | mTmpChildOrderMap.get(summary); |
| 1777 | if (orderedChildren == null) { |
| 1778 | orderedChildren = new ArrayList<>(); |
| 1779 | mTmpChildOrderMap.put(summary, orderedChildren); |
| 1780 | } |
| 1781 | orderedChildren.add(ent.row); |
| 1782 | } else { |
| 1783 | toShow.add(ent.row); |
| 1784 | } |
| 1785 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1786 | } |
| 1787 | |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1788 | ArrayList<ExpandableNotificationRow> toRemove = new ArrayList<>(); |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 1789 | for (int i=0; i< mStackScroller.getChildCount(); i++) { |
| 1790 | View child = mStackScroller.getChildAt(i); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1791 | if (!toShow.contains(child) && child instanceof ExpandableNotificationRow) { |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1792 | toRemove.add((ExpandableNotificationRow) child); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1793 | } |
| 1794 | } |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1795 | |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1796 | for (ExpandableNotificationRow remove : toRemove) { |
| 1797 | if (mGroupManager.isChildInGroupWithSummary(remove.getStatusBarNotification())) { |
| 1798 | // we are only transfering this notification to its parent, don't generate an animation |
| 1799 | mStackScroller.setChildTransferInProgress(true); |
| 1800 | } |
Selim Cinek | c1e389d | 2016-04-07 11:02:57 -0700 | [diff] [blame] | 1801 | if (remove.isSummaryWithChildren()) { |
| 1802 | remove.removeAllChildren(); |
| 1803 | } |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 1804 | mStackScroller.removeView(remove); |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1805 | mStackScroller.setChildTransferInProgress(false); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1806 | } |
Selim Cinek | 2b54242 | 2016-03-04 18:10:37 -0800 | [diff] [blame] | 1807 | |
| 1808 | removeNotificationChildren(); |
| 1809 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1810 | for (int i=0; i<toShow.size(); i++) { |
| 1811 | View v = toShow.get(i); |
| 1812 | if (v.getParent() == null) { |
Selim Cinek | add9526 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 1813 | mVisualStabilityManager.notifyViewAddition(v); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1814 | mStackScroller.addView(v); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1815 | } |
| 1816 | } |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 1817 | |
Selim Cinek | 2b54242 | 2016-03-04 18:10:37 -0800 | [diff] [blame] | 1818 | addNotificationChildrenAndSort(); |
| 1819 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1820 | // So after all this work notifications still aren't sorted correctly. |
| 1821 | // Let's do that now by advancing through toShow and mStackScroller in |
| 1822 | // lock-step, making sure mStackScroller matches what we see in toShow. |
| 1823 | int j = 0; |
| 1824 | for (int i = 0; i < mStackScroller.getChildCount(); i++) { |
| 1825 | View child = mStackScroller.getChildAt(i); |
| 1826 | if (!(child instanceof ExpandableNotificationRow)) { |
| 1827 | // We don't care about non-notification views. |
| 1828 | continue; |
| 1829 | } |
| 1830 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1831 | ExpandableNotificationRow targetChild = toShow.get(j); |
| 1832 | if (child != targetChild) { |
| 1833 | // Oops, wrong notification at this position. Put the right one |
| 1834 | // here and advance both lists. |
Selim Cinek | add9526 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 1835 | if (mVisualStabilityManager.canReorderNotification(targetChild)) { |
| 1836 | mStackScroller.changeViewPosition(targetChild, i); |
| 1837 | } else { |
| 1838 | mVisualStabilityManager.addReorderingAllowedCallback(this); |
| 1839 | } |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1840 | } |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1841 | j++; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1842 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1843 | } |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1844 | |
Selim Cinek | add9526 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 1845 | mVisualStabilityManager.onReorderingFinished(); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1846 | // clear the map again for the next usage |
| 1847 | mTmpChildOrderMap.clear(); |
| 1848 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1849 | updateRowStates(); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1850 | updateSpeedbump(); |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1851 | updateClearAll(); |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 1852 | updateEmptyShadeView(); |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1853 | |
Benjamin Franz | 27cf146 | 2015-04-23 19:36:42 +0100 | [diff] [blame] | 1854 | updateQsExpansionEnabled(); |
| 1855 | mShadeUpdates.check(); |
| 1856 | } |
| 1857 | |
| 1858 | /** |
| 1859 | * Disable QS if device not provisioned. |
| 1860 | * If the user switcher is simple then disable QS during setup because |
| 1861 | * the user intends to use the lock screen user switcher, QS in not needed. |
| 1862 | */ |
| 1863 | private void updateQsExpansionEnabled() { |
Jason Monk | 3ad242d | 2014-09-15 11:13:35 -0400 | [diff] [blame] | 1864 | mNotificationPanel.setQsExpansionEnabled(isDeviceProvisioned() |
Adrian Roos | 2b154a9 | 2014-11-17 15:18:39 +0100 | [diff] [blame] | 1865 | && (mUserSetup || mUserSwitcherController == null |
Benjamin Franz | 27cf146 | 2015-04-23 19:36:42 +0100 | [diff] [blame] | 1866 | || !mUserSwitcherController.isSimpleUserSwitcher()) |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 1867 | && ((mDisabled2 & StatusBarManager.DISABLE2_QUICK_SETTINGS) == 0) |
| 1868 | && !ONLY_CORE_APPS); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1869 | } |
| 1870 | |
Selim Cinek | 2b54242 | 2016-03-04 18:10:37 -0800 | [diff] [blame] | 1871 | private void addNotificationChildrenAndSort() { |
Selim Cinek | 322ec7e | 2016-02-11 14:47:06 -0800 | [diff] [blame] | 1872 | // Let's now add all notification children which are missing |
| 1873 | boolean orderChanged = false; |
| 1874 | for (int i = 0; i < mStackScroller.getChildCount(); i++) { |
| 1875 | View view = mStackScroller.getChildAt(i); |
| 1876 | if (!(view instanceof ExpandableNotificationRow)) { |
| 1877 | // We don't care about non-notification views. |
| 1878 | continue; |
| 1879 | } |
| 1880 | |
| 1881 | ExpandableNotificationRow parent = (ExpandableNotificationRow) view; |
| 1882 | List<ExpandableNotificationRow> children = parent.getNotificationChildren(); |
| 1883 | List<ExpandableNotificationRow> orderedChildren = mTmpChildOrderMap.get(parent); |
| 1884 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1885 | for (int childIndex = 0; orderedChildren != null && childIndex < orderedChildren.size(); |
| 1886 | childIndex++) { |
| 1887 | ExpandableNotificationRow childView = orderedChildren.get(childIndex); |
| 1888 | if (children == null || !children.contains(childView)) { |
Selim Cinek | add9526 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 1889 | mVisualStabilityManager.notifyViewAddition(childView); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1890 | parent.addChildNotification(childView, childIndex); |
| 1891 | mStackScroller.notifyGroupChildAdded(childView); |
| 1892 | } |
| 1893 | } |
| 1894 | |
| 1895 | // Finally after removing and adding has been beformed we can apply the order. |
Selim Cinek | add9526 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 1896 | orderChanged |= parent.applyChildOrder(orderedChildren, mVisualStabilityManager, this); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1897 | } |
| 1898 | if (orderChanged) { |
| 1899 | mStackScroller.generateChildOrderChangedEvent(); |
| 1900 | } |
| 1901 | } |
| 1902 | |
Selim Cinek | 2b54242 | 2016-03-04 18:10:37 -0800 | [diff] [blame] | 1903 | private void removeNotificationChildren() { |
| 1904 | // First let's remove all children which don't belong in the parents |
| 1905 | ArrayList<ExpandableNotificationRow> toRemove = new ArrayList<>(); |
| 1906 | for (int i = 0; i < mStackScroller.getChildCount(); i++) { |
| 1907 | View view = mStackScroller.getChildAt(i); |
| 1908 | if (!(view instanceof ExpandableNotificationRow)) { |
| 1909 | // We don't care about non-notification views. |
| 1910 | continue; |
| 1911 | } |
| 1912 | |
| 1913 | ExpandableNotificationRow parent = (ExpandableNotificationRow) view; |
| 1914 | List<ExpandableNotificationRow> children = parent.getNotificationChildren(); |
| 1915 | List<ExpandableNotificationRow> orderedChildren = mTmpChildOrderMap.get(parent); |
| 1916 | |
| 1917 | if (children != null) { |
| 1918 | toRemove.clear(); |
| 1919 | for (ExpandableNotificationRow childRow : children) { |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1920 | if ((orderedChildren == null |
| 1921 | || !orderedChildren.contains(childRow)) |
| 1922 | && !childRow.keepInParent()) { |
Selim Cinek | 2b54242 | 2016-03-04 18:10:37 -0800 | [diff] [blame] | 1923 | toRemove.add(childRow); |
| 1924 | } |
| 1925 | } |
| 1926 | for (ExpandableNotificationRow remove : toRemove) { |
| 1927 | parent.removeChildNotification(remove); |
| 1928 | if (mNotificationData.get(remove.getStatusBarNotification().getKey()) == null) { |
| 1929 | // We only want to add an animation if the view is completely removed |
| 1930 | // otherwise it's just a transfer |
Selim Cinek | d139564 | 2016-04-28 12:22:42 -0700 | [diff] [blame] | 1931 | mStackScroller.notifyGroupChildRemoved(remove, |
| 1932 | parent.getChildrenContainer()); |
Selim Cinek | 2b54242 | 2016-03-04 18:10:37 -0800 | [diff] [blame] | 1933 | } |
| 1934 | } |
| 1935 | } |
| 1936 | } |
| 1937 | } |
| 1938 | |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 1939 | @Override |
| 1940 | public void addQsTile(ComponentName tile) { |
| 1941 | mQSPanel.getHost().addTile(tile); |
| 1942 | } |
| 1943 | |
| 1944 | @Override |
| 1945 | public void remQsTile(ComponentName tile) { |
| 1946 | mQSPanel.getHost().removeTile(tile); |
| 1947 | } |
| 1948 | |
| 1949 | @Override |
| 1950 | public void clickTile(ComponentName tile) { |
| 1951 | mQSPanel.clickTile(tile); |
| 1952 | } |
| 1953 | |
Chris Wren | 3ad4e3a | 2014-09-02 17:23:51 -0400 | [diff] [blame] | 1954 | private boolean packageHasVisibilityOverride(String key) { |
Julia Reynolds | 26fa8a5 | 2016-02-24 08:31:22 -0500 | [diff] [blame] | 1955 | return mNotificationData.getVisibilityOverride(key) == Notification.VISIBILITY_PRIVATE; |
Chris Wren | 3ad4e3a | 2014-09-02 17:23:51 -0400 | [diff] [blame] | 1956 | } |
| 1957 | |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1958 | private void updateClearAll() { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1959 | boolean showDismissView = |
| 1960 | mState != StatusBarState.KEYGUARD && |
Selim Cinek | 1d35979 | 2017-01-13 14:43:43 -0800 | [diff] [blame] | 1961 | hasActiveClearableNotifications(); |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1962 | mStackScroller.updateDismissView(showDismissView); |
| 1963 | } |
| 1964 | |
Selim Cinek | 1d35979 | 2017-01-13 14:43:43 -0800 | [diff] [blame] | 1965 | /** |
| 1966 | * Return whether there are any clearable notifications |
| 1967 | */ |
| 1968 | private boolean hasActiveClearableNotifications() { |
| 1969 | int childCount = mStackScroller.getChildCount(); |
| 1970 | for (int i = 0; i < childCount; i++) { |
| 1971 | View child = mStackScroller.getChildAt(i); |
| 1972 | if (!(child instanceof ExpandableNotificationRow)) { |
| 1973 | continue; |
| 1974 | } |
| 1975 | if (((ExpandableNotificationRow) child).canViewBeDismissed()) { |
| 1976 | return true; |
| 1977 | } |
| 1978 | } |
| 1979 | return false; |
| 1980 | } |
| 1981 | |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 1982 | private void updateEmptyShadeView() { |
| 1983 | boolean showEmptyShade = |
| 1984 | mState != StatusBarState.KEYGUARD && |
| 1985 | mNotificationData.getActiveNotifications().size() == 0; |
| 1986 | mNotificationPanel.setShadeEmpty(showEmptyShade); |
| 1987 | } |
| 1988 | |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1989 | private void updateSpeedbump() { |
Selim Cinek | add9526 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 1990 | int speedBumpIndex = 0; |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1991 | int currentIndex = 0; |
Selim Cinek | 2a73934 | 2016-03-17 10:28:55 -0700 | [diff] [blame] | 1992 | final int N = mStackScroller.getChildCount(); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1993 | for (int i = 0; i < N; i++) { |
Selim Cinek | 2a73934 | 2016-03-17 10:28:55 -0700 | [diff] [blame] | 1994 | View view = mStackScroller.getChildAt(i); |
| 1995 | if (view.getVisibility() == View.GONE || !(view instanceof ExpandableNotificationRow)) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1996 | continue; |
| 1997 | } |
Selim Cinek | 2a73934 | 2016-03-17 10:28:55 -0700 | [diff] [blame] | 1998 | ExpandableNotificationRow row = (ExpandableNotificationRow) view; |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1999 | currentIndex++; |
Selim Cinek | add9526 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 2000 | if (!mNotificationData.isAmbient(row.getStatusBarNotification().getKey())) { |
| 2001 | speedBumpIndex = currentIndex; |
| 2002 | } |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 2003 | } |
Selim Cinek | add9526 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 2004 | mStackScroller.updateSpeedBumpIndex(speedBumpIndex); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 2005 | } |
| 2006 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 2007 | public static boolean isTopLevelChild(Entry entry) { |
| 2008 | return entry.row.getParent() instanceof NotificationStackScrollLayout; |
| 2009 | } |
| 2010 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2011 | @Override |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 2012 | protected void updateNotifications() { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 2013 | mNotificationData.filterAndSort(); |
| 2014 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 2015 | updateNotificationShade(); |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 2016 | mIconController.updateNotificationIcons(mNotificationData); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 2017 | } |
| 2018 | |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 2019 | public void requestNotificationUpdate() { |
| 2020 | updateNotifications(); |
| 2021 | } |
| 2022 | |
Jorim Jaggi | 5404542 | 2014-07-03 18:30:40 +0200 | [diff] [blame] | 2023 | @Override |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2024 | protected void setAreThereNotifications() { |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 2025 | |
Chris Wren | 6d15a36 | 2013-08-20 18:46:29 -0400 | [diff] [blame] | 2026 | if (SPEW) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 2027 | final boolean clearable = hasActiveNotifications() && |
Selim Cinek | 1d35979 | 2017-01-13 14:43:43 -0800 | [diff] [blame] | 2028 | hasActiveClearableNotifications(); |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 2029 | Log.d(TAG, "setAreThereNotifications: N=" + |
| 2030 | mNotificationData.getActiveNotifications().size() + " any=" + |
| 2031 | hasActiveNotifications() + " clearable=" + clearable); |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 2032 | } |
| 2033 | |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 2034 | final View nlo = mStatusBarView.findViewById(R.id.notification_lights_out); |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 2035 | final boolean showDot = hasActiveNotifications() && !areLightsOn(); |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 2036 | if (showDot != (nlo.getAlpha() == 1.0f)) { |
| 2037 | if (showDot) { |
| 2038 | nlo.setAlpha(0f); |
| 2039 | nlo.setVisibility(View.VISIBLE); |
| 2040 | } |
| 2041 | nlo.animate() |
| 2042 | .alpha(showDot?1:0) |
| 2043 | .setDuration(showDot?750:250) |
| 2044 | .setInterpolator(new AccelerateInterpolator(2.0f)) |
| 2045 | .setListener(showDot ? null : new AnimatorListenerAdapter() { |
| 2046 | @Override |
| 2047 | public void onAnimationEnd(Animator _a) { |
| 2048 | nlo.setVisibility(View.GONE); |
| 2049 | } |
| 2050 | }) |
| 2051 | .start(); |
| 2052 | } |
Daniel Sandler | 3d32a24 | 2012-06-05 13:44:14 -0400 | [diff] [blame] | 2053 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2054 | findAndUpdateMediaNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2055 | } |
| 2056 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2057 | public void findAndUpdateMediaNotifications() { |
| 2058 | boolean metaDataChanged = false; |
| 2059 | |
| 2060 | synchronized (mNotificationData) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 2061 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
| 2062 | final int N = activeNotifications.size(); |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2063 | |
| 2064 | // Promote the media notification with a controller in 'playing' state, if any. |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2065 | Entry mediaNotification = null; |
| 2066 | MediaController controller = null; |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 2067 | for (int i = 0; i < N; i++) { |
| 2068 | final Entry entry = activeNotifications.get(i); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2069 | if (isMediaNotification(entry)) { |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2070 | final MediaSession.Token token = |
| 2071 | entry.notification.getNotification().extras |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2072 | .getParcelable(Notification.EXTRA_MEDIA_SESSION); |
| 2073 | if (token != null) { |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2074 | MediaController aController = new MediaController(mContext, token); |
| 2075 | if (PlaybackState.STATE_PLAYING == |
| 2076 | getMediaControllerPlaybackState(aController)) { |
| 2077 | if (DEBUG_MEDIA) { |
| 2078 | Log.v(TAG, "DEBUG_MEDIA: found mediastyle controller matching " |
| 2079 | + entry.notification.getKey()); |
| 2080 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2081 | mediaNotification = entry; |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2082 | controller = aController; |
| 2083 | break; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2084 | } |
| 2085 | } |
| 2086 | } |
| 2087 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2088 | if (mediaNotification == null) { |
| 2089 | // Still nothing? OK, let's just look for live media sessions and see if they match |
| 2090 | // one of our notifications. This will catch apps that aren't (yet!) using media |
| 2091 | // notifications. |
| 2092 | |
| 2093 | if (mMediaSessionManager != null) { |
| 2094 | final List<MediaController> sessions |
| 2095 | = mMediaSessionManager.getActiveSessionsForUser( |
| 2096 | null, |
| 2097 | UserHandle.USER_ALL); |
| 2098 | |
| 2099 | for (MediaController aController : sessions) { |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2100 | if (PlaybackState.STATE_PLAYING == |
| 2101 | getMediaControllerPlaybackState(aController)) { |
| 2102 | // now to see if we have one like this |
| 2103 | final String pkg = aController.getPackageName(); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2104 | |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2105 | for (int i = 0; i < N; i++) { |
| 2106 | final Entry entry = activeNotifications.get(i); |
| 2107 | if (entry.notification.getPackageName().equals(pkg)) { |
| 2108 | if (DEBUG_MEDIA) { |
| 2109 | Log.v(TAG, "DEBUG_MEDIA: found controller matching " |
| 2110 | + entry.notification.getKey()); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2111 | } |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2112 | controller = aController; |
| 2113 | mediaNotification = entry; |
| 2114 | break; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2115 | } |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2116 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2117 | } |
| 2118 | } |
| 2119 | } |
| 2120 | } |
| 2121 | |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2122 | if (controller != null && !sameSessions(mMediaController, controller)) { |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2123 | // We have a new media session |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2124 | clearCurrentMediaNotification(); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2125 | mMediaController = controller; |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2126 | mMediaController.registerCallback(mMediaListener); |
| 2127 | mMediaMetadata = mMediaController.getMetadata(); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2128 | if (DEBUG_MEDIA) { |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2129 | Log.v(TAG, "DEBUG_MEDIA: insert listener, receive metadata: " |
| 2130 | + mMediaMetadata); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2131 | } |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2132 | |
| 2133 | if (mediaNotification != null) { |
| 2134 | mMediaNotificationKey = mediaNotification.notification.getKey(); |
| 2135 | if (DEBUG_MEDIA) { |
| 2136 | Log.v(TAG, "DEBUG_MEDIA: Found new media notification: key=" |
| 2137 | + mMediaNotificationKey + " controller=" + mMediaController); |
| 2138 | } |
| 2139 | } |
| 2140 | metaDataChanged = true; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2141 | } |
| 2142 | } |
| 2143 | |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2144 | if (metaDataChanged) { |
| 2145 | updateNotifications(); |
| 2146 | } |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 2147 | updateMediaMetaData(metaDataChanged, true); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2148 | } |
| 2149 | |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2150 | private int getMediaControllerPlaybackState(MediaController controller) { |
| 2151 | if (controller != null) { |
| 2152 | final PlaybackState playbackState = controller.getPlaybackState(); |
| 2153 | if (playbackState != null) { |
| 2154 | return playbackState.getState(); |
| 2155 | } |
| 2156 | } |
| 2157 | return PlaybackState.STATE_NONE; |
| 2158 | } |
| 2159 | |
| 2160 | private boolean isPlaybackActive(int state) { |
| 2161 | if (state != PlaybackState.STATE_STOPPED |
| 2162 | && state != PlaybackState.STATE_ERROR |
| 2163 | && state != PlaybackState.STATE_NONE) { |
| 2164 | return true; |
| 2165 | } |
| 2166 | return false; |
| 2167 | } |
| 2168 | |
| 2169 | private void clearCurrentMediaNotification() { |
| 2170 | mMediaNotificationKey = null; |
| 2171 | mMediaMetadata = null; |
| 2172 | if (mMediaController != null) { |
| 2173 | if (DEBUG_MEDIA) { |
| 2174 | Log.v(TAG, "DEBUG_MEDIA: Disconnecting from old controller: " |
| 2175 | + mMediaController.getPackageName()); |
| 2176 | } |
| 2177 | mMediaController.unregisterCallback(mMediaListener); |
| 2178 | } |
| 2179 | mMediaController = null; |
| 2180 | } |
| 2181 | |
Christoph Studer | b5245d8 | 2014-09-19 16:54:36 +0200 | [diff] [blame] | 2182 | private boolean sameSessions(MediaController a, MediaController b) { |
| 2183 | if (a == b) return true; |
| 2184 | if (a == null) return false; |
| 2185 | return a.controlsSameSession(b); |
| 2186 | } |
| 2187 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2188 | /** |
Dan Sandler | 7dea0ee | 2014-07-21 21:07:15 -0400 | [diff] [blame] | 2189 | * Hide the album artwork that is fading out and release its bitmap. |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2190 | */ |
| 2191 | private Runnable mHideBackdropFront = new Runnable() { |
| 2192 | @Override |
| 2193 | public void run() { |
| 2194 | if (DEBUG_MEDIA) { |
| 2195 | Log.v(TAG, "DEBUG_MEDIA: removing fade layer"); |
| 2196 | } |
| 2197 | mBackdropFront.setVisibility(View.INVISIBLE); |
Dan Sandler | 7dea0ee | 2014-07-21 21:07:15 -0400 | [diff] [blame] | 2198 | mBackdropFront.animate().cancel(); |
| 2199 | mBackdropFront.setImageDrawable(null); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2200 | } |
| 2201 | }; |
| 2202 | |
| 2203 | /** |
Adrian Roos | e381c16 | 2016-02-11 15:26:42 -0800 | [diff] [blame] | 2204 | * Refresh or remove lockscreen artwork from media metadata or the lockscreen wallpaper. |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2205 | */ |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 2206 | public void updateMediaMetaData(boolean metaDataChanged, boolean allowEnterAnimation) { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 2207 | Trace.beginSection("PhoneStatusBar#updateMediaMetaData"); |
| 2208 | if (!SHOW_LOCKSCREEN_MEDIA_ARTWORK) { |
| 2209 | Trace.endSection(); |
| 2210 | return; |
| 2211 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2212 | |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 2213 | if (mBackdrop == null) { |
| 2214 | Trace.endSection(); |
| 2215 | return; // called too early |
| 2216 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2217 | |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 2218 | if (mLaunchTransitionFadingAway) { |
| 2219 | mBackdrop.setVisibility(View.INVISIBLE); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 2220 | Trace.endSection(); |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 2221 | return; |
| 2222 | } |
| 2223 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2224 | if (DEBUG_MEDIA) { |
| 2225 | Log.v(TAG, "DEBUG_MEDIA: updating album art for notification " + mMediaNotificationKey |
Selim Cinek | 131c1e2 | 2015-05-11 19:04:49 -0700 | [diff] [blame] | 2226 | + " metadata=" + mMediaMetadata |
| 2227 | + " metaDataChanged=" + metaDataChanged |
| 2228 | + " state=" + mState); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2229 | } |
| 2230 | |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 2231 | Drawable artworkDrawable = null; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2232 | if (mMediaMetadata != null) { |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 2233 | Bitmap artworkBitmap = null; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2234 | artworkBitmap = mMediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ART); |
| 2235 | if (artworkBitmap == null) { |
| 2236 | artworkBitmap = mMediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART); |
| 2237 | // might still be null |
| 2238 | } |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 2239 | if (artworkBitmap != null) { |
| 2240 | artworkDrawable = new BitmapDrawable(mBackdropBack.getResources(), artworkBitmap); |
| 2241 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2242 | } |
Adrian Roos | a3760a4 | 2016-04-25 16:21:06 -0700 | [diff] [blame] | 2243 | boolean allowWhenShade = false; |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 2244 | if (ENABLE_LOCKSCREEN_WALLPAPER && artworkDrawable == null) { |
| 2245 | Bitmap lockWallpaper = mLockscreenWallpaper.getBitmap(); |
| 2246 | if (lockWallpaper != null) { |
| 2247 | artworkDrawable = new LockscreenWallpaper.WallpaperDrawable( |
| 2248 | mBackdropBack.getResources(), lockWallpaper); |
Adrian Roos | a3760a4 | 2016-04-25 16:21:06 -0700 | [diff] [blame] | 2249 | // We're in the SHADE mode on the SIM screen - yet we still need to show |
| 2250 | // the lockscreen wallpaper in that mode. |
| 2251 | allowWhenShade = mStatusBarKeyguardViewManager != null |
| 2252 | && mStatusBarKeyguardViewManager.isShowing(); |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 2253 | } |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 2254 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2255 | |
Adrian Roos | a3760a4 | 2016-04-25 16:21:06 -0700 | [diff] [blame] | 2256 | boolean hideBecauseOccluded = mStatusBarKeyguardViewManager != null |
| 2257 | && mStatusBarKeyguardViewManager.isOccluded(); |
| 2258 | |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 2259 | final boolean hasArtwork = artworkDrawable != null; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2260 | |
Adrian Roos | a3760a4 | 2016-04-25 16:21:06 -0700 | [diff] [blame] | 2261 | if ((hasArtwork || DEBUG_MEDIA_FAKE_ARTWORK) |
| 2262 | && (mState != StatusBarState.SHADE || allowWhenShade) |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2263 | && mFingerprintUnlockController.getMode() |
Adrian Roos | a3760a4 | 2016-04-25 16:21:06 -0700 | [diff] [blame] | 2264 | != FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING |
| 2265 | && !hideBecauseOccluded) { |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2266 | // time to show some art! |
| 2267 | if (mBackdrop.getVisibility() != View.VISIBLE) { |
| 2268 | mBackdrop.setVisibility(View.VISIBLE); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 2269 | if (allowEnterAnimation) { |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 2270 | mBackdrop.setAlpha(SRC_MIN_ALPHA); |
| 2271 | mBackdrop.animate().alpha(1f); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 2272 | } else { |
| 2273 | mBackdrop.animate().cancel(); |
| 2274 | mBackdrop.setAlpha(1f); |
| 2275 | } |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 2276 | mStatusBarWindowManager.setBackdropShowing(true); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2277 | metaDataChanged = true; |
| 2278 | if (DEBUG_MEDIA) { |
| 2279 | Log.v(TAG, "DEBUG_MEDIA: Fading in album artwork"); |
| 2280 | } |
| 2281 | } |
| 2282 | if (metaDataChanged) { |
| 2283 | if (mBackdropBack.getDrawable() != null) { |
Julia Reynolds | 4b9658a | 2015-07-22 17:07:42 -0400 | [diff] [blame] | 2284 | Drawable drawable = |
Adrian Roos | 751f33f | 2016-04-19 16:41:18 -0700 | [diff] [blame] | 2285 | mBackdropBack.getDrawable().getConstantState() |
| 2286 | .newDrawable(mBackdropFront.getResources()).mutate(); |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 2287 | mBackdropFront.setImageDrawable(drawable); |
Jorim Jaggi | 0e66439 | 2014-09-27 01:30:22 +0200 | [diff] [blame] | 2288 | if (mScrimSrcModeEnabled) { |
| 2289 | mBackdropFront.getDrawable().mutate().setXfermode(mSrcOverXferMode); |
| 2290 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2291 | mBackdropFront.setAlpha(1f); |
| 2292 | mBackdropFront.setVisibility(View.VISIBLE); |
| 2293 | } else { |
| 2294 | mBackdropFront.setVisibility(View.INVISIBLE); |
| 2295 | } |
| 2296 | |
| 2297 | if (DEBUG_MEDIA_FAKE_ARTWORK) { |
| 2298 | final int c = 0xFF000000 | (int)(Math.random() * 0xFFFFFF); |
| 2299 | Log.v(TAG, String.format("DEBUG_MEDIA: setting new color: 0x%08x", c)); |
| 2300 | mBackdropBack.setBackgroundColor(0xFFFFFFFF); |
| 2301 | mBackdropBack.setImageDrawable(new ColorDrawable(c)); |
| 2302 | } else { |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 2303 | mBackdropBack.setImageDrawable(artworkDrawable); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2304 | } |
Jorim Jaggi | 0e66439 | 2014-09-27 01:30:22 +0200 | [diff] [blame] | 2305 | if (mScrimSrcModeEnabled) { |
| 2306 | mBackdropBack.getDrawable().mutate().setXfermode(mSrcXferMode); |
| 2307 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2308 | |
| 2309 | if (mBackdropFront.getVisibility() == View.VISIBLE) { |
| 2310 | if (DEBUG_MEDIA) { |
| 2311 | Log.v(TAG, "DEBUG_MEDIA: Crossfading album artwork from " |
| 2312 | + mBackdropFront.getDrawable() |
| 2313 | + " to " |
| 2314 | + mBackdropBack.getDrawable()); |
| 2315 | } |
Jorim Jaggi | 4e0880e | 2014-07-25 14:51:50 +0200 | [diff] [blame] | 2316 | mBackdropFront.animate() |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2317 | .setDuration(250) |
| 2318 | .alpha(0f).withEndAction(mHideBackdropFront); |
| 2319 | } |
| 2320 | } |
| 2321 | } else { |
| 2322 | // need to hide the album art, either because we are unlocked or because |
| 2323 | // the metadata isn't there to support it |
| 2324 | if (mBackdrop.getVisibility() != View.GONE) { |
| 2325 | if (DEBUG_MEDIA) { |
| 2326 | Log.v(TAG, "DEBUG_MEDIA: Fading out album artwork"); |
| 2327 | } |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2328 | if (mFingerprintUnlockController.getMode() |
Adrian Roos | a3760a4 | 2016-04-25 16:21:06 -0700 | [diff] [blame] | 2329 | == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING |
| 2330 | || hideBecauseOccluded) { |
Jorim Jaggi | 4e0880e | 2014-07-25 14:51:50 +0200 | [diff] [blame] | 2331 | |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2332 | // We are unlocking directly - no animation! |
| 2333 | mBackdrop.setVisibility(View.GONE); |
Vadim Tryshev | e7d7d57 | 2016-03-09 16:44:30 -0800 | [diff] [blame] | 2334 | mBackdropBack.setImageDrawable(null); |
Adrian Roos | d5c2db6 | 2016-03-08 16:11:31 -0800 | [diff] [blame] | 2335 | mStatusBarWindowManager.setBackdropShowing(false); |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2336 | } else { |
Adrian Roos | d5c2db6 | 2016-03-08 16:11:31 -0800 | [diff] [blame] | 2337 | mStatusBarWindowManager.setBackdropShowing(false); |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2338 | mBackdrop.animate() |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 2339 | .alpha(SRC_MIN_ALPHA) |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 2340 | .setInterpolator(Interpolators.ACCELERATE_DECELERATE) |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2341 | .setDuration(300) |
| 2342 | .setStartDelay(0) |
| 2343 | .withEndAction(new Runnable() { |
| 2344 | @Override |
| 2345 | public void run() { |
| 2346 | mBackdrop.setVisibility(View.GONE); |
| 2347 | mBackdropFront.animate().cancel(); |
Vadim Tryshev | e7d7d57 | 2016-03-09 16:44:30 -0800 | [diff] [blame] | 2348 | mBackdropBack.setImageDrawable(null); |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2349 | mHandler.post(mHideBackdropFront); |
| 2350 | } |
| 2351 | }); |
| 2352 | if (mKeyguardFadingAway) { |
| 2353 | mBackdrop.animate() |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2354 | // Make it disappear faster, as the focus should be on the activity |
| 2355 | // behind. |
| 2356 | .setDuration(mKeyguardFadingAwayDuration / 2) |
| 2357 | .setStartDelay(mKeyguardFadingAwayDelay) |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 2358 | .setInterpolator(Interpolators.LINEAR) |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2359 | .start(); |
| 2360 | } |
Jorim Jaggi | 4e0880e | 2014-07-25 14:51:50 +0200 | [diff] [blame] | 2361 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2362 | } |
| 2363 | } |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 2364 | Trace.endSection(); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2365 | } |
| 2366 | |
Adrian Roos | 7bb38a9 | 2016-07-21 11:44:01 -0700 | [diff] [blame] | 2367 | private void updateReportRejectedTouchVisibility() { |
| 2368 | if (mReportRejectedTouch == null) { |
| 2369 | return; |
| 2370 | } |
| 2371 | mReportRejectedTouch.setVisibility(mState == StatusBarState.KEYGUARD |
| 2372 | && mFalsingManager.isReportingEnabled() ? View.VISIBLE : View.INVISIBLE); |
| 2373 | } |
| 2374 | |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 2375 | protected int adjustDisableFlags(int state) { |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 2376 | if (!mLaunchTransitionFadingAway && !mKeyguardFadingAway |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 2377 | && (mExpandedVisible || mBouncerShowing || mWaitingForKeyguardExit)) { |
Jorim Jaggi | b13d36d | 2014-06-06 18:03:52 +0200 | [diff] [blame] | 2378 | state |= StatusBarManager.DISABLE_NOTIFICATION_ICONS; |
| 2379 | state |= StatusBarManager.DISABLE_SYSTEM_INFO; |
| 2380 | } |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 2381 | if (mNetworkController != null && EncryptionHelper.IS_DATA_ENCRYPTED) { |
| 2382 | if (mNetworkController.hasEmergencyCryptKeeperText()) { |
| 2383 | state |= StatusBarManager.DISABLE_NOTIFICATION_ICONS; |
| 2384 | } |
| 2385 | if (!mNetworkController.isRadioOn()) { |
| 2386 | state |= StatusBarManager.DISABLE_SYSTEM_INFO; |
| 2387 | } |
| 2388 | } |
Jorim Jaggi | b13d36d | 2014-06-06 18:03:52 +0200 | [diff] [blame] | 2389 | return state; |
| 2390 | } |
| 2391 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2392 | /** |
| 2393 | * State is one or more of the DISABLE constants from StatusBarManager. |
| 2394 | */ |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2395 | @Override |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2396 | public void disable(int state1, int state2, boolean animate) { |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2397 | animate &= mStatusBarWindowState != WINDOW_STATE_HIDDEN; |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2398 | mDisabledUnmodified1 = state1; |
| 2399 | mDisabledUnmodified2 = state2; |
| 2400 | state1 = adjustDisableFlags(state1); |
| 2401 | final int old1 = mDisabled1; |
| 2402 | final int diff1 = state1 ^ old1; |
| 2403 | mDisabled1 = state1; |
| 2404 | |
| 2405 | final int old2 = mDisabled2; |
| 2406 | final int diff2 = state2 ^ old2; |
| 2407 | mDisabled2 = state2; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2408 | |
Daniel Sandler | e21f288 | 2011-08-18 10:14:59 -0400 | [diff] [blame] | 2409 | if (DEBUG) { |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2410 | Log.d(TAG, String.format("disable1: 0x%08x -> 0x%08x (diff1: 0x%08x)", |
| 2411 | old1, state1, diff1)); |
| 2412 | Log.d(TAG, String.format("disable2: 0x%08x -> 0x%08x (diff2: 0x%08x)", |
| 2413 | old2, state2, diff2)); |
Daniel Sandler | e21f288 | 2011-08-18 10:14:59 -0400 | [diff] [blame] | 2414 | } |
| 2415 | |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2416 | StringBuilder flagdbg = new StringBuilder(); |
| 2417 | flagdbg.append("disable: < "); |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2418 | flagdbg.append(((state1 & StatusBarManager.DISABLE_EXPAND) != 0) ? "EXPAND" : "expand"); |
| 2419 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_EXPAND) != 0) ? "* " : " "); |
| 2420 | flagdbg.append(((state1 & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) ? "ICONS" : "icons"); |
| 2421 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) ? "* " : " "); |
| 2422 | flagdbg.append(((state1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) ? "ALERTS" : "alerts"); |
| 2423 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) ? "* " : " "); |
| 2424 | flagdbg.append(((state1 & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) ? "SYSTEM_INFO" : "system_info"); |
| 2425 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) ? "* " : " "); |
| 2426 | flagdbg.append(((state1 & StatusBarManager.DISABLE_BACK) != 0) ? "BACK" : "back"); |
| 2427 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_BACK) != 0) ? "* " : " "); |
| 2428 | flagdbg.append(((state1 & StatusBarManager.DISABLE_HOME) != 0) ? "HOME" : "home"); |
| 2429 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_HOME) != 0) ? "* " : " "); |
| 2430 | flagdbg.append(((state1 & StatusBarManager.DISABLE_RECENT) != 0) ? "RECENT" : "recent"); |
| 2431 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_RECENT) != 0) ? "* " : " "); |
| 2432 | flagdbg.append(((state1 & StatusBarManager.DISABLE_CLOCK) != 0) ? "CLOCK" : "clock"); |
| 2433 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_CLOCK) != 0) ? "* " : " "); |
| 2434 | flagdbg.append(((state1 & StatusBarManager.DISABLE_SEARCH) != 0) ? "SEARCH" : "search"); |
| 2435 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_SEARCH) != 0) ? "* " : " "); |
Benjamin Franz | 27cf146 | 2015-04-23 19:36:42 +0100 | [diff] [blame] | 2436 | flagdbg.append(((state2 & StatusBarManager.DISABLE2_QUICK_SETTINGS) != 0) ? "QUICK_SETTINGS" |
| 2437 | : "quick_settings"); |
| 2438 | flagdbg.append(((diff2 & StatusBarManager.DISABLE2_QUICK_SETTINGS) != 0) ? "* " : " "); |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2439 | flagdbg.append(">"); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2440 | Log.d(TAG, flagdbg.toString()); |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 2441 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2442 | if ((diff1 & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) { |
| 2443 | if ((state1 & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) { |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 2444 | mIconController.hideSystemIconArea(animate); |
Daniel Sandler | 8e18dc7 | 2012-05-17 00:44:59 -0400 | [diff] [blame] | 2445 | } else { |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 2446 | mIconController.showSystemIconArea(animate); |
Daniel Sandler | 8e18dc7 | 2012-05-17 00:44:59 -0400 | [diff] [blame] | 2447 | } |
| 2448 | } |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2449 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2450 | if ((diff1 & StatusBarManager.DISABLE_CLOCK) != 0) { |
| 2451 | boolean visible = (state1 & StatusBarManager.DISABLE_CLOCK) == 0; |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 2452 | mIconController.setClockVisibility(visible); |
Jeff Sharkey | f52c70b | 2011-08-30 22:05:47 -0700 | [diff] [blame] | 2453 | } |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2454 | if ((diff1 & StatusBarManager.DISABLE_EXPAND) != 0) { |
| 2455 | if ((state1 & StatusBarManager.DISABLE_EXPAND) != 0) { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2456 | animateCollapsePanels(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2457 | } |
| 2458 | } |
Daniel Sandler | e21f288 | 2011-08-18 10:14:59 -0400 | [diff] [blame] | 2459 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2460 | if ((diff1 & (StatusBarManager.DISABLE_HOME |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 2461 | | StatusBarManager.DISABLE_RECENT |
Daniel Sandler | d5483c3 | 2012-10-19 16:44:15 -0400 | [diff] [blame] | 2462 | | StatusBarManager.DISABLE_BACK |
| 2463 | | StatusBarManager.DISABLE_SEARCH)) != 0) { |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame] | 2464 | // the nav bar will take care of these |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2465 | if (mNavigationBarView != null) mNavigationBarView.setDisabledFlags(state1); |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2466 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2467 | if ((state1 & StatusBarManager.DISABLE_RECENT) != 0) { |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2468 | // close recents if it's visible |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2469 | mHandler.removeMessages(MSG_HIDE_RECENT_APPS); |
| 2470 | mHandler.sendEmptyMessage(MSG_HIDE_RECENT_APPS); |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2471 | } |
Daniel Sandler | e21f288 | 2011-08-18 10:14:59 -0400 | [diff] [blame] | 2472 | } |
| 2473 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2474 | if ((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { |
| 2475 | if ((state1 & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 2476 | mIconController.hideNotificationIconArea(animate); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2477 | } else { |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 2478 | mIconController.showNotificationIconArea(animate); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2479 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2480 | } |
Jason Monk | f701954 | 2014-07-31 12:42:25 -0400 | [diff] [blame] | 2481 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2482 | if ((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) { |
Jason Monk | f701954 | 2014-07-31 12:42:25 -0400 | [diff] [blame] | 2483 | mDisableNotificationAlerts = |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2484 | (state1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0; |
Jason Monk | f701954 | 2014-07-31 12:42:25 -0400 | [diff] [blame] | 2485 | mHeadsUpObserver.onChange(true); |
| 2486 | } |
Benjamin Franz | 27cf146 | 2015-04-23 19:36:42 +0100 | [diff] [blame] | 2487 | |
| 2488 | if ((diff2 & StatusBarManager.DISABLE2_QUICK_SETTINGS) != 0) { |
| 2489 | updateQsExpansionEnabled(); |
| 2490 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2491 | } |
| 2492 | |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 2493 | /** |
| 2494 | * Reapplies the disable flags as last requested by StatusBarManager. |
| 2495 | * |
| 2496 | * This needs to be called if state used by {@link #adjustDisableFlags} changes. |
| 2497 | */ |
| 2498 | private void recomputeDisableFlags(boolean animate) { |
| 2499 | disable(mDisabledUnmodified1, mDisabledUnmodified2, animate); |
| 2500 | } |
| 2501 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2502 | @Override |
Michael Jurka | ecc395a | 2012-03-30 05:31:46 -0700 | [diff] [blame] | 2503 | protected BaseStatusBar.H createHandler() { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2504 | return new PhoneStatusBar.H(); |
| 2505 | } |
| 2506 | |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 2507 | @Override |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 2508 | public void startActivity(Intent intent, boolean dismissShade) { |
| 2509 | startActivityDismissingKeyguard(intent, false, dismissShade); |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 2510 | } |
| 2511 | |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 2512 | @Override |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 2513 | public void startActivity(Intent intent, boolean dismissShade, Callback callback) { |
| 2514 | startActivityDismissingKeyguard(intent, false, dismissShade, callback); |
| 2515 | } |
| 2516 | |
| 2517 | @Override |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 2518 | public void preventNextAnimation() { |
| 2519 | overrideActivityPendingAppTransition(true /* keyguardShowing */); |
| 2520 | } |
| 2521 | |
Jorim Jaggi | b690f0d | 2014-07-03 23:25:44 +0200 | [diff] [blame] | 2522 | public void setQsExpanded(boolean expanded) { |
| 2523 | mStatusBarWindowManager.setQsExpanded(expanded); |
Adrian Roos | 4c7d960 | 2015-06-10 13:44:48 -0700 | [diff] [blame] | 2524 | mKeyguardStatusView.setImportantForAccessibility(expanded |
| 2525 | ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS |
| 2526 | : View.IMPORTANT_FOR_ACCESSIBILITY_AUTO); |
Jorim Jaggi | b690f0d | 2014-07-03 23:25:44 +0200 | [diff] [blame] | 2527 | } |
| 2528 | |
Jorim Jaggi | 84a3e7a | 2014-08-13 17:58:58 +0200 | [diff] [blame] | 2529 | public boolean isGoingToNotificationShade() { |
| 2530 | return mLeaveOpenOnKeyguardHide; |
| 2531 | } |
| 2532 | |
Jorim Jaggi | d692dd0 | 2014-08-14 20:57:42 +0200 | [diff] [blame] | 2533 | public boolean isQsExpanded() { |
| 2534 | return mNotificationPanel.isQsExpanded(); |
| 2535 | } |
| 2536 | |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 2537 | public boolean isWakeUpComingFromTouch() { |
| 2538 | return mWakeUpComingFromTouch; |
Selim Cinek | 29ed3c9 | 2014-09-23 20:44:35 +0200 | [diff] [blame] | 2539 | } |
| 2540 | |
Selim Cinek | 19c8c70 | 2014-08-25 22:09:19 +0200 | [diff] [blame] | 2541 | public boolean isFalsingThresholdNeeded() { |
Selim Cinek | 9db7105 | 2015-04-24 18:54:30 -0700 | [diff] [blame] | 2542 | return getBarState() == StatusBarState.KEYGUARD; |
Selim Cinek | 19c8c70 | 2014-08-25 22:09:19 +0200 | [diff] [blame] | 2543 | } |
| 2544 | |
John Spurlock | 0b99ea9 | 2014-10-01 15:32:22 -0400 | [diff] [blame] | 2545 | public boolean isDozing() { |
| 2546 | return mDozing; |
| 2547 | } |
| 2548 | |
Christoph Studer | 2e731b5 | 2014-08-22 16:01:51 +0200 | [diff] [blame] | 2549 | @Override // NotificationData.Environment |
| 2550 | public String getCurrentMediaNotificationKey() { |
| 2551 | return mMediaNotificationKey; |
| 2552 | } |
| 2553 | |
Jorim Jaggi | 0e66439 | 2014-09-27 01:30:22 +0200 | [diff] [blame] | 2554 | public boolean isScrimSrcModeEnabled() { |
| 2555 | return mScrimSrcModeEnabled; |
| 2556 | } |
| 2557 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2558 | /** |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 2559 | * To be called when there's a state change in StatusBarKeyguardViewManager. |
| 2560 | */ |
| 2561 | public void onKeyguardViewManagerStatesUpdated() { |
| 2562 | logStateToEventlog(); |
| 2563 | } |
| 2564 | |
| 2565 | @Override // UnlockMethodCache.OnUnlockMethodChangedListener |
| 2566 | public void onUnlockMethodStateChanged() { |
| 2567 | logStateToEventlog(); |
| 2568 | } |
| 2569 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2570 | @Override |
John Spurlock | b349af57 | 2015-04-29 12:24:19 -0400 | [diff] [blame] | 2571 | public void onHeadsUpPinnedModeChanged(boolean inPinnedMode) { |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2572 | if (inPinnedMode) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2573 | mStatusBarWindowManager.setHeadsUpShowing(true); |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2574 | mStatusBarWindowManager.setForceStatusBarVisible(true); |
Selim Cinek | 131c1e2 | 2015-05-11 19:04:49 -0700 | [diff] [blame] | 2575 | if (mNotificationPanel.isFullyCollapsed()) { |
| 2576 | // We need to ensure that the touchable region is updated before the window will be |
| 2577 | // resized, in order to not catch any touches. A layout will ensure that |
| 2578 | // onComputeInternalInsets will be called and after that we can resize the layout. Let's |
| 2579 | // make sure that the window stays small for one frame until the touchableRegion is set. |
| 2580 | mNotificationPanel.requestLayout(); |
| 2581 | mStatusBarWindowManager.setForceWindowCollapsed(true); |
| 2582 | mNotificationPanel.post(new Runnable() { |
| 2583 | @Override |
| 2584 | public void run() { |
| 2585 | mStatusBarWindowManager.setForceWindowCollapsed(false); |
| 2586 | } |
| 2587 | }); |
| 2588 | } |
Selim Cinek | 737bff3 | 2015-05-08 16:08:35 -0700 | [diff] [blame] | 2589 | } else { |
Selim Cinek | 131c1e2 | 2015-05-11 19:04:49 -0700 | [diff] [blame] | 2590 | if (!mNotificationPanel.isFullyCollapsed() || mNotificationPanel.isTracking()) { |
| 2591 | // We are currently tracking or is open and the shade doesn't need to be kept |
| 2592 | // open artificially. |
Selim Cinek | 737bff3 | 2015-05-08 16:08:35 -0700 | [diff] [blame] | 2593 | mStatusBarWindowManager.setHeadsUpShowing(false); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2594 | } else { |
Selim Cinek | 131c1e2 | 2015-05-11 19:04:49 -0700 | [diff] [blame] | 2595 | // we need to keep the panel open artificially, let's wait until the animation |
| 2596 | // is finished. |
Selim Cinek | 737bff3 | 2015-05-08 16:08:35 -0700 | [diff] [blame] | 2597 | mHeadsUpManager.setHeadsUpGoingAway(true); |
| 2598 | mStackScroller.runAfterAnimationFinished(new Runnable() { |
| 2599 | @Override |
| 2600 | public void run() { |
| 2601 | if (!mHeadsUpManager.hasPinnedHeadsUp()) { |
| 2602 | mStatusBarWindowManager.setHeadsUpShowing(false); |
| 2603 | mHeadsUpManager.setHeadsUpGoingAway(false); |
| 2604 | } |
Adrian Roos | 9550f2e | 2016-08-23 18:23:01 +0200 | [diff] [blame] | 2605 | removeRemoteInputEntriesKeptUntilCollapsed(); |
Selim Cinek | 737bff3 | 2015-05-08 16:08:35 -0700 | [diff] [blame] | 2606 | } |
| 2607 | }); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2608 | } |
| 2609 | } |
| 2610 | } |
| 2611 | |
| 2612 | @Override |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2613 | public void onHeadsUpPinned(ExpandableNotificationRow headsUp) { |
John Spurlock | b349af57 | 2015-04-29 12:24:19 -0400 | [diff] [blame] | 2614 | dismissVolumeDialog(); |
Selim Cinek | 1f3f544 | 2015-04-10 17:54:46 -0700 | [diff] [blame] | 2615 | } |
| 2616 | |
| 2617 | @Override |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2618 | public void onHeadsUpUnPinned(ExpandableNotificationRow headsUp) { |
| 2619 | } |
| 2620 | |
| 2621 | @Override |
| 2622 | public void onHeadsUpStateChanged(Entry entry, boolean isHeadsUp) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2623 | if (!isHeadsUp && mHeadsUpEntriesToRemoveOnSwitch.contains(entry)) { |
| 2624 | removeNotification(entry.key, mLatestRankingMap); |
| 2625 | mHeadsUpEntriesToRemoveOnSwitch.remove(entry); |
| 2626 | if (mHeadsUpEntriesToRemoveOnSwitch.isEmpty()) { |
| 2627 | mLatestRankingMap = null; |
| 2628 | } |
Selim Cinek | fbe9a44 | 2015-04-13 16:09:49 -0700 | [diff] [blame] | 2629 | } else { |
| 2630 | updateNotificationRanking(null); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2631 | } |
Selim Cinek | fbe9a44 | 2015-04-13 16:09:49 -0700 | [diff] [blame] | 2632 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2633 | } |
| 2634 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2635 | @Override |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 2636 | protected void updateHeadsUp(String key, Entry entry, boolean shouldPeek, |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 2637 | boolean alertAgain) { |
| 2638 | final boolean wasHeadsUp = isHeadsUp(key); |
| 2639 | if (wasHeadsUp) { |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 2640 | if (!shouldPeek) { |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 2641 | // We don't want this to be interrupting anymore, lets remove it |
Adrian Roos | c721fcc5 | 2016-04-29 11:28:37 -0700 | [diff] [blame] | 2642 | mHeadsUpManager.removeNotification(key, false /* ignoreEarliestRemovalTime */); |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2643 | } else { |
| 2644 | mHeadsUpManager.updateNotification(entry, alertAgain); |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 2645 | } |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 2646 | } else if (shouldPeek && alertAgain) { |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 2647 | // This notification was updated to be a heads-up, show it! |
| 2648 | mHeadsUpManager.showNotification(entry); |
| 2649 | } |
| 2650 | } |
| 2651 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2652 | @Override |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 2653 | protected void setHeadsUpUser(int newUserId) { |
| 2654 | if (mHeadsUpManager != null) { |
| 2655 | mHeadsUpManager.setUser(newUserId); |
| 2656 | } |
| 2657 | } |
| 2658 | |
| 2659 | public boolean isHeadsUp(String key) { |
| 2660 | return mHeadsUpManager.isHeadsUp(key); |
| 2661 | } |
| 2662 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2663 | @Override |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 2664 | protected boolean isSnoozedPackage(StatusBarNotification sbn) { |
| 2665 | return mHeadsUpManager.isSnoozed(sbn.getPackageName()); |
| 2666 | } |
| 2667 | |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 2668 | public boolean isKeyguardCurrentlySecure() { |
Selim Cinek | e8bae62 | 2015-07-15 13:24:06 -0700 | [diff] [blame] | 2669 | return !mUnlockMethodCache.canSkipBouncer(); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 2670 | } |
| 2671 | |
Selim Cinek | 4a21a7f | 2015-05-19 11:00:38 -0700 | [diff] [blame] | 2672 | public void setPanelExpanded(boolean isExpanded) { |
| 2673 | mStatusBarWindowManager.setPanelExpanded(isExpanded); |
Selim Cinek | add9526 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 2674 | mVisualStabilityManager.setPanelExpanded(isExpanded); |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 2675 | if (isExpanded && getBarState() != StatusBarState.KEYGUARD) { |
| 2676 | if (DEBUG) { |
| 2677 | Log.v(TAG, "clearing notification effects from setPanelExpanded"); |
| 2678 | } |
| 2679 | clearNotificationEffects(); |
| 2680 | } |
| 2681 | |
| 2682 | if (!isExpanded) { |
| 2683 | removeRemoteInputEntriesKeptUntilCollapsed(); |
| 2684 | } |
| 2685 | } |
| 2686 | |
| 2687 | private void removeRemoteInputEntriesKeptUntilCollapsed() { |
| 2688 | for (int i = 0; i < mRemoteInputEntriesToRemoveOnCollapse.size(); i++) { |
| 2689 | Entry entry = mRemoteInputEntriesToRemoveOnCollapse.valueAt(i); |
Adrian Roos | 7813dd7 | 2016-09-23 17:12:17 -0700 | [diff] [blame] | 2690 | mRemoteInputController.removeRemoteInput(entry, null); |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 2691 | removeNotification(entry.key, mLatestRankingMap); |
| 2692 | } |
| 2693 | mRemoteInputEntriesToRemoveOnCollapse.clear(); |
Selim Cinek | 4a21a7f | 2015-05-19 11:00:38 -0700 | [diff] [blame] | 2694 | } |
| 2695 | |
Adrian Roos | 401caae | 2016-03-04 13:35:21 -0800 | [diff] [blame] | 2696 | public void onScreenTurnedOff() { |
| 2697 | mFalsingManager.onScreenOff(); |
| 2698 | } |
| 2699 | |
Selim Cinek | add9526 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 2700 | @Override |
| 2701 | public void onReorderingAllowed() { |
| 2702 | updateNotifications(); |
| 2703 | } |
| 2704 | |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 2705 | /** |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2706 | * All changes to the status bar and notifications funnel through here and are batched. |
| 2707 | */ |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2708 | private class H extends BaseStatusBar.H { |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2709 | @Override |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2710 | public void handleMessage(Message m) { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2711 | super.handleMessage(m); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2712 | switch (m.what) { |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2713 | case MSG_OPEN_NOTIFICATION_PANEL: |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2714 | animateExpandNotificationsPanel(); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2715 | break; |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2716 | case MSG_OPEN_SETTINGS_PANEL: |
Jason Monk | a992732 | 2015-12-13 16:22:37 -0500 | [diff] [blame] | 2717 | animateExpandSettingsPanel((String) m.obj); |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2718 | break; |
| 2719 | case MSG_CLOSE_PANELS: |
| 2720 | animateCollapsePanels(); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2721 | break; |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 2722 | case MSG_LAUNCH_TRANSITION_TIMEOUT: |
| 2723 | onLaunchTransitionTimeout(); |
| 2724 | break; |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2725 | } |
| 2726 | } |
| 2727 | } |
| 2728 | |
Chris Wren | 930ecca | 2014-11-12 17:43:41 -0500 | [diff] [blame] | 2729 | @Override |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2730 | public void maybeEscalateHeadsUp() { |
Selim Cinek | 3362c13 | 2016-02-11 15:43:03 -0800 | [diff] [blame] | 2731 | Collection<HeadsUpManager.HeadsUpEntry> entries = mHeadsUpManager.getAllEntries(); |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 2732 | for (HeadsUpManager.HeadsUpEntry entry : entries) { |
| 2733 | final StatusBarNotification sbn = entry.entry.notification; |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2734 | final Notification notification = sbn.getNotification(); |
| 2735 | if (notification.fullScreenIntent != null) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2736 | if (DEBUG) { |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2737 | Log.d(TAG, "converting a heads up to fullScreen"); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2738 | } |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2739 | try { |
Chris Wren | 223c66b6 | 2014-11-10 16:00:09 -0500 | [diff] [blame] | 2740 | EventLog.writeEvent(EventLogTags.SYSUI_HEADS_UP_ESCALATION, |
| 2741 | sbn.getKey()); |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2742 | notification.fullScreenIntent.send(); |
Selim Cinek | b18a20f | 2015-06-04 17:08:35 +0200 | [diff] [blame] | 2743 | entry.entry.notifyFullScreenIntentLaunched(); |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2744 | } catch (PendingIntent.CanceledException e) { |
| 2745 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2746 | } |
| 2747 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2748 | mHeadsUpManager.releaseAllImmediately(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2749 | } |
| 2750 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2751 | /** |
| 2752 | * Called for system navigation gestures. First action opens the panel, second opens |
| 2753 | * settings. Down action closes the entire panel. |
| 2754 | */ |
| 2755 | @Override |
| 2756 | public void handleSystemNavigationKey(int key) { |
| 2757 | if (SPEW) Log.d(TAG, "handleSystemNavigationKey: " + key); |
Jim Miller | 1c21fc5 | 2016-08-02 16:12:58 -0700 | [diff] [blame] | 2758 | if (!panelsEnabled() || !mKeyguardMonitor.isDeviceInteractive() |
Jim Miller | 69c1241 | 2016-10-06 19:11:03 -0700 | [diff] [blame] | 2759 | || mKeyguardMonitor.isShowing() && !mKeyguardMonitor.isOccluded()) { |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2760 | return; |
| 2761 | } |
| 2762 | |
| 2763 | // Panels are not available in setup |
| 2764 | if (!mUserSetup) return; |
| 2765 | |
| 2766 | if (KeyEvent.KEYCODE_SYSTEM_NAVIGATION_UP == key) { |
Doris Ling | 3c00afb | 2016-07-19 17:04:21 -0700 | [diff] [blame] | 2767 | MetricsLogger.action(mContext, MetricsEvent.ACTION_SYSTEM_NAVIGATION_KEY_UP); |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2768 | mNotificationPanel.collapse(false /* delayed */, 1.0f /* speedUpFactor */); |
| 2769 | } else if (KeyEvent.KEYCODE_SYSTEM_NAVIGATION_DOWN == key) { |
Doris Ling | 3c00afb | 2016-07-19 17:04:21 -0700 | [diff] [blame] | 2770 | MetricsLogger.action(mContext, MetricsEvent.ACTION_SYSTEM_NAVIGATION_KEY_DOWN); |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2771 | if (mNotificationPanel.isFullyCollapsed()) { |
| 2772 | mNotificationPanel.expand(true /* animate */); |
Doris Ling | 3c00afb | 2016-07-19 17:04:21 -0700 | [diff] [blame] | 2773 | MetricsLogger.count(mContext, NotificationPanelView.COUNTER_PANEL_OPEN, 1); |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2774 | } else if (!mNotificationPanel.isInSettings() && !mNotificationPanel.isExpanding()){ |
| 2775 | mNotificationPanel.flingSettings(0 /* velocity */, true /* expand */); |
Doris Ling | 3c00afb | 2016-07-19 17:04:21 -0700 | [diff] [blame] | 2776 | MetricsLogger.count(mContext, NotificationPanelView.COUNTER_PANEL_OPEN_QS, 1); |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2777 | } |
| 2778 | } |
| 2779 | |
| 2780 | } |
| 2781 | |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2782 | boolean panelsEnabled() { |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 2783 | return (mDisabled1 & StatusBarManager.DISABLE_EXPAND) == 0 && !ONLY_CORE_APPS; |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2784 | } |
| 2785 | |
Jorim Jaggi | fa505a7 | 2014-04-28 20:04:11 +0200 | [diff] [blame] | 2786 | void makeExpandedVisible(boolean force) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2787 | if (SPEW) Log.d(TAG, "Make expanded visible: expanded visible=" + mExpandedVisible); |
Jorim Jaggi | fa505a7 | 2014-04-28 20:04:11 +0200 | [diff] [blame] | 2788 | if (!force && (mExpandedVisible || !panelsEnabled())) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2789 | return; |
| 2790 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 2791 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2792 | mExpandedVisible = true; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2793 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 2794 | // Expand the window to encompass the full screen in anticipation of the drag. |
| 2795 | // This is only possible to do atomically because the status bar is at the top of the screen! |
Selim Cinek | 4a21a7f | 2015-05-19 11:00:38 -0700 | [diff] [blame] | 2796 | mStatusBarWindowManager.setPanelVisible(true); |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 2797 | |
| 2798 | visibilityChanged(true); |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 2799 | mWaitingForKeyguardExit = false; |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 2800 | recomputeDisableFlags(!force /* animate */); |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 2801 | setInteracting(StatusBarManager.WINDOW_STATUS_BAR, true); |
| 2802 | } |
| 2803 | |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2804 | public void animateCollapsePanels() { |
| 2805 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 2806 | } |
| 2807 | |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 2808 | private final Runnable mAnimateCollapsePanels = new Runnable() { |
| 2809 | @Override |
| 2810 | public void run() { |
| 2811 | animateCollapsePanels(); |
| 2812 | } |
| 2813 | }; |
| 2814 | |
| 2815 | public void postAnimateCollapsePanels() { |
| 2816 | mHandler.post(mAnimateCollapsePanels); |
| 2817 | } |
| 2818 | |
Jason Monk | ba2318e | 2015-12-08 09:04:23 -0500 | [diff] [blame] | 2819 | public void postAnimateOpenPanels() { |
| 2820 | mHandler.sendEmptyMessage(MSG_OPEN_SETTINGS_PANEL); |
| 2821 | } |
| 2822 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2823 | @Override |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2824 | public void animateCollapsePanels(int flags) { |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 2825 | animateCollapsePanels(flags, false /* force */, false /* delayed */, |
| 2826 | 1.0f /* speedUpFactor */); |
Jorim Jaggi | 3425076 | 2014-07-03 23:51:19 +0200 | [diff] [blame] | 2827 | } |
| 2828 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2829 | @Override |
Jorim Jaggi | 3425076 | 2014-07-03 23:51:19 +0200 | [diff] [blame] | 2830 | public void animateCollapsePanels(int flags, boolean force) { |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 2831 | animateCollapsePanels(flags, force, false /* delayed */, 1.0f /* speedUpFactor */); |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 2832 | } |
| 2833 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2834 | @Override |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 2835 | public void animateCollapsePanels(int flags, boolean force, boolean delayed) { |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 2836 | animateCollapsePanels(flags, force, delayed, 1.0f /* speedUpFactor */); |
| 2837 | } |
| 2838 | |
| 2839 | public void animateCollapsePanels(int flags, boolean force, boolean delayed, |
| 2840 | float speedUpFactor) { |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 2841 | if (!force && mState != StatusBarState.SHADE) { |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2842 | runPostCollapseRunnables(); |
Jorim Jaggi | c1cf1ae | 2014-05-02 21:19:17 +0200 | [diff] [blame] | 2843 | return; |
| 2844 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2845 | if (SPEW) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2846 | Log.d(TAG, "animateCollapse():" |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2847 | + " mExpandedVisible=" + mExpandedVisible |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 2848 | + " flags=" + flags); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2849 | } |
| 2850 | |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 2851 | if ((flags & CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL) == 0) { |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame] | 2852 | if (!mHandler.hasMessages(MSG_HIDE_RECENT_APPS)) { |
| 2853 | mHandler.removeMessages(MSG_HIDE_RECENT_APPS); |
| 2854 | mHandler.sendEmptyMessage(MSG_HIDE_RECENT_APPS); |
| 2855 | } |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 2856 | } |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 2857 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 2858 | if (mStatusBarWindow != null) { |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 2859 | // release focus immediately to kick off focus change transition |
| 2860 | mStatusBarWindowManager.setStatusBarFocusable(false); |
| 2861 | |
John Spurlock | ab847cf | 2014-01-15 14:13:59 -0500 | [diff] [blame] | 2862 | mStatusBarWindow.cancelExpandHelper(); |
Xiaohui Chen | 9f96711 | 2016-01-07 14:14:06 -0800 | [diff] [blame] | 2863 | mStatusBarView.collapsePanel(true /* animate */, delayed, speedUpFactor); |
John Spurlock | ab847cf | 2014-01-15 14:13:59 -0500 | [diff] [blame] | 2864 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2865 | } |
| 2866 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2867 | private void runPostCollapseRunnables() { |
Selim Cinek | ae77f8e | 2015-07-07 18:43:59 -0700 | [diff] [blame] | 2868 | ArrayList<Runnable> clonedList = new ArrayList<>(mPostCollapseRunnables); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2869 | mPostCollapseRunnables.clear(); |
Selim Cinek | ae77f8e | 2015-07-07 18:43:59 -0700 | [diff] [blame] | 2870 | int size = clonedList.size(); |
| 2871 | for (int i = 0; i < size; i++) { |
| 2872 | clonedList.get(i).run(); |
| 2873 | } |
| 2874 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2875 | } |
| 2876 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 2877 | @Override |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2878 | public void animateExpandNotificationsPanel() { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2879 | if (SPEW) Log.d(TAG, "animateExpand: mExpandedVisible=" + mExpandedVisible); |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2880 | if (!panelsEnabled()) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2881 | return ; |
| 2882 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2883 | |
Oren Blasberg | 8d3fea1 | 2015-07-10 14:21:44 -0700 | [diff] [blame] | 2884 | mNotificationPanel.expand(true /* animate */); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2885 | |
| 2886 | if (false) postStartTracing(); |
| 2887 | } |
| 2888 | |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 2889 | @Override |
Jason Monk | a992732 | 2015-12-13 16:22:37 -0500 | [diff] [blame] | 2890 | public void animateExpandSettingsPanel(String subPanel) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2891 | if (SPEW) Log.d(TAG, "animateExpand: mExpandedVisible=" + mExpandedVisible); |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2892 | if (!panelsEnabled()) { |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 2893 | return; |
| 2894 | } |
| 2895 | |
Daniel Sandler | a8ef3b0 | 2012-11-29 15:52:39 -0500 | [diff] [blame] | 2896 | // Settings are not available in setup |
| 2897 | if (!mUserSetup) return; |
| 2898 | |
Jason Monk | a992732 | 2015-12-13 16:22:37 -0500 | [diff] [blame] | 2899 | |
| 2900 | if (subPanel != null) { |
| 2901 | mQSPanel.openDetails(subPanel); |
| 2902 | } |
Jason Monk | 3c68ca2 | 2015-01-30 11:30:29 -0500 | [diff] [blame] | 2903 | mNotificationPanel.expandWithQs(); |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 2904 | |
| 2905 | if (false) postStartTracing(); |
| 2906 | } |
| 2907 | |
| 2908 | public void animateCollapseQuickSettings() { |
Jorim Jaggi | 449981b | 2014-10-03 14:24:55 -0700 | [diff] [blame] | 2909 | if (mState == StatusBarState.SHADE) { |
Xiaohui Chen | 9f96711 | 2016-01-07 14:14:06 -0800 | [diff] [blame] | 2910 | mStatusBarView.collapsePanel(true, false /* delayed */, 1.0f /* speedUpFactor */); |
Jorim Jaggi | 449981b | 2014-10-03 14:24:55 -0700 | [diff] [blame] | 2911 | } |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 2912 | } |
| 2913 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 2914 | void makeExpandedInvisible() { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2915 | if (SPEW) Log.d(TAG, "makeExpandedInvisible: mExpandedVisible=" + mExpandedVisible |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2916 | + " mExpandedVisible=" + mExpandedVisible); |
| 2917 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 2918 | if (!mExpandedVisible || mStatusBarWindow == null) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2919 | return; |
| 2920 | } |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 2921 | |
Daniel Sandler | c38bbc3 | 2012-10-05 12:21:38 -0400 | [diff] [blame] | 2922 | // Ensure the panel is fully collapsed (just in case; bug 6765842, 7260868) |
Xiaohui Chen | 9f96711 | 2016-01-07 14:14:06 -0800 | [diff] [blame] | 2923 | mStatusBarView.collapsePanel(/*animate=*/ false, false /* delayed*/, |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 2924 | 1.0f /* speedUpFactor */); |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 2925 | |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 2926 | mNotificationPanel.closeQs(); |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 2927 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2928 | mExpandedVisible = false; |
| 2929 | visibilityChanged(false); |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 2930 | |
| 2931 | // Shrink the window to the size of the status bar only |
Selim Cinek | 4a21a7f | 2015-05-19 11:00:38 -0700 | [diff] [blame] | 2932 | mStatusBarWindowManager.setPanelVisible(false); |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2933 | mStatusBarWindowManager.setForceStatusBarVisible(false); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2934 | |
Daniel Sandler | 469e96e | 2012-05-04 15:56:19 -0400 | [diff] [blame] | 2935 | // Close any "App info" popups that might have snuck on-screen |
| 2936 | dismissPopups(); |
| 2937 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2938 | runPostCollapseRunnables(); |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 2939 | setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false); |
Adrian Roos | f37fce5 | 2016-12-13 15:12:02 -0800 | [diff] [blame] | 2940 | showBouncerIfKeyguard(); |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 2941 | recomputeDisableFlags(true /* animate */); |
Jorim Jaggi | 786afcb | 2014-09-25 02:41:29 +0200 | [diff] [blame] | 2942 | |
| 2943 | // Trimming will happen later if Keyguard is showing - doing it here might cause a jank in |
| 2944 | // the bouncer appear animation. |
| 2945 | if (!mStatusBarKeyguardViewManager.isShowing()) { |
| 2946 | WindowManagerGlobal.getInstance().trimMemory(ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN); |
| 2947 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2948 | } |
| 2949 | |
Daniel Sandler | b17a726 | 2012-10-05 14:32:50 -0400 | [diff] [blame] | 2950 | public boolean interceptTouchEvent(MotionEvent event) { |
Chris Wren | 64161cc | 2012-12-17 16:49:30 -0500 | [diff] [blame] | 2951 | if (DEBUG_GESTURES) { |
| 2952 | if (event.getActionMasked() != MotionEvent.ACTION_MOVE) { |
| 2953 | EventLog.writeEvent(EventLogTags.SYSUI_STATUSBAR_TOUCH, |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2954 | event.getActionMasked(), (int) event.getX(), (int) event.getY(), |
| 2955 | mDisabled1, mDisabled2); |
Chris Wren | 64161cc | 2012-12-17 16:49:30 -0500 | [diff] [blame] | 2956 | } |
| 2957 | |
| 2958 | } |
| 2959 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2960 | if (SPEW) { |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2961 | Log.d(TAG, "Touch: rawY=" + event.getRawY() + " event=" + event + " mDisabled1=" |
| 2962 | + mDisabled1 + " mDisabled2=" + mDisabled2 + " mTracking=" + mTracking); |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 2963 | } else if (CHATTY) { |
Daniel Sandler | fe172cc | 2011-09-12 13:47:25 -0400 | [diff] [blame] | 2964 | if (event.getAction() != MotionEvent.ACTION_MOVE) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2965 | Log.d(TAG, String.format( |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2966 | "panel: %s at (%f, %f) mDisabled1=0x%08x mDisabled2=0x%08x", |
Daniel Sandler | fe172cc | 2011-09-12 13:47:25 -0400 | [diff] [blame] | 2967 | MotionEvent.actionToString(event.getAction()), |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2968 | event.getRawX(), event.getRawY(), mDisabled1, mDisabled2)); |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 2969 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2970 | } |
| 2971 | |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 2972 | if (DEBUG_GESTURES) { |
| 2973 | mGestureRec.add(event); |
| 2974 | } |
Daniel Sandler | 3380534 | 2012-07-23 15:45:12 -0400 | [diff] [blame] | 2975 | |
John Spurlock | 686820a | 2013-09-03 14:44:16 -0400 | [diff] [blame] | 2976 | if (mStatusBarWindowState == WINDOW_STATE_SHOWING) { |
John Spurlock | 5fee836 | 2013-09-12 10:34:33 -0400 | [diff] [blame] | 2977 | final boolean upOrCancel = |
| 2978 | event.getAction() == MotionEvent.ACTION_UP || |
| 2979 | event.getAction() == MotionEvent.ACTION_CANCEL; |
| 2980 | if (upOrCancel && !mExpandedVisible) { |
| 2981 | setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false); |
| 2982 | } else { |
| 2983 | setInteracting(StatusBarManager.WINDOW_STATUS_BAR, true); |
| 2984 | } |
John Spurlock | 686820a | 2013-09-03 14:44:16 -0400 | [diff] [blame] | 2985 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2986 | return false; |
| 2987 | } |
| 2988 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 2989 | public GestureRecorder getGestureRecorder() { |
| 2990 | return mGestureRec; |
Jeff Brown | 911fe30 | 2011-09-12 14:21:17 -0700 | [diff] [blame] | 2991 | } |
| 2992 | |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 2993 | private void setNavigationIconHints(int hints) { |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 2994 | if (hints == mNavigationIconHints) return; |
| 2995 | |
| 2996 | mNavigationIconHints = hints; |
| 2997 | |
| 2998 | if (mNavigationBarView != null) { |
| 2999 | mNavigationBarView.setNavigationIconHints(hints); |
| 3000 | } |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3001 | checkBarModes(); |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 3002 | } |
| 3003 | |
| 3004 | @Override // CommandQueue |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 3005 | public void setWindowState(int window, int state) { |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3006 | boolean showing = state == WINDOW_STATE_SHOWING; |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 3007 | if (mStatusBarWindow != null |
| 3008 | && window == StatusBarManager.WINDOW_STATUS_BAR |
| 3009 | && mStatusBarWindowState != state) { |
| 3010 | mStatusBarWindowState = state; |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 3011 | if (DEBUG_WINDOW_STATE) Log.d(TAG, "Status bar " + windowStateToString(state)); |
Jorim Jaggi | 449981b | 2014-10-03 14:24:55 -0700 | [diff] [blame] | 3012 | if (!showing && mState == StatusBarState.SHADE) { |
Xiaohui Chen | 9f96711 | 2016-01-07 14:14:06 -0800 | [diff] [blame] | 3013 | mStatusBarView.collapsePanel(false /* animate */, false /* delayed */, |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 3014 | 1.0f /* speedUpFactor */); |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 3015 | } |
| 3016 | } |
| 3017 | if (mNavigationBarView != null |
| 3018 | && window == StatusBarManager.WINDOW_NAVIGATION_BAR |
| 3019 | && mNavigationBarWindowState != state) { |
| 3020 | mNavigationBarWindowState = state; |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 3021 | if (DEBUG_WINDOW_STATE) Log.d(TAG, "Navigation bar " + windowStateToString(state)); |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 3022 | } |
| 3023 | } |
| 3024 | |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 3025 | @Override // CommandQueue |
John Spurlock | cad5768 | 2014-07-26 17:09:56 -0400 | [diff] [blame] | 3026 | public void buzzBeepBlinked() { |
| 3027 | if (mDozeServiceHost != null) { |
| 3028 | mDozeServiceHost.fireBuzzBeepBlinked(); |
| 3029 | } |
| 3030 | } |
| 3031 | |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 3032 | @Override |
| 3033 | public void notificationLightOff() { |
| 3034 | if (mDozeServiceHost != null) { |
| 3035 | mDozeServiceHost.fireNotificationLight(false); |
| 3036 | } |
| 3037 | } |
| 3038 | |
| 3039 | @Override |
| 3040 | public void notificationLightPulse(int argb, int onMillis, int offMillis) { |
| 3041 | if (mDozeServiceHost != null) { |
| 3042 | mDozeServiceHost.fireNotificationLight(true); |
| 3043 | } |
| 3044 | } |
| 3045 | |
John Spurlock | cad5768 | 2014-07-26 17:09:56 -0400 | [diff] [blame] | 3046 | @Override // CommandQueue |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 3047 | public void setSystemUiVisibility(int vis, int fullscreenStackVis, int dockedStackVis, |
| 3048 | int mask, Rect fullscreenStackBounds, Rect dockedStackBounds) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3049 | final int oldVal = mSystemUiVisibility; |
| 3050 | final int newVal = (oldVal&~mask) | (vis&mask); |
| 3051 | final int diff = newVal ^ oldVal; |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 3052 | if (DEBUG) Log.d(TAG, String.format( |
John Spurlock | dcf4f21 | 2013-05-21 17:19:53 -0400 | [diff] [blame] | 3053 | "setSystemUiVisibility vis=%s mask=%s oldVal=%s newVal=%s diff=%s", |
| 3054 | Integer.toHexString(vis), Integer.toHexString(mask), |
| 3055 | Integer.toHexString(oldVal), Integer.toHexString(newVal), |
| 3056 | Integer.toHexString(diff))); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 3057 | boolean sbModeChanged = false; |
Daniel Sandler | e137a1e | 2011-08-17 16:47:19 -0400 | [diff] [blame] | 3058 | if (diff != 0) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3059 | mSystemUiVisibility = newVal; |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 3060 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3061 | // update low profile |
| 3062 | if ((diff & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) { |
John Spurlock | 7edfbca | 2013-09-14 11:58:55 -0400 | [diff] [blame] | 3063 | setAreThereNotifications(); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 3064 | } |
| 3065 | |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 3066 | // ready to unhide |
| 3067 | if ((vis & View.STATUS_BAR_UNHIDE) != 0) { |
| 3068 | mSystemUiVisibility &= ~View.STATUS_BAR_UNHIDE; |
| 3069 | mNoAnimationOnNextBarModeChange = true; |
| 3070 | } |
| 3071 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3072 | // update status bar mode |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3073 | final int sbMode = computeBarMode(oldVal, newVal, mStatusBarView.getBarTransitions(), |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 3074 | View.STATUS_BAR_TRANSIENT, View.STATUS_BAR_TRANSLUCENT, |
| 3075 | View.STATUS_BAR_TRANSPARENT); |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3076 | |
| 3077 | // update navigation bar mode |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3078 | final int nbMode = mNavigationBarView == null ? -1 : computeBarMode( |
John Spurlock | f6b6397 | 2013-08-27 16:08:28 -0400 | [diff] [blame] | 3079 | oldVal, newVal, mNavigationBarView.getBarTransitions(), |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 3080 | View.NAVIGATION_BAR_TRANSIENT, View.NAVIGATION_BAR_TRANSLUCENT, |
| 3081 | View.NAVIGATION_BAR_TRANSPARENT); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 3082 | sbModeChanged = sbMode != -1; |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3083 | final boolean nbModeChanged = nbMode != -1; |
| 3084 | boolean checkBarModes = false; |
| 3085 | if (sbModeChanged && sbMode != mStatusBarMode) { |
| 3086 | mStatusBarMode = sbMode; |
| 3087 | checkBarModes = true; |
| 3088 | } |
| 3089 | if (nbModeChanged && nbMode != mNavigationBarMode) { |
| 3090 | mNavigationBarMode = nbMode; |
| 3091 | checkBarModes = true; |
| 3092 | } |
| 3093 | if (checkBarModes) { |
| 3094 | checkBarModes(); |
| 3095 | } |
| 3096 | if (sbModeChanged || nbModeChanged) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3097 | // update transient bar autohide |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3098 | if (mStatusBarMode == MODE_SEMI_TRANSPARENT || mNavigationBarMode == MODE_SEMI_TRANSPARENT) { |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3099 | scheduleAutohide(); |
| 3100 | } else { |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3101 | cancelAutohide(); |
| 3102 | } |
| 3103 | } |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3104 | |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 3105 | if ((vis & View.NAVIGATION_BAR_UNHIDE) != 0) { |
| 3106 | mSystemUiVisibility &= ~View.NAVIGATION_BAR_UNHIDE; |
| 3107 | } |
| 3108 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3109 | // send updated sysui visibility to window manager |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3110 | notifyUiVisibilityChanged(mSystemUiVisibility); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3111 | } |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 3112 | |
| 3113 | mLightStatusBarController.onSystemUiVisibilityChanged(fullscreenStackVis, dockedStackVis, |
| 3114 | mask, fullscreenStackBounds, dockedStackBounds, sbModeChanged, mStatusBarMode); |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 3115 | } |
| 3116 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3117 | private int computeBarMode(int oldVis, int newVis, BarTransitions transitions, |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 3118 | int transientFlag, int translucentFlag, int transparentFlag) { |
| 3119 | final int oldMode = barMode(oldVis, transientFlag, translucentFlag, transparentFlag); |
| 3120 | final int newMode = barMode(newVis, transientFlag, translucentFlag, transparentFlag); |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3121 | if (oldMode == newMode) { |
| 3122 | return -1; // no mode change |
| 3123 | } |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3124 | return newMode; |
| 3125 | } |
| 3126 | |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 3127 | private int barMode(int vis, int transientFlag, int translucentFlag, int transparentFlag) { |
| 3128 | int lightsOutTransparent = View.SYSTEM_UI_FLAG_LOW_PROFILE | transparentFlag; |
John Spurlock | 89835dd | 2013-08-16 15:06:51 -0400 | [diff] [blame] | 3129 | return (vis & transientFlag) != 0 ? MODE_SEMI_TRANSPARENT |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3130 | : (vis & translucentFlag) != 0 ? MODE_TRANSLUCENT |
Adrian Roos | c0f0a74 | 2014-10-28 16:39:56 +0100 | [diff] [blame] | 3131 | : (vis & lightsOutTransparent) == lightsOutTransparent ? MODE_LIGHTS_OUT_TRANSPARENT |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 3132 | : (vis & transparentFlag) != 0 ? MODE_TRANSPARENT |
John Spurlock | 7edfbca | 2013-09-14 11:58:55 -0400 | [diff] [blame] | 3133 | : (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0 ? MODE_LIGHTS_OUT |
John Spurlock | 3b139a9 | 2013-08-17 17:18:08 -0400 | [diff] [blame] | 3134 | : MODE_OPAQUE; |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3135 | } |
| 3136 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3137 | private void checkBarModes() { |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3138 | if (mDemoMode) return; |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 3139 | checkBarMode(mStatusBarMode, mStatusBarWindowState, mStatusBarView.getBarTransitions(), |
| 3140 | mNoAnimationOnNextBarModeChange); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3141 | if (mNavigationBarView != null) { |
| 3142 | checkBarMode(mNavigationBarMode, |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 3143 | mNavigationBarWindowState, mNavigationBarView.getBarTransitions(), |
| 3144 | mNoAnimationOnNextBarModeChange); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3145 | } |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 3146 | mNoAnimationOnNextBarModeChange = false; |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3147 | } |
| 3148 | |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 3149 | private void checkBarMode(int mode, int windowState, BarTransitions transitions, |
| 3150 | boolean noAnimation) { |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 3151 | final boolean powerSave = mBatteryController.isPowerSave(); |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 3152 | final boolean anim = !noAnimation && mDeviceInteractive |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 3153 | && windowState != WINDOW_STATE_HIDDEN && !powerSave; |
John Spurlock | 1bb480a | 2014-08-02 17:12:43 -0400 | [diff] [blame] | 3154 | if (powerSave && getBarState() == StatusBarState.SHADE) { |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 3155 | mode = MODE_WARNING; |
| 3156 | } |
John Spurlock | c68d577 | 2013-10-08 11:47:58 -0400 | [diff] [blame] | 3157 | transitions.transitionTo(mode, anim); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3158 | } |
| 3159 | |
John Spurlock | 4219726 | 2013-10-21 09:32:25 -0400 | [diff] [blame] | 3160 | private void finishBarAnimations() { |
| 3161 | mStatusBarView.getBarTransitions().finishAnimations(); |
| 3162 | if (mNavigationBarView != null) { |
| 3163 | mNavigationBarView.getBarTransitions().finishAnimations(); |
| 3164 | } |
| 3165 | } |
| 3166 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3167 | private final Runnable mCheckBarModes = new Runnable() { |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 3168 | @Override |
| 3169 | public void run() { |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3170 | checkBarModes(); |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 3171 | } |
| 3172 | }; |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 3173 | |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3174 | @Override |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 3175 | public void setInteracting(int barWindow, boolean interacting) { |
John Spurlock | 7fbf573 | 2014-11-18 11:40:22 -0500 | [diff] [blame] | 3176 | final boolean changing = ((mInteractingWindows & barWindow) != 0) != interacting; |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 3177 | mInteractingWindows = interacting |
| 3178 | ? (mInteractingWindows | barWindow) |
| 3179 | : (mInteractingWindows & ~barWindow); |
| 3180 | if (mInteractingWindows != 0) { |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3181 | suspendAutohide(); |
| 3182 | } else { |
| 3183 | resumeSuspendedAutohide(); |
| 3184 | } |
John Spurlock | 7fbf573 | 2014-11-18 11:40:22 -0500 | [diff] [blame] | 3185 | // manually dismiss the volume panel when interacting with the nav bar |
| 3186 | if (changing && interacting && barWindow == StatusBarManager.WINDOW_NAVIGATION_BAR) { |
John Spurlock | b349af57 | 2015-04-29 12:24:19 -0400 | [diff] [blame] | 3187 | dismissVolumeDialog(); |
John Spurlock | 7fbf573 | 2014-11-18 11:40:22 -0500 | [diff] [blame] | 3188 | } |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3189 | checkBarModes(); |
| 3190 | } |
| 3191 | |
John Spurlock | b349af57 | 2015-04-29 12:24:19 -0400 | [diff] [blame] | 3192 | private void dismissVolumeDialog() { |
| 3193 | if (mVolumeComponent != null) { |
| 3194 | mVolumeComponent.dismissNow(); |
| 3195 | } |
| 3196 | } |
| 3197 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3198 | private void resumeSuspendedAutohide() { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3199 | if (mAutohideSuspended) { |
| 3200 | scheduleAutohide(); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3201 | mHandler.postDelayed(mCheckBarModes, 500); // longer than home -> launcher |
John Spurlock | 3b139a9 | 2013-08-17 17:18:08 -0400 | [diff] [blame] | 3202 | } |
| 3203 | } |
| 3204 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3205 | private void suspendAutohide() { |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3206 | mHandler.removeCallbacks(mAutohide); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3207 | mHandler.removeCallbacks(mCheckBarModes); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 3208 | mAutohideSuspended = (mSystemUiVisibility & STATUS_OR_NAV_TRANSIENT) != 0; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3209 | } |
| 3210 | |
| 3211 | private void cancelAutohide() { |
| 3212 | mAutohideSuspended = false; |
| 3213 | mHandler.removeCallbacks(mAutohide); |
| 3214 | } |
| 3215 | |
| 3216 | private void scheduleAutohide() { |
| 3217 | cancelAutohide(); |
| 3218 | mHandler.postDelayed(mAutohide, AUTOHIDE_TIMEOUT_MS); |
| 3219 | } |
| 3220 | |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 3221 | private void checkUserAutohide(View v, MotionEvent event) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3222 | if ((mSystemUiVisibility & STATUS_OR_NAV_TRANSIENT) != 0 // a transient bar is revealed |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 3223 | && event.getAction() == MotionEvent.ACTION_OUTSIDE // touch outside the source bar |
| 3224 | && event.getX() == 0 && event.getY() == 0 // a touch outside both bars |
Adrian Roos | 5e47645 | 2016-05-27 12:07:33 -0700 | [diff] [blame] | 3225 | && !mRemoteInputController.isRemoteInputActive()) { // not due to typing in IME |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 3226 | userAutohide(); |
| 3227 | } |
| 3228 | } |
| 3229 | |
Adrian Roos | 6d53de6 | 2016-12-19 16:17:50 -0800 | [diff] [blame] | 3230 | private void checkRemoteInputOutside(MotionEvent event) { |
| 3231 | if (event.getAction() == MotionEvent.ACTION_OUTSIDE // touch outside the source bar |
| 3232 | && event.getX() == 0 && event.getY() == 0 // a touch outside both bars |
| 3233 | && mRemoteInputController.isRemoteInputActive()) { |
| 3234 | mRemoteInputController.closeRemoteInputs(); |
| 3235 | } |
| 3236 | } |
| 3237 | |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 3238 | private void userAutohide() { |
| 3239 | cancelAutohide(); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 3240 | mHandler.postDelayed(mAutohide, 350); // longer than app gesture -> flag clear |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 3241 | } |
| 3242 | |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 3243 | private boolean areLightsOn() { |
| 3244 | return 0 == (mSystemUiVisibility & View.SYSTEM_UI_FLAG_LOW_PROFILE); |
| 3245 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 3246 | |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 3247 | public void setLightsOn(boolean on) { |
| 3248 | Log.v(TAG, "setLightsOn(" + on + ")"); |
| 3249 | if (on) { |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 3250 | setSystemUiVisibility(0, 0, 0, View.SYSTEM_UI_FLAG_LOW_PROFILE, |
| 3251 | mLastFullscreenStackBounds, mLastDockedStackBounds); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 3252 | } else { |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 3253 | setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE, 0, 0, |
| 3254 | View.SYSTEM_UI_FLAG_LOW_PROFILE, mLastFullscreenStackBounds, |
| 3255 | mLastDockedStackBounds); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 3256 | } |
| 3257 | } |
| 3258 | |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3259 | private void notifyUiVisibilityChanged(int vis) { |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 3260 | try { |
Adrian Roos | 389beec | 2015-05-12 13:33:25 -0700 | [diff] [blame] | 3261 | if (mLastDispatchedSystemUiVisibility != vis) { |
| 3262 | mWindowManagerService.statusBarVisibilityChanged(vis); |
| 3263 | mLastDispatchedSystemUiVisibility = vis; |
| 3264 | } |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 3265 | } catch (RemoteException ex) { |
| 3266 | } |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3267 | } |
| 3268 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 3269 | @Override |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 3270 | public void topAppWindowChanged(boolean showMenu) { |
Chris Wren | 8a1638f | 2016-05-02 16:19:14 -0400 | [diff] [blame] | 3271 | if (SPEW) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 3272 | Log.d(TAG, (showMenu?"showing":"hiding") + " the MENU button"); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 3273 | } |
| 3274 | if (mNavigationBarView != null) { |
Daniel Sandler | f1ebcee | 2011-09-15 16:02:56 -0400 | [diff] [blame] | 3275 | mNavigationBarView.setMenuVisibility(showMenu); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 3276 | } |
| 3277 | |
| 3278 | // See above re: lights-out policy for legacy apps. |
| 3279 | if (showMenu) setLightsOn(true); |
| 3280 | } |
| 3281 | |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 3282 | @Override |
Jason Monk | b605fec | 2014-05-02 17:04:10 -0400 | [diff] [blame] | 3283 | public void setImeWindowStatus(IBinder token, int vis, int backDisposition, |
| 3284 | boolean showImeSwitcher) { |
Jason Monk | f1ff209 | 2014-04-29 16:50:53 -0400 | [diff] [blame] | 3285 | boolean imeShown = (vis & InputMethodService.IME_VISIBLE) != 0; |
| 3286 | int flags = mNavigationIconHints; |
| 3287 | if ((backDisposition == InputMethodService.BACK_DISPOSITION_WILL_DISMISS) || imeShown) { |
| 3288 | flags |= NAVIGATION_HINT_BACK_ALT; |
| 3289 | } else { |
| 3290 | flags &= ~NAVIGATION_HINT_BACK_ALT; |
| 3291 | } |
Jason Monk | b605fec | 2014-05-02 17:04:10 -0400 | [diff] [blame] | 3292 | if (showImeSwitcher) { |
Jason Monk | f1ff209 | 2014-04-29 16:50:53 -0400 | [diff] [blame] | 3293 | flags |= NAVIGATION_HINT_IME_SHOWN; |
| 3294 | } else { |
| 3295 | flags &= ~NAVIGATION_HINT_IME_SHOWN; |
| 3296 | } |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 3297 | |
Jason Monk | f1ff209 | 2014-04-29 16:50:53 -0400 | [diff] [blame] | 3298 | setNavigationIconHints(flags); |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 3299 | } |
| 3300 | |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 3301 | public static String viewInfo(View v) { |
| 3302 | return "[(" + v.getLeft() + "," + v.getTop() + ")(" + v.getRight() + "," + v.getBottom() |
| 3303 | + ") " + v.getWidth() + "x" + v.getHeight() + "]"; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3304 | } |
| 3305 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 3306 | @Override |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 3307 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3308 | synchronized (mQueueLock) { |
| 3309 | pw.println("Current Status Bar state:"); |
Daniel Sandler | e7237fc | 2012-08-14 16:08:27 -0400 | [diff] [blame] | 3310 | pw.println(" mExpandedVisible=" + mExpandedVisible |
Daniel Sandler | fdbac77 | 2012-07-03 14:30:10 -0400 | [diff] [blame] | 3311 | + ", mTrackingPosition=" + mTrackingPosition); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3312 | pw.println(" mTracking=" + mTracking); |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 3313 | pw.println(" mDisplayMetrics=" + mDisplayMetrics); |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 3314 | pw.println(" mStackScroller: " + viewInfo(mStackScroller)); |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 3315 | pw.println(" mStackScroller: " + viewInfo(mStackScroller) |
| 3316 | + " scroll " + mStackScroller.getScrollX() |
| 3317 | + "," + mStackScroller.getScrollY()); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3318 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3319 | |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 3320 | pw.print(" mInteractingWindows="); pw.println(mInteractingWindows); |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 3321 | pw.print(" mStatusBarWindowState="); |
| 3322 | pw.println(windowStateToString(mStatusBarWindowState)); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3323 | pw.print(" mStatusBarMode="); |
| 3324 | pw.println(BarTransitions.modeToString(mStatusBarMode)); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 3325 | pw.print(" mDozing="); pw.println(mDozing); |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 3326 | pw.print(" mZenMode="); |
| 3327 | pw.println(Settings.Global.zenModeToString(mZenMode)); |
Chris Wren | 3b6745b | 2014-03-07 14:34:35 -0500 | [diff] [blame] | 3328 | pw.print(" mUseHeadsUp="); |
| 3329 | pw.println(mUseHeadsUp); |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 3330 | dumpBarTransitions(pw, "mStatusBarView", mStatusBarView.getBarTransitions()); |
| 3331 | if (mNavigationBarView != null) { |
| 3332 | pw.print(" mNavigationBarWindowState="); |
| 3333 | pw.println(windowStateToString(mNavigationBarWindowState)); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3334 | pw.print(" mNavigationBarMode="); |
| 3335 | pw.println(BarTransitions.modeToString(mNavigationBarMode)); |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 3336 | dumpBarTransitions(pw, "mNavigationBarView", mNavigationBarView.getBarTransitions()); |
| 3337 | } |
| 3338 | |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 3339 | pw.print(" mNavigationBarView="); |
| 3340 | if (mNavigationBarView == null) { |
| 3341 | pw.println("null"); |
| 3342 | } else { |
| 3343 | mNavigationBarView.dump(fd, pw, args); |
| 3344 | } |
| 3345 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 3346 | pw.print(" mMediaSessionManager="); |
| 3347 | pw.println(mMediaSessionManager); |
| 3348 | pw.print(" mMediaNotificationKey="); |
| 3349 | pw.println(mMediaNotificationKey); |
| 3350 | pw.print(" mMediaController="); |
| 3351 | pw.print(mMediaController); |
| 3352 | if (mMediaController != null) { |
| 3353 | pw.print(" state=" + mMediaController.getPlaybackState()); |
| 3354 | } |
| 3355 | pw.println(); |
| 3356 | pw.print(" mMediaMetadata="); |
| 3357 | pw.print(mMediaMetadata); |
| 3358 | if (mMediaMetadata != null) { |
RoboErik | 75847b9 | 2014-07-29 13:10:17 -0700 | [diff] [blame] | 3359 | pw.print(" title=" + mMediaMetadata.getText(MediaMetadata.METADATA_KEY_TITLE)); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 3360 | } |
| 3361 | pw.println(); |
| 3362 | |
Daniel Sandler | 37a38aa | 2013-02-13 17:15:57 -0500 | [diff] [blame] | 3363 | pw.println(" Panels: "); |
| 3364 | if (mNotificationPanel != null) { |
| 3365 | pw.println(" mNotificationPanel=" + |
| 3366 | mNotificationPanel + " params=" + mNotificationPanel.getLayoutParams().debug("")); |
| 3367 | pw.print (" "); |
| 3368 | mNotificationPanel.dump(fd, pw, args); |
| 3369 | } |
Daniel Sandler | 37a38aa | 2013-02-13 17:15:57 -0500 | [diff] [blame] | 3370 | |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 3371 | DozeLog.dump(pw); |
| 3372 | |
Daniel Sandler | 7579bca | 2011-08-18 15:47:26 -0400 | [diff] [blame] | 3373 | if (DUMPTRUCK) { |
| 3374 | synchronized (mNotificationData) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 3375 | mNotificationData.dump(pw, " "); |
Daniel Sandler | 7579bca | 2011-08-18 15:47:26 -0400 | [diff] [blame] | 3376 | } |
| 3377 | |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 3378 | mIconController.dump(pw); |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 3379 | |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 3380 | if (false) { |
| 3381 | pw.println("see the logcat for a dump of the views we have created."); |
| 3382 | // must happen on ui thread |
| 3383 | mHandler.post(new Runnable() { |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 3384 | @Override |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 3385 | public void run() { |
| 3386 | mStatusBarView.getLocationOnScreen(mAbsPos); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 3387 | Log.d(TAG, "mStatusBarView: ----- (" + mAbsPos[0] + "," + mAbsPos[1] |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 3388 | + ") " + mStatusBarView.getWidth() + "x" |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 3389 | + getStatusBarHeight()); |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 3390 | mStatusBarView.debug(); |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 3391 | } |
| 3392 | }); |
| 3393 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3394 | } |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 3395 | |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 3396 | if (DEBUG_GESTURES) { |
| 3397 | pw.print(" status bar gestures: "); |
| 3398 | mGestureRec.dump(fd, pw, args); |
| 3399 | } |
Selim Cinek | 7025f26 | 2015-07-13 16:22:48 -0700 | [diff] [blame] | 3400 | if (mStatusBarWindowManager != null) { |
| 3401 | mStatusBarWindowManager.dump(fd, pw, args); |
| 3402 | } |
John Spurlock | 486b78e | 2014-07-07 08:37:56 -0400 | [diff] [blame] | 3403 | if (mNetworkController != null) { |
| 3404 | mNetworkController.dump(fd, pw, args); |
| 3405 | } |
| 3406 | if (mBluetoothController != null) { |
| 3407 | mBluetoothController.dump(fd, pw, args); |
| 3408 | } |
Jason Monk | dd5bdc6 | 2015-07-20 12:18:38 -0400 | [diff] [blame] | 3409 | if (mHotspotController != null) { |
| 3410 | mHotspotController.dump(fd, pw, args); |
| 3411 | } |
John Spurlock | 1e6eb17 | 2014-07-13 11:59:50 -0400 | [diff] [blame] | 3412 | if (mCastController != null) { |
| 3413 | mCastController.dump(fd, pw, args); |
| 3414 | } |
Adrian Roos | 00a0b1f | 2014-07-16 16:44:49 +0200 | [diff] [blame] | 3415 | if (mUserSwitcherController != null) { |
| 3416 | mUserSwitcherController.dump(fd, pw, args); |
| 3417 | } |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 3418 | if (mBatteryController != null) { |
| 3419 | mBatteryController.dump(fd, pw, args); |
| 3420 | } |
Jorim Jaggi | c7dea6e | 2014-07-26 14:36:57 +0200 | [diff] [blame] | 3421 | if (mNextAlarmController != null) { |
| 3422 | mNextAlarmController.dump(fd, pw, args); |
| 3423 | } |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 3424 | if (mSecurityController != null) { |
| 3425 | mSecurityController.dump(fd, pw, args); |
| 3426 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 3427 | if (mHeadsUpManager != null) { |
| 3428 | mHeadsUpManager.dump(fd, pw, args); |
Chris Wren | 428c6b6 | 2014-12-05 16:07:06 -0500 | [diff] [blame] | 3429 | } else { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 3430 | pw.println(" mHeadsUpManager: null"); |
Chris Wren | 428c6b6 | 2014-12-05 16:07:06 -0500 | [diff] [blame] | 3431 | } |
Selim Cinek | 52941c5 | 2016-05-07 18:29:32 -0400 | [diff] [blame] | 3432 | if (mGroupManager != null) { |
| 3433 | mGroupManager.dump(fd, pw, args); |
| 3434 | } else { |
| 3435 | pw.println(" mGroupManager: null"); |
| 3436 | } |
Jason Monk | ab52527 | 2015-07-13 17:02:49 -0400 | [diff] [blame] | 3437 | if (KeyguardUpdateMonitor.getInstance(mContext) != null) { |
| 3438 | KeyguardUpdateMonitor.getInstance(mContext).dump(fd, pw, args); |
| 3439 | } |
Jason Monk | ad32c55 | 2016-10-04 14:50:11 -0400 | [diff] [blame] | 3440 | if (mFlashlightController != null) { |
| 3441 | mFlashlightController.dump(fd, pw, args); |
| 3442 | } |
Chris Wren | 428c6b6 | 2014-12-05 16:07:06 -0500 | [diff] [blame] | 3443 | |
Adrian Roos | 401caae | 2016-03-04 13:35:21 -0800 | [diff] [blame] | 3444 | FalsingManager.getInstance(mContext).dump(pw); |
| 3445 | FalsingLog.dump(pw); |
| 3446 | |
John Spurlock | 7bbb9f6 | 2014-10-21 12:15:28 -0400 | [diff] [blame] | 3447 | pw.println("SharedPreferences:"); |
Andrew Flynn | 8286257 | 2015-04-01 14:22:37 -0400 | [diff] [blame] | 3448 | for (Map.Entry<String, ?> entry : Prefs.getAll(mContext).entrySet()) { |
John Spurlock | 7bbb9f6 | 2014-10-21 12:15:28 -0400 | [diff] [blame] | 3449 | pw.print(" "); pw.print(entry.getKey()); pw.print("="); pw.println(entry.getValue()); |
| 3450 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3451 | } |
| 3452 | |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 3453 | private static void dumpBarTransitions(PrintWriter pw, String var, BarTransitions transitions) { |
| 3454 | pw.print(" "); pw.print(var); pw.print(".BarTransitions.mMode="); |
| 3455 | pw.println(BarTransitions.modeToString(transitions.getMode())); |
| 3456 | } |
| 3457 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 3458 | @Override |
| 3459 | public void createAndAddWindows() { |
| 3460 | addStatusBarWindow(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3461 | } |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 3462 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 3463 | private void addStatusBarWindow() { |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 3464 | makeStatusBarView(); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3465 | mStatusBarWindowManager = new StatusBarWindowManager(mContext); |
Adrian Roos | 1c0ca50 | 2015-10-07 12:20:42 -0700 | [diff] [blame] | 3466 | mRemoteInputController = new RemoteInputController(mStatusBarWindowManager, |
| 3467 | mHeadsUpManager); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3468 | mStatusBarWindowManager.add(mStatusBarWindow, getStatusBarHeight()); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3469 | } |
| 3470 | |
Daniel Sandler | 747a9e9 | 2012-08-10 16:39:19 -0400 | [diff] [blame] | 3471 | // called by makeStatusbar and also by PhoneStatusBarView |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 3472 | void updateDisplaySize() { |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 3473 | mDisplay.getMetrics(mDisplayMetrics); |
Daniel Sandler | 7e8ae50 | 2013-10-10 23:38:19 -0400 | [diff] [blame] | 3474 | mDisplay.getSize(mCurrentDisplaySize); |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 3475 | if (DEBUG_GESTURES) { |
John Spurlock | 209bede | 2013-07-17 12:23:27 -0400 | [diff] [blame] | 3476 | mGestureRec.tag("display", |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 3477 | String.format("%dx%d", mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels)); |
| 3478 | } |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 3479 | } |
| 3480 | |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 3481 | float getDisplayDensity() { |
| 3482 | return mDisplayMetrics.density; |
| 3483 | } |
| 3484 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 3485 | public void startActivityDismissingKeyguard(final Intent intent, boolean onlyProvisioned, |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3486 | boolean dismissShade) { |
| 3487 | startActivityDismissingKeyguard(intent, onlyProvisioned, dismissShade, null /* callback */); |
| 3488 | } |
| 3489 | |
| 3490 | public void startActivityDismissingKeyguard(final Intent intent, boolean onlyProvisioned, |
| 3491 | final boolean dismissShade, final Callback callback) { |
Daniel Sandler | 3679bf5 | 2012-10-16 21:30:28 -0400 | [diff] [blame] | 3492 | if (onlyProvisioned && !isDeviceProvisioned()) return; |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 3493 | |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 3494 | final boolean afterKeyguardGone = PreviewInflater.wouldLaunchResolverActivity( |
| 3495 | mContext, intent, mCurrentUserId); |
Jorim Jaggi | c7dea6e | 2014-07-26 14:36:57 +0200 | [diff] [blame] | 3496 | final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing(); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3497 | Runnable runnable = new Runnable() { |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 3498 | @Override |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3499 | public void run() { |
Jorim Jaggi | b835dd7 | 2015-06-08 12:28:42 -0700 | [diff] [blame] | 3500 | mAssistManager.hideAssist(); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3501 | intent.setFlags( |
| 3502 | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3503 | int result = ActivityManager.START_CANCELED; |
Robert Carr | fd10cd1 | 2016-06-29 16:41:50 -0700 | [diff] [blame] | 3504 | ActivityOptions options = new ActivityOptions(getActivityOptions()); |
| 3505 | if (intent == KeyguardBottomAreaView.INSECURE_CAMERA_INTENT) { |
| 3506 | // Normally an activity will set it's requested rotation |
| 3507 | // animation on its window. However when launching an activity |
| 3508 | // causes the orientation to change this is too late. In these cases |
| 3509 | // the default animation is used. This doesn't look good for |
| 3510 | // the camera (as it rotates the camera contents out of sync |
| 3511 | // with physical reality). So, we ask the WindowManager to |
| 3512 | // force the crossfade animation if an orientation change |
| 3513 | // happens to occur during the launch. |
| 3514 | options.setRotationAnimationHint( |
Robert Carr | 57d9fbd | 2016-08-15 12:00:35 -0700 | [diff] [blame] | 3515 | WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS); |
Robert Carr | fd10cd1 | 2016-06-29 16:41:50 -0700 | [diff] [blame] | 3516 | } |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3517 | try { |
| 3518 | result = ActivityManagerNative.getDefault().startActivityAsUser( |
| 3519 | null, mContext.getBasePackageName(), |
| 3520 | intent, |
| 3521 | intent.resolveTypeIfNeeded(mContext.getContentResolver()), |
Jorim Jaggi | e6e108e | 2016-03-28 13:38:45 -0700 | [diff] [blame] | 3522 | null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, |
Robert Carr | fd10cd1 | 2016-06-29 16:41:50 -0700 | [diff] [blame] | 3523 | options.toBundle(), UserHandle.CURRENT.getIdentifier()); |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3524 | } catch (RemoteException e) { |
| 3525 | Log.w(TAG, "Unable to start activity", e); |
| 3526 | } |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3527 | overrideActivityPendingAppTransition( |
| 3528 | keyguardShowing && !afterKeyguardGone); |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3529 | if (callback != null) { |
| 3530 | callback.onActivityStarted(result); |
| 3531 | } |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3532 | } |
| 3533 | }; |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3534 | Runnable cancelRunnable = new Runnable() { |
| 3535 | @Override |
| 3536 | public void run() { |
Jorim Jaggi | 5cc8659 | 2015-06-08 14:48:28 -0700 | [diff] [blame] | 3537 | if (callback != null) { |
| 3538 | callback.onActivityStarted(ActivityManager.START_CANCELED); |
| 3539 | } |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3540 | } |
| 3541 | }; |
Jorim Jaggi | b835dd7 | 2015-06-08 12:28:42 -0700 | [diff] [blame] | 3542 | executeRunnableDismissingKeyguard(runnable, cancelRunnable, dismissShade, |
Felipe Leme | ee5d630 | 2016-04-22 16:11:19 -0700 | [diff] [blame] | 3543 | afterKeyguardGone, true /* deferred */); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3544 | } |
| 3545 | |
| 3546 | public void executeRunnableDismissingKeyguard(final Runnable runnable, |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3547 | final Runnable cancelAction, |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3548 | final boolean dismissShade, |
Felipe Leme | ee5d630 | 2016-04-22 16:11:19 -0700 | [diff] [blame] | 3549 | final boolean afterKeyguardGone, |
| 3550 | final boolean deferred) { |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3551 | final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing(); |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 3552 | dismissKeyguardThenExecute(new OnDismissAction() { |
| 3553 | @Override |
| 3554 | public boolean onDismiss() { |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 3555 | AsyncTask.execute(new Runnable() { |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 3556 | @Override |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 3557 | public void run() { |
| 3558 | try { |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 3559 | if (keyguardShowing && !afterKeyguardGone) { |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 3560 | ActivityManagerNative.getDefault() |
| 3561 | .keyguardWaitingForActivityDrawn(); |
| 3562 | } |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3563 | if (runnable != null) { |
| 3564 | runnable.run(); |
| 3565 | } |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 3566 | } catch (RemoteException e) { |
| 3567 | } |
| 3568 | } |
| 3569 | }); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 3570 | if (dismissShade) { |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 3571 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */, |
| 3572 | true /* delayed*/); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 3573 | } |
Felipe Leme | ee5d630 | 2016-04-22 16:11:19 -0700 | [diff] [blame] | 3574 | return deferred; |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 3575 | } |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3576 | }, cancelAction, afterKeyguardGone); |
Daniel Sandler | 3679bf5 | 2012-10-16 21:30:28 -0400 | [diff] [blame] | 3577 | } |
| 3578 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3579 | private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 3580 | @Override |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3581 | public void onReceive(Context context, Intent intent) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 3582 | if (DEBUG) Log.v(TAG, "onReceive: " + intent); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3583 | String action = intent.getAction(); |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 3584 | if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) { |
Andrei Stingaceanu | f86bc97 | 2016-04-12 15:29:25 +0100 | [diff] [blame] | 3585 | KeyboardShortcuts.dismiss(); |
Adrian Roos | 0721535 | 2016-06-23 11:19:28 -0700 | [diff] [blame] | 3586 | if (mRemoteInputController != null) { |
| 3587 | mRemoteInputController.closeRemoteInputs(); |
| 3588 | } |
Kenny Guy | 44fc65f | 2014-11-28 22:18:14 +0000 | [diff] [blame] | 3589 | if (isCurrentProfile(getSendingUserId())) { |
| 3590 | int flags = CommandQueue.FLAG_EXCLUDE_NONE; |
| 3591 | String reason = intent.getStringExtra("reason"); |
| 3592 | if (reason != null && reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) { |
| 3593 | flags |= CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL; |
| 3594 | } |
| 3595 | animateCollapsePanels(flags); |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 3596 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3597 | } |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 3598 | else if (Intent.ACTION_SCREEN_OFF.equals(action)) { |
John Spurlock | 1bbd49d | 2012-10-19 11:09:32 -0400 | [diff] [blame] | 3599 | notifyNavigationBarScreenOn(false); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 3600 | notifyHeadsUpScreenOff(); |
John Spurlock | 4219726 | 2013-10-21 09:32:25 -0400 | [diff] [blame] | 3601 | finishBarAnimations(); |
Selim Cinek | ccd14fb | 2014-08-12 18:53:24 +0200 | [diff] [blame] | 3602 | resetUserExpandedStates(); |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 3603 | } |
Daniel Sandler | 7f3cf95 | 2012-08-31 14:57:09 -0400 | [diff] [blame] | 3604 | else if (Intent.ACTION_SCREEN_ON.equals(action)) { |
John Spurlock | 1bbd49d | 2012-10-19 11:09:32 -0400 | [diff] [blame] | 3605 | notifyNavigationBarScreenOn(true); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3606 | } |
phweiss | 923d2cc | 2016-12-14 21:37:48 +0100 | [diff] [blame] | 3607 | else if (DevicePolicyManager.ACTION_SHOW_DEVICE_MONITORING_DIALOG.equals(action)) { |
| 3608 | mQSPanel.showDeviceMonitoringDialog(); |
| 3609 | } |
Adrian Roos | 8e3e836 | 2015-07-16 19:42:22 -0700 | [diff] [blame] | 3610 | } |
| 3611 | }; |
| 3612 | |
| 3613 | private BroadcastReceiver mDemoReceiver = new BroadcastReceiver() { |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 3614 | @Override |
Adrian Roos | 8e3e836 | 2015-07-16 19:42:22 -0700 | [diff] [blame] | 3615 | public void onReceive(Context context, Intent intent) { |
| 3616 | if (DEBUG) Log.v(TAG, "onReceive: " + intent); |
| 3617 | String action = intent.getAction(); |
| 3618 | if (ACTION_DEMO.equals(action)) { |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3619 | Bundle bundle = intent.getExtras(); |
| 3620 | if (bundle != null) { |
| 3621 | String command = bundle.getString("command", "").trim().toLowerCase(); |
| 3622 | if (command.length() > 0) { |
| 3623 | try { |
| 3624 | dispatchDemoCommand(command, bundle); |
| 3625 | } catch (Throwable t) { |
| 3626 | Log.w(TAG, "Error running demo command, intent=" + intent, t); |
| 3627 | } |
| 3628 | } |
| 3629 | } |
Adrian Roos | 8e3e836 | 2015-07-16 19:42:22 -0700 | [diff] [blame] | 3630 | } else if (ACTION_FAKE_ARTWORK.equals(action)) { |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 3631 | if (DEBUG_MEDIA_FAKE_ARTWORK) { |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 3632 | updateMediaMetaData(true, true); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 3633 | } |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3634 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3635 | } |
| 3636 | }; |
| 3637 | |
Selim Cinek | 78f4008 | 2016-03-10 18:06:27 -0800 | [diff] [blame] | 3638 | public void resetUserExpandedStates() { |
Selim Cinek | ccd14fb | 2014-08-12 18:53:24 +0200 | [diff] [blame] | 3639 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
| 3640 | final int notificationCount = activeNotifications.size(); |
| 3641 | for (int i = 0; i < notificationCount; i++) { |
| 3642 | NotificationData.Entry entry = activeNotifications.get(i); |
| 3643 | if (entry.row != null) { |
| 3644 | entry.row.resetUserExpansion(); |
| 3645 | } |
| 3646 | } |
| 3647 | } |
| 3648 | |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 3649 | @Override |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3650 | protected void dismissKeyguardThenExecute(OnDismissAction action, boolean afterKeyguardGone) { |
| 3651 | dismissKeyguardThenExecute(action, null /* cancelRunnable */, afterKeyguardGone); |
| 3652 | } |
| 3653 | |
Jason Monk | abe1974 | 2015-09-29 09:47:06 -0400 | [diff] [blame] | 3654 | public void dismissKeyguard() { |
| 3655 | mStatusBarKeyguardViewManager.dismiss(); |
| 3656 | } |
| 3657 | |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3658 | private void dismissKeyguardThenExecute(OnDismissAction action, Runnable cancelAction, |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 3659 | boolean afterKeyguardGone) { |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 3660 | if (mStatusBarKeyguardViewManager.isShowing()) { |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3661 | mStatusBarKeyguardViewManager.dismissWithAction(action, cancelAction, |
| 3662 | afterKeyguardGone); |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 3663 | } else { |
| 3664 | action.onDismiss(); |
| 3665 | } |
| 3666 | } |
| 3667 | |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 3668 | // SystemUIService notifies SystemBars of configuration changes, which then calls down here |
| 3669 | @Override |
| 3670 | protected void onConfigurationChanged(Configuration newConfig) { |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 3671 | updateResources(); |
| 3672 | updateDisplaySize(); // populates mDisplayMetrics |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 3673 | super.onConfigurationChanged(newConfig); // calls refreshLayout |
| 3674 | |
| 3675 | if (DEBUG) { |
| 3676 | Log.v(TAG, "configuration changed: " + mContext.getResources().getConfiguration()); |
| 3677 | } |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 3678 | |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 3679 | repositionNavigationBar(); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 3680 | updateRowStates(); |
Jason Monk | 18f99d9 | 2014-09-11 13:36:42 -0400 | [diff] [blame] | 3681 | mScreenPinningRequest.onConfigurationChanged(); |
Jason Monk | 1c040db | 2015-07-20 09:45:54 -0400 | [diff] [blame] | 3682 | mNetworkController.onConfigurationChanged(); |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 3683 | } |
| 3684 | |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 3685 | @Override |
| 3686 | public void userSwitched(int newUserId) { |
Chris Wren | a6d4fb6 | 2014-11-20 14:46:23 -0500 | [diff] [blame] | 3687 | super.userSwitched(newUserId); |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 3688 | if (MULTIUSER_DEBUG) mNotificationPanelDebugText.setText("USER " + newUserId); |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 3689 | animateCollapsePanels(); |
Adrian Roos | 31b844b | 2014-11-21 13:55:09 +0100 | [diff] [blame] | 3690 | updatePublicMode(); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 3691 | updateNotifications(); |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 3692 | resetUserSetupObserver(); |
John Spurlock | 89f060a | 2014-07-16 21:03:15 -0400 | [diff] [blame] | 3693 | setControllerUsers(); |
Julia Reynolds | 86ef8e2 | 2015-09-09 16:42:38 -0400 | [diff] [blame] | 3694 | clearCurrentMediaNotification(); |
Vadim Tryshev | 12a30e8 | 2016-02-12 15:39:28 -0800 | [diff] [blame] | 3695 | mLockscreenWallpaper.setCurrentUser(newUserId); |
Jorim Jaggi | e31f6b8 | 2016-07-01 16:15:09 -0700 | [diff] [blame] | 3696 | mScrimController.setCurrentUser(newUserId); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 3697 | updateMediaMetaData(true, false); |
John Spurlock | 89f060a | 2014-07-16 21:03:15 -0400 | [diff] [blame] | 3698 | } |
| 3699 | |
| 3700 | private void setControllerUsers() { |
| 3701 | if (mZenModeController != null) { |
| 3702 | mZenModeController.setUserId(mCurrentUserId); |
| 3703 | } |
Robin Lee | 63204ee | 2015-06-04 01:53:01 +0100 | [diff] [blame] | 3704 | if (mSecurityController != null) { |
| 3705 | mSecurityController.onUserSwitched(mCurrentUserId); |
| 3706 | } |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 3707 | } |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 3708 | |
| 3709 | private void resetUserSetupObserver() { |
| 3710 | mContext.getContentResolver().unregisterContentObserver(mUserSetupObserver); |
| 3711 | mUserSetupObserver.onChange(false); |
| 3712 | mContext.getContentResolver().registerContentObserver( |
| 3713 | Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE), true, |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 3714 | mUserSetupObserver, mCurrentUserId); |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 3715 | } |
| 3716 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3717 | /** |
| 3718 | * Reload some of our resources when the configuration changes. |
| 3719 | * |
| 3720 | * We don't reload everything when the configuration changes -- we probably |
| 3721 | * should, but getting that smooth is tough. Someday we'll fix that. In the |
| 3722 | * meantime, just update the things that we know change. |
| 3723 | */ |
| 3724 | void updateResources() { |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 3725 | // Update the quick setting tiles |
John Spurlock | 7e6809a | 2014-08-06 16:03:14 -0400 | [diff] [blame] | 3726 | if (mQSPanel != null) { |
| 3727 | mQSPanel.updateResources(); |
| 3728 | } |
Winson Chung | d63c5978 | 2012-09-05 17:34:41 -0700 | [diff] [blame] | 3729 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 3730 | loadDimens(); |
John Spurlock | 7e6809a | 2014-08-06 16:03:14 -0400 | [diff] [blame] | 3731 | |
| 3732 | if (mNotificationPanel != null) { |
| 3733 | mNotificationPanel.updateResources(); |
| 3734 | } |
Adrian Roos | 5fd872e | 2014-08-12 17:28:58 +0200 | [diff] [blame] | 3735 | if (mBrightnessMirrorController != null) { |
| 3736 | mBrightnessMirrorController.updateResources(); |
| 3737 | } |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 3738 | } |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 3739 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 3740 | protected void loadDimens() { |
| 3741 | final Resources res = mContext.getResources(); |
| 3742 | |
Jorim Jaggi | 11c62e1 | 2016-04-05 20:41:21 -0700 | [diff] [blame] | 3743 | int oldBarHeight = mNaturalBarHeight; |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 3744 | mNaturalBarHeight = res.getDimensionPixelSize( |
| 3745 | com.android.internal.R.dimen.status_bar_height); |
Jorim Jaggi | 11c62e1 | 2016-04-05 20:41:21 -0700 | [diff] [blame] | 3746 | if (mStatusBarWindowManager != null && mNaturalBarHeight != oldBarHeight) { |
| 3747 | mStatusBarWindowManager.setBarHeight(mNaturalBarHeight); |
| 3748 | } |
| 3749 | mMaxAllowedKeyguardNotifications = res.getInteger( |
| 3750 | R.integer.keyguard_max_notification_count); |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 3751 | |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 3752 | if (DEBUG) Log.v(TAG, "defineSlots"); |
John Spurlock | 804df70 | 2012-06-01 15:34:27 -0400 | [diff] [blame] | 3753 | } |
| 3754 | |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3755 | // Visibility reporting |
| 3756 | |
| 3757 | @Override |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 3758 | protected void handleVisibleToUserChanged(boolean visibleToUser) { |
| 3759 | if (visibleToUser) { |
| 3760 | super.handleVisibleToUserChanged(visibleToUser); |
| 3761 | startNotificationLogging(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3762 | } else { |
Christoph Studer | 037e34c | 2014-04-30 20:06:04 +0200 | [diff] [blame] | 3763 | stopNotificationLogging(); |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 3764 | super.handleVisibleToUserChanged(visibleToUser); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3765 | } |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3766 | } |
| 3767 | |
Christoph Studer | 037e34c | 2014-04-30 20:06:04 +0200 | [diff] [blame] | 3768 | private void stopNotificationLogging() { |
| 3769 | // Report all notifications as invisible and turn down the |
| 3770 | // reporter. |
| 3771 | if (!mCurrentlyVisibleNotifications.isEmpty()) { |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 3772 | logNotificationVisibilityChanges(Collections.<NotificationVisibility>emptyList(), |
| 3773 | mCurrentlyVisibleNotifications); |
| 3774 | recycleAllVisibilityObjects(mCurrentlyVisibleNotifications); |
Christoph Studer | 037e34c | 2014-04-30 20:06:04 +0200 | [diff] [blame] | 3775 | } |
| 3776 | mHandler.removeCallbacks(mVisibilityReporter); |
| 3777 | mStackScroller.setChildLocationsChangedListener(null); |
| 3778 | } |
| 3779 | |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 3780 | private void startNotificationLogging() { |
| 3781 | mStackScroller.setChildLocationsChangedListener(mNotificationLocationsChangedListener); |
| 3782 | // Some transitions like mVisibleToUser=false -> mVisibleToUser=true don't |
| 3783 | // cause the scroller to emit child location events. Hence generate |
| 3784 | // one ourselves to guarantee that we're reporting visible |
| 3785 | // notifications. |
| 3786 | // (Note that in cases where the scroller does emit events, this |
| 3787 | // additional event doesn't break anything.) |
| 3788 | mNotificationLocationsChangedListener.onChildLocationsChanged(mStackScroller); |
Christoph Studer | 037e34c | 2014-04-30 20:06:04 +0200 | [diff] [blame] | 3789 | } |
| 3790 | |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3791 | private void logNotificationVisibilityChanges( |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 3792 | Collection<NotificationVisibility> newlyVisible, |
| 3793 | Collection<NotificationVisibility> noLongerVisible) { |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3794 | if (newlyVisible.isEmpty() && noLongerVisible.isEmpty()) { |
| 3795 | return; |
| 3796 | } |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 3797 | NotificationVisibility[] newlyVisibleAr = |
| 3798 | newlyVisible.toArray(new NotificationVisibility[newlyVisible.size()]); |
| 3799 | NotificationVisibility[] noLongerVisibleAr = |
| 3800 | noLongerVisible.toArray(new NotificationVisibility[noLongerVisible.size()]); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3801 | try { |
| 3802 | mBarService.onNotificationVisibilityChanged(newlyVisibleAr, noLongerVisibleAr); |
| 3803 | } catch (RemoteException e) { |
| 3804 | // Ignore. |
| 3805 | } |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 3806 | |
| 3807 | final int N = newlyVisible.size(); |
Amith Yamasani | 7649567 | 2015-07-07 15:22:54 -0700 | [diff] [blame] | 3808 | if (N > 0) { |
| 3809 | String[] newlyVisibleKeyAr = new String[N]; |
| 3810 | for (int i = 0; i < N; i++) { |
| 3811 | newlyVisibleKeyAr[i] = newlyVisibleAr[i].key; |
| 3812 | } |
| 3813 | |
| 3814 | setNotificationsShown(newlyVisibleKeyAr); |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 3815 | } |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3816 | } |
| 3817 | |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 3818 | // State logging |
| 3819 | |
| 3820 | private void logStateToEventlog() { |
| 3821 | boolean isShowing = mStatusBarKeyguardViewManager.isShowing(); |
| 3822 | boolean isOccluded = mStatusBarKeyguardViewManager.isOccluded(); |
| 3823 | boolean isBouncerShowing = mStatusBarKeyguardViewManager.isBouncerShowing(); |
| 3824 | boolean isSecure = mUnlockMethodCache.isMethodSecure(); |
Selim Cinek | e8bae62 | 2015-07-15 13:24:06 -0700 | [diff] [blame] | 3825 | boolean canSkipBouncer = mUnlockMethodCache.canSkipBouncer(); |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 3826 | int stateFingerprint = getLoggingFingerprint(mState, |
| 3827 | isShowing, |
| 3828 | isOccluded, |
| 3829 | isBouncerShowing, |
| 3830 | isSecure, |
Selim Cinek | e8bae62 | 2015-07-15 13:24:06 -0700 | [diff] [blame] | 3831 | canSkipBouncer); |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 3832 | if (stateFingerprint != mLastLoggedStateFingerprint) { |
| 3833 | EventLogTags.writeSysuiStatusBarState(mState, |
| 3834 | isShowing ? 1 : 0, |
| 3835 | isOccluded ? 1 : 0, |
| 3836 | isBouncerShowing ? 1 : 0, |
| 3837 | isSecure ? 1 : 0, |
Selim Cinek | e8bae62 | 2015-07-15 13:24:06 -0700 | [diff] [blame] | 3838 | canSkipBouncer ? 1 : 0); |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 3839 | mLastLoggedStateFingerprint = stateFingerprint; |
| 3840 | } |
| 3841 | } |
| 3842 | |
| 3843 | /** |
| 3844 | * Returns a fingerprint of fields logged to eventlog |
| 3845 | */ |
| 3846 | private static int getLoggingFingerprint(int statusBarState, boolean keyguardShowing, |
| 3847 | boolean keyguardOccluded, boolean bouncerShowing, boolean secure, |
| 3848 | boolean currentlyInsecure) { |
| 3849 | // Reserve 8 bits for statusBarState. We'll never go higher than |
| 3850 | // that, right? Riiiight. |
| 3851 | return (statusBarState & 0xFF) |
| 3852 | | ((keyguardShowing ? 1 : 0) << 8) |
| 3853 | | ((keyguardOccluded ? 1 : 0) << 9) |
| 3854 | | ((bouncerShowing ? 1 : 0) << 10) |
| 3855 | | ((secure ? 1 : 0) << 11) |
| 3856 | | ((currentlyInsecure ? 1 : 0) << 12); |
| 3857 | } |
| 3858 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3859 | // |
| 3860 | // tracing |
| 3861 | // |
| 3862 | |
| 3863 | void postStartTracing() { |
| 3864 | mHandler.postDelayed(mStartTracing, 3000); |
| 3865 | } |
| 3866 | |
| 3867 | void vibrate() { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 3868 | android.os.Vibrator vib = (android.os.Vibrator)mContext.getSystemService( |
| 3869 | Context.VIBRATOR_SERVICE); |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 3870 | vib.vibrate(250, VIBRATION_ATTRIBUTES); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3871 | } |
| 3872 | |
| 3873 | Runnable mStartTracing = new Runnable() { |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 3874 | @Override |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3875 | public void run() { |
| 3876 | vibrate(); |
| 3877 | SystemClock.sleep(250); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 3878 | Log.d(TAG, "startTracing"); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3879 | android.os.Debug.startMethodTracing("/data/statusbar-traces/trace"); |
| 3880 | mHandler.postDelayed(mStopTracing, 10000); |
| 3881 | } |
| 3882 | }; |
| 3883 | |
| 3884 | Runnable mStopTracing = new Runnable() { |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 3885 | @Override |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3886 | public void run() { |
| 3887 | android.os.Debug.stopMethodTracing(); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 3888 | Log.d(TAG, "stopTracing"); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3889 | vibrate(); |
| 3890 | } |
| 3891 | }; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 3892 | |
| 3893 | @Override |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 3894 | public boolean shouldDisableNavbarGestures() { |
Jorim Jaggi | 18976a5 | 2015-07-24 13:18:19 -0700 | [diff] [blame] | 3895 | return !isDeviceProvisioned() || (mDisabled1 & StatusBarManager.DISABLE_SEARCH) != 0; |
Jim Miller | 670d9dd | 2012-05-12 13:28:26 -0700 | [diff] [blame] | 3896 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3897 | |
Jason Monk | ba2318e | 2015-12-08 09:04:23 -0500 | [diff] [blame] | 3898 | public void postQSRunnableDismissingKeyguard(final Runnable runnable) { |
| 3899 | mHandler.post(new Runnable() { |
| 3900 | @Override |
| 3901 | public void run() { |
| 3902 | mLeaveOpenOnKeyguardHide = true; |
Felipe Leme | ee5d630 | 2016-04-22 16:11:19 -0700 | [diff] [blame] | 3903 | executeRunnableDismissingKeyguard(runnable, null, false, false, false); |
Jason Monk | ba2318e | 2015-12-08 09:04:23 -0500 | [diff] [blame] | 3904 | } |
| 3905 | }); |
| 3906 | } |
| 3907 | |
Adrian Roos | 62692b2 | 2015-09-11 17:46:23 -0700 | [diff] [blame] | 3908 | public void postStartActivityDismissingKeyguard(final PendingIntent intent) { |
| 3909 | mHandler.post(new Runnable() { |
| 3910 | @Override |
| 3911 | public void run() { |
| 3912 | startPendingIntentDismissingKeyguard(intent); |
| 3913 | } |
| 3914 | }); |
| 3915 | } |
| 3916 | |
Jason Monk | ee43cdf | 2015-06-19 14:20:46 -0400 | [diff] [blame] | 3917 | public void postStartActivityDismissingKeyguard(final Intent intent, int delay) { |
John Spurlock | d47a3f3 | 2014-05-18 19:14:14 -0400 | [diff] [blame] | 3918 | mHandler.postDelayed(new Runnable() { |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 3919 | @Override |
| 3920 | public void run() { |
Jason Monk | ee43cdf | 2015-06-19 14:20:46 -0400 | [diff] [blame] | 3921 | handleStartActivityDismissingKeyguard(intent, true /*onlyProvisioned*/); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 3922 | } |
John Spurlock | d47a3f3 | 2014-05-18 19:14:14 -0400 | [diff] [blame] | 3923 | }, delay); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 3924 | } |
| 3925 | |
Jason Monk | ee43cdf | 2015-06-19 14:20:46 -0400 | [diff] [blame] | 3926 | private void handleStartActivityDismissingKeyguard(Intent intent, boolean onlyProvisioned) { |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 3927 | startActivityDismissingKeyguard(intent, onlyProvisioned, true /* dismissShade */); |
John Spurlock | de54700 | 2014-02-28 17:50:39 -0500 | [diff] [blame] | 3928 | } |
| 3929 | |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 3930 | private static class FastColorDrawable extends Drawable { |
| 3931 | private final int mColor; |
| 3932 | |
| 3933 | public FastColorDrawable(int color) { |
| 3934 | mColor = 0xff000000 | color; |
| 3935 | } |
| 3936 | |
| 3937 | @Override |
| 3938 | public void draw(Canvas canvas) { |
| 3939 | canvas.drawColor(mColor, PorterDuff.Mode.SRC); |
| 3940 | } |
| 3941 | |
| 3942 | @Override |
| 3943 | public void setAlpha(int alpha) { |
| 3944 | } |
| 3945 | |
| 3946 | @Override |
Chris Craik | bd3bfc5 | 2015-03-02 10:43:29 -0800 | [diff] [blame] | 3947 | public void setColorFilter(ColorFilter colorFilter) { |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 3948 | } |
| 3949 | |
| 3950 | @Override |
| 3951 | public int getOpacity() { |
| 3952 | return PixelFormat.OPAQUE; |
| 3953 | } |
| 3954 | |
| 3955 | @Override |
| 3956 | public void setBounds(int left, int top, int right, int bottom) { |
| 3957 | } |
| 3958 | |
| 3959 | @Override |
| 3960 | public void setBounds(Rect bounds) { |
| 3961 | } |
| 3962 | } |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 3963 | |
| 3964 | @Override |
| 3965 | public void destroy() { |
| 3966 | super.destroy(); |
| 3967 | if (mStatusBarWindow != null) { |
| 3968 | mWindowManager.removeViewImmediate(mStatusBarWindow); |
John Spurlock | ab847cf | 2014-01-15 14:13:59 -0500 | [diff] [blame] | 3969 | mStatusBarWindow = null; |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 3970 | } |
| 3971 | if (mNavigationBarView != null) { |
| 3972 | mWindowManager.removeViewImmediate(mNavigationBarView); |
John Spurlock | ab847cf | 2014-01-15 14:13:59 -0500 | [diff] [blame] | 3973 | mNavigationBarView = null; |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 3974 | } |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 3975 | if (mHandlerThread != null) { |
| 3976 | mHandlerThread.quitSafely(); |
| 3977 | mHandlerThread = null; |
| 3978 | } |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 3979 | mContext.unregisterReceiver(mBroadcastReceiver); |
Adrian Roos | 8e3e836 | 2015-07-16 19:42:22 -0700 | [diff] [blame] | 3980 | mContext.unregisterReceiver(mDemoReceiver); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3981 | mAssistManager.destroy(); |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 3982 | |
| 3983 | final SignalClusterView signalCluster = |
| 3984 | (SignalClusterView) mStatusBarView.findViewById(R.id.signal_cluster); |
| 3985 | final SignalClusterView signalClusterKeyguard = |
| 3986 | (SignalClusterView) mKeyguardStatusBar.findViewById(R.id.signal_cluster); |
| 3987 | final SignalClusterView signalClusterQs = |
| 3988 | (SignalClusterView) mHeader.findViewById(R.id.signal_cluster); |
Jason Monk | 5e74517 | 2015-06-02 19:14:44 -0400 | [diff] [blame] | 3989 | mNetworkController.removeSignalCallback(signalCluster); |
| 3990 | mNetworkController.removeSignalCallback(signalClusterKeyguard); |
| 3991 | mNetworkController.removeSignalCallback(signalClusterQs); |
| 3992 | if (mQSPanel != null && mQSPanel.getHost() != null) { |
| 3993 | mQSPanel.getHost().destroy(); |
| 3994 | } |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 3995 | } |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3996 | |
| 3997 | private boolean mDemoModeAllowed; |
| 3998 | private boolean mDemoMode; |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3999 | |
| 4000 | @Override |
| 4001 | public void dispatchDemoCommand(String command, Bundle args) { |
| 4002 | if (!mDemoModeAllowed) { |
| 4003 | mDemoModeAllowed = Settings.Global.getInt(mContext.getContentResolver(), |
Jason Monk | 431ad73 | 2015-07-16 08:58:15 -0400 | [diff] [blame] | 4004 | DEMO_MODE_ALLOWED, 0) != 0; |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 4005 | } |
| 4006 | if (!mDemoModeAllowed) return; |
| 4007 | if (command.equals(COMMAND_ENTER)) { |
| 4008 | mDemoMode = true; |
| 4009 | } else if (command.equals(COMMAND_EXIT)) { |
| 4010 | mDemoMode = false; |
| 4011 | checkBarModes(); |
| 4012 | } else if (!mDemoMode) { |
| 4013 | // automatically enter demo mode on first demo command |
| 4014 | dispatchDemoCommand(COMMAND_ENTER, new Bundle()); |
| 4015 | } |
| 4016 | boolean modeChange = command.equals(COMMAND_ENTER) || command.equals(COMMAND_EXIT); |
John Spurlock | bb4a702 | 2014-11-08 12:40:19 -0500 | [diff] [blame] | 4017 | if ((modeChange || command.equals(COMMAND_VOLUME)) && mVolumeComponent != null) { |
| 4018 | mVolumeComponent.dispatchDemoCommand(command, args); |
| 4019 | } |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 4020 | if (modeChange || command.equals(COMMAND_CLOCK)) { |
| 4021 | dispatchDemoCommandToView(command, args, R.id.clock); |
| 4022 | } |
| 4023 | if (modeChange || command.equals(COMMAND_BATTERY)) { |
Jason Monk | 98d7c7a | 2016-04-12 13:08:31 -0400 | [diff] [blame] | 4024 | mBatteryController.dispatchDemoCommand(command, args); |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 4025 | } |
| 4026 | if (modeChange || command.equals(COMMAND_STATUS)) { |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 4027 | mIconController.dispatchDemoCommand(command, args); |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 4028 | } |
| 4029 | if (mNetworkController != null && (modeChange || command.equals(COMMAND_NETWORK))) { |
| 4030 | mNetworkController.dispatchDemoCommand(command, args); |
| 4031 | } |
John Spurlock | 7f42fc5 | 2014-01-14 16:20:39 -0500 | [diff] [blame] | 4032 | if (modeChange || command.equals(COMMAND_NOTIFICATIONS)) { |
| 4033 | View notifications = mStatusBarView == null ? null |
| 4034 | : mStatusBarView.findViewById(R.id.notification_icon_area); |
| 4035 | if (notifications != null) { |
| 4036 | String visible = args.getString("visible"); |
| 4037 | int vis = mDemoMode && "false".equals(visible) ? View.INVISIBLE : View.VISIBLE; |
| 4038 | notifications.setVisibility(vis); |
| 4039 | } |
| 4040 | } |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 4041 | if (command.equals(COMMAND_BARS)) { |
| 4042 | String mode = args.getString("mode"); |
| 4043 | int barMode = "opaque".equals(mode) ? MODE_OPAQUE : |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 4044 | "translucent".equals(mode) ? MODE_TRANSLUCENT : |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 4045 | "semi-transparent".equals(mode) ? MODE_SEMI_TRANSPARENT : |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 4046 | "transparent".equals(mode) ? MODE_TRANSPARENT : |
| 4047 | "warning".equals(mode) ? MODE_WARNING : |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 4048 | -1; |
| 4049 | if (barMode != -1) { |
| 4050 | boolean animate = true; |
| 4051 | if (mStatusBarView != null) { |
| 4052 | mStatusBarView.getBarTransitions().transitionTo(barMode, animate); |
| 4053 | } |
| 4054 | if (mNavigationBarView != null) { |
| 4055 | mNavigationBarView.getBarTransitions().transitionTo(barMode, animate); |
| 4056 | } |
| 4057 | } |
| 4058 | } |
| 4059 | } |
| 4060 | |
| 4061 | private void dispatchDemoCommandToView(String command, Bundle args, int id) { |
| 4062 | if (mStatusBarView == null) return; |
| 4063 | View v = mStatusBarView.findViewById(id); |
| 4064 | if (v instanceof DemoMode) { |
| 4065 | ((DemoMode)v).dispatchDemoCommand(command, args); |
| 4066 | } |
| 4067 | } |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4068 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4069 | /** |
| 4070 | * @return The {@link StatusBarState} the status bar is in. |
| 4071 | */ |
| 4072 | public int getBarState() { |
| 4073 | return mState; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4074 | } |
| 4075 | |
Chris Wren | 1689594 | 2015-06-23 11:22:20 -0400 | [diff] [blame] | 4076 | @Override |
Yorke Lee | e4ea6ab | 2016-03-03 14:51:49 -0800 | [diff] [blame] | 4077 | public boolean isPanelFullyCollapsed() { |
Chris Wren | 1689594 | 2015-06-23 11:22:20 -0400 | [diff] [blame] | 4078 | return mNotificationPanel.isFullyCollapsed(); |
| 4079 | } |
| 4080 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4081 | public void showKeyguard() { |
Jorim Jaggi | 5e08e69 | 2014-10-03 15:17:20 -0700 | [diff] [blame] | 4082 | if (mLaunchTransitionFadingAway) { |
| 4083 | mNotificationPanel.animate().cancel(); |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 4084 | onLaunchTransitionFadingEnded(); |
Jorim Jaggi | 5e08e69 | 2014-10-03 15:17:20 -0700 | [diff] [blame] | 4085 | } |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 4086 | mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 4087 | if (mUserSwitcherController != null && mUserSwitcherController.useFullscreenUserSwitcher()) { |
| 4088 | setBarState(StatusBarState.FULLSCREEN_USER_SWITCHER); |
| 4089 | } else { |
| 4090 | setBarState(StatusBarState.KEYGUARD); |
| 4091 | } |
Jorim Jaggi | 98f8530 | 2014-08-07 17:45:04 +0200 | [diff] [blame] | 4092 | updateKeyguardState(false /* goingToFullShade */, false /* fromShadeLocked */); |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4093 | if (!mDeviceInteractive) { |
Jorim Jaggi | d41083a | 2014-09-12 02:54:40 +0200 | [diff] [blame] | 4094 | |
| 4095 | // If the screen is off already, we need to disable touch events because these might |
| 4096 | // collapse the panel after we expanded it, and thus we would end up with a blank |
| 4097 | // Keyguard. |
| 4098 | mNotificationPanel.setTouchDisabled(true); |
| 4099 | } |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 4100 | if (mState == StatusBarState.KEYGUARD) { |
| 4101 | instantExpandNotificationsPanel(); |
| 4102 | } else if (mState == StatusBarState.FULLSCREEN_USER_SWITCHER) { |
| 4103 | instantCollapseNotificationPanel(); |
| 4104 | } |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4105 | mLeaveOpenOnKeyguardHide = false; |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4106 | if (mDraggedDownRow != null) { |
| 4107 | mDraggedDownRow.setUserLocked(false); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 4108 | mDraggedDownRow.notifyHeightChanged(false /* needsAnimation */); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4109 | mDraggedDownRow = null; |
| 4110 | } |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 4111 | mPendingRemoteInputView = null; |
Jorim Jaggi | 19695d9 | 2015-07-20 15:51:40 -0700 | [diff] [blame] | 4112 | mAssistManager.onLockscreenShown(); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4113 | } |
| 4114 | |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 4115 | private void onLaunchTransitionFadingEnded() { |
| 4116 | mNotificationPanel.setAlpha(1.0f); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4117 | mNotificationPanel.onAffordanceLaunchEnded(); |
| 4118 | releaseGestureWakeLock(); |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 4119 | runLaunchTransitionEndRunnable(); |
| 4120 | mLaunchTransitionFadingAway = false; |
| 4121 | mScrimController.forceHideScrims(false /* hide */); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 4122 | updateMediaMetaData(true /* metaDataChanged */, true); |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 4123 | } |
| 4124 | |
Selim Cinek | 36b0223 | 2016-05-11 23:07:05 -0400 | [diff] [blame] | 4125 | @Override |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 4126 | public boolean isCollapsing() { |
| 4127 | return mNotificationPanel.isCollapsing(); |
| 4128 | } |
| 4129 | |
Selim Cinek | 36b0223 | 2016-05-11 23:07:05 -0400 | [diff] [blame] | 4130 | @Override |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 4131 | public void addPostCollapseAction(Runnable r) { |
| 4132 | mPostCollapseRunnables.add(r); |
| 4133 | } |
| 4134 | |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 4135 | public boolean isInLaunchTransition() { |
| 4136 | return mNotificationPanel.isLaunchTransitionRunning() |
| 4137 | || mNotificationPanel.isLaunchTransitionFinished(); |
| 4138 | } |
| 4139 | |
| 4140 | /** |
| 4141 | * Fades the content of the keyguard away after the launch transition is done. |
| 4142 | * |
| 4143 | * @param beforeFading the runnable to be run when the circle is fully expanded and the fading |
| 4144 | * starts |
| 4145 | * @param endRunnable the runnable to be run when the transition is done |
| 4146 | */ |
| 4147 | public void fadeKeyguardAfterLaunchTransition(final Runnable beforeFading, |
Jorim Jaggi | 5e08e69 | 2014-10-03 15:17:20 -0700 | [diff] [blame] | 4148 | Runnable endRunnable) { |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 4149 | mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); |
Jorim Jaggi | 5e08e69 | 2014-10-03 15:17:20 -0700 | [diff] [blame] | 4150 | mLaunchTransitionEndRunnable = endRunnable; |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 4151 | Runnable hideRunnable = new Runnable() { |
| 4152 | @Override |
| 4153 | public void run() { |
| 4154 | mLaunchTransitionFadingAway = true; |
| 4155 | if (beforeFading != null) { |
| 4156 | beforeFading.run(); |
| 4157 | } |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 4158 | mScrimController.forceHideScrims(true /* hide */); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 4159 | updateMediaMetaData(false, true); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 4160 | mNotificationPanel.setAlpha(1); |
Selim Cinek | 07304f522 | 2016-05-19 18:31:36 -0700 | [diff] [blame] | 4161 | mStackScroller.setParentFadingOut(true); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 4162 | mNotificationPanel.animate() |
| 4163 | .alpha(0) |
| 4164 | .setStartDelay(FADE_KEYGUARD_START_DELAY) |
| 4165 | .setDuration(FADE_KEYGUARD_DURATION) |
| 4166 | .withLayer() |
| 4167 | .withEndAction(new Runnable() { |
| 4168 | @Override |
| 4169 | public void run() { |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 4170 | onLaunchTransitionFadingEnded(); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 4171 | } |
| 4172 | }); |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4173 | mIconController.appTransitionStarting(SystemClock.uptimeMillis(), |
| 4174 | StatusBarIconController.DEFAULT_TINT_ANIMATION_DURATION); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 4175 | } |
| 4176 | }; |
| 4177 | if (mNotificationPanel.isLaunchTransitionRunning()) { |
| 4178 | mNotificationPanel.setLaunchTransitionEndRunnable(hideRunnable); |
| 4179 | } else { |
| 4180 | hideRunnable.run(); |
| 4181 | } |
| 4182 | } |
| 4183 | |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4184 | /** |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 4185 | * Fades the content of the Keyguard while we are dozing and makes it invisible when finished |
| 4186 | * fading. |
| 4187 | */ |
| 4188 | public void fadeKeyguardWhilePulsing() { |
| 4189 | mNotificationPanel.animate() |
| 4190 | .alpha(0f) |
| 4191 | .setStartDelay(0) |
| 4192 | .setDuration(FADE_KEYGUARD_DURATION_PULSING) |
Jorim Jaggi | ab45a21 | 2015-08-20 16:59:44 -0700 | [diff] [blame] | 4193 | .setInterpolator(ScrimController.KEYGUARD_FADE_OUT_INTERPOLATOR) |
| 4194 | .start(); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 4195 | } |
| 4196 | |
| 4197 | /** |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 4198 | * Plays the animation when an activity that was occluding Keyguard goes away. |
| 4199 | */ |
| 4200 | public void animateKeyguardUnoccluding() { |
| 4201 | mScrimController.animateKeyguardUnoccluding(500); |
| 4202 | mNotificationPanel.setExpandedFraction(0f); |
| 4203 | animateExpandNotificationsPanel(); |
| 4204 | } |
| 4205 | |
| 4206 | /** |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 4207 | * Starts the timeout when we try to start the affordances on Keyguard. We usually rely that |
| 4208 | * Keyguard goes away via fadeKeyguardAfterLaunchTransition, however, that might not happen |
| 4209 | * because the launched app crashed or something else went wrong. |
| 4210 | */ |
| 4211 | public void startLaunchTransitionTimeout() { |
| 4212 | mHandler.sendEmptyMessageDelayed(MSG_LAUNCH_TRANSITION_TIMEOUT, |
| 4213 | LAUNCH_TRANSITION_TIMEOUT_MS); |
| 4214 | } |
| 4215 | |
| 4216 | private void onLaunchTransitionTimeout() { |
| 4217 | Log.w(TAG, "Launch transition: Timeout!"); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4218 | mNotificationPanel.onAffordanceLaunchEnded(); |
| 4219 | releaseGestureWakeLock(); |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 4220 | mNotificationPanel.resetViews(); |
| 4221 | } |
| 4222 | |
| 4223 | private void runLaunchTransitionEndRunnable() { |
| 4224 | if (mLaunchTransitionEndRunnable != null) { |
| 4225 | Runnable r = mLaunchTransitionEndRunnable; |
| 4226 | |
| 4227 | // mLaunchTransitionEndRunnable might call showKeyguard, which would execute it again, |
| 4228 | // which would lead to infinite recursion. Protect against it. |
| 4229 | mLaunchTransitionEndRunnable = null; |
| 4230 | r.run(); |
| 4231 | } |
| 4232 | } |
| 4233 | |
| 4234 | /** |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4235 | * @return true if we would like to stay in the shade, false if it should go away entirely |
| 4236 | */ |
| 4237 | public boolean hideKeyguard() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 4238 | Trace.beginSection("PhoneStatusBar#hideKeyguard"); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4239 | boolean staying = mLeaveOpenOnKeyguardHide; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4240 | setBarState(StatusBarState.SHADE); |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 4241 | View viewToClick = null; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4242 | if (mLeaveOpenOnKeyguardHide) { |
| 4243 | mLeaveOpenOnKeyguardHide = false; |
Jorim Jaggi | 37c1180 | 2015-08-18 20:27:54 -0700 | [diff] [blame] | 4244 | long delay = calculateGoingToFullShadeDelay(); |
| 4245 | mNotificationPanel.animateToFullShade(delay); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4246 | if (mDraggedDownRow != null) { |
| 4247 | mDraggedDownRow.setUserLocked(false); |
| 4248 | mDraggedDownRow = null; |
| 4249 | } |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 4250 | viewToClick = mPendingRemoteInputView; |
| 4251 | mPendingRemoteInputView = null; |
Jorim Jaggi | 37c1180 | 2015-08-18 20:27:54 -0700 | [diff] [blame] | 4252 | |
| 4253 | // Disable layout transitions in navbar for this transition because the load is just |
| 4254 | // too heavy for the CPU and GPU on any device. |
| 4255 | if (mNavigationBarView != null) { |
| 4256 | mNavigationBarView.setLayoutTransitionsEnabled(false); |
| 4257 | mNavigationBarView.postDelayed(new Runnable() { |
| 4258 | @Override |
| 4259 | public void run() { |
| 4260 | mNavigationBarView.setLayoutTransitionsEnabled(true); |
| 4261 | } |
| 4262 | }, delay + StackStateAnimator.ANIMATION_DURATION_GO_TO_FULL_SHADE); |
| 4263 | } |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4264 | } else { |
| 4265 | instantCollapseNotificationPanel(); |
| 4266 | } |
Jorim Jaggi | 98f8530 | 2014-08-07 17:45:04 +0200 | [diff] [blame] | 4267 | updateKeyguardState(staying, false /* fromShadeLocked */); |
Jorim Jaggi | 1ecd7cd | 2014-11-03 16:18:03 +0100 | [diff] [blame] | 4268 | |
Adrian Roos | b22665d | 2016-10-17 15:08:03 -0700 | [diff] [blame] | 4269 | if (viewToClick != null && viewToClick.isAttachedToWindow()) { |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 4270 | viewToClick.callOnClick(); |
| 4271 | } |
| 4272 | |
Jorim Jaggi | 1ecd7cd | 2014-11-03 16:18:03 +0100 | [diff] [blame] | 4273 | // Keyguard state has changed, but QS is not listening anymore. Make sure to update the tile |
| 4274 | // visibilities so next time we open the panel we know the correct height already. |
| 4275 | if (mQSPanel != null) { |
| 4276 | mQSPanel.refreshAllTiles(); |
| 4277 | } |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 4278 | mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4279 | releaseGestureWakeLock(); |
| 4280 | mNotificationPanel.onAffordanceLaunchEnded(); |
Jorim Jaggi | 52429b4 | 2015-09-03 19:58:19 -0700 | [diff] [blame] | 4281 | mNotificationPanel.animate().cancel(); |
Jorim Jaggi | 9097885 | 2015-08-18 19:55:53 -0700 | [diff] [blame] | 4282 | mNotificationPanel.setAlpha(1f); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 4283 | Trace.endSection(); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4284 | return staying; |
| 4285 | } |
| 4286 | |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4287 | private void releaseGestureWakeLock() { |
| 4288 | if (mGestureWakeLock.isHeld()) { |
| 4289 | mGestureWakeLock.release(); |
| 4290 | } |
| 4291 | } |
| 4292 | |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4293 | public long calculateGoingToFullShadeDelay() { |
| 4294 | return mKeyguardFadingAwayDelay + mKeyguardFadingAwayDuration; |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 4295 | } |
| 4296 | |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4297 | /** |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4298 | * Notifies the status bar that Keyguard is going away very soon. |
| 4299 | */ |
| 4300 | public void keyguardGoingAway() { |
| 4301 | |
| 4302 | // Treat Keyguard exit animation as an app transition to achieve nice transition for status |
| 4303 | // bar. |
Adrian Roos | 46df1ca | 2015-09-11 12:38:43 -0700 | [diff] [blame] | 4304 | mKeyguardGoingAway = true; |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4305 | mIconController.appTransitionPending(); |
| 4306 | } |
| 4307 | |
| 4308 | /** |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4309 | * Notifies the status bar the Keyguard is fading away with the specified timings. |
| 4310 | * |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4311 | * @param startTime the start time of the animations in uptime millis |
| 4312 | * @param delay the precalculated animation delay in miliseconds |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4313 | * @param fadeoutDuration the duration of the exit animation, in milliseconds |
| 4314 | */ |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4315 | public void setKeyguardFadingAway(long startTime, long delay, long fadeoutDuration) { |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4316 | mKeyguardFadingAway = true; |
| 4317 | mKeyguardFadingAwayDelay = delay; |
| 4318 | mKeyguardFadingAwayDuration = fadeoutDuration; |
| 4319 | mWaitingForKeyguardExit = false; |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4320 | mIconController.appTransitionStarting( |
| 4321 | startTime + fadeoutDuration |
| 4322 | - StatusBarIconController.DEFAULT_TINT_ANIMATION_DURATION, |
| 4323 | StatusBarIconController.DEFAULT_TINT_ANIMATION_DURATION); |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 4324 | recomputeDisableFlags(fadeoutDuration > 0 /* animate */); |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4325 | } |
| 4326 | |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 4327 | public boolean isKeyguardFadingAway() { |
| 4328 | return mKeyguardFadingAway; |
| 4329 | } |
| 4330 | |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4331 | /** |
| 4332 | * Notifies that the Keyguard fading away animation is done. |
| 4333 | */ |
| 4334 | public void finishKeyguardFadingAway() { |
| 4335 | mKeyguardFadingAway = false; |
Adrian Roos | 46df1ca | 2015-09-11 12:38:43 -0700 | [diff] [blame] | 4336 | mKeyguardGoingAway = false; |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4337 | } |
| 4338 | |
Adrian Roos | d322f1a | 2015-04-23 15:19:45 -0700 | [diff] [blame] | 4339 | public void stopWaitingForKeyguardExit() { |
| 4340 | mWaitingForKeyguardExit = false; |
| 4341 | } |
| 4342 | |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 4343 | private void updatePublicMode() { |
Tony Mak | 92c989d | 2016-04-19 14:02:44 +0100 | [diff] [blame] | 4344 | boolean isPublic = false; |
| 4345 | if (mStatusBarKeyguardViewManager.isShowing()) { |
| 4346 | for (int i = mCurrentProfiles.size() - 1; i >= 0; i--) { |
| 4347 | UserInfo userInfo = mCurrentProfiles.valueAt(i); |
| 4348 | if (mStatusBarKeyguardViewManager.isSecure(userInfo.id)) { |
| 4349 | isPublic = true; |
| 4350 | break; |
| 4351 | } |
| 4352 | } |
| 4353 | } |
| 4354 | setLockscreenPublicMode(isPublic); |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 4355 | } |
| 4356 | |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 4357 | protected void updateKeyguardState(boolean goingToFullShade, boolean fromShadeLocked) { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 4358 | Trace.beginSection("PhoneStatusBar#updateKeyguardState"); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4359 | if (mState == StatusBarState.KEYGUARD) { |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4360 | mKeyguardIndicationController.setVisible(true); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 4361 | mNotificationPanel.resetViews(); |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 4362 | if (mKeyguardUserSwitcher != null) { |
| 4363 | mKeyguardUserSwitcher.setKeyguard(true, fromShadeLocked); |
| 4364 | } |
Selim Cinek | 80c2abe | 2015-06-17 15:37:30 -0700 | [diff] [blame] | 4365 | mStatusBarView.removePendingHideExpandedRunnables(); |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 4366 | } else { |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4367 | mKeyguardIndicationController.setVisible(false); |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 4368 | if (mKeyguardUserSwitcher != null) { |
| 4369 | mKeyguardUserSwitcher.setKeyguard(false, |
| 4370 | goingToFullShade || |
| 4371 | mState == StatusBarState.SHADE_LOCKED || |
| 4372 | fromShadeLocked); |
| 4373 | } |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 4374 | } |
Jorim Jaggi | 2042ef2 | 2014-05-13 21:55:18 +0200 | [diff] [blame] | 4375 | if (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) { |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 4376 | mScrimController.setKeyguardShowing(true); |
Jorim Jaggi | 2042ef2 | 2014-05-13 21:55:18 +0200 | [diff] [blame] | 4377 | } else { |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 4378 | mScrimController.setKeyguardShowing(false); |
Jorim Jaggi | 2042ef2 | 2014-05-13 21:55:18 +0200 | [diff] [blame] | 4379 | } |
Nicolas Prevot | 1dbbe7d | 2016-05-17 12:52:54 +0100 | [diff] [blame] | 4380 | mIconPolicy.notifyKeyguardShowingChanged(); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4381 | mNotificationPanel.setBarState(mState, mKeyguardFadingAway, goingToFullShade); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4382 | updateDozingState(); |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 4383 | updatePublicMode(); |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 4384 | updateStackScrollerState(goingToFullShade, fromShadeLocked); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 4385 | updateNotifications(); |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 4386 | checkBarModes(); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 4387 | updateMediaMetaData(false, mState != StatusBarState.KEYGUARD); |
John Spurlock | 657c62c | 2014-07-22 12:18:09 -0400 | [diff] [blame] | 4388 | mKeyguardMonitor.notifyKeyguardState(mStatusBarKeyguardViewManager.isShowing(), |
Jim Miller | 69c1241 | 2016-10-06 19:11:03 -0700 | [diff] [blame] | 4389 | mStatusBarKeyguardViewManager.isSecure(), |
| 4390 | mStatusBarKeyguardViewManager.isOccluded()); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 4391 | Trace.endSection(); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4392 | } |
| 4393 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4394 | private void updateDozingState() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 4395 | Trace.beginSection("PhoneStatusBar#updateDozingState"); |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 4396 | boolean animate = !mDozing && mDozeScrimController.isPulsing(); |
| 4397 | mNotificationPanel.setDozing(mDozing, animate); |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4398 | mStackScroller.setDark(mDozing, animate, mWakeUpTouchLocation); |
Jorim Jaggi | 048af1f | 2014-11-11 22:51:10 +0100 | [diff] [blame] | 4399 | mScrimController.setDozing(mDozing); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 4400 | |
| 4401 | // Immediately abort the dozing from the doze scrim controller in case of wake-and-unlock |
| 4402 | // for pulsing so the Keyguard fade-out animation scrim can take over. |
| 4403 | mDozeScrimController.setDozing(mDozing && |
| 4404 | mFingerprintUnlockController.getMode() |
| 4405 | != FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING, animate); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 4406 | Trace.endSection(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4407 | } |
| 4408 | |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 4409 | public void updateStackScrollerState(boolean goingToFullShade, boolean fromShadeLocked) { |
John Spurlock | 4b3bda2 | 2014-05-22 14:32:20 -0400 | [diff] [blame] | 4410 | if (mStackScroller == null) return; |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 4411 | boolean onKeyguard = mState == StatusBarState.KEYGUARD; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 4412 | mStackScroller.setHideSensitive(isLockscreenPublicMode(), goingToFullShade); |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 4413 | mStackScroller.setDimmed(onKeyguard, fromShadeLocked /* animate */); |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 4414 | mStackScroller.setExpandingEnabled(!onKeyguard); |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 4415 | ActivatableNotificationView activatedChild = mStackScroller.getActivatedChild(); |
| 4416 | mStackScroller.setActivatedChild(null); |
| 4417 | if (activatedChild != null) { |
| 4418 | activatedChild.makeInactive(false /* animate */); |
| 4419 | } |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4420 | } |
| 4421 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4422 | public void userActivity() { |
Jorim Jaggi | b690f0d | 2014-07-03 23:25:44 +0200 | [diff] [blame] | 4423 | if (mState == StatusBarState.KEYGUARD) { |
| 4424 | mKeyguardViewMediatorCallback.userActivity(); |
| 4425 | } |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4426 | } |
| 4427 | |
Jorim Jaggi | df99351 | 2014-05-13 23:06:35 +0200 | [diff] [blame] | 4428 | public boolean interceptMediaKey(KeyEvent event) { |
| 4429 | return mState == StatusBarState.KEYGUARD |
| 4430 | && mStatusBarKeyguardViewManager.interceptMediaKey(event); |
| 4431 | } |
| 4432 | |
Jorim Jaggi | 8c8bcc1 | 2014-04-16 21:36:51 +0200 | [diff] [blame] | 4433 | public boolean onMenuPressed() { |
Selim Cinek | 2854019 | 2016-02-19 17:25:08 -0800 | [diff] [blame] | 4434 | if (mDeviceInteractive && mState != StatusBarState.SHADE |
| 4435 | && mStatusBarKeyguardViewManager.shouldDismissOnMenuPressed()) { |
| 4436 | animateCollapsePanels( |
| 4437 | CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL /* flags */, true /* force */); |
| 4438 | return true; |
| 4439 | } |
| 4440 | return false; |
Jorim Jaggi | 8c8bcc1 | 2014-04-16 21:36:51 +0200 | [diff] [blame] | 4441 | } |
| 4442 | |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4443 | public void endAffordanceLaunch() { |
| 4444 | releaseGestureWakeLock(); |
| 4445 | mNotificationPanel.onAffordanceLaunchEnded(); |
| 4446 | } |
| 4447 | |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 4448 | public boolean onBackPressed() { |
Adrian Roos | 0002a45 | 2014-07-03 13:46:07 +0200 | [diff] [blame] | 4449 | if (mStatusBarKeyguardViewManager.onBackPressed()) { |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 4450 | return true; |
| 4451 | } |
Adrian Roos | 0002a45 | 2014-07-03 13:46:07 +0200 | [diff] [blame] | 4452 | if (mNotificationPanel.isQsExpanded()) { |
John Spurlock | f7ae442 | 2014-08-01 12:45:18 -0400 | [diff] [blame] | 4453 | if (mNotificationPanel.isQsDetailShowing()) { |
| 4454 | mNotificationPanel.closeQsDetail(); |
| 4455 | } else { |
| 4456 | mNotificationPanel.animateCloseQs(); |
| 4457 | } |
Adrian Roos | 0002a45 | 2014-07-03 13:46:07 +0200 | [diff] [blame] | 4458 | return true; |
| 4459 | } |
| 4460 | if (mState != StatusBarState.KEYGUARD && mState != StatusBarState.SHADE_LOCKED) { |
| 4461 | animateCollapsePanels(); |
| 4462 | return true; |
| 4463 | } |
| 4464 | return false; |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 4465 | } |
| 4466 | |
Jorim Jaggi | 3425076 | 2014-07-03 23:51:19 +0200 | [diff] [blame] | 4467 | public boolean onSpacePressed() { |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 4468 | if (mDeviceInteractive && mState != StatusBarState.SHADE) { |
Jorim Jaggi | 4eedc1d | 2014-10-27 13:45:56 +0100 | [diff] [blame] | 4469 | animateCollapsePanels( |
| 4470 | CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL /* flags */, true /* force */); |
Jorim Jaggi | 3425076 | 2014-07-03 23:51:19 +0200 | [diff] [blame] | 4471 | return true; |
| 4472 | } |
| 4473 | return false; |
| 4474 | } |
| 4475 | |
Adrian Roos | f37fce5 | 2016-12-13 15:12:02 -0800 | [diff] [blame] | 4476 | private void showBouncerIfKeyguard() { |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4477 | if (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) { |
Adrian Roos | f37fce5 | 2016-12-13 15:12:02 -0800 | [diff] [blame] | 4478 | showBouncer(); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4479 | } |
| 4480 | } |
| 4481 | |
Adrian Roos | f37fce5 | 2016-12-13 15:12:02 -0800 | [diff] [blame] | 4482 | private void showBouncer() { |
| 4483 | mWaitingForKeyguardExit = mStatusBarKeyguardViewManager.isShowing(); |
| 4484 | mStatusBarKeyguardViewManager.dismiss(); |
| 4485 | } |
| 4486 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4487 | private void instantExpandNotificationsPanel() { |
Jorim Jaggi | c357ca2 | 2014-04-25 14:56:15 +0200 | [diff] [blame] | 4488 | |
Jorim Jaggi | 0a27be8 | 2014-06-11 03:22:39 +0200 | [diff] [blame] | 4489 | // Make our window larger and the panel expanded. |
Jorim Jaggi | fa505a7 | 2014-04-28 20:04:11 +0200 | [diff] [blame] | 4490 | makeExpandedVisible(true); |
Oren Blasberg | 8d3fea1 | 2015-07-10 14:21:44 -0700 | [diff] [blame] | 4491 | mNotificationPanel.expand(false /* animate */); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4492 | } |
Adrian Roos | 5a46cd3 | 2014-04-03 16:51:58 +0200 | [diff] [blame] | 4493 | |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 4494 | private void instantCollapseNotificationPanel() { |
Selim Cinek | 6bb4a9b | 2014-10-09 17:48:05 -0700 | [diff] [blame] | 4495 | mNotificationPanel.instantCollapse(); |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 4496 | } |
| 4497 | |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 4498 | @Override |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 4499 | public void onActivated(ActivatableNotificationView view) { |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 4500 | EventLogTags.writeSysuiLockscreenGesture( |
| 4501 | EventLogConstants.SYSUI_LOCKSCREEN_GESTURE_TAP_NOTIFICATION_ACTIVATE, |
| 4502 | 0 /* lengthDp - N/A */, 0 /* velocityDp - N/A */); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4503 | mKeyguardIndicationController.showTransientIndication(R.string.notification_tap_again); |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 4504 | ActivatableNotificationView previousView = mStackScroller.getActivatedChild(); |
| 4505 | if (previousView != null) { |
| 4506 | previousView.makeInactive(true /* animate */); |
| 4507 | } |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4508 | mStackScroller.setActivatedChild(view); |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 4509 | } |
| 4510 | |
Annie Chin | edeb517 | 2016-06-24 17:07:08 -0700 | [diff] [blame] | 4511 | public ButtonDispatcher getHomeButton() { |
| 4512 | return mNavigationBarView.getHomeButton(); |
| 4513 | } |
| 4514 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4515 | /** |
| 4516 | * @param state The {@link StatusBarState} to set. |
| 4517 | */ |
| 4518 | public void setBarState(int state) { |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 4519 | // If we're visible and switched to SHADE_LOCKED (the user dragged |
| 4520 | // down on the lockscreen), clear notification LED, vibration, |
| 4521 | // ringing. |
| 4522 | // Other transitions are covered in handleVisibleToUserChanged(). |
Selim Cinek | 6577cae | 2015-08-31 16:15:49 -0700 | [diff] [blame] | 4523 | if (state != mState && mVisible && (state == StatusBarState.SHADE_LOCKED |
| 4524 | || (state == StatusBarState.SHADE && isGoingToNotificationShade()))) { |
| 4525 | clearNotificationEffects(); |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 4526 | } |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 4527 | if (state == StatusBarState.KEYGUARD) { |
| 4528 | removeRemoteInputEntriesKeptUntilCollapsed(); |
Selim Cinek | 9941539 | 2016-09-09 14:58:41 -0700 | [diff] [blame] | 4529 | maybeEscalateHeadsUp(); |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 4530 | } |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4531 | mState = state; |
Selim Cinek | 9c4c414 | 2015-12-04 16:44:56 -0800 | [diff] [blame] | 4532 | mGroupManager.setStatusBarState(state); |
Selim Cinek | ab24dc9 | 2016-12-21 18:23:11 +0100 | [diff] [blame] | 4533 | mHeadsUpManager.setStatusBarState(state); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4534 | mFalsingManager.setStatusBarState(state); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4535 | mStatusBarWindowManager.setStatusBarState(state); |
Adrian Roos | 7bb38a9 | 2016-07-21 11:44:01 -0700 | [diff] [blame] | 4536 | updateReportRejectedTouchVisibility(); |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 4537 | updateDozing(); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4538 | } |
| 4539 | |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 4540 | @Override |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 4541 | public void onActivationReset(ActivatableNotificationView view) { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4542 | if (view == mStackScroller.getActivatedChild()) { |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4543 | mKeyguardIndicationController.hideTransientIndication(); |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4544 | mStackScroller.setActivatedChild(null); |
| 4545 | } |
Jorim Jaggi | e70d31f | 2014-04-24 22:08:30 +0200 | [diff] [blame] | 4546 | } |
| 4547 | |
| 4548 | public void onTrackingStarted() { |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 4549 | runPostCollapseRunnables(); |
Jorim Jaggi | 9012958 | 2014-06-02 14:44:49 +0200 | [diff] [blame] | 4550 | } |
| 4551 | |
Selim Cinek | dbbcfbe | 2014-10-24 17:52:35 +0200 | [diff] [blame] | 4552 | public void onClosingFinished() { |
| 4553 | runPostCollapseRunnables(); |
| 4554 | } |
| 4555 | |
Jorim Jaggi | 9012958 | 2014-06-02 14:44:49 +0200 | [diff] [blame] | 4556 | public void onUnlockHintStarted() { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4557 | mFalsingManager.onUnlockHintStarted(); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4558 | mKeyguardIndicationController.showTransientIndication(R.string.keyguard_unlock); |
Jorim Jaggi | 9012958 | 2014-06-02 14:44:49 +0200 | [diff] [blame] | 4559 | } |
| 4560 | |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 4561 | public void onHintFinished() { |
Jorim Jaggi | 93a2bb2 | 2014-06-02 19:57:28 +0200 | [diff] [blame] | 4562 | // Delay the reset a bit so the user can read the text. |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4563 | mKeyguardIndicationController.hideTransientIndicationDelayed(HINT_RESET_DELAY_MS); |
Jorim Jaggi | e70d31f | 2014-04-24 22:08:30 +0200 | [diff] [blame] | 4564 | } |
| 4565 | |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 4566 | public void onCameraHintStarted() { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4567 | mFalsingManager.onCameraHintStarted(); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4568 | mKeyguardIndicationController.showTransientIndication(R.string.camera_hint); |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 4569 | } |
| 4570 | |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 4571 | public void onVoiceAssistHintStarted() { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4572 | mFalsingManager.onLeftAffordanceHintStarted(); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 4573 | mKeyguardIndicationController.showTransientIndication(R.string.voice_hint); |
| 4574 | } |
| 4575 | |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 4576 | public void onPhoneHintStarted() { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4577 | mFalsingManager.onLeftAffordanceHintStarted(); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4578 | mKeyguardIndicationController.showTransientIndication(R.string.phone_hint); |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 4579 | } |
| 4580 | |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 4581 | public void onTrackingStopped(boolean expand) { |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 4582 | if (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) { |
Selim Cinek | e8bae62 | 2015-07-15 13:24:06 -0700 | [diff] [blame] | 4583 | if (!expand && !mUnlockMethodCache.canSkipBouncer()) { |
Adrian Roos | f37fce5 | 2016-12-13 15:12:02 -0800 | [diff] [blame] | 4584 | showBouncerIfKeyguard(); |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 4585 | } |
| 4586 | } |
Jorim Jaggi | e70d31f | 2014-04-24 22:08:30 +0200 | [diff] [blame] | 4587 | } |
| 4588 | |
| 4589 | @Override |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 4590 | protected int getMaxKeyguardNotifications(boolean recompute) { |
| 4591 | if (recompute) { |
| 4592 | mMaxKeyguardNotifications = Math.max(1, |
| 4593 | mNotificationPanel.computeMaxKeyguardNotifications( |
| 4594 | mMaxAllowedKeyguardNotifications)); |
| 4595 | return mMaxKeyguardNotifications; |
| 4596 | } |
| 4597 | return mMaxKeyguardNotifications; |
| 4598 | } |
| 4599 | |
| 4600 | public int getMaxKeyguardNotifications() { |
| 4601 | return getMaxKeyguardNotifications(false /* recompute */); |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 4602 | } |
| 4603 | |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 4604 | public NavigationBarView getNavigationBarView() { |
| 4605 | return mNavigationBarView; |
| 4606 | } |
| 4607 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4608 | // ---------------------- DragDownHelper.OnDragDownListener ------------------------------------ |
| 4609 | |
Chris Wren | 6abeeb9 | 2016-05-26 14:44:38 -0400 | [diff] [blame] | 4610 | |
| 4611 | /* Only ever called as a consequence of a lockscreen expansion gesture. */ |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4612 | @Override |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 4613 | public boolean onDraggedDown(View startingChild, int dragLengthY) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 4614 | if (hasActiveNotifications()) { |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 4615 | EventLogTags.writeSysuiLockscreenGesture( |
| 4616 | EventLogConstants.SYSUI_LOCKSCREEN_GESTURE_SWIPE_DOWN_FULL_SHADE, |
| 4617 | (int) (dragLengthY / mDisplayMetrics.density), |
| 4618 | 0 /* velocityDp - N/A */); |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 4619 | |
| 4620 | // We have notifications, go to locked shade. |
| 4621 | goToLockedShade(startingChild); |
Chris Wren | 6abeeb9 | 2016-05-26 14:44:38 -0400 | [diff] [blame] | 4622 | if (startingChild instanceof ExpandableNotificationRow) { |
| 4623 | ExpandableNotificationRow row = (ExpandableNotificationRow) startingChild; |
| 4624 | row.onExpandedByGesture(true /* drag down is always an open */); |
| 4625 | } |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 4626 | return true; |
| 4627 | } else { |
| 4628 | |
| 4629 | // No notifications - abort gesture. |
| 4630 | return false; |
| 4631 | } |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4632 | } |
| 4633 | |
| 4634 | @Override |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4635 | public void onDragDownReset() { |
| 4636 | mStackScroller.setDimmed(true /* dimmed */, true /* animated */); |
Selim Cinek | 177fd43 | 2015-11-18 11:53:47 -0800 | [diff] [blame] | 4637 | mStackScroller.resetScrollPosition(); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4638 | } |
| 4639 | |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 4640 | @Override |
Selim Cinek | 177fd43 | 2015-11-18 11:53:47 -0800 | [diff] [blame] | 4641 | public void onCrossedThreshold(boolean above) { |
| 4642 | mStackScroller.setDimmed(!above /* dimmed */, true /* animate */); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4643 | } |
| 4644 | |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 4645 | @Override |
| 4646 | public void onTouchSlopExceeded() { |
| 4647 | mStackScroller.removeLongPressCallback(); |
| 4648 | } |
| 4649 | |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 4650 | @Override |
| 4651 | public void setEmptyDragAmount(float amount) { |
| 4652 | mNotificationPanel.setEmptyDragAmount(amount); |
| 4653 | } |
| 4654 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4655 | /** |
| 4656 | * If secure with redaction: Show bouncer, go to unlocked shade. |
| 4657 | * |
Jorim Jaggi | 2042ef2 | 2014-05-13 21:55:18 +0200 | [diff] [blame] | 4658 | * <p>If secure without redaction or no security: Go to {@link StatusBarState#SHADE_LOCKED}.</p> |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4659 | * |
| 4660 | * @param expandView The view to expand after going to the shade. |
| 4661 | */ |
| 4662 | public void goToLockedShade(View expandView) { |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4663 | ExpandableNotificationRow row = null; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4664 | if (expandView instanceof ExpandableNotificationRow) { |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4665 | row = (ExpandableNotificationRow) expandView; |
Selim Cinek | cb24ab8 | 2016-02-25 12:49:08 -0800 | [diff] [blame] | 4666 | row.setUserExpanded(true /* userExpanded */, true /* allowChildExpansion */); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 4667 | // Indicate that the group expansion is changing at this time -- this way the group |
| 4668 | // and children backgrounds / divider animations will look correct. |
| 4669 | row.setGroupExpansionChanging(true); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4670 | } |
Adrian Roos | aee7046 | 2014-09-03 16:27:39 +0200 | [diff] [blame] | 4671 | boolean fullShadeNeedsBouncer = !userAllowsPrivateNotificationsInPublic(mCurrentUserId) |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4672 | || !mShowLockscreenNotifications || mFalsingManager.shouldEnforceBouncer(); |
Adrian Roos | aee7046 | 2014-09-03 16:27:39 +0200 | [diff] [blame] | 4673 | if (isLockscreenPublicMode() && fullShadeNeedsBouncer) { |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4674 | mLeaveOpenOnKeyguardHide = true; |
Adrian Roos | f37fce5 | 2016-12-13 15:12:02 -0800 | [diff] [blame] | 4675 | showBouncerIfKeyguard(); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4676 | mDraggedDownRow = row; |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 4677 | mPendingRemoteInputView = null; |
Jorim Jaggi | 2042ef2 | 2014-05-13 21:55:18 +0200 | [diff] [blame] | 4678 | } else { |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4679 | mNotificationPanel.animateToFullShade(0 /* delay */); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4680 | setBarState(StatusBarState.SHADE_LOCKED); |
Jorim Jaggi | 98f8530 | 2014-08-07 17:45:04 +0200 | [diff] [blame] | 4681 | updateKeyguardState(false /* goingToFullShade */, false /* fromShadeLocked */); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4682 | } |
| 4683 | } |
| 4684 | |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 4685 | @Override |
Mady Mellor | 8e8a69e | 2016-03-14 12:30:10 -0700 | [diff] [blame] | 4686 | public void onLockedNotificationImportanceChange(OnDismissAction dismissAction) { |
| 4687 | mLeaveOpenOnKeyguardHide = true; |
| 4688 | dismissKeyguardThenExecute(dismissAction, true /* afterKeyguardGone */); |
| 4689 | } |
| 4690 | |
| 4691 | @Override |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 4692 | protected void onLockedRemoteInput(ExpandableNotificationRow row, View clicked) { |
| 4693 | mLeaveOpenOnKeyguardHide = true; |
| 4694 | showBouncer(); |
| 4695 | mPendingRemoteInputView = clicked; |
| 4696 | } |
| 4697 | |
| 4698 | @Override |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 4699 | protected boolean startWorkChallengeIfNecessary(int userId, IntentSender intendSender, |
| 4700 | String notificationKey) { |
| 4701 | // Clear pending remote view, as we do not want to trigger pending remote input view when |
| 4702 | // it's called by other code |
| 4703 | mPendingWorkRemoteInputView = null; |
| 4704 | return super.startWorkChallengeIfNecessary(userId, intendSender, notificationKey); |
| 4705 | } |
| 4706 | |
| 4707 | @Override |
| 4708 | protected void onLockedWorkRemoteInput(int userId, ExpandableNotificationRow row, |
| 4709 | View clicked) { |
| 4710 | // Collapse notification and show work challenge |
| 4711 | animateCollapsePanels(); |
| 4712 | startWorkChallengeIfNecessary(userId, null, null); |
| 4713 | // Add pending remote input view after starting work challenge, as starting work challenge |
| 4714 | // will clear all previous pending review view |
| 4715 | mPendingWorkRemoteInputView = clicked; |
| 4716 | } |
| 4717 | |
| 4718 | @Override |
| 4719 | protected void onWorkChallengeUnlocked() { |
| 4720 | if (mPendingWorkRemoteInputView != null) { |
| 4721 | final View pendingWorkRemoteInputView = mPendingWorkRemoteInputView; |
| 4722 | // Expand notification panel and the notification row, then click on remote input view |
| 4723 | final Runnable clickPendingViewRunnable = new Runnable() { |
| 4724 | @Override |
| 4725 | public void run() { |
| 4726 | if (mPendingWorkRemoteInputView != null) { |
| 4727 | final View pendingWorkRemoteInputView = mPendingWorkRemoteInputView; |
| 4728 | ViewParent p = pendingWorkRemoteInputView.getParent(); |
| 4729 | while (p != null) { |
| 4730 | if (p instanceof ExpandableNotificationRow) { |
| 4731 | final ExpandableNotificationRow row = (ExpandableNotificationRow) p; |
| 4732 | ViewParent viewParent = row.getParent(); |
| 4733 | if (viewParent instanceof NotificationStackScrollLayout) { |
| 4734 | final NotificationStackScrollLayout scrollLayout = |
| 4735 | (NotificationStackScrollLayout) viewParent; |
| 4736 | row.makeActionsVisibile(); |
| 4737 | row.post(new Runnable() { |
| 4738 | @Override |
| 4739 | public void run() { |
| 4740 | final Runnable finishScrollingCallback = new Runnable() |
| 4741 | { |
| 4742 | @Override |
| 4743 | public void run() { |
| 4744 | mPendingWorkRemoteInputView.callOnClick(); |
| 4745 | mPendingWorkRemoteInputView = null; |
| 4746 | scrollLayout.setFinishScrollingCallback(null); |
| 4747 | } |
| 4748 | }; |
| 4749 | if (scrollLayout.scrollTo(row)) { |
| 4750 | // It scrolls! So call it when it's finished. |
| 4751 | scrollLayout.setFinishScrollingCallback( |
| 4752 | finishScrollingCallback); |
| 4753 | } else { |
| 4754 | // It does not scroll, so call it now! |
| 4755 | finishScrollingCallback.run(); |
| 4756 | } |
| 4757 | } |
| 4758 | }); |
| 4759 | } |
| 4760 | break; |
| 4761 | } |
| 4762 | p = p.getParent(); |
| 4763 | } |
| 4764 | } |
| 4765 | } |
| 4766 | }; |
| 4767 | mNotificationPanel.getViewTreeObserver().addOnGlobalLayoutListener( |
| 4768 | new ViewTreeObserver.OnGlobalLayoutListener() { |
| 4769 | @Override |
| 4770 | public void onGlobalLayout() { |
| 4771 | if (mNotificationPanel.mStatusBar.getStatusBarWindow() |
| 4772 | .getHeight() != mNotificationPanel.mStatusBar |
| 4773 | .getStatusBarHeight()) { |
| 4774 | mNotificationPanel.getViewTreeObserver() |
| 4775 | .removeOnGlobalLayoutListener(this); |
| 4776 | mNotificationPanel.post(clickPendingViewRunnable); |
| 4777 | } |
| 4778 | } |
| 4779 | }); |
| 4780 | instantExpandNotificationsPanel(); |
| 4781 | } |
| 4782 | } |
| 4783 | |
| 4784 | @Override |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 4785 | public void onExpandClicked(Entry clickedEntry, boolean nowExpanded) { |
| 4786 | mHeadsUpManager.setExpanded(clickedEntry, nowExpanded); |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 4787 | if (mState == StatusBarState.KEYGUARD && nowExpanded) { |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 4788 | goToLockedShade(clickedEntry.row); |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 4789 | } |
| 4790 | } |
| 4791 | |
Adrian Roos | 5a46cd3 | 2014-04-03 16:51:58 +0200 | [diff] [blame] | 4792 | /** |
Jorim Jaggi | 6539a83 | 2014-06-03 23:33:09 +0200 | [diff] [blame] | 4793 | * Goes back to the keyguard after hanging around in {@link StatusBarState#SHADE_LOCKED}. |
| 4794 | */ |
| 4795 | public void goToKeyguard() { |
| 4796 | if (mState == StatusBarState.SHADE_LOCKED) { |
Selim Cinek | d9acca5 | 2014-09-01 22:33:25 +0200 | [diff] [blame] | 4797 | mStackScroller.onGoToKeyguard(); |
Jorim Jaggi | 6539a83 | 2014-06-03 23:33:09 +0200 | [diff] [blame] | 4798 | setBarState(StatusBarState.KEYGUARD); |
Jorim Jaggi | 98f8530 | 2014-08-07 17:45:04 +0200 | [diff] [blame] | 4799 | updateKeyguardState(false /* goingToFullShade */, true /* fromShadeLocked*/); |
Jorim Jaggi | 6539a83 | 2014-06-03 23:33:09 +0200 | [diff] [blame] | 4800 | } |
| 4801 | } |
| 4802 | |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4803 | public long getKeyguardFadingAwayDelay() { |
| 4804 | return mKeyguardFadingAwayDelay; |
| 4805 | } |
| 4806 | |
| 4807 | public long getKeyguardFadingAwayDuration() { |
| 4808 | return mKeyguardFadingAwayDuration; |
| 4809 | } |
| 4810 | |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4811 | @Override |
| 4812 | public void setBouncerShowing(boolean bouncerShowing) { |
| 4813 | super.setBouncerShowing(bouncerShowing); |
Adrian Roos | d0b2f7d | 2015-04-29 13:36:12 -0700 | [diff] [blame] | 4814 | mStatusBarView.setBouncerShowing(bouncerShowing); |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 4815 | recomputeDisableFlags(true /* animate */); |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4816 | } |
| 4817 | |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4818 | public void onStartedGoingToSleep() { |
| 4819 | mStartedGoingToSleep = true; |
| 4820 | } |
| 4821 | |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4822 | public void onFinishedGoingToSleep() { |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4823 | mNotificationPanel.onAffordanceLaunchEnded(); |
| 4824 | releaseGestureWakeLock(); |
| 4825 | mLaunchCameraOnScreenTurningOn = false; |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4826 | mStartedGoingToSleep = false; |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4827 | mDeviceInteractive = false; |
| 4828 | mWakeUpComingFromTouch = false; |
| 4829 | mWakeUpTouchLocation = null; |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 4830 | mStackScroller.setAnimationsEnabled(false); |
Selim Cinek | add9526 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 4831 | mVisualStabilityManager.setScreenOn(false); |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 4832 | updateVisibleToUser(); |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4833 | if (mLaunchCameraOnFinishedGoingToSleep) { |
| 4834 | mLaunchCameraOnFinishedGoingToSleep = false; |
| 4835 | |
| 4836 | // This gets executed before we will show Keyguard, so post it in order that the state |
| 4837 | // is correct. |
| 4838 | mHandler.post(new Runnable() { |
| 4839 | @Override |
| 4840 | public void run() { |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 4841 | onCameraLaunchGestureDetected(mLastCameraLaunchSource); |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4842 | } |
| 4843 | }); |
| 4844 | } |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 4845 | } |
| 4846 | |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4847 | public void onStartedWakingUp() { |
| 4848 | mDeviceInteractive = true; |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 4849 | mStackScroller.setAnimationsEnabled(true); |
Selim Cinek | add9526 | 2016-12-06 14:34:47 -0800 | [diff] [blame] | 4850 | mVisualStabilityManager.setScreenOn(true); |
Jorim Jaggi | d41083a | 2014-09-12 02:54:40 +0200 | [diff] [blame] | 4851 | mNotificationPanel.setTouchDisabled(false); |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 4852 | updateVisibleToUser(); |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 4853 | } |
John Spurlock | d08f91f | 2014-05-23 11:00:34 -0400 | [diff] [blame] | 4854 | |
Jorim Jaggi | 9373911 | 2015-08-13 15:53:14 -0700 | [diff] [blame] | 4855 | public void onScreenTurningOn() { |
Selim Cinek | 1b6f819 | 2015-09-03 16:01:53 -0700 | [diff] [blame] | 4856 | mScreenTurningOn = true; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4857 | mFalsingManager.onScreenTurningOn(); |
Jorim Jaggi | 9373911 | 2015-08-13 15:53:14 -0700 | [diff] [blame] | 4858 | mNotificationPanel.onScreenTurningOn(); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4859 | if (mLaunchCameraOnScreenTurningOn) { |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 4860 | mNotificationPanel.launchCamera(false, mLastCameraLaunchSource); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4861 | mLaunchCameraOnScreenTurningOn = false; |
| 4862 | } |
Jorim Jaggi | 9373911 | 2015-08-13 15:53:14 -0700 | [diff] [blame] | 4863 | } |
| 4864 | |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 4865 | private void vibrateForCameraGesture() { |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4866 | // Make sure to pass -1 for repeat so VibratorService doesn't stop us when going to sleep. |
Jorim Jaggi | 8ba1cb3 | 2016-06-24 17:33:01 -0700 | [diff] [blame] | 4867 | mVibrator.vibrate(new long[]{0, 400}, -1 /* repeat */); |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 4868 | } |
| 4869 | |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4870 | public void onScreenTurnedOn() { |
Selim Cinek | 1b6f819 | 2015-09-03 16:01:53 -0700 | [diff] [blame] | 4871 | mScreenTurningOn = false; |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4872 | mDozeScrimController.onScreenTurnedOn(); |
| 4873 | } |
| 4874 | |
Jason Monk | 815e057 | 2014-08-12 17:26:36 -0400 | [diff] [blame] | 4875 | /** |
Jorim Jaggi | 4e723e6 | 2016-12-14 11:02:39 -0800 | [diff] [blame] | 4876 | * This handles long-press of both back and recents. They are |
| 4877 | * handled together to capture them both being long-pressed |
| 4878 | * at the same time to exit screen pinning (lock task). |
| 4879 | * |
| 4880 | * When accessibility mode is on, only a long-press from recents |
| 4881 | * is required to exit. |
| 4882 | * |
| 4883 | * In all other circumstances we try to pass through long-press events |
| 4884 | * for Back, so that apps can still use it. Which can be from two things. |
| 4885 | * 1) Not currently in screen pinning (lock task). |
| 4886 | * 2) Back is long-pressed without recents. |
Jason Monk | 815e057 | 2014-08-12 17:26:36 -0400 | [diff] [blame] | 4887 | */ |
Jorim Jaggi | 4e723e6 | 2016-12-14 11:02:39 -0800 | [diff] [blame] | 4888 | private boolean handleLongPressBackRecents(View v) { |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 4889 | try { |
Jorim Jaggi | 4e723e6 | 2016-12-14 11:02:39 -0800 | [diff] [blame] | 4890 | boolean sendBackLongPress = false; |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 4891 | IActivityManager activityManager = ActivityManagerNative.getDefault(); |
Jorim Jaggi | 4e723e6 | 2016-12-14 11:02:39 -0800 | [diff] [blame] | 4892 | boolean touchExplorationEnabled = mAccessibilityManager.isTouchExplorationEnabled(); |
| 4893 | boolean inLockTaskMode = activityManager.isInLockTaskMode(); |
| 4894 | if (inLockTaskMode && !touchExplorationEnabled) { |
| 4895 | long time = System.currentTimeMillis(); |
| 4896 | // If we recently long-pressed the other button then they were |
| 4897 | // long-pressed 'together' |
| 4898 | if ((time - mLastLockToAppLongPress) < LOCK_TO_APP_GESTURE_TOLERENCE) { |
| 4899 | activityManager.stopLockTaskMode(); |
| 4900 | // When exiting refresh disabled flags. |
| 4901 | mNavigationBarView.setDisabledFlags(mDisabled1, true); |
| 4902 | return true; |
| 4903 | } else if ((v.getId() == R.id.back) |
| 4904 | && !mNavigationBarView.getRecentsButton().getCurrentView().isPressed()) { |
| 4905 | // If we aren't pressing recents right now then they presses |
| 4906 | // won't be together, so send the standard long-press action. |
| 4907 | sendBackLongPress = true; |
| 4908 | } |
| 4909 | mLastLockToAppLongPress = time; |
| 4910 | } else { |
| 4911 | // If this is back still need to handle sending the long-press event. |
| 4912 | if (v.getId() == R.id.back) { |
| 4913 | sendBackLongPress = true; |
| 4914 | } else if (touchExplorationEnabled && inLockTaskMode) { |
| 4915 | // When in accessibility mode a long press that is recents (not back) |
| 4916 | // should stop lock task. |
| 4917 | activityManager.stopLockTaskMode(); |
| 4918 | // When exiting refresh disabled flags. |
| 4919 | mNavigationBarView.setDisabledFlags(mDisabled1, true); |
| 4920 | return true; |
| 4921 | } else if (v.getId() == R.id.recent_apps) { |
| 4922 | return handleLongPressRecents(); |
| 4923 | } |
| 4924 | } |
| 4925 | if (sendBackLongPress) { |
| 4926 | KeyButtonView keyButtonView = (KeyButtonView) v; |
| 4927 | keyButtonView.sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_LONG_PRESS); |
| 4928 | keyButtonView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED); |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 4929 | return true; |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 4930 | } |
| 4931 | } catch (RemoteException e) { |
Jason Monk | 815e057 | 2014-08-12 17:26:36 -0400 | [diff] [blame] | 4932 | Log.d(TAG, "Unable to reach activity manager", e); |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 4933 | } |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 4934 | return false; |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 4935 | } |
| 4936 | |
Jorim Jaggi | 4e723e6 | 2016-12-14 11:02:39 -0800 | [diff] [blame] | 4937 | private boolean handleLongPressRecents() { |
| 4938 | if (mRecents == null || !ActivityManager.supportsMultiWindow() |
| 4939 | || !getComponent(Divider.class).getView().getSnapAlgorithm() |
| 4940 | .isSplitScreenFeasible()) { |
| 4941 | return false; |
| 4942 | } |
| 4943 | |
| 4944 | toggleSplitScreenMode(MetricsEvent.ACTION_WINDOW_DOCK_LONGPRESS, |
| 4945 | MetricsEvent.ACTION_WINDOW_UNDOCK_LONGPRESS); |
| 4946 | return true; |
| 4947 | } |
| 4948 | |
Jason Monk | 5565cb4 | 2014-09-12 10:59:21 -0400 | [diff] [blame] | 4949 | @Override |
Andrii Kulian | 0f051f5 | 2016-04-14 00:41:51 -0700 | [diff] [blame] | 4950 | public void showScreenPinningRequest(int taskId) { |
Jason Monk | 18f99d9 | 2014-09-11 13:36:42 -0400 | [diff] [blame] | 4951 | if (mKeyguardMonitor.isShowing()) { |
| 4952 | // Don't allow apps to trigger this from keyguard. |
| 4953 | return; |
| 4954 | } |
| 4955 | // Show screen pinning request, since this comes from an app, show 'no thanks', button. |
Andrii Kulian | 0f051f5 | 2016-04-14 00:41:51 -0700 | [diff] [blame] | 4956 | showScreenPinningRequest(taskId, true); |
Jason Monk | 18f99d9 | 2014-09-11 13:36:42 -0400 | [diff] [blame] | 4957 | } |
| 4958 | |
Andrii Kulian | 0f051f5 | 2016-04-14 00:41:51 -0700 | [diff] [blame] | 4959 | public void showScreenPinningRequest(int taskId, boolean allowCancel) { |
| 4960 | mScreenPinningRequest.showPrompt(taskId, allowCancel); |
Jason Monk | 5565cb4 | 2014-09-12 10:59:21 -0400 | [diff] [blame] | 4961 | } |
| 4962 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 4963 | public boolean hasActiveNotifications() { |
| 4964 | return !mNotificationData.getActiveNotifications().isEmpty(); |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 4965 | } |
| 4966 | |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 4967 | public void wakeUpIfDozing(long time, MotionEvent event) { |
Jorim Jaggi | 048af1f | 2014-11-11 22:51:10 +0100 | [diff] [blame] | 4968 | if (mDozing && mDozeScrimController.isPulsing()) { |
John Spurlock | 8b12f22 | 2014-09-09 11:54:11 -0400 | [diff] [blame] | 4969 | PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); |
Dianne Hackborn | 280a64e | 2015-07-13 14:48:08 -0700 | [diff] [blame] | 4970 | pm.wakeUp(time, "com.android.systemui:NODOZE"); |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4971 | mWakeUpComingFromTouch = true; |
| 4972 | mWakeUpTouchLocation = new PointF(event.getX(), event.getY()); |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 4973 | mNotificationPanel.setTouchDisabled(false); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 4974 | mStatusBarKeyguardViewManager.notifyDeviceWakeUpRequested(); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4975 | mFalsingManager.onScreenOnFromTouch(); |
John Spurlock | 8b12f22 | 2014-09-09 11:54:11 -0400 | [diff] [blame] | 4976 | } |
| 4977 | } |
| 4978 | |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 4979 | @Override |
| 4980 | public void appTransitionPending() { |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4981 | |
| 4982 | // Use own timings when Keyguard is going away, see keyguardGoingAway and |
| 4983 | // setKeyguardFadingAway |
| 4984 | if (!mKeyguardFadingAway) { |
| 4985 | mIconController.appTransitionPending(); |
| 4986 | } |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 4987 | } |
| 4988 | |
| 4989 | @Override |
| 4990 | public void appTransitionCancelled() { |
| 4991 | mIconController.appTransitionCancelled(); |
Jorim Jaggi | 2adba07 | 2016-03-03 13:43:39 +0100 | [diff] [blame] | 4992 | EventBus.getDefault().send(new AppTransitionFinishedEvent()); |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 4993 | } |
| 4994 | |
| 4995 | @Override |
| 4996 | public void appTransitionStarting(long startTime, long duration) { |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4997 | |
| 4998 | // Use own timings when Keyguard is going away, see keyguardGoingAway and |
Adrian Roos | 46df1ca | 2015-09-11 12:38:43 -0700 | [diff] [blame] | 4999 | // setKeyguardFadingAway. |
| 5000 | if (!mKeyguardGoingAway) { |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 5001 | mIconController.appTransitionStarting(startTime, duration); |
| 5002 | } |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 5003 | if (mIconPolicy != null) { |
| 5004 | mIconPolicy.appTransitionStarting(startTime, duration); |
| 5005 | } |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 5006 | } |
| 5007 | |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 5008 | @Override |
Jorim Jaggi | 2adba07 | 2016-03-03 13:43:39 +0100 | [diff] [blame] | 5009 | public void appTransitionFinished() { |
| 5010 | EventBus.getDefault().send(new AppTransitionFinishedEvent()); |
| 5011 | } |
| 5012 | |
| 5013 | @Override |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 5014 | public void onCameraLaunchGestureDetected(int source) { |
| 5015 | mLastCameraLaunchSource = source; |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 5016 | if (mStartedGoingToSleep) { |
| 5017 | mLaunchCameraOnFinishedGoingToSleep = true; |
| 5018 | return; |
| 5019 | } |
Zhentao Sun | 04f9740 | 2015-08-26 17:37:30 -0700 | [diff] [blame] | 5020 | if (!mNotificationPanel.canCameraGestureBeLaunched( |
| 5021 | mStatusBarKeyguardViewManager.isShowing() && mExpandedVisible)) { |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 5022 | return; |
| 5023 | } |
| 5024 | if (!mDeviceInteractive) { |
| 5025 | PowerManager pm = mContext.getSystemService(PowerManager.class); |
| 5026 | pm.wakeUp(SystemClock.uptimeMillis(), "com.android.systemui:CAMERA_GESTURE"); |
| 5027 | mStatusBarKeyguardViewManager.notifyDeviceWakeUpRequested(); |
| 5028 | } |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 5029 | vibrateForCameraGesture(); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 5030 | if (!mStatusBarKeyguardViewManager.isShowing()) { |
| 5031 | startActivity(KeyguardBottomAreaView.INSECURE_CAMERA_INTENT, |
| 5032 | true /* dismissShade */); |
| 5033 | } else { |
| 5034 | if (!mDeviceInteractive) { |
| 5035 | // Avoid flickering of the scrim when we instant launch the camera and the bouncer |
| 5036 | // comes on. |
| 5037 | mScrimController.dontAnimateBouncerChangesUntilNextFrame(); |
| 5038 | mGestureWakeLock.acquire(LAUNCH_TRANSITION_TIMEOUT_MS + 1000L); |
| 5039 | } |
Selim Cinek | 1b6f819 | 2015-09-03 16:01:53 -0700 | [diff] [blame] | 5040 | if (mScreenTurningOn || mStatusBarKeyguardViewManager.isScreenTurnedOn()) { |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 5041 | mNotificationPanel.launchCamera(mDeviceInteractive /* animate */, source); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 5042 | } else { |
| 5043 | // We need to defer the camera launch until the screen comes on, since otherwise |
| 5044 | // we will dismiss us too early since we are waiting on an activity to be drawn and |
| 5045 | // incorrectly get notified because of the screen on event (which resumes and pauses |
| 5046 | // some activities) |
| 5047 | mLaunchCameraOnScreenTurningOn = true; |
| 5048 | } |
| 5049 | } |
| 5050 | } |
| 5051 | |
Jaewan Kim | c552b04 | 2016-01-18 16:08:45 +0900 | [diff] [blame] | 5052 | @Override |
Jaewan Kim | f0fd218 | 2016-04-20 21:17:58 +0900 | [diff] [blame] | 5053 | public void showTvPictureInPictureMenu() { |
Jaewan Kim | c552b04 | 2016-01-18 16:08:45 +0900 | [diff] [blame] | 5054 | // no-op. |
| 5055 | } |
| 5056 | |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 5057 | public void notifyFpAuthModeChanged() { |
| 5058 | updateDozing(); |
| 5059 | } |
| 5060 | |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 5061 | private void updateDozing() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 5062 | Trace.beginSection("PhoneStatusBar#updateDozing"); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 5063 | // When in wake-and-unlock while pulsing, keep dozing state until fully unlocked. |
| 5064 | mDozing = mDozingRequested && mState == StatusBarState.KEYGUARD |
| 5065 | || mFingerprintUnlockController.getMode() |
| 5066 | == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING; |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 5067 | updateDozingState(); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 5068 | Trace.endSection(); |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 5069 | } |
| 5070 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5071 | private final class ShadeUpdates { |
| 5072 | private final ArraySet<String> mVisibleNotifications = new ArraySet<String>(); |
| 5073 | private final ArraySet<String> mNewVisibleNotifications = new ArraySet<String>(); |
| 5074 | |
| 5075 | public void check() { |
| 5076 | mNewVisibleNotifications.clear(); |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 5077 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
| 5078 | for (int i = 0; i < activeNotifications.size(); i++) { |
| 5079 | final Entry entry = activeNotifications.get(i); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5080 | final boolean visible = entry.row != null |
| 5081 | && entry.row.getVisibility() == View.VISIBLE; |
| 5082 | if (visible) { |
| 5083 | mNewVisibleNotifications.add(entry.key + entry.notification.getPostTime()); |
| 5084 | } |
| 5085 | } |
| 5086 | final boolean updates = !mVisibleNotifications.containsAll(mNewVisibleNotifications); |
| 5087 | mVisibleNotifications.clear(); |
Dianne Hackborn | 497175b | 2014-07-01 12:56:08 -0700 | [diff] [blame] | 5088 | mVisibleNotifications.addAll(mNewVisibleNotifications); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5089 | |
| 5090 | // We have new notifications |
| 5091 | if (updates && mDozeServiceHost != null) { |
| 5092 | mDozeServiceHost.fireNewNotifications(); |
| 5093 | } |
| 5094 | } |
| 5095 | } |
| 5096 | |
Selim Cinek | 9941539 | 2016-09-09 14:58:41 -0700 | [diff] [blame] | 5097 | private final class DozeServiceHost implements DozeHost { |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5098 | // Amount of time to allow to update the time shown on the screen before releasing |
| 5099 | // the wakelock. This timeout is design to compensate for the fact that we don't |
| 5100 | // currently have a way to know when time display contents have actually been |
| 5101 | // refreshed once we've finished rendering a new frame. |
| 5102 | private static final long PROCESSING_TIME = 500; |
| 5103 | |
| 5104 | private final ArrayList<Callback> mCallbacks = new ArrayList<Callback>(); |
| 5105 | private final H mHandler = new H(); |
| 5106 | |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 5107 | // Keeps the last reported state by fireNotificationLight. |
| 5108 | private boolean mNotificationLightOn; |
| 5109 | |
John Spurlock | c6eed84 | 2014-08-25 12:19:41 -0400 | [diff] [blame] | 5110 | @Override |
| 5111 | public String toString() { |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 5112 | return "PSB.DozeServiceHost[mCallbacks=" + mCallbacks.size() + "]"; |
John Spurlock | 8b12f22 | 2014-09-09 11:54:11 -0400 | [diff] [blame] | 5113 | } |
| 5114 | |
John Spurlock | d96179e | 2014-08-21 16:43:45 -0400 | [diff] [blame] | 5115 | public void firePowerSaveChanged(boolean active) { |
| 5116 | for (Callback callback : mCallbacks) { |
| 5117 | callback.onPowerSaveChanged(active); |
| 5118 | } |
| 5119 | } |
| 5120 | |
John Spurlock | cad5768 | 2014-07-26 17:09:56 -0400 | [diff] [blame] | 5121 | public void fireBuzzBeepBlinked() { |
| 5122 | for (Callback callback : mCallbacks) { |
| 5123 | callback.onBuzzBeepBlinked(); |
| 5124 | } |
| 5125 | } |
| 5126 | |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 5127 | public void fireNotificationLight(boolean on) { |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 5128 | mNotificationLightOn = on; |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 5129 | for (Callback callback : mCallbacks) { |
| 5130 | callback.onNotificationLight(on); |
| 5131 | } |
| 5132 | } |
| 5133 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5134 | public void fireNewNotifications() { |
| 5135 | for (Callback callback : mCallbacks) { |
| 5136 | callback.onNewNotifications(); |
| 5137 | } |
| 5138 | } |
| 5139 | |
| 5140 | @Override |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 5141 | public void addCallback(@NonNull Callback callback) { |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5142 | mCallbacks.add(callback); |
| 5143 | } |
| 5144 | |
| 5145 | @Override |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 5146 | public void removeCallback(@NonNull Callback callback) { |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5147 | mCallbacks.remove(callback); |
| 5148 | } |
| 5149 | |
| 5150 | @Override |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 5151 | public void startDozing(@NonNull Runnable ready) { |
| 5152 | mHandler.obtainMessage(H.MSG_START_DOZING, ready).sendToTarget(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5153 | } |
| 5154 | |
| 5155 | @Override |
John Spurlock | eab28e6 | 2014-11-29 11:33:49 -0500 | [diff] [blame] | 5156 | public void pulseWhileDozing(@NonNull PulseCallback callback, int reason) { |
| 5157 | mHandler.obtainMessage(H.MSG_PULSE_WHILE_DOZING, reason, 0, callback).sendToTarget(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5158 | } |
| 5159 | |
| 5160 | @Override |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 5161 | public void stopDozing() { |
| 5162 | mHandler.obtainMessage(H.MSG_STOP_DOZING).sendToTarget(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5163 | } |
| 5164 | |
John Spurlock | d96179e | 2014-08-21 16:43:45 -0400 | [diff] [blame] | 5165 | @Override |
| 5166 | public boolean isPowerSaveActive() { |
| 5167 | return mBatteryController != null && mBatteryController.isPowerSave(); |
| 5168 | } |
| 5169 | |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 5170 | @Override |
Jorim Jaggi | 007f0e8 | 2015-08-14 13:56:01 -0700 | [diff] [blame] | 5171 | public boolean isPulsingBlocked() { |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 5172 | return mFingerprintUnlockController.getMode() |
| 5173 | == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK; |
Jorim Jaggi | 007f0e8 | 2015-08-14 13:56:01 -0700 | [diff] [blame] | 5174 | } |
| 5175 | |
| 5176 | @Override |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 5177 | public boolean isNotificationLightOn() { |
| 5178 | return mNotificationLightOn; |
| 5179 | } |
| 5180 | |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 5181 | private void handleStartDozing(@NonNull Runnable ready) { |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 5182 | if (!mDozingRequested) { |
| 5183 | mDozingRequested = true; |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 5184 | DozeLog.traceDozing(mContext, mDozing); |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 5185 | updateDozing(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5186 | } |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 5187 | ready.run(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5188 | } |
| 5189 | |
John Spurlock | eab28e6 | 2014-11-29 11:33:49 -0500 | [diff] [blame] | 5190 | private void handlePulseWhileDozing(@NonNull PulseCallback callback, int reason) { |
Selim Cinek | cd5b22f | 2016-03-08 16:15:41 -0800 | [diff] [blame] | 5191 | mDozeScrimController.pulse(new PulseCallback() { |
| 5192 | |
| 5193 | @Override |
| 5194 | public void onPulseStarted() { |
| 5195 | callback.onPulseStarted(); |
| 5196 | mStackScroller.setPulsing(true); |
| 5197 | } |
| 5198 | |
| 5199 | @Override |
| 5200 | public void onPulseFinished() { |
| 5201 | callback.onPulseFinished(); |
| 5202 | mStackScroller.setPulsing(false); |
| 5203 | } |
| 5204 | }, reason); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5205 | } |
| 5206 | |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 5207 | private void handleStopDozing() { |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 5208 | if (mDozingRequested) { |
| 5209 | mDozingRequested = false; |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 5210 | DozeLog.traceDozing(mContext, mDozing); |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 5211 | updateDozing(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5212 | } |
| 5213 | } |
| 5214 | |
| 5215 | private final class H extends Handler { |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 5216 | private static final int MSG_START_DOZING = 1; |
| 5217 | private static final int MSG_PULSE_WHILE_DOZING = 2; |
| 5218 | private static final int MSG_STOP_DOZING = 3; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5219 | |
| 5220 | @Override |
| 5221 | public void handleMessage(Message msg) { |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 5222 | switch (msg.what) { |
| 5223 | case MSG_START_DOZING: |
| 5224 | handleStartDozing((Runnable) msg.obj); |
| 5225 | break; |
| 5226 | case MSG_PULSE_WHILE_DOZING: |
John Spurlock | eab28e6 | 2014-11-29 11:33:49 -0500 | [diff] [blame] | 5227 | handlePulseWhileDozing((PulseCallback) msg.obj, msg.arg1); |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 5228 | break; |
| 5229 | case MSG_STOP_DOZING: |
| 5230 | handleStopDozing(); |
| 5231 | break; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5232 | } |
| 5233 | } |
| 5234 | } |
| 5235 | } |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 5236 | } |