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; |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 39 | import android.app.IActivityManager; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 40 | import android.app.Notification; |
| 41 | import android.app.PendingIntent; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 42 | import android.app.StatusBarManager; |
| 43 | import android.content.BroadcastReceiver; |
Jorim Jaggi | 786afcb | 2014-09-25 02:41:29 +0200 | [diff] [blame] | 44 | import android.content.ComponentCallbacks2; |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 45 | import android.content.ComponentName; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 46 | import android.content.Context; |
| 47 | import android.content.Intent; |
| 48 | import android.content.IntentFilter; |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 49 | import android.content.IntentSender; |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 50 | import android.content.pm.IPackageManager; |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 51 | import android.content.pm.PackageManager; |
Tony Mak | 92c989d | 2016-04-19 14:02:44 +0100 | [diff] [blame] | 52 | import android.content.pm.UserInfo; |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 53 | import android.content.res.Configuration; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 54 | import android.content.res.Resources; |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 55 | import android.database.ContentObserver; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 56 | import android.graphics.Bitmap; |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 57 | import android.graphics.Canvas; |
| 58 | import android.graphics.ColorFilter; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 59 | import android.graphics.PixelFormat; |
Daniel Sandler | e680f54 | 2012-09-28 12:22:27 -0400 | [diff] [blame] | 60 | import android.graphics.Point; |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 61 | import android.graphics.PointF; |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 62 | import android.graphics.PorterDuff; |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 63 | import android.graphics.PorterDuffXfermode; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 64 | import android.graphics.Rect; |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 65 | import android.graphics.drawable.BitmapDrawable; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 66 | import android.graphics.drawable.ColorDrawable; |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 67 | import android.graphics.drawable.Drawable; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 68 | import android.inputmethodservice.InputMethodService; |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 69 | import android.media.AudioAttributes; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 70 | import android.media.MediaMetadata; |
| 71 | import android.media.session.MediaController; |
| 72 | import android.media.session.MediaSession; |
| 73 | import android.media.session.MediaSessionManager; |
| 74 | import android.media.session.PlaybackState; |
Adrian Roos | 7bb38a9 | 2016-07-21 11:44:01 -0700 | [diff] [blame] | 75 | import android.net.Uri; |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 76 | import android.os.AsyncTask; |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 77 | import android.os.Bundle; |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 78 | import android.os.Handler; |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 79 | import android.os.HandlerThread; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 80 | import android.os.IBinder; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 81 | import android.os.Message; |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 82 | import android.os.PowerManager; |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 83 | import android.os.Process; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 84 | import android.os.RemoteException; |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 85 | import android.os.ServiceManager; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 86 | import android.os.SystemClock; |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 87 | import android.os.Trace; |
Adrian Roos | 7bb38a9 | 2016-07-21 11:44:01 -0700 | [diff] [blame] | 88 | import android.os.SystemProperties; |
Dianne Hackborn | f02b60a | 2012-08-16 10:48:27 -0700 | [diff] [blame] | 89 | import android.os.UserHandle; |
Adrian Roos | 2b154a9 | 2014-11-17 15:18:39 +0100 | [diff] [blame] | 90 | import android.os.UserManager; |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 91 | import android.os.Vibrator; |
Daniel Sandler | d309056 | 2011-08-09 00:28:44 -0400 | [diff] [blame] | 92 | import android.provider.Settings; |
Chris Wren | 3ad4e3a | 2014-09-02 17:23:51 -0400 | [diff] [blame] | 93 | import android.service.notification.NotificationListenerService; |
Christoph Studer | d0694b6 | 2014-06-04 16:36:01 +0200 | [diff] [blame] | 94 | import android.service.notification.NotificationListenerService.RankingMap; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 95 | import android.service.notification.StatusBarNotification; |
Selim Cinek | 64be772 | 2016-07-22 13:28:16 -0700 | [diff] [blame] | 96 | import android.telecom.TelecomManager; |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 97 | import android.util.ArraySet; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 98 | import android.util.DisplayMetrics; |
Chris Wren | 64161cc | 2012-12-17 16:49:30 -0500 | [diff] [blame] | 99 | import android.util.EventLog; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 100 | import android.util.Log; |
| 101 | import android.view.Display; |
Adrian Roos | a98b32c | 2016-08-11 10:41:08 -0700 | [diff] [blame] | 102 | import android.view.IRotationWatcher; |
Jorim Jaggi | df99351 | 2014-05-13 23:06:35 +0200 | [diff] [blame] | 103 | import android.view.KeyEvent; |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 104 | import android.view.LayoutInflater; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 105 | import android.view.MotionEvent; |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 106 | import android.view.ThreadedRenderer; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 107 | import android.view.View; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 108 | import android.view.ViewGroup; |
Jim Miller | f2a16b2 | 2011-07-06 17:32:48 -0700 | [diff] [blame] | 109 | import android.view.ViewGroup.LayoutParams; |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 110 | import android.view.ViewParent; |
Dan Sandler | 44c0dfd | 2014-06-09 11:26:16 -0400 | [diff] [blame] | 111 | import android.view.ViewStub; |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 112 | import android.view.ViewTreeObserver; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 113 | import android.view.WindowManager; |
Jorim Jaggi | 786afcb | 2014-09-25 02:41:29 +0200 | [diff] [blame] | 114 | import android.view.WindowManagerGlobal; |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 115 | import android.view.animation.AccelerateInterpolator; |
Jorim Jaggi | b13d36d | 2014-06-06 18:03:52 +0200 | [diff] [blame] | 116 | import android.view.animation.Interpolator; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 117 | import android.widget.ImageView; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 118 | import android.widget.TextView; |
Selim Cinek | 64be772 | 2016-07-22 13:28:16 -0700 | [diff] [blame] | 119 | |
Chris Wren | 9763d42 | 2015-04-30 15:24:05 -0400 | [diff] [blame] | 120 | import com.android.internal.logging.MetricsLogger; |
Tamas Berghammer | cbd3f0c | 2016-06-22 15:21:38 +0100 | [diff] [blame^] | 121 | import com.android.internal.logging.nano.MetricsProto.MetricsEvent; |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 122 | import com.android.internal.statusbar.NotificationVisibility; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 123 | import com.android.internal.statusbar.StatusBarIcon; |
Jorim Jaggi | 6b88cdf | 2014-12-22 20:56:50 +0100 | [diff] [blame] | 124 | import com.android.keyguard.KeyguardHostView.OnDismissAction; |
Jason Monk | ab52527 | 2015-07-13 17:02:49 -0400 | [diff] [blame] | 125 | import com.android.keyguard.KeyguardUpdateMonitor; |
Jorim Jaggi | 007f0e8 | 2015-08-14 13:56:01 -0700 | [diff] [blame] | 126 | import com.android.keyguard.KeyguardUpdateMonitorCallback; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 127 | import com.android.keyguard.ViewMediatorCallback; |
Clara Bayarri | 9b1fdff | 2016-04-21 14:28:47 +0100 | [diff] [blame] | 128 | import com.android.systemui.AutoReinflateContainer; |
| 129 | import com.android.systemui.AutoReinflateContainer.InflateListener; |
Jorim Jaggi | 708f772 | 2014-08-20 17:30:38 +0200 | [diff] [blame] | 130 | import com.android.systemui.BatteryMeterView; |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 131 | import com.android.systemui.DemoMode; |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 132 | import com.android.systemui.EventLogConstants; |
Chris Wren | 64161cc | 2012-12-17 16:49:30 -0500 | [diff] [blame] | 133 | import com.android.systemui.EventLogTags; |
Winson | c0d7058 | 2016-01-29 10:24:39 -0800 | [diff] [blame] | 134 | import com.android.systemui.Interpolators; |
Andrew Flynn | 8286257 | 2015-04-01 14:22:37 -0400 | [diff] [blame] | 135 | import com.android.systemui.Prefs; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 136 | import com.android.systemui.R; |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 137 | import com.android.systemui.SystemUIFactory; |
Adrian Roos | 401caae | 2016-03-04 13:35:21 -0800 | [diff] [blame] | 138 | import com.android.systemui.classifier.FalsingLog; |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 139 | import com.android.systemui.classifier.FalsingManager; |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 140 | import com.android.systemui.doze.DozeHost; |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 141 | import com.android.systemui.doze.DozeLog; |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 142 | import com.android.systemui.keyguard.KeyguardViewMediator; |
Jason Monk | 162011e | 2016-02-19 08:11:55 -0500 | [diff] [blame] | 143 | import com.android.systemui.qs.QSContainer; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 144 | import com.android.systemui.qs.QSPanel; |
Jorim Jaggi | d61f227 | 2014-12-19 20:35:35 +0100 | [diff] [blame] | 145 | import com.android.systemui.recents.ScreenPinningRequest; |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 146 | import com.android.systemui.recents.events.EventBus; |
Jorim Jaggi | 2adba07 | 2016-03-03 13:43:39 +0100 | [diff] [blame] | 147 | import com.android.systemui.recents.events.activity.AppTransitionFinishedEvent; |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 148 | import com.android.systemui.recents.events.activity.UndockingTaskEvent; |
Jorim Jaggi | dd98d41 | 2015-11-18 15:57:38 -0800 | [diff] [blame] | 149 | import com.android.systemui.stackdivider.Divider; |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 150 | import com.android.systemui.stackdivider.WindowManagerProxy; |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 151 | import com.android.systemui.statusbar.ActivatableNotificationView; |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 152 | import com.android.systemui.statusbar.BackDropView; |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 153 | import com.android.systemui.statusbar.BaseStatusBar; |
Michael Jurka | a600fd9 | 2012-06-25 15:57:05 -0700 | [diff] [blame] | 154 | import com.android.systemui.statusbar.CommandQueue; |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 155 | import com.android.systemui.statusbar.DismissView; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 156 | import com.android.systemui.statusbar.DragDownHelper; |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 157 | import com.android.systemui.statusbar.EmptyShadeView; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 158 | import com.android.systemui.statusbar.ExpandableNotificationRow; |
Daniel Sandler | 3380534 | 2012-07-23 15:45:12 -0400 | [diff] [blame] | 159 | import com.android.systemui.statusbar.GestureRecorder; |
Andrei Stingaceanu | f86bc97 | 2016-04-12 15:29:25 +0100 | [diff] [blame] | 160 | import com.android.systemui.statusbar.KeyboardShortcuts; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 161 | import com.android.systemui.statusbar.KeyguardIndicationController; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 162 | import com.android.systemui.statusbar.NotificationData; |
Daniel Sandler | 58b173b | 2012-05-03 11:25:29 -0400 | [diff] [blame] | 163 | import com.android.systemui.statusbar.NotificationData.Entry; |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 164 | import com.android.systemui.statusbar.NotificationOverflowContainer; |
Adrian Roos | 1c0ca50 | 2015-10-07 12:20:42 -0700 | [diff] [blame] | 165 | import com.android.systemui.statusbar.RemoteInputController; |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 166 | import com.android.systemui.statusbar.ScrimView; |
Christian Robertson | 2e34742 | 2011-08-11 14:01:04 -0700 | [diff] [blame] | 167 | import com.android.systemui.statusbar.SignalClusterView; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 168 | import com.android.systemui.statusbar.StatusBarState; |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 169 | import com.android.systemui.statusbar.phone.UnlockMethodCache.OnUnlockMethodChangedListener; |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 170 | import com.android.systemui.statusbar.policy.AccessibilityController; |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 171 | import com.android.systemui.statusbar.policy.BatteryController; |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 172 | import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback; |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 173 | import com.android.systemui.statusbar.policy.BatteryControllerImpl; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 174 | import com.android.systemui.statusbar.policy.BluetoothControllerImpl; |
Adrian Roos | 5fd872e | 2014-08-12 17:28:58 +0200 | [diff] [blame] | 175 | import com.android.systemui.statusbar.policy.BrightnessMirrorController; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 176 | import com.android.systemui.statusbar.policy.CastControllerImpl; |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 177 | import com.android.systemui.statusbar.policy.EncryptionHelper; |
Adrian Roos | b83777b | 2014-06-30 15:11:53 +0200 | [diff] [blame] | 178 | import com.android.systemui.statusbar.policy.FlashlightController; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 179 | import com.android.systemui.statusbar.policy.HeadsUpManager; |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 180 | import com.android.systemui.statusbar.policy.HotspotControllerImpl; |
John Spurlock | 657c62c | 2014-07-22 12:18:09 -0400 | [diff] [blame] | 181 | import com.android.systemui.statusbar.policy.KeyguardMonitor; |
Adrian Roos | 8ddb2da | 2014-06-16 18:56:22 -0700 | [diff] [blame] | 182 | import com.android.systemui.statusbar.policy.KeyguardUserSwitcher; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 183 | import com.android.systemui.statusbar.policy.LocationControllerImpl; |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 184 | import com.android.systemui.statusbar.policy.NetworkController; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 185 | import com.android.systemui.statusbar.policy.NetworkControllerImpl; |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 186 | import com.android.systemui.statusbar.policy.NextAlarmController; |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 187 | import com.android.systemui.statusbar.policy.PreviewInflater; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 188 | import com.android.systemui.statusbar.policy.RotationLockControllerImpl; |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 189 | import com.android.systemui.statusbar.policy.SecurityControllerImpl; |
| 190 | import com.android.systemui.statusbar.policy.UserInfoController; |
Adrian Roos | 00a0b1f | 2014-07-16 16:44:49 +0200 | [diff] [blame] | 191 | import com.android.systemui.statusbar.policy.UserSwitcherController; |
John Spurlock | 8600534 | 2014-05-23 11:58:00 -0400 | [diff] [blame] | 192 | import com.android.systemui.statusbar.policy.ZenModeController; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 193 | import com.android.systemui.statusbar.stack.NotificationStackScrollLayout; |
Selim Cinek | 64be772 | 2016-07-22 13:28:16 -0700 | [diff] [blame] | 194 | import com.android.systemui.statusbar.stack.NotificationStackScrollLayout |
| 195 | .OnChildLocationsChangedListener; |
Jorim Jaggi | 37c1180 | 2015-08-18 20:27:54 -0700 | [diff] [blame] | 196 | import com.android.systemui.statusbar.stack.StackStateAnimator; |
Selim Cinek | b036ca4 | 2015-02-20 15:56:28 +0100 | [diff] [blame] | 197 | import com.android.systemui.statusbar.stack.StackViewState; |
John Spurlock | 8600534 | 2014-05-23 11:58:00 -0400 | [diff] [blame] | 198 | import com.android.systemui.volume.VolumeComponent; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 199 | |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 200 | import java.io.FileDescriptor; |
| 201 | import java.io.PrintWriter; |
Adrian Roos | 7bb38a9 | 2016-07-21 11:44:01 -0700 | [diff] [blame] | 202 | import java.io.StringWriter; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 203 | import java.util.ArrayList; |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 204 | import java.util.Collection; |
| 205 | import java.util.Collections; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 206 | import java.util.HashMap; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 207 | import java.util.List; |
John Spurlock | 7bbb9f6 | 2014-10-21 12:15:28 -0400 | [diff] [blame] | 208 | import java.util.Map; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 209 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 210 | public class PhoneStatusBar extends BaseStatusBar implements DemoMode, |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 211 | DragDownHelper.DragDownCallback, ActivityStarter, OnUnlockMethodChangedListener, |
Adrian Roos | a98b32c | 2016-08-11 10:41:08 -0700 | [diff] [blame] | 212 | HeadsUpManager.OnHeadsUpChangedListener { |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 213 | static final String TAG = "PhoneStatusBar"; |
Daniel Sandler | 198a030 | 2012-08-17 16:04:31 -0400 | [diff] [blame] | 214 | public static final boolean DEBUG = BaseStatusBar.DEBUG; |
Chris Wren | 6d15a36 | 2013-08-20 18:46:29 -0400 | [diff] [blame] | 215 | public static final boolean SPEW = false; |
Daniel Sandler | 7579bca | 2011-08-18 15:47:26 -0400 | [diff] [blame] | 216 | public static final boolean DUMPTRUCK = true; // extra dumpsys info |
Daniel Sandler | fa027f5 | 2013-04-11 22:01:47 -0400 | [diff] [blame] | 217 | public static final boolean DEBUG_GESTURES = false; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 218 | public static final boolean DEBUG_MEDIA = false; |
| 219 | public static final boolean DEBUG_MEDIA_FAKE_ARTWORK = false; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 220 | |
John Spurlock | 342cad7 | 2013-10-08 09:36:50 -0400 | [diff] [blame] | 221 | public static final boolean DEBUG_WINDOW_STATE = false; |
Daniel Sandler | b17a726 | 2012-10-05 14:32:50 -0400 | [diff] [blame] | 222 | |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 223 | // additional instrumentation for testing purposes; intended to be left on during development |
Daniel Sandler | 7c35174 | 2011-10-17 10:48:06 -0400 | [diff] [blame] | 224 | public static final boolean CHATTY = DEBUG; |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 225 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 226 | public static final boolean SHOW_LOCKSCREEN_MEDIA_ARTWORK = true; |
| 227 | |
Adrian Roos | 8e3e836 | 2015-07-16 19:42:22 -0700 | [diff] [blame] | 228 | public static final String ACTION_FAKE_ARTWORK = "fake_artwork"; |
| 229 | |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 230 | private static final int MSG_OPEN_NOTIFICATION_PANEL = 1000; |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 231 | private static final int MSG_CLOSE_PANELS = 1001; |
| 232 | private static final int MSG_OPEN_SETTINGS_PANEL = 1002; |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 233 | private static final int MSG_LAUNCH_TRANSITION_TIMEOUT = 1003; |
Winson Chung | b1f7499 | 2014-08-08 12:53:09 -0700 | [diff] [blame] | 234 | // 1020-1040 reserved for BaseStatusBar |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 235 | |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 236 | // Time after we abort the launch transition. |
| 237 | private static final long LAUNCH_TRANSITION_TIMEOUT_MS = 5000; |
| 238 | |
Daniel Sandler | 8cc36e5 | 2011-10-17 14:18:46 -0400 | [diff] [blame] | 239 | private static final boolean CLOSE_PANEL_WHEN_EMPTIED = true; |
| 240 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 241 | private static final int STATUS_OR_NAV_TRANSIENT = |
| 242 | View.STATUS_BAR_TRANSIENT | View.NAVIGATION_BAR_TRANSIENT; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 243 | private static final long AUTOHIDE_TIMEOUT_MS = 3000; |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 244 | |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 245 | /** The minimum delay in ms between reports of notification visibility. */ |
| 246 | private static final int VISIBILITY_REPORT_MIN_DELAY_MS = 500; |
| 247 | |
Jorim Jaggi | 93a2bb2 | 2014-06-02 19:57:28 +0200 | [diff] [blame] | 248 | /** |
| 249 | * The delay to reset the hint text when the hint animation is finished running. |
| 250 | */ |
| 251 | private static final int HINT_RESET_DELAY_MS = 1200; |
| 252 | |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 253 | private static final AudioAttributes VIBRATION_ATTRIBUTES = new AudioAttributes.Builder() |
| 254 | .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) |
| 255 | .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) |
| 256 | .build(); |
| 257 | |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 258 | public static final int FADE_KEYGUARD_START_DELAY = 100; |
| 259 | public static final int FADE_KEYGUARD_DURATION = 300; |
Jorim Jaggi | 9097885 | 2015-08-18 19:55:53 -0700 | [diff] [blame] | 260 | public static final int FADE_KEYGUARD_DURATION_PULSING = 96; |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 261 | |
Jason Monk | 815e057 | 2014-08-12 17:26:36 -0400 | [diff] [blame] | 262 | /** Allow some time inbetween the long press for back and recents. */ |
| 263 | private static final int LOCK_TO_APP_GESTURE_TOLERENCE = 200; |
| 264 | |
Adrian Roos | 2f2bd9a | 2015-06-04 18:11:14 -0700 | [diff] [blame] | 265 | /** If true, the system is in the half-boot-to-decryption-screen state. |
| 266 | * Prudently disable QS and notifications. */ |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 267 | private static final boolean ONLY_CORE_APPS; |
| 268 | |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 269 | /** If true, the lockscreen will show a distinct wallpaper */ |
Adrian Roos | e381c16 | 2016-02-11 15:26:42 -0800 | [diff] [blame] | 270 | private static final boolean ENABLE_LOCKSCREEN_WALLPAPER = true; |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 271 | |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 272 | /* If true, the device supports freeform window management. |
| 273 | * This affects the status bar UI. */ |
| 274 | private static final boolean FREEFORM_WINDOW_MANAGEMENT; |
| 275 | |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 276 | /** |
| 277 | * How long to wait before auto-dismissing a notification that was kept for remote input, and |
| 278 | * has now sent a remote input. We auto-dismiss, because the app may not see a reason to cancel |
| 279 | * these given that they technically don't exist anymore. We wait a bit in case the app issues |
| 280 | * an update. |
| 281 | */ |
| 282 | private static final int REMOTE_INPUT_KEPT_ENTRY_AUTO_CANCEL_DELAY = 200; |
| 283 | |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 284 | /** |
| 285 | * Never let the alpha become zero for surfaces that draw with SRC - otherwise the RenderNode |
| 286 | * won't draw anything and uninitialized memory will show through |
| 287 | * if mScrimSrcModeEnabled. Note that 0.001 is rounded down to 0 in |
| 288 | * libhwui. |
| 289 | */ |
| 290 | private static final float SRC_MIN_ALPHA = 0.002f; |
| 291 | |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 292 | static { |
| 293 | boolean onlyCoreApps; |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 294 | boolean freeformWindowManagement; |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 295 | try { |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 296 | IPackageManager packageManager = |
| 297 | IPackageManager.Stub.asInterface(ServiceManager.getService("package")); |
| 298 | onlyCoreApps = packageManager.isOnlyCoreApps(); |
| 299 | freeformWindowManagement = packageManager.hasSystemFeature( |
Jeff Sharkey | 115d2c1 | 2016-02-15 17:25:57 -0700 | [diff] [blame] | 300 | PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT, 0); |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 301 | } catch (RemoteException e) { |
| 302 | onlyCoreApps = false; |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 303 | freeformWindowManagement = false; |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 304 | } |
| 305 | ONLY_CORE_APPS = onlyCoreApps; |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 306 | FREEFORM_WINDOW_MANAGEMENT = freeformWindowManagement; |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 307 | } |
| 308 | |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 309 | PhoneStatusBarPolicy mIconPolicy; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 310 | |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 311 | // 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] | 312 | BluetoothControllerImpl mBluetoothController; |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 313 | SecurityControllerImpl mSecurityController; |
Xiaohui Chen | 8bdcd1f | 2016-01-19 13:52:07 -0800 | [diff] [blame] | 314 | protected BatteryController mBatteryController; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 315 | LocationControllerImpl mLocationController; |
| 316 | NetworkControllerImpl mNetworkController; |
Jason Monk | 51e4dc0 | 2014-07-22 12:00:47 -0400 | [diff] [blame] | 317 | HotspotControllerImpl mHotspotController; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 318 | RotationLockControllerImpl mRotationLockController; |
Jorim Jaggi | 3d878be | 2014-05-10 03:22:32 +0200 | [diff] [blame] | 319 | UserInfoController mUserInfoController; |
Muyuan Li | 40e1135 | 2016-03-23 11:43:58 -0700 | [diff] [blame] | 320 | protected ZenModeController mZenModeController; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 321 | CastControllerImpl mCastController; |
John Spurlock | 8600534 | 2014-05-23 11:58:00 -0400 | [diff] [blame] | 322 | VolumeComponent mVolumeComponent; |
Adrian Roos | 8ddb2da | 2014-06-16 18:56:22 -0700 | [diff] [blame] | 323 | KeyguardUserSwitcher mKeyguardUserSwitcher; |
Adrian Roos | b83777b | 2014-06-30 15:11:53 +0200 | [diff] [blame] | 324 | FlashlightController mFlashlightController; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 325 | protected UserSwitcherController mUserSwitcherController; |
Jorim Jaggi | c7dea6e | 2014-07-26 14:36:57 +0200 | [diff] [blame] | 326 | NextAlarmController mNextAlarmController; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 327 | protected KeyguardMonitor mKeyguardMonitor; |
Adrian Roos | 5fd872e | 2014-08-12 17:28:58 +0200 | [diff] [blame] | 328 | BrightnessMirrorController mBrightnessMirrorController; |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 329 | AccessibilityController mAccessibilityController; |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 330 | FingerprintUnlockController mFingerprintUnlockController; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 331 | LightStatusBarController mLightStatusBarController; |
Vadim Tryshev | 12a30e8 | 2016-02-12 15:39:28 -0800 | [diff] [blame] | 332 | protected LockscreenWallpaper mLockscreenWallpaper; |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 333 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 334 | int mNaturalBarHeight = -1; |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 335 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 336 | Display mDisplay; |
Daniel Sandler | e680f54 | 2012-09-28 12:22:27 -0400 | [diff] [blame] | 337 | Point mCurrentDisplaySize = new Point(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 338 | |
Xiaohui Chen | d839d1a | 2016-01-21 13:05:02 -0800 | [diff] [blame] | 339 | protected StatusBarWindowView mStatusBarWindow; |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 340 | protected PhoneStatusBarView mStatusBarView; |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 341 | private int mStatusBarWindowState = WINDOW_STATE_SHOWING; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 342 | protected StatusBarWindowManager mStatusBarWindowManager; |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 343 | private UnlockMethodCache mUnlockMethodCache; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 344 | private DozeServiceHost mDozeServiceHost; |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 345 | private boolean mWakeUpComingFromTouch; |
| 346 | private PointF mWakeUpTouchLocation; |
Selim Cinek | 1b6f819 | 2015-09-03 16:01:53 -0700 | [diff] [blame] | 347 | private boolean mScreenTurningOn; |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 348 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 349 | int mPixelFormat; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 350 | Object mQueueLock = new Object(); |
| 351 | |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 352 | protected StatusBarIconController mIconController; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 353 | |
| 354 | // expanded notifications |
Xiaohui Chen | ea4b6ba | 2016-02-18 10:53:17 -0800 | [diff] [blame] | 355 | protected NotificationPanelView mNotificationPanel; // the sliding/resizing panel within the notification window |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 356 | View mExpandedContents; |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 357 | TextView mNotificationPanelDebugText; |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 358 | |
Daniel Sandler | 8e72c9e | 2012-08-15 00:09:26 -0400 | [diff] [blame] | 359 | // settings |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 360 | private QSPanel mQSPanel; |
Daniel Sandler | 8e72c9e | 2012-08-15 00:09:26 -0400 | [diff] [blame] | 361 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 362 | // top bar |
Jason Monk | 0e1101d | 2015-10-07 13:06:09 -0400 | [diff] [blame] | 363 | BaseStatusBarHeader mHeader; |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 364 | protected KeyguardStatusBarView mKeyguardStatusBar; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 365 | View mKeyguardStatusView; |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 366 | KeyguardBottomAreaView mKeyguardBottomArea; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 367 | boolean mLeaveOpenOnKeyguardHide; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 368 | KeyguardIndicationController mKeyguardIndicationController; |
Jorim Jaggi | e70d31f | 2014-04-24 22:08:30 +0200 | [diff] [blame] | 369 | |
Adrian Roos | 46df1ca | 2015-09-11 12:38:43 -0700 | [diff] [blame] | 370 | // Keyguard is going away soon. |
| 371 | private boolean mKeyguardGoingAway; |
| 372 | // Keyguard is actually fading away now. |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 373 | private boolean mKeyguardFadingAway; |
| 374 | private long mKeyguardFadingAwayDelay; |
| 375 | private long mKeyguardFadingAwayDuration; |
| 376 | |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 377 | // RemoteInputView to be activated after unlock |
| 378 | private View mPendingRemoteInputView; |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 379 | private View mPendingWorkRemoteInputView; |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 380 | |
Adrian Roos | 7bb38a9 | 2016-07-21 11:44:01 -0700 | [diff] [blame] | 381 | private View mReportRejectedTouch; |
| 382 | |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 383 | int mMaxAllowedKeyguardNotifications; |
Daniel Sandler | d309056 | 2011-08-09 00:28:44 -0400 | [diff] [blame] | 384 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 385 | boolean mExpandedVisible; |
| 386 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 387 | private int mNavigationBarWindowState = WINDOW_STATE_SHOWING; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 388 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 389 | // the tracker view |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 390 | int mTrackingPosition; // the position of the top of the tracking view. |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 391 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 392 | // Tracking finger for opening/closing. |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 393 | boolean mTracking; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 394 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 395 | int[] mAbsPos = new int[2]; |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 396 | ArrayList<Runnable> mPostCollapseRunnables = new ArrayList<>(); |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 397 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 398 | // for disabling the status bar |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 399 | int mDisabled1 = 0; |
| 400 | int mDisabled2 = 0; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 401 | |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 402 | // tracking calls to View.setSystemUiVisibility() |
| 403 | int mSystemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 404 | private final Rect mLastFullscreenStackBounds = new Rect(); |
| 405 | private final Rect mLastDockedStackBounds = new Rect(); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 406 | |
Adrian Roos | 389beec | 2015-05-12 13:33:25 -0700 | [diff] [blame] | 407 | // last value sent to window manager |
| 408 | private int mLastDispatchedSystemUiVisibility = ~View.SYSTEM_UI_FLAG_VISIBLE; |
| 409 | |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 410 | DisplayMetrics mDisplayMetrics = new DisplayMetrics(); |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 411 | |
Daniel Sandler | 3380534 | 2012-07-23 15:45:12 -0400 | [diff] [blame] | 412 | // XXX: gesture research |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 413 | private final GestureRecorder mGestureRec = DEBUG_GESTURES |
John Spurlock | 209bede | 2013-07-17 12:23:27 -0400 | [diff] [blame] | 414 | ? new GestureRecorder("/sdcard/statusbar_gestures.dat") |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 415 | : null; |
Daniel Sandler | 3380534 | 2012-07-23 15:45:12 -0400 | [diff] [blame] | 416 | |
Jason Monk | 18f99d9 | 2014-09-11 13:36:42 -0400 | [diff] [blame] | 417 | private ScreenPinningRequest mScreenPinningRequest; |
| 418 | |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 419 | private int mNavigationIconHints = 0; |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 420 | private HandlerThread mHandlerThread; |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 421 | |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 422 | // ensure quick settings is disabled until the current user makes it through the setup wizard |
| 423 | private boolean mUserSetup = false; |
| 424 | private ContentObserver mUserSetupObserver = new ContentObserver(new Handler()) { |
| 425 | @Override |
| 426 | public void onChange(boolean selfChange) { |
| 427 | final boolean userSetup = 0 != Settings.Secure.getIntForUser( |
| 428 | mContext.getContentResolver(), |
| 429 | Settings.Secure.USER_SETUP_COMPLETE, |
| 430 | 0 /*default */, |
| 431 | mCurrentUserId); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 432 | if (MULTIUSER_DEBUG) Log.d(TAG, String.format("User setup changed: " + |
John Spurlock | e4e8c56 | 2012-10-04 09:55:01 -0400 | [diff] [blame] | 433 | "selfChange=%s userSetup=%s mUserSetup=%s", |
| 434 | selfChange, userSetup, mUserSetup)); |
John Spurlock | 73203eb | 2014-04-15 16:14:46 -0400 | [diff] [blame] | 435 | |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 436 | if (userSetup != mUserSetup) { |
| 437 | mUserSetup = userSetup; |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 438 | if (!mUserSetup && mStatusBarView != null) |
| 439 | animateCollapseQuickSettings(); |
Adrian Roos | a4eba9f | 2015-07-22 18:13:04 -0700 | [diff] [blame] | 440 | if (mKeyguardBottomArea != null) { |
| 441 | mKeyguardBottomArea.setUserSetupComplete(mUserSetup); |
| 442 | } |
Jason Monk | fd57ea7 | 2016-04-29 13:37:58 -0400 | [diff] [blame] | 443 | if (mNetworkController != null) { |
| 444 | mNetworkController.setUserSetupComplete(mUserSetup); |
| 445 | } |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 446 | } |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 447 | if (mIconPolicy != null) { |
| 448 | mIconPolicy.setCurrentUserSetup(mUserSetup); |
| 449 | } |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 450 | } |
| 451 | }; |
| 452 | |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 453 | final private ContentObserver mHeadsUpObserver = new ContentObserver(mHandler) { |
| 454 | @Override |
| 455 | public void onChange(boolean selfChange) { |
| 456 | boolean wasUsing = mUseHeadsUp; |
Jason Monk | f701954 | 2014-07-31 12:42:25 -0400 | [diff] [blame] | 457 | mUseHeadsUp = ENABLE_HEADS_UP && !mDisableNotificationAlerts |
| 458 | && Settings.Global.HEADS_UP_OFF != Settings.Global.getInt( |
Chris Wren | 10d82df | 2014-03-01 10:34:51 -0500 | [diff] [blame] | 459 | mContext.getContentResolver(), Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED, |
Chris Wren | 7bd24123 | 2014-02-28 16:25:05 -0500 | [diff] [blame] | 460 | Settings.Global.HEADS_UP_OFF); |
Chris Wren | 22ae46e | 2014-02-26 18:08:09 -0500 | [diff] [blame] | 461 | mHeadsUpTicker = mUseHeadsUp && 0 != Settings.Global.getInt( |
| 462 | mContext.getContentResolver(), SETTING_HEADS_UP_TICKER, 0); |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 463 | Log.d(TAG, "heads up is " + (mUseHeadsUp ? "enabled" : "disabled")); |
| 464 | if (wasUsing != mUseHeadsUp) { |
| 465 | if (!mUseHeadsUp) { |
| 466 | Log.d(TAG, "dismissing any existing heads up notification on disable event"); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 467 | mHeadsUpManager.releaseAllImmediately(); |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 468 | } |
| 469 | } |
| 470 | } |
| 471 | }; |
| 472 | |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 473 | private int mInteractingWindows; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 474 | private boolean mAutohideSuspended; |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 475 | private int mStatusBarMode; |
| 476 | private int mNavigationBarMode; |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 477 | private int mMaxKeyguardNotifications; |
Jorim Jaggi | d41083a | 2014-09-12 02:54:40 +0200 | [diff] [blame] | 478 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 479 | private ViewMediatorCallback mKeyguardViewMediatorCallback; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 480 | protected ScrimController mScrimController; |
| 481 | protected DozeScrimController mDozeScrimController; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 482 | |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 483 | private final Runnable mAutohide = new Runnable() { |
| 484 | @Override |
| 485 | public void run() { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 486 | int requested = mSystemUiVisibility & ~STATUS_OR_NAV_TRANSIENT; |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 487 | if (mSystemUiVisibility != requested) { |
| 488 | notifyUiVisibilityChanged(requested); |
| 489 | } |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 490 | }}; |
| 491 | |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 492 | private boolean mWaitingForKeyguardExit; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 493 | private boolean mDozing; |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 494 | private boolean mDozingRequested; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 495 | protected boolean mScrimSrcModeEnabled; |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 496 | |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 497 | public static final Interpolator ALPHA_IN = Interpolators.ALPHA_IN; |
| 498 | public static final Interpolator ALPHA_OUT = Interpolators.ALPHA_OUT; |
Jorim Jaggi | b13d36d | 2014-06-06 18:03:52 +0200 | [diff] [blame] | 499 | |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 500 | private BackDropView mBackdrop; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 501 | private ImageView mBackdropFront, mBackdropBack; |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 502 | private PorterDuffXfermode mSrcXferMode = new PorterDuffXfermode(PorterDuff.Mode.SRC); |
| 503 | private PorterDuffXfermode mSrcOverXferMode = new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 504 | |
| 505 | private MediaSessionManager mMediaSessionManager; |
| 506 | private MediaController mMediaController; |
| 507 | private String mMediaNotificationKey; |
| 508 | private MediaMetadata mMediaMetadata; |
| 509 | private MediaController.Callback mMediaListener |
| 510 | = new MediaController.Callback() { |
| 511 | @Override |
| 512 | public void onPlaybackStateChanged(PlaybackState state) { |
| 513 | super.onPlaybackStateChanged(state); |
| 514 | if (DEBUG_MEDIA) Log.v(TAG, "DEBUG_MEDIA: onPlaybackStateChanged: " + state); |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 515 | if (state != null) { |
| 516 | if (!isPlaybackActive(state.getState())) { |
| 517 | clearCurrentMediaNotification(); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 518 | updateMediaMetaData(true, true); |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 519 | } |
| 520 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 521 | } |
| 522 | |
| 523 | @Override |
| 524 | public void onMetadataChanged(MediaMetadata metadata) { |
| 525 | super.onMetadataChanged(metadata); |
| 526 | if (DEBUG_MEDIA) Log.v(TAG, "DEBUG_MEDIA: onMetadataChanged: " + metadata); |
| 527 | mMediaMetadata = metadata; |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 528 | updateMediaMetaData(true, true); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 529 | } |
| 530 | }; |
| 531 | |
| 532 | private final OnChildLocationsChangedListener mOnChildLocationsChangedListener = |
| 533 | new OnChildLocationsChangedListener() { |
| 534 | @Override |
| 535 | public void onChildLocationsChanged(NotificationStackScrollLayout stackScrollLayout) { |
| 536 | userActivity(); |
| 537 | } |
| 538 | }; |
| 539 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 540 | private int mDisabledUnmodified1; |
| 541 | private int mDisabledUnmodified2; |
Jorim Jaggi | b13d36d | 2014-06-06 18:03:52 +0200 | [diff] [blame] | 542 | |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 543 | /** Keys of notifications currently visible to the user. */ |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 544 | private final ArraySet<NotificationVisibility> mCurrentlyVisibleNotifications = |
| 545 | new ArraySet<>(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 546 | private long mLastVisibilityReportUptimeMs; |
| 547 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 548 | private final ShadeUpdates mShadeUpdates = new ShadeUpdates(); |
| 549 | |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 550 | private Runnable mLaunchTransitionEndRunnable; |
| 551 | private boolean mLaunchTransitionFadingAway; |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 552 | private ExpandableNotificationRow mDraggedDownRow; |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 553 | private boolean mLaunchCameraOnScreenTurningOn; |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 554 | private boolean mLaunchCameraOnFinishedGoingToSleep; |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 555 | private int mLastCameraLaunchSource; |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 556 | private PowerManager.WakeLock mGestureWakeLock; |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 557 | private Vibrator mVibrator; |
Jorim Jaggi | 362dd6d | 2014-07-09 19:04:07 +0200 | [diff] [blame] | 558 | |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 559 | // Fingerprint (as computed by getLoggingFingerprint() of the last logged state. |
| 560 | private int mLastLoggedStateFingerprint; |
| 561 | |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 562 | /** |
| 563 | * If set, the device has started going to sleep but isn't fully non-interactive yet. |
| 564 | */ |
| 565 | protected boolean mStartedGoingToSleep; |
| 566 | |
Selim Cinek | 3776fe0 | 2016-02-04 13:32:43 -0800 | [diff] [blame] | 567 | private static final int VISIBLE_LOCATIONS = StackViewState.LOCATION_FIRST_HUN |
Chris Wren | 35a7c92 | 2015-06-22 16:31:01 -0400 | [diff] [blame] | 568 | | StackViewState.LOCATION_MAIN_AREA; |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 569 | |
| 570 | private final OnChildLocationsChangedListener mNotificationLocationsChangedListener = |
| 571 | new OnChildLocationsChangedListener() { |
| 572 | @Override |
| 573 | public void onChildLocationsChanged( |
| 574 | NotificationStackScrollLayout stackScrollLayout) { |
| 575 | if (mHandler.hasCallbacks(mVisibilityReporter)) { |
| 576 | // Visibilities will be reported when the existing |
| 577 | // callback is executed. |
| 578 | return; |
| 579 | } |
| 580 | // Calculate when we're allowed to run the visibility |
| 581 | // reporter. Note that this timestamp might already have |
| 582 | // passed. That's OK, the callback will just be executed |
| 583 | // ASAP. |
| 584 | long nextReportUptimeMs = |
| 585 | mLastVisibilityReportUptimeMs + VISIBILITY_REPORT_MIN_DELAY_MS; |
| 586 | mHandler.postAtTime(mVisibilityReporter, nextReportUptimeMs); |
| 587 | } |
| 588 | }; |
| 589 | |
| 590 | // Tracks notifications currently visible in mNotificationStackScroller and |
| 591 | // emits visibility events via NoMan on changes. |
| 592 | private final Runnable mVisibilityReporter = new Runnable() { |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 593 | private final ArraySet<NotificationVisibility> mTmpNewlyVisibleNotifications = |
| 594 | new ArraySet<>(); |
| 595 | private final ArraySet<NotificationVisibility> mTmpCurrentlyVisibleNotifications = |
| 596 | new ArraySet<>(); |
| 597 | private final ArraySet<NotificationVisibility> mTmpNoLongerVisibleNotifications = |
| 598 | new ArraySet<>(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 599 | |
| 600 | @Override |
| 601 | public void run() { |
| 602 | mLastVisibilityReportUptimeMs = SystemClock.uptimeMillis(); |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 603 | final String mediaKey = getCurrentMediaNotificationKey(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 604 | |
| 605 | // 1. Loop over mNotificationData entries: |
| 606 | // A. Keep list of visible notifications. |
| 607 | // B. Keep list of previously hidden, now visible notifications. |
| 608 | // 2. Compute no-longer visible notifications by removing currently |
| 609 | // visible notifications from the set of previously visible |
| 610 | // notifications. |
| 611 | // 3. Report newly visible and no-longer visible notifications. |
| 612 | // 4. Keep currently visible notifications for next report. |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 613 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
| 614 | int N = activeNotifications.size(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 615 | for (int i = 0; i < N; i++) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 616 | Entry entry = activeNotifications.get(i); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 617 | String key = entry.notification.getKey(); |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 618 | boolean isVisible = |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 619 | (mStackScroller.getChildLocation(entry.row) & VISIBLE_LOCATIONS) != 0; |
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 | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 668 | |
Selim Cinek | 9941539 | 2016-09-09 14:58:41 -0700 | [diff] [blame] | 669 | private KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() { |
| 670 | @Override |
| 671 | public void onDreamingStateChanged(boolean dreaming) { |
| 672 | if (dreaming) { |
| 673 | maybeEscalateHeadsUp(); |
| 674 | } |
| 675 | } |
| 676 | }; |
| 677 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 678 | @Override |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 679 | public void start() { |
| 680 | mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)) |
| 681 | .getDefaultDisplay(); |
Daniel Sandler | 7e8ae50 | 2013-10-10 23:38:19 -0400 | [diff] [blame] | 682 | updateDisplaySize(); |
Jorim Jaggi | 0e66439 | 2014-09-27 01:30:22 +0200 | [diff] [blame] | 683 | mScrimSrcModeEnabled = mContext.getResources().getBoolean( |
| 684 | R.bool.config_status_bar_scrim_behind_use_src); |
Adrian Roos | 75fa385 | 2015-01-27 20:21:44 +0100 | [diff] [blame] | 685 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 686 | super.start(); // calls createAndAddWindows() |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 687 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 688 | mMediaSessionManager |
| 689 | = (MediaSessionManager) mContext.getSystemService(Context.MEDIA_SESSION_SERVICE); |
| 690 | // TODO: use MediaSessionManager.SessionListener to hook us up to future updates |
| 691 | // in session state |
| 692 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 693 | addNavigationBar(); |
| 694 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 695 | // Lastly, call to the icon policy to install/update all the icons. |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 696 | mIconPolicy = new PhoneStatusBarPolicy(mContext, mIconController, mCastController, |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 697 | mHotspotController, mUserInfoController, mBluetoothController, |
Julia Reynolds | 4e6024b | 2016-04-26 16:12:26 -0400 | [diff] [blame] | 698 | mRotationLockController, mNetworkController.getDataSaverController(), mNextAlarmController); |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 699 | mIconPolicy.setCurrentUserSetup(mUserSetup); |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 700 | mSettingsObserver.onChange(false); // set up |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 701 | |
| 702 | mHeadsUpObserver.onChange(true); // set up |
| 703 | if (ENABLE_HEADS_UP) { |
| 704 | mContext.getContentResolver().registerContentObserver( |
Chris Wren | 10d82df | 2014-03-01 10:34:51 -0500 | [diff] [blame] | 705 | Settings.Global.getUriFor(Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED), true, |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 706 | mHeadsUpObserver); |
Chris Wren | 22ae46e | 2014-02-26 18:08:09 -0500 | [diff] [blame] | 707 | mContext.getContentResolver().registerContentObserver( |
| 708 | Settings.Global.getUriFor(SETTING_HEADS_UP_TICKER), true, |
| 709 | mHeadsUpObserver); |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 710 | } |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 711 | mUnlockMethodCache = UnlockMethodCache.getInstance(mContext); |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 712 | mUnlockMethodCache.addListener(this); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 713 | startKeyguard(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 714 | |
Selim Cinek | 9941539 | 2016-09-09 14:58:41 -0700 | [diff] [blame] | 715 | KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateCallback); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 716 | mDozeServiceHost = new DozeServiceHost(); |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 717 | putComponent(DozeHost.class, mDozeServiceHost); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 718 | putComponent(PhoneStatusBar.class, this); |
John Spurlock | 89f060a | 2014-07-16 21:03:15 -0400 | [diff] [blame] | 719 | |
| 720 | setControllerUsers(); |
Chris Wren | cd8f4f7 | 2014-08-27 18:48:13 -0400 | [diff] [blame] | 721 | |
| 722 | notifyUserAboutHiddenNotifications(); |
Jason Monk | 18f99d9 | 2014-09-11 13:36:42 -0400 | [diff] [blame] | 723 | |
| 724 | mScreenPinningRequest = new ScreenPinningRequest(mContext); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 725 | mFalsingManager = FalsingManager.getInstance(mContext); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 726 | } |
| 727 | |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 728 | protected void createIconController() { |
| 729 | mIconController = new StatusBarIconController( |
| 730 | mContext, mStatusBarView, mKeyguardStatusBar, this); |
| 731 | } |
| 732 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 733 | // ================================================================================ |
| 734 | // Constructing the view |
| 735 | // ================================================================================ |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 736 | protected PhoneStatusBarView makeStatusBarView() { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 737 | final Context context = mContext; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 738 | |
Daniel Sandler | 6e8db88 | 2011-10-26 15:40:51 -0400 | [diff] [blame] | 739 | updateDisplaySize(); // populates mDisplayMetrics |
Jorim Jaggi | 2e115c5 | 2014-07-01 21:27:58 +0200 | [diff] [blame] | 740 | updateResources(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 741 | |
Xiaohui Chen | d839d1a | 2016-01-21 13:05:02 -0800 | [diff] [blame] | 742 | inflateStatusBarWindow(context); |
Selim Cinek | 4e6b2d3 | 2015-06-25 20:15:33 -0400 | [diff] [blame] | 743 | mStatusBarWindow.setService(this); |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 744 | mStatusBarWindow.setOnTouchListener(new View.OnTouchListener() { |
| 745 | @Override |
| 746 | public boolean onTouch(View v, MotionEvent event) { |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 747 | checkUserAutohide(v, event); |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 748 | if (event.getAction() == MotionEvent.ACTION_DOWN) { |
Daniel Sandler | 37a38aa | 2013-02-13 17:15:57 -0500 | [diff] [blame] | 749 | if (mExpandedVisible) { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 750 | animateCollapsePanels(); |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 751 | } |
| 752 | } |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame] | 753 | return mStatusBarWindow.onTouchEvent(event); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 754 | } |
| 755 | }); |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 756 | |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 757 | mNotificationPanel = (NotificationPanelView) mStatusBarWindow.findViewById( |
| 758 | R.id.notification_panel); |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 759 | mNotificationPanel.setStatusBar(this); |
Selim Cinek | 53f8e7d | 2016-03-25 02:28:01 -0700 | [diff] [blame] | 760 | mNotificationPanel.setGroupManager(mGroupManager); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 761 | |
Xiaohui Chen | 9f96711 | 2016-01-07 14:14:06 -0800 | [diff] [blame] | 762 | mStatusBarView = (PhoneStatusBarView) mStatusBarWindow.findViewById(R.id.status_bar); |
| 763 | mStatusBarView.setBar(this); |
| 764 | mStatusBarView.setPanel(mNotificationPanel); |
| 765 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 766 | if (!ActivityManager.isHighEndGfx()) { |
Romain Guy | 328b358 | 2012-05-08 15:30:57 -0700 | [diff] [blame] | 767 | mStatusBarWindow.setBackground(null); |
Alan Viverette | 4a357cd | 2015-03-18 18:37:18 -0700 | [diff] [blame] | 768 | mNotificationPanel.setBackground(new FastColorDrawable(context.getColor( |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 769 | R.color.notification_panel_solid_background))); |
Romain Guy | 328b358 | 2012-05-08 15:30:57 -0700 | [diff] [blame] | 770 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 771 | |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 772 | mHeadsUpManager = new HeadsUpManager(context, mStatusBarWindow, mGroupManager); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 773 | mHeadsUpManager.setBar(this); |
| 774 | mHeadsUpManager.addListener(this); |
| 775 | mHeadsUpManager.addListener(mNotificationPanel); |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 776 | mHeadsUpManager.addListener(mGroupManager); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 777 | mNotificationPanel.setHeadsUpManager(mHeadsUpManager); |
Selim Cinek | fbe9a44 | 2015-04-13 16:09:49 -0700 | [diff] [blame] | 778 | mNotificationData.setHeadsUpManager(mHeadsUpManager); |
Selim Cinek | 967ed2a | 2016-04-08 18:29:11 -0700 | [diff] [blame] | 779 | mGroupManager.setHeadsUpManager(mHeadsUpManager); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 780 | |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 781 | if (MULTIUSER_DEBUG) { |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 782 | mNotificationPanelDebugText = (TextView) mNotificationPanel.findViewById( |
| 783 | R.id.header_debug_info); |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 784 | mNotificationPanelDebugText.setVisibility(View.VISIBLE); |
| 785 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 786 | |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 787 | try { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 788 | boolean showNav = mWindowManagerService.hasNavigationBar(); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 789 | if (DEBUG) Log.v(TAG, "hasNavigationBar=" + showNav); |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 790 | if (showNav) { |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 791 | createNavigationBarView(context); |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 792 | } |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 793 | } catch (RemoteException ex) { |
| 794 | // no window manager? good luck with that |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 795 | } |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 796 | |
Annie Chin | 937a991 | 2016-05-31 10:14:23 -0700 | [diff] [blame] | 797 | mAssistManager = SystemUIFactory.getInstance().createAssistManager(this, context); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 798 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 799 | // figure out which pixel-format to use for the status bar. |
Daniel Sandler | f733c2a | 2011-09-25 15:03:40 -0400 | [diff] [blame] | 800 | mPixelFormat = PixelFormat.OPAQUE; |
Daniel Sandler | 173bae2 | 2012-09-25 14:37:42 -0400 | [diff] [blame] | 801 | |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 802 | mStackScroller = (NotificationStackScrollLayout) mStatusBarWindow.findViewById( |
| 803 | R.id.notification_stack_scroller); |
| 804 | mStackScroller.setLongPressListener(getNotificationLongClicker()); |
Selim Cinek | 19c8c70 | 2014-08-25 22:09:19 +0200 | [diff] [blame] | 805 | mStackScroller.setPhoneStatusBar(this); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 806 | mStackScroller.setGroupManager(mGroupManager); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 807 | mStackScroller.setHeadsUpManager(mHeadsUpManager); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 808 | mGroupManager.setOnGroupChangeListener(mStackScroller); |
Selim Cinek | 80a14e5 | 2014-03-27 16:58:04 +0100 | [diff] [blame] | 809 | |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 810 | inflateOverflowContainer(); |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 811 | inflateEmptyShadeView(); |
| 812 | inflateDismissView(); |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 813 | mExpandedContents = mStackScroller; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 814 | |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 815 | mBackdrop = (BackDropView) mStatusBarWindow.findViewById(R.id.backdrop); |
| 816 | mBackdropFront = (ImageView) mBackdrop.findViewById(R.id.backdrop_front); |
| 817 | mBackdropBack = (ImageView) mBackdrop.findViewById(R.id.backdrop_back); |
| 818 | |
Jorim Jaggi | e31f6b8 | 2016-07-01 16:15:09 -0700 | [diff] [blame] | 819 | if (ENABLE_LOCKSCREEN_WALLPAPER) { |
| 820 | mLockscreenWallpaper = new LockscreenWallpaper(mContext, this, mHandler); |
| 821 | } |
| 822 | |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 823 | ScrimView scrimBehind = (ScrimView) mStatusBarWindow.findViewById(R.id.scrim_behind); |
| 824 | ScrimView scrimInFront = (ScrimView) mStatusBarWindow.findViewById(R.id.scrim_in_front); |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 825 | View headsUpScrim = mStatusBarWindow.findViewById(R.id.heads_up_scrim); |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 826 | mScrimController = SystemUIFactory.getInstance().createScrimController( |
Jorim Jaggi | e31f6b8 | 2016-07-01 16:15:09 -0700 | [diff] [blame] | 827 | scrimBehind, scrimInFront, headsUpScrim, mLockscreenWallpaper); |
Selim Cinek | 2550325 | 2016-03-03 15:31:43 -0800 | [diff] [blame] | 828 | if (mScrimSrcModeEnabled) { |
| 829 | Runnable runnable = new Runnable() { |
| 830 | @Override |
| 831 | public void run() { |
| 832 | boolean asSrc = mBackdrop.getVisibility() != View.VISIBLE; |
| 833 | mScrimController.setDrawBehindAsSrc(asSrc); |
| 834 | mStackScroller.setDrawBackgroundAsSrc(asSrc); |
| 835 | } |
| 836 | }; |
| 837 | mBackdrop.setOnVisibilityChangedRunnable(runnable); |
| 838 | runnable.run(); |
| 839 | } |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 840 | mHeadsUpManager.addListener(mScrimController); |
| 841 | mStackScroller.setScrimController(mScrimController); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 842 | mStatusBarView.setScrimController(mScrimController); |
Jorim Jaggi | 048af1f | 2014-11-11 22:51:10 +0100 | [diff] [blame] | 843 | mDozeScrimController = new DozeScrimController(mScrimController, context); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 844 | |
Jorim Jaggi | 4538027d | 2014-07-30 15:43:13 +0200 | [diff] [blame] | 845 | mKeyguardStatusBar = (KeyguardStatusBarView) mStatusBarWindow.findViewById(R.id.keyguard_header); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 846 | mKeyguardStatusView = mStatusBarWindow.findViewById(R.id.keyguard_status_view); |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 847 | mKeyguardBottomArea = |
| 848 | (KeyguardBottomAreaView) mStatusBarWindow.findViewById(R.id.keyguard_bottom_area); |
| 849 | mKeyguardBottomArea.setActivityStarter(this); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 850 | mKeyguardBottomArea.setAssistManager(mAssistManager); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 851 | mKeyguardIndicationController = new KeyguardIndicationController(mContext, |
| 852 | (KeyguardIndicationTextView) mStatusBarWindow.findViewById( |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 853 | R.id.keyguard_indication_text), |
| 854 | mKeyguardBottomArea.getLockIcon()); |
Adrian Roos | 4ebcdfd | 2014-08-12 23:33:49 +0200 | [diff] [blame] | 855 | mKeyguardBottomArea.setKeyguardIndicationController(mKeyguardIndicationController); |
Daniel Sandler | e111ad3 | 2012-10-13 15:17:45 -0400 | [diff] [blame] | 856 | |
Xiaohui Chen | f43491f | 2016-02-01 12:19:35 -0800 | [diff] [blame] | 857 | // set the initial view visibility |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 858 | setAreThereNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 859 | |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 860 | createIconController(); |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 861 | |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 862 | // Background thread for any controllers that need it. |
| 863 | mHandlerThread = new HandlerThread(TAG, Process.THREAD_PRIORITY_BACKGROUND); |
| 864 | mHandlerThread.start(); |
| 865 | |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 866 | // Other icons |
Jason Monk | 05b86bc | 2015-05-19 14:21:28 -0400 | [diff] [blame] | 867 | mLocationController = new LocationControllerImpl(mContext, |
| 868 | mHandlerThread.getLooper()); // will post a notification |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 869 | mBatteryController = createBatteryController(); |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 870 | mBatteryController.addStateChangedCallback(new BatteryStateChangeCallback() { |
| 871 | @Override |
Jason Monk | c06fbb1 | 2016-01-08 14:12:18 -0500 | [diff] [blame] | 872 | public void onPowerSaveChanged(boolean isPowerSave) { |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 873 | mHandler.post(mCheckBarModes); |
John Spurlock | d96179e | 2014-08-21 16:43:45 -0400 | [diff] [blame] | 874 | if (mDozeServiceHost != null) { |
Jason Monk | c06fbb1 | 2016-01-08 14:12:18 -0500 | [diff] [blame] | 875 | mDozeServiceHost.firePowerSaveChanged(isPowerSave); |
John Spurlock | d96179e | 2014-08-21 16:43:45 -0400 | [diff] [blame] | 876 | } |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 877 | } |
| 878 | @Override |
| 879 | public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) { |
| 880 | // noop |
| 881 | } |
| 882 | }); |
Jason Monk | 30d8004 | 2015-05-08 16:54:18 -0400 | [diff] [blame] | 883 | mNetworkController = new NetworkControllerImpl(mContext, mHandlerThread.getLooper()); |
Jason Monk | fd57ea7 | 2016-04-29 13:37:58 -0400 | [diff] [blame] | 884 | mNetworkController.setUserSetupComplete(mUserSetup); |
Jason Monk | 51e4dc0 | 2014-07-22 12:00:47 -0400 | [diff] [blame] | 885 | mHotspotController = new HotspotControllerImpl(mContext); |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 886 | mBluetoothController = new BluetoothControllerImpl(mContext, mHandlerThread.getLooper()); |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 887 | mSecurityController = new SecurityControllerImpl(mContext); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 888 | if (mContext.getResources().getBoolean(R.bool.config_showRotationLock)) { |
| 889 | mRotationLockController = new RotationLockControllerImpl(mContext); |
John Spurlock | 8ab172e | 2013-12-19 16:39:23 -0500 | [diff] [blame] | 890 | } |
Jorim Jaggi | 3d878be | 2014-05-10 03:22:32 +0200 | [diff] [blame] | 891 | mUserInfoController = new UserInfoController(mContext); |
John Spurlock | 8600534 | 2014-05-23 11:58:00 -0400 | [diff] [blame] | 892 | mVolumeComponent = getComponent(VolumeComponent.class); |
John Spurlock | f2565a8 | 2014-10-23 20:16:22 -0400 | [diff] [blame] | 893 | if (mVolumeComponent != null) { |
| 894 | mZenModeController = mVolumeComponent.getZenController(); |
| 895 | } |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 896 | mCastController = new CastControllerImpl(mContext); |
Xiaohui Chen | 1094230 | 2015-12-16 16:38:13 -0800 | [diff] [blame] | 897 | |
| 898 | initSignalCluster(mStatusBarView); |
| 899 | initSignalCluster(mKeyguardStatusBar); |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 900 | initEmergencyCryptkeeperText(); |
Daniel Sandler | dd4ef49 | 2012-07-27 11:19:52 -0400 | [diff] [blame] | 901 | |
Adrian Roos | b83777b | 2014-06-30 15:11:53 +0200 | [diff] [blame] | 902 | mFlashlightController = new FlashlightController(mContext); |
Adrian Roos | 1e1d6ac | 2014-07-22 17:18:55 +0200 | [diff] [blame] | 903 | mKeyguardBottomArea.setFlashlightController(mFlashlightController); |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 904 | mKeyguardBottomArea.setPhoneStatusBar(this); |
Adrian Roos | a4eba9f | 2015-07-22 18:13:04 -0700 | [diff] [blame] | 905 | mKeyguardBottomArea.setUserSetupComplete(mUserSetup); |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 906 | mAccessibilityController = new AccessibilityController(mContext); |
| 907 | mKeyguardBottomArea.setAccessibilityController(mAccessibilityController); |
Jorim Jaggi | c7dea6e | 2014-07-26 14:36:57 +0200 | [diff] [blame] | 908 | mNextAlarmController = new NextAlarmController(mContext); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 909 | mLightStatusBarController = new LightStatusBarController(mIconController, |
| 910 | mBatteryController); |
Jason Monk | 8a3a964 | 2015-06-05 11:01:30 -0400 | [diff] [blame] | 911 | mKeyguardMonitor = new KeyguardMonitor(mContext); |
Amith Yamasani | 6947636 | 2016-07-13 11:59:16 -0700 | [diff] [blame] | 912 | mUserSwitcherController = new UserSwitcherController(mContext, mKeyguardMonitor, |
| 913 | mHandler, this); |
Fyodor Kupolov | cd86ebf | 2015-09-29 17:06:50 -0700 | [diff] [blame] | 914 | if (UserManager.get(mContext).isUserSwitcherEnabled()) { |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 915 | createUserSwitcher(); |
Adrian Roos | 2b154a9 | 2014-11-17 15:18:39 +0100 | [diff] [blame] | 916 | } |
Adrian Roos | 723632e | 2014-07-23 21:13:21 +0200 | [diff] [blame] | 917 | |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 918 | // Set up the quick settings tile panel |
Clara Bayarri | 9b1fdff | 2016-04-21 14:28:47 +0100 | [diff] [blame] | 919 | AutoReinflateContainer container = (AutoReinflateContainer) mStatusBarWindow.findViewById( |
| 920 | R.id.qs_auto_reinflate_container); |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 921 | if (container != null) { |
Xiaohui Chen | 311b98e | 2016-03-30 11:55:54 -0700 | [diff] [blame] | 922 | final QSTileHost qsh = SystemUIFactory.getInstance().createQSTileHost(mContext, this, |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 923 | mBluetoothController, mLocationController, mRotationLockController, |
Jason Monk | 51e4dc0 | 2014-07-22 12:00:47 -0400 | [diff] [blame] | 924 | mNetworkController, mZenModeController, mHotspotController, |
John Spurlock | 657c62c | 2014-07-22 12:18:09 -0400 | [diff] [blame] | 925 | mCastController, mFlashlightController, |
Jason Monk | abe1974 | 2015-09-29 09:47:06 -0400 | [diff] [blame] | 926 | mUserSwitcherController, mUserInfoController, mKeyguardMonitor, |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 927 | mSecurityController, mBatteryController, mIconController, |
| 928 | mNextAlarmController); |
Adrian Roos | 5fd872e | 2014-08-12 17:28:58 +0200 | [diff] [blame] | 929 | mBrightnessMirrorController = new BrightnessMirrorController(mStatusBarWindow); |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 930 | container.addInflateListener(new InflateListener() { |
John Spurlock | bceed06 | 2014-08-10 18:04:16 -0400 | [diff] [blame] | 931 | @Override |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 932 | public void onInflated(View v) { |
| 933 | QSContainer qsContainer = (QSContainer) v.findViewById( |
| 934 | R.id.quick_settings_container); |
| 935 | qsContainer.setHost(qsh); |
| 936 | mQSPanel = qsContainer.getQsPanel(); |
| 937 | mQSPanel.setBrightnessMirror(mBrightnessMirrorController); |
Kaori Katou | ccf08d7 | 2015-05-26 16:25:04 +0900 | [diff] [blame] | 938 | mKeyguardStatusBar.setQSPanel(mQSPanel); |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 939 | mHeader = qsContainer.getHeader(); |
| 940 | initSignalCluster(mHeader); |
| 941 | mHeader.setActivityStarter(PhoneStatusBar.this); |
John Spurlock | bceed06 | 2014-08-10 18:04:16 -0400 | [diff] [blame] | 942 | } |
| 943 | }); |
Siva Velusamy | 537421b | 2012-09-14 14:45:02 -0700 | [diff] [blame] | 944 | } |
| 945 | |
Jorim Jaggi | 3d878be | 2014-05-10 03:22:32 +0200 | [diff] [blame] | 946 | // User info. Trigger first load. |
Jorim Jaggi | 4538027d | 2014-07-30 15:43:13 +0200 | [diff] [blame] | 947 | mKeyguardStatusBar.setUserInfoController(mUserInfoController); |
Adrian Roos | ffc9097 | 2015-06-09 18:09:49 -0700 | [diff] [blame] | 948 | mKeyguardStatusBar.setUserSwitcherController(mUserSwitcherController); |
Jorim Jaggi | 3d878be | 2014-05-10 03:22:32 +0200 | [diff] [blame] | 949 | mUserInfoController.reloadUserInfo(); |
| 950 | |
Jorim Jaggi | 708f772 | 2014-08-20 17:30:38 +0200 | [diff] [blame] | 951 | ((BatteryMeterView) mStatusBarView.findViewById(R.id.battery)).setBatteryController( |
| 952 | mBatteryController); |
Jorim Jaggi | 4538027d | 2014-07-30 15:43:13 +0200 | [diff] [blame] | 953 | mKeyguardStatusBar.setBatteryController(mBatteryController); |
Jorim Jaggi | 853b070 | 2014-07-05 04:31:14 +0200 | [diff] [blame] | 954 | |
Adrian Roos | 7bb38a9 | 2016-07-21 11:44:01 -0700 | [diff] [blame] | 955 | mReportRejectedTouch = mStatusBarWindow.findViewById(R.id.report_rejected_touch); |
| 956 | if (mReportRejectedTouch != null) { |
| 957 | updateReportRejectedTouchVisibility(); |
| 958 | mReportRejectedTouch.setOnClickListener(v -> { |
| 959 | Uri session = mFalsingManager.reportRejectedTouch(); |
| 960 | if (session == null) { return; } |
| 961 | |
| 962 | StringWriter message = new StringWriter(); |
| 963 | message.write("Build info: "); |
| 964 | message.write(SystemProperties.get("ro.build.description")); |
| 965 | message.write("\nSerial number: "); |
| 966 | message.write(SystemProperties.get("ro.serialno")); |
| 967 | message.write("\n"); |
| 968 | |
| 969 | PrintWriter falsingPw = new PrintWriter(message); |
| 970 | FalsingLog.dump(falsingPw); |
| 971 | falsingPw.flush(); |
| 972 | |
| 973 | startActivityDismissingKeyguard(Intent.createChooser(new Intent(Intent.ACTION_SEND) |
| 974 | .setType("*/*") |
| 975 | .putExtra(Intent.EXTRA_SUBJECT, "Rejected touch report") |
| 976 | .putExtra(Intent.EXTRA_STREAM, session) |
| 977 | .putExtra(Intent.EXTRA_TEXT, message.toString()), |
| 978 | "Share rejected touch report") |
| 979 | .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), |
| 980 | true /* onlyProvisioned */, true /* dismissShade */); |
| 981 | }); |
| 982 | } |
| 983 | |
| 984 | |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 985 | PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); |
| 986 | mBroadcastReceiver.onReceive(mContext, |
| 987 | new Intent(pm.isScreenOn() ? Intent.ACTION_SCREEN_ON : Intent.ACTION_SCREEN_OFF)); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 988 | mGestureWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, |
| 989 | "GestureWakeLock"); |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 990 | mVibrator = mContext.getSystemService(Vibrator.class); |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 991 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 992 | // receive broadcasts |
| 993 | IntentFilter filter = new IntentFilter(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 994 | filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); |
| 995 | filter.addAction(Intent.ACTION_SCREEN_OFF); |
Daniel Sandler | 7f3cf95 | 2012-08-31 14:57:09 -0400 | [diff] [blame] | 996 | filter.addAction(Intent.ACTION_SCREEN_ON); |
Kenny Guy | 44fc65f | 2014-11-28 22:18:14 +0000 | [diff] [blame] | 997 | context.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 998 | |
Adrian Roos | 8e3e836 | 2015-07-16 19:42:22 -0700 | [diff] [blame] | 999 | IntentFilter demoFilter = new IntentFilter(); |
| 1000 | if (DEBUG_MEDIA_FAKE_ARTWORK) { |
| 1001 | demoFilter.addAction(ACTION_FAKE_ARTWORK); |
| 1002 | } |
| 1003 | demoFilter.addAction(ACTION_DEMO); |
| 1004 | context.registerReceiverAsUser(mDemoReceiver, UserHandle.ALL, demoFilter, |
| 1005 | android.Manifest.permission.DUMP, null); |
| 1006 | |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 1007 | // listen for USER_SETUP_COMPLETE setting (per-user) |
| 1008 | resetUserSetupObserver(); |
| 1009 | |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 1010 | // disable profiling bars, since they overlap and clutter the output on app windows |
| 1011 | ThreadedRenderer.overrideProperty("disableProfileBars", "true"); |
| 1012 | |
| 1013 | // Private API call to make the shadows look better for Recents |
| 1014 | ThreadedRenderer.overrideProperty("ambientRatio", String.valueOf(1.5f)); |
| 1015 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1016 | return mStatusBarView; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1017 | } |
| 1018 | |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 1019 | private void initEmergencyCryptkeeperText() { |
| 1020 | View emergencyViewStub = mStatusBarWindow.findViewById(R.id.emergency_cryptkeeper_text); |
| 1021 | if (mNetworkController.hasEmergencyCryptKeeperText()) { |
| 1022 | if (emergencyViewStub != null) { |
| 1023 | ((ViewStub) emergencyViewStub).inflate(); |
| 1024 | } |
| 1025 | mNetworkController.addSignalCallback(new NetworkController.SignalCallback() { |
| 1026 | @Override |
| 1027 | public void setIsAirplaneMode(NetworkController.IconState icon) { |
| 1028 | recomputeDisableFlags(true /* animate */); |
| 1029 | } |
| 1030 | }); |
| 1031 | } else if (emergencyViewStub != null) { |
| 1032 | ViewGroup parent = (ViewGroup) emergencyViewStub.getParent(); |
| 1033 | parent.removeView(emergencyViewStub); |
| 1034 | } |
| 1035 | } |
| 1036 | |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 1037 | protected BatteryController createBatteryController() { |
| 1038 | return new BatteryControllerImpl(mContext); |
| 1039 | } |
| 1040 | |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 1041 | private void inflateOverflowContainer() { |
| 1042 | mKeyguardIconOverflowContainer = |
| 1043 | (NotificationOverflowContainer) LayoutInflater.from(mContext).inflate( |
| 1044 | R.layout.status_bar_notification_keyguard_overflow, mStackScroller, false); |
| 1045 | mKeyguardIconOverflowContainer.setOnActivatedListener(this); |
| 1046 | mKeyguardIconOverflowContainer.setOnClickListener(mOverflowClickListener); |
| 1047 | mStackScroller.setOverflowContainer(mKeyguardIconOverflowContainer); |
| 1048 | } |
| 1049 | |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 1050 | @Override |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 1051 | protected void onDensityOrFontScaleChanged() { |
| 1052 | super.onDensityOrFontScaleChanged(); |
| 1053 | mScrimController.onDensityOrFontScaleChanged(); |
| 1054 | mStatusBarView.onDensityOrFontScaleChanged(); |
Adrian Roos | d390b89 | 2016-05-05 10:50:49 -0400 | [diff] [blame] | 1055 | if (mBrightnessMirrorController != null) { |
| 1056 | mBrightnessMirrorController.onDensityOrFontScaleChanged(); |
| 1057 | } |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 1058 | inflateSignalClusters(); |
| 1059 | mIconController.onDensityOrFontScaleChanged(); |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 1060 | inflateDismissView(); |
| 1061 | updateClearAll(); |
| 1062 | inflateEmptyShadeView(); |
| 1063 | updateEmptyShadeView(); |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 1064 | inflateOverflowContainer(); |
Selim Cinek | aa8bbf1 | 2016-05-04 14:13:20 -0700 | [diff] [blame] | 1065 | mStatusBarKeyguardViewManager.onDensityOrFontScaleChanged(); |
Adrian Roos | d390b89 | 2016-05-05 10:50:49 -0400 | [diff] [blame] | 1066 | mUserInfoController.onDensityOrFontScaleChanged(); |
| 1067 | if (mUserSwitcherController != null) { |
| 1068 | mUserSwitcherController.onDensityOrFontScaleChanged(); |
| 1069 | } |
| 1070 | if (mKeyguardUserSwitcher != null) { |
| 1071 | mKeyguardUserSwitcher.onDensityOrFontScaleChanged(); |
| 1072 | } |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 1073 | } |
| 1074 | |
| 1075 | private void inflateSignalClusters() { |
| 1076 | SignalClusterView signalClusterView = reinflateSignalCluster(mStatusBarView); |
| 1077 | mIconController.setSignalCluster(signalClusterView); |
Selim Cinek | 6ebba59 | 2016-05-31 15:28:28 -0700 | [diff] [blame] | 1078 | reinflateSignalCluster(mKeyguardStatusBar); |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 1079 | } |
| 1080 | |
| 1081 | private SignalClusterView reinflateSignalCluster(View view) { |
| 1082 | SignalClusterView signalCluster = |
| 1083 | (SignalClusterView) view.findViewById(R.id.signal_cluster); |
| 1084 | if (signalCluster != null) { |
| 1085 | ViewParent parent = signalCluster.getParent(); |
| 1086 | if (parent instanceof ViewGroup) { |
| 1087 | ViewGroup viewParent = (ViewGroup) parent; |
| 1088 | int index = viewParent.indexOfChild(signalCluster); |
| 1089 | viewParent.removeView(signalCluster); |
| 1090 | SignalClusterView newCluster = (SignalClusterView) LayoutInflater.from(mContext) |
| 1091 | .inflate(R.layout.signal_cluster_view, viewParent, false); |
| 1092 | ViewGroup.MarginLayoutParams layoutParams = |
| 1093 | (ViewGroup.MarginLayoutParams) viewParent.getLayoutParams(); |
| 1094 | layoutParams.setMarginsRelative( |
| 1095 | mContext.getResources().getDimensionPixelSize( |
| 1096 | R.dimen.signal_cluster_margin_start), |
| 1097 | 0, 0, 0); |
| 1098 | newCluster.setLayoutParams(layoutParams); |
| 1099 | newCluster.setSecurityController(mSecurityController); |
| 1100 | newCluster.setNetworkController(mNetworkController); |
| 1101 | viewParent.addView(newCluster, index); |
| 1102 | return newCluster; |
| 1103 | } |
| 1104 | return signalCluster; |
| 1105 | } |
| 1106 | return null; |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 1107 | } |
| 1108 | |
| 1109 | private void inflateEmptyShadeView() { |
| 1110 | mEmptyShadeView = (EmptyShadeView) LayoutInflater.from(mContext).inflate( |
| 1111 | R.layout.status_bar_no_notifications, mStackScroller, false); |
| 1112 | mStackScroller.setEmptyShadeView(mEmptyShadeView); |
| 1113 | } |
| 1114 | |
| 1115 | private void inflateDismissView() { |
| 1116 | mDismissView = (DismissView) LayoutInflater.from(mContext).inflate( |
| 1117 | R.layout.status_bar_notification_dismiss_all, mStackScroller, false); |
| 1118 | mDismissView.setOnButtonClickListener(new View.OnClickListener() { |
| 1119 | @Override |
| 1120 | public void onClick(View v) { |
| 1121 | MetricsLogger.action(mContext, MetricsEvent.ACTION_DISMISS_ALL_NOTES); |
| 1122 | clearAllNotifications(); |
| 1123 | } |
| 1124 | }); |
| 1125 | mStackScroller.setDismissView(mDismissView); |
| 1126 | } |
| 1127 | |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 1128 | protected void createUserSwitcher() { |
| 1129 | mKeyguardUserSwitcher = new KeyguardUserSwitcher(mContext, |
| 1130 | (ViewStub) mStatusBarWindow.findViewById(R.id.keyguard_user_switcher), |
| 1131 | mKeyguardStatusBar, mNotificationPanel, mUserSwitcherController); |
| 1132 | } |
| 1133 | |
Xiaohui Chen | d839d1a | 2016-01-21 13:05:02 -0800 | [diff] [blame] | 1134 | protected void inflateStatusBarWindow(Context context) { |
| 1135 | mStatusBarWindow = (StatusBarWindowView) View.inflate(context, |
| 1136 | R.layout.super_status_bar, null); |
| 1137 | } |
| 1138 | |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 1139 | protected void createNavigationBarView(Context context) { |
Xiaohui Chen | 8bdcd1f | 2016-01-19 13:52:07 -0800 | [diff] [blame] | 1140 | inflateNavigationBarView(context); |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 1141 | mNavigationBarView.setDisabledFlags(mDisabled1); |
| 1142 | mNavigationBarView.setComponents(mRecents, getComponent(Divider.class)); |
| 1143 | mNavigationBarView.setOnVerticalChangedListener( |
| 1144 | new NavigationBarView.OnVerticalChangedListener() { |
| 1145 | @Override |
| 1146 | public void onVerticalChanged(boolean isVertical) { |
| 1147 | if (mAssistManager != null) { |
| 1148 | mAssistManager.onConfigurationChanged(); |
| 1149 | } |
| 1150 | mNotificationPanel.setQsScrimEnabled(!isVertical); |
| 1151 | } |
| 1152 | }); |
| 1153 | mNavigationBarView.setOnTouchListener(new View.OnTouchListener() { |
| 1154 | @Override |
| 1155 | public boolean onTouch(View v, MotionEvent event) { |
| 1156 | checkUserAutohide(v, event); |
| 1157 | return false; |
| 1158 | }}); |
| 1159 | } |
| 1160 | |
Xiaohui Chen | 8bdcd1f | 2016-01-19 13:52:07 -0800 | [diff] [blame] | 1161 | protected void inflateNavigationBarView(Context context) { |
Jason Monk | 4f878ef | 2016-01-23 14:37:38 -0500 | [diff] [blame] | 1162 | mNavigationBarView = (NavigationBarView) View.inflate( |
| 1163 | context, R.layout.navigation_bar, null); |
Xiaohui Chen | 8bdcd1f | 2016-01-19 13:52:07 -0800 | [diff] [blame] | 1164 | } |
| 1165 | |
| 1166 | protected void initSignalCluster(View containerView) { |
Xiaohui Chen | 1094230 | 2015-12-16 16:38:13 -0800 | [diff] [blame] | 1167 | SignalClusterView signalCluster = |
| 1168 | (SignalClusterView) containerView.findViewById(R.id.signal_cluster); |
| 1169 | if (signalCluster != null) { |
Xiaohui Chen | 1094230 | 2015-12-16 16:38:13 -0800 | [diff] [blame] | 1170 | signalCluster.setSecurityController(mSecurityController); |
| 1171 | signalCluster.setNetworkController(mNetworkController); |
| 1172 | } |
| 1173 | } |
| 1174 | |
Muyuan Li | c510b5e | 2016-03-09 17:15:05 -0800 | [diff] [blame] | 1175 | public void clearAllNotifications() { |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1176 | |
| 1177 | // animate-swipe all dismissable notifications, then animate the shade closed |
| 1178 | int numChildren = mStackScroller.getChildCount(); |
| 1179 | |
| 1180 | final ArrayList<View> viewsToHide = new ArrayList<View>(numChildren); |
| 1181 | for (int i = 0; i < numChildren; i++) { |
| 1182 | final View child = mStackScroller.getChildAt(i); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1183 | if (child instanceof ExpandableNotificationRow) { |
| 1184 | if (mStackScroller.canChildBeDismissed(child)) { |
| 1185 | if (child.getVisibility() == View.VISIBLE) { |
| 1186 | viewsToHide.add(child); |
| 1187 | } |
| 1188 | } |
| 1189 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
| 1190 | List<ExpandableNotificationRow> children = row.getNotificationChildren(); |
| 1191 | if (row.areChildrenExpanded() && children != null) { |
| 1192 | for (ExpandableNotificationRow childRow : children) { |
| 1193 | if (childRow.getVisibility() == View.VISIBLE) { |
| 1194 | viewsToHide.add(childRow); |
| 1195 | } |
| 1196 | } |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1197 | } |
| 1198 | } |
| 1199 | } |
| 1200 | if (viewsToHide.isEmpty()) { |
| 1201 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
| 1202 | return; |
| 1203 | } |
| 1204 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1205 | addPostCollapseAction(new Runnable() { |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1206 | @Override |
| 1207 | public void run() { |
Selim Cinek | 9c17b77 | 2015-07-07 20:37:09 -0700 | [diff] [blame] | 1208 | mStackScroller.setDismissAllInProgress(false); |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1209 | try { |
| 1210 | mBarService.onClearAllNotifications(mCurrentUserId); |
| 1211 | } catch (Exception ex) { } |
| 1212 | } |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1213 | }); |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1214 | |
| 1215 | performDismissAllAnimations(viewsToHide); |
| 1216 | |
| 1217 | } |
| 1218 | |
| 1219 | private void performDismissAllAnimations(ArrayList<View> hideAnimatedList) { |
| 1220 | Runnable animationFinishAction = new Runnable() { |
| 1221 | @Override |
| 1222 | public void run() { |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1223 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
| 1224 | } |
| 1225 | }; |
| 1226 | |
| 1227 | // let's disable our normal animations |
| 1228 | mStackScroller.setDismissAllInProgress(true); |
| 1229 | |
| 1230 | // Decrease the delay for every row we animate to give the sense of |
| 1231 | // accelerating the swipes |
| 1232 | int rowDelayDecrement = 10; |
| 1233 | int currentDelay = 140; |
Selim Cinek | 7d5f374 | 2014-11-07 18:07:49 +0100 | [diff] [blame] | 1234 | int totalDelay = 180; |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1235 | int numItems = hideAnimatedList.size(); |
Selim Cinek | 7d5f374 | 2014-11-07 18:07:49 +0100 | [diff] [blame] | 1236 | for (int i = numItems - 1; i >= 0; i--) { |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1237 | View view = hideAnimatedList.get(i); |
| 1238 | Runnable endRunnable = null; |
Selim Cinek | 7d5f374 | 2014-11-07 18:07:49 +0100 | [diff] [blame] | 1239 | if (i == 0) { |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1240 | endRunnable = animationFinishAction; |
| 1241 | } |
| 1242 | mStackScroller.dismissViewAnimated(view, endRunnable, totalDelay, 260); |
| 1243 | currentDelay = Math.max(50, currentDelay - rowDelayDecrement); |
| 1244 | totalDelay += currentDelay; |
| 1245 | } |
| 1246 | } |
| 1247 | |
John Spurlock | ae641c9 | 2014-06-30 18:11:40 -0400 | [diff] [blame] | 1248 | @Override |
| 1249 | protected void setZenMode(int mode) { |
| 1250 | super.setZenMode(mode); |
| 1251 | if (mIconPolicy != null) { |
| 1252 | mIconPolicy.setZenMode(mode); |
| 1253 | } |
| 1254 | } |
| 1255 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 1256 | protected void startKeyguard() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1257 | Trace.beginSection("PhoneStatusBar#startKeyguard"); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 1258 | KeyguardViewMediator keyguardViewMediator = getComponent(KeyguardViewMediator.class); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 1259 | mFingerprintUnlockController = new FingerprintUnlockController(mContext, |
| 1260 | mStatusBarWindowManager, mDozeScrimController, keyguardViewMediator, |
| 1261 | mScrimController, this); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 1262 | mStatusBarKeyguardViewManager = keyguardViewMediator.registerStatusBar(this, |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 1263 | getBouncerContainer(), mStatusBarWindowManager, mScrimController, |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 1264 | mFingerprintUnlockController); |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 1265 | mKeyguardIndicationController.setStatusBarKeyguardViewManager( |
| 1266 | mStatusBarKeyguardViewManager); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 1267 | mFingerprintUnlockController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager); |
Nicolas Prevot | 1dbbe7d | 2016-05-17 12:52:54 +0100 | [diff] [blame] | 1268 | mIconPolicy.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager); |
Adrian Roos | d28ccd7 | 2016-01-06 15:23:14 +0100 | [diff] [blame] | 1269 | mRemoteInputController.addCallback(mStatusBarKeyguardViewManager); |
Adrian Roos | c0a579e | 2016-03-30 16:43:58 -0700 | [diff] [blame] | 1270 | |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 1271 | mRemoteInputController.addCallback(new RemoteInputController.Callback() { |
| 1272 | @Override |
| 1273 | public void onRemoteInputSent(Entry entry) { |
| 1274 | if (FORCE_REMOTE_INPUT_HISTORY && mKeysKeptForRemoteInput.contains(entry.key)) { |
| 1275 | removeNotification(entry.key, null); |
| 1276 | } else if (mRemoteInputEntriesToRemoveOnCollapse.contains(entry)) { |
| 1277 | // We're currently holding onto this notification, but from the apps point of |
| 1278 | // view it is already canceled, so we'll need to cancel it on the apps behalf |
| 1279 | // after sending - unless the app posts an update in the mean time, so wait a |
| 1280 | // bit. |
| 1281 | mHandler.postDelayed(() -> { |
| 1282 | if (mRemoteInputEntriesToRemoveOnCollapse.remove(entry)) { |
| 1283 | removeNotification(entry.key, null); |
| 1284 | } |
| 1285 | }, REMOTE_INPUT_KEPT_ENTRY_AUTO_CANCEL_DELAY); |
Adrian Roos | c0a579e | 2016-03-30 16:43:58 -0700 | [diff] [blame] | 1286 | } |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 1287 | } |
| 1288 | }); |
Adrian Roos | c0a579e | 2016-03-30 16:43:58 -0700 | [diff] [blame] | 1289 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 1290 | mKeyguardViewMediatorCallback = keyguardViewMediator.getViewMediatorCallback(); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 1291 | mLightStatusBarController.setFingerprintUnlockController(mFingerprintUnlockController); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1292 | Trace.endSection(); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1293 | } |
| 1294 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1295 | @Override |
Michael Jurka | cb2522c | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 1296 | protected View getStatusBarView() { |
| 1297 | return mStatusBarView; |
| 1298 | } |
| 1299 | |
Jorim Jaggi | 0a27be8 | 2014-06-11 03:22:39 +0200 | [diff] [blame] | 1300 | public StatusBarWindowView getStatusBarWindow() { |
| 1301 | return mStatusBarWindow; |
| 1302 | } |
| 1303 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 1304 | protected ViewGroup getBouncerContainer() { |
| 1305 | return mStatusBarWindow; |
| 1306 | } |
| 1307 | |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 1308 | public int getStatusBarHeight() { |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1309 | if (mNaturalBarHeight < 0) { |
| 1310 | final Resources res = mContext.getResources(); |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 1311 | mNaturalBarHeight = |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1312 | res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); |
| 1313 | } |
| 1314 | return mNaturalBarHeight; |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 1315 | } |
| 1316 | |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1317 | private View.OnClickListener mRecentsClickListener = new View.OnClickListener() { |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 1318 | @Override |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1319 | public void onClick(View v) { |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 1320 | awakenDreams(); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1321 | toggleRecentApps(); |
| 1322 | } |
| 1323 | }; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1324 | |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 1325 | private View.OnLongClickListener mLongPressBackListener = new View.OnLongClickListener() { |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 1326 | @Override |
| 1327 | public boolean onLongClick(View v) { |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 1328 | return handleLongPressBack(); |
| 1329 | } |
| 1330 | }; |
| 1331 | |
| 1332 | private View.OnLongClickListener mRecentsLongClickListener = new View.OnLongClickListener() { |
| 1333 | |
| 1334 | @Override |
| 1335 | public boolean onLongClick(View v) { |
Jorim Jaggi | 19cf297 | 2016-04-07 23:26:10 -0700 | [diff] [blame] | 1336 | if (mRecents == null || !ActivityManager.supportsMultiWindow() |
| 1337 | || !getComponent(Divider.class).getView().getSnapAlgorithm() |
| 1338 | .isSplitScreenFeasible()) { |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1339 | return false; |
| 1340 | } |
Winson | c694a50 | 2016-03-10 16:35:03 -0800 | [diff] [blame] | 1341 | |
Jorim Jaggi | 29379ec | 2016-04-11 23:43:42 -0700 | [diff] [blame] | 1342 | toggleSplitScreenMode(MetricsEvent.ACTION_WINDOW_DOCK_LONGPRESS, |
| 1343 | MetricsEvent.ACTION_WINDOW_UNDOCK_LONGPRESS); |
| 1344 | return true; |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 1345 | } |
| 1346 | }; |
| 1347 | |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1348 | @Override |
Jorim Jaggi | 29379ec | 2016-04-11 23:43:42 -0700 | [diff] [blame] | 1349 | protected void toggleSplitScreenMode(int metricsDockAction, int metricsUndockAction) { |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1350 | if (mRecents == null) { |
Jorim Jaggi | 29379ec | 2016-04-11 23:43:42 -0700 | [diff] [blame] | 1351 | return; |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1352 | } |
| 1353 | int dockSide = WindowManagerProxy.getInstance().getDockSide(); |
| 1354 | if (dockSide == WindowManager.DOCKED_INVALID) { |
Jorim Jaggi | 29379ec | 2016-04-11 23:43:42 -0700 | [diff] [blame] | 1355 | mRecents.dockTopTask(NavigationBarGestureHelper.DRAG_MODE_NONE, |
| 1356 | ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT, null, metricsDockAction); |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1357 | } else { |
| 1358 | EventBus.getDefault().send(new UndockingTaskEvent()); |
Jorim Jaggi | 29379ec | 2016-04-11 23:43:42 -0700 | [diff] [blame] | 1359 | if (metricsUndockAction != -1) { |
| 1360 | MetricsLogger.action(mContext, metricsUndockAction); |
| 1361 | } |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1362 | } |
| 1363 | } |
| 1364 | |
Jorim Jaggi | 7e6571f | 2015-06-25 11:52:48 -0700 | [diff] [blame] | 1365 | private final View.OnLongClickListener mLongPressHomeListener |
| 1366 | = new View.OnLongClickListener() { |
| 1367 | @Override |
| 1368 | public boolean onLongClick(View v) { |
| 1369 | if (shouldDisableNavbarGestures()) { |
| 1370 | return false; |
| 1371 | } |
Chris Wren | f6e9228b | 2016-01-26 18:04:35 -0500 | [diff] [blame] | 1372 | MetricsLogger.action(mContext, MetricsEvent.ACTION_ASSIST_LONG_PRESS); |
Jorim Jaggi | 165ce06 | 2015-07-06 16:18:11 -0700 | [diff] [blame] | 1373 | mAssistManager.startAssist(new Bundle() /* args */); |
Daniel Sandler | a2fbe53 | 2012-08-10 01:19:03 -0400 | [diff] [blame] | 1374 | awakenDreams(); |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 1375 | if (mNavigationBarView != null) { |
Xiyuan Xia | ee7dd05 | 2015-05-15 09:46:27 -0700 | [diff] [blame] | 1376 | mNavigationBarView.abortCurrentGesture(); |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 1377 | } |
Jorim Jaggi | 7e6571f | 2015-06-25 11:52:48 -0700 | [diff] [blame] | 1378 | return true; |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 1379 | } |
| 1380 | }; |
| 1381 | |
Jorim Jaggi | 7e6571f | 2015-06-25 11:52:48 -0700 | [diff] [blame] | 1382 | private final View.OnTouchListener mHomeActionListener = new View.OnTouchListener() { |
Selim Cinek | 64be772 | 2016-07-22 13:28:16 -0700 | [diff] [blame] | 1383 | public boolean mBlockedThisTouch; |
| 1384 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 1385 | @Override |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 1386 | public boolean onTouch(View v, MotionEvent event) { |
Selim Cinek | 64be772 | 2016-07-22 13:28:16 -0700 | [diff] [blame] | 1387 | if (mBlockedThisTouch && event.getActionMasked() != MotionEvent.ACTION_DOWN) { |
| 1388 | return true; |
| 1389 | } |
| 1390 | // If an incoming call is ringing, HOME is totally disabled. |
| 1391 | // (The user is already on the InCallUI at this point, |
| 1392 | // and his ONLY options are to answer or reject the call.) |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 1393 | switch (event.getAction()) { |
Selim Cinek | 64be772 | 2016-07-22 13:28:16 -0700 | [diff] [blame] | 1394 | case MotionEvent.ACTION_DOWN: |
| 1395 | mBlockedThisTouch = false; |
| 1396 | TelecomManager telecomManager = mContext.getSystemService(TelecomManager.class); |
| 1397 | if (telecomManager != null && telecomManager.isRinging()) { |
| 1398 | if (mStatusBarKeyguardViewManager.isShowing()) { |
| 1399 | Log.i(TAG, "Ignoring HOME; there's a ringing incoming call. " + |
| 1400 | "No heads up"); |
| 1401 | mBlockedThisTouch = true; |
| 1402 | return true; |
| 1403 | } |
| 1404 | } |
| 1405 | break; |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 1406 | case MotionEvent.ACTION_UP: |
| 1407 | case MotionEvent.ACTION_CANCEL: |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 1408 | awakenDreams(); |
| 1409 | break; |
| 1410 | } |
| 1411 | return false; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 1412 | } |
| 1413 | }; |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1414 | |
Daniel Sandler | a2fbe53 | 2012-08-10 01:19:03 -0400 | [diff] [blame] | 1415 | private void awakenDreams() { |
| 1416 | if (mDreamManager != null) { |
| 1417 | try { |
| 1418 | mDreamManager.awaken(); |
| 1419 | } catch (RemoteException e) { |
| 1420 | // fine, stay asleep then |
| 1421 | } |
| 1422 | } |
| 1423 | } |
| 1424 | |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 1425 | private void prepareNavigationBarView() { |
| 1426 | mNavigationBarView.reorient(); |
| 1427 | |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 1428 | ButtonDispatcher recentsButton = mNavigationBarView.getRecentsButton(); |
| 1429 | recentsButton.setOnClickListener(mRecentsClickListener); |
| 1430 | recentsButton.setOnTouchListener(mRecentsPreloadOnTouchListener); |
| 1431 | recentsButton.setLongClickable(true); |
| 1432 | recentsButton.setOnLongClickListener(mRecentsLongClickListener); |
Anthony Chen | ada1304 | 2016-01-19 16:57:20 -0800 | [diff] [blame] | 1433 | |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 1434 | ButtonDispatcher backButton = mNavigationBarView.getBackButton(); |
| 1435 | backButton.setLongClickable(true); |
| 1436 | backButton.setOnLongClickListener(mLongPressBackListener); |
Anthony Chen | ada1304 | 2016-01-19 16:57:20 -0800 | [diff] [blame] | 1437 | |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 1438 | ButtonDispatcher homeButton = mNavigationBarView.getHomeButton(); |
| 1439 | homeButton.setOnTouchListener(mHomeActionListener); |
| 1440 | homeButton.setOnLongClickListener(mLongPressHomeListener); |
Anthony Chen | ada1304 | 2016-01-19 16:57:20 -0800 | [diff] [blame] | 1441 | |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 1442 | mAssistManager.onConfigurationChanged(); |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 1443 | } |
| 1444 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1445 | // For small-screen devices (read: phones) that lack hardware navigation buttons |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 1446 | protected void addNavigationBar() { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 1447 | if (DEBUG) Log.v(TAG, "addNavigationBar: about to add " + mNavigationBarView); |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 1448 | if (mNavigationBarView == null) return; |
Jim Miller | 17dfec7 | 2011-07-08 19:09:55 -0700 | [diff] [blame] | 1449 | |
Adrian Roos | a98b32c | 2016-08-11 10:41:08 -0700 | [diff] [blame] | 1450 | try { |
| 1451 | WindowManagerGlobal.getWindowManagerService() |
| 1452 | .watchRotation(new IRotationWatcher.Stub() { |
| 1453 | @Override |
| 1454 | public void onRotationChanged(int rotation) throws RemoteException { |
| 1455 | // We need this to be scheduled as early as possible to beat the redrawing of |
| 1456 | // window in response to the orientation change. |
| 1457 | Message msg = Message.obtain(mHandler, () -> { |
| 1458 | if (mNavigationBarView != null |
| 1459 | && mNavigationBarView.needsReorient(rotation)) { |
| 1460 | repositionNavigationBar(); |
| 1461 | } |
| 1462 | }); |
| 1463 | msg.setAsynchronous(true); |
| 1464 | mHandler.sendMessageAtFrontOfQueue(msg); |
| 1465 | } |
| 1466 | }); |
| 1467 | } catch (RemoteException e) { |
| 1468 | throw e.rethrowFromSystemServer(); |
| 1469 | } |
| 1470 | |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 1471 | prepareNavigationBarView(); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1472 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1473 | mWindowManager.addView(mNavigationBarView, getNavigationBarLayoutParams()); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1474 | } |
| 1475 | |
Victor Chan | ecdb8b0 | 2016-01-07 18:32:43 -0800 | [diff] [blame] | 1476 | protected void repositionNavigationBar() { |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 1477 | if (mNavigationBarView == null || !mNavigationBarView.isAttachedToWindow()) return; |
Jim Miller | 17dfec7 | 2011-07-08 19:09:55 -0700 | [diff] [blame] | 1478 | |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 1479 | prepareNavigationBarView(); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1480 | |
Jorim Jaggi | 90dfb89 | 2016-07-25 15:57:36 +0200 | [diff] [blame] | 1481 | mWindowManager.updateViewLayout(mNavigationBarView, mNavigationBarView.getLayoutParams()); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1482 | } |
| 1483 | |
John Spurlock | 1bbd49d | 2012-10-19 11:09:32 -0400 | [diff] [blame] | 1484 | private void notifyNavigationBarScreenOn(boolean screenOn) { |
| 1485 | if (mNavigationBarView == null) return; |
| 1486 | mNavigationBarView.notifyScreenOn(screenOn); |
| 1487 | } |
| 1488 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1489 | private WindowManager.LayoutParams getNavigationBarLayoutParams() { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1490 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1491 | LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1492 | WindowManager.LayoutParams.TYPE_NAVIGATION_BAR, |
| 1493 | 0 |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1494 | | WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING |
| 1495 | | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 1496 | | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
Daniel Sandler | c26185b | 2012-08-29 15:49:53 -0400 | [diff] [blame] | 1497 | | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
Jorim Jaggi | c59a23f | 2016-05-24 14:53:36 -0700 | [diff] [blame] | 1498 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH |
| 1499 | | WindowManager.LayoutParams.FLAG_SLIPPERY, |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1500 | PixelFormat.TRANSLUCENT); |
Daniel Sandler | c638c1e | 2011-08-24 16:19:23 -0700 | [diff] [blame] | 1501 | // 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] | 1502 | if (ActivityManager.isHighEndGfx()) { |
Daniel Sandler | c638c1e | 2011-08-24 16:19:23 -0700 | [diff] [blame] | 1503 | lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
| 1504 | } |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1505 | |
| 1506 | lp.setTitle("NavigationBar"); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1507 | lp.windowAnimations = 0; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1508 | return lp; |
| 1509 | } |
| 1510 | |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 1511 | @Override |
| 1512 | public void setIcon(String slot, StatusBarIcon icon) { |
| 1513 | mIconController.setIcon(slot, icon); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1514 | } |
| 1515 | |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 1516 | @Override |
| 1517 | public void removeIcon(String slot) { |
| 1518 | mIconController.removeIcon(slot); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1519 | } |
| 1520 | |
John Spurlock | bf20eab | 2014-04-09 16:40:39 -0400 | [diff] [blame] | 1521 | public UserHandle getCurrentUserHandle() { |
| 1522 | return new UserHandle(mCurrentUserId); |
| 1523 | } |
| 1524 | |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 1525 | @Override |
Selim Cinek | 379ff8f | 2015-02-20 17:03:16 +0100 | [diff] [blame] | 1526 | public void addNotification(StatusBarNotification notification, RankingMap ranking, |
| 1527 | Entry oldEntry) { |
Chris Wren | aaa58d1 | 2014-06-03 14:29:12 -0400 | [diff] [blame] | 1528 | if (DEBUG) Log.d(TAG, "addNotification key=" + notification.getKey()); |
Chris Wren | d4db6cb | 2013-08-07 16:05:23 -0400 | [diff] [blame] | 1529 | |
Julia Reynolds | f612869ae | 2015-11-05 16:48:55 -0500 | [diff] [blame] | 1530 | mNotificationData.updateRanking(ranking); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1531 | Entry shadeEntry = createNotificationViews(notification); |
Chris Wren | a4ef620 | 2014-06-09 18:07:30 -0400 | [diff] [blame] | 1532 | if (shadeEntry == null) { |
| 1533 | return; |
| 1534 | } |
Adrian Roos | f6967e06 | 2016-06-21 16:12:48 -0700 | [diff] [blame] | 1535 | boolean isHeadsUped = shouldPeek(shadeEntry); |
Selim Cinek | 31d9ef7 | 2015-04-15 19:29:49 -0700 | [diff] [blame] | 1536 | if (isHeadsUped) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1537 | mHeadsUpManager.showNotification(shadeEntry); |
Amith Yamasani | f47e51e | 2015-04-17 10:02:15 -0700 | [diff] [blame] | 1538 | // Mark as seen immediately |
| 1539 | setNotificationShown(notification); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1540 | } |
Chris Wren | a4ef620 | 2014-06-09 18:07:30 -0400 | [diff] [blame] | 1541 | |
Selim Cinek | 31d9ef7 | 2015-04-15 19:29:49 -0700 | [diff] [blame] | 1542 | if (!isHeadsUped && notification.getNotification().fullScreenIntent != null) { |
Julia Reynolds | d560729 | 2016-02-05 15:25:58 -0500 | [diff] [blame] | 1543 | if (shouldSuppressFullScreenIntent(notification.getKey())) { |
Julia Reynolds | 6172158 | 2016-01-05 08:35:25 -0500 | [diff] [blame] | 1544 | if (DEBUG) { |
| 1545 | Log.d(TAG, "No Fullscreen intent: suppressed by DND: " + notification.getKey()); |
| 1546 | } |
Julia Reynolds | f0f629f | 2016-02-25 09:34:04 -0500 | [diff] [blame] | 1547 | } else if (mNotificationData.getImportance(notification.getKey()) |
| 1548 | < NotificationListenerService.Ranking.IMPORTANCE_MAX) { |
| 1549 | if (DEBUG) { |
| 1550 | Log.d(TAG, "No Fullscreen intent: not important enough: " |
| 1551 | + notification.getKey()); |
| 1552 | } |
Julia Reynolds | 6172158 | 2016-01-05 08:35:25 -0500 | [diff] [blame] | 1553 | } else { |
| 1554 | // Stop screensaver if the notification has a full-screen intent. |
| 1555 | // (like an incoming phone call) |
| 1556 | awakenDreams(); |
Daniel Sandler | c9ce0ab | 2012-09-04 13:27:09 -0400 | [diff] [blame] | 1557 | |
Julia Reynolds | 6172158 | 2016-01-05 08:35:25 -0500 | [diff] [blame] | 1558 | // not immersive & a full-screen alert should be shown |
| 1559 | if (DEBUG) |
| 1560 | Log.d(TAG, "Notification has fullScreenIntent; sending fullScreenIntent"); |
| 1561 | try { |
| 1562 | EventLog.writeEvent(EventLogTags.SYSUI_FULLSCREEN_NOTIFICATION, |
| 1563 | notification.getKey()); |
| 1564 | notification.getNotification().fullScreenIntent.send(); |
| 1565 | shadeEntry.notifyFullScreenIntentLaunched(); |
| 1566 | MetricsLogger.count(mContext, "note_fullscreen", 1); |
| 1567 | } catch (PendingIntent.CanceledException e) { |
| 1568 | } |
John Spurlock | bf20eab | 2014-04-09 16:40:39 -0400 | [diff] [blame] | 1569 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1570 | } |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1571 | addNotificationViews(shadeEntry, ranking); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1572 | // Recalculate the position of the sliding windows and the titles. |
| 1573 | setAreThereNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1574 | } |
| 1575 | |
Julia Reynolds | d560729 | 2016-02-05 15:25:58 -0500 | [diff] [blame] | 1576 | private boolean shouldSuppressFullScreenIntent(String key) { |
Dan Sandler | dc34df5 | 2016-04-07 21:04:46 -0400 | [diff] [blame] | 1577 | if (isDeviceInVrMode()) { |
| 1578 | return true; |
| 1579 | } |
| 1580 | |
Julia Reynolds | 0971cb0 | 2016-01-26 17:00:22 -0500 | [diff] [blame] | 1581 | if (mPowerManager.isInteractive()) { |
Julia Reynolds | 0971cb0 | 2016-01-26 17:00:22 -0500 | [diff] [blame] | 1582 | return mNotificationData.shouldSuppressScreenOn(key); |
Julia Reynolds | d560729 | 2016-02-05 15:25:58 -0500 | [diff] [blame] | 1583 | } else { |
| 1584 | return mNotificationData.shouldSuppressScreenOff(key); |
Julia Reynolds | 0971cb0 | 2016-01-26 17:00:22 -0500 | [diff] [blame] | 1585 | } |
| 1586 | } |
| 1587 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1588 | @Override |
Christoph Studer | e71fefc | 2014-06-24 16:16:49 +0200 | [diff] [blame] | 1589 | protected void updateNotificationRanking(RankingMap ranking) { |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 1590 | mNotificationData.updateRanking(ranking); |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 1591 | updateNotifications(); |
| 1592 | } |
| 1593 | |
| 1594 | @Override |
Christoph Studer | e71fefc | 2014-06-24 16:16:49 +0200 | [diff] [blame] | 1595 | public void removeNotification(String key, RankingMap ranking) { |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1596 | boolean deferRemoval = false; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1597 | if (mHeadsUpManager.isHeadsUp(key)) { |
Adrian Roos | c721fcc5 | 2016-04-29 11:28:37 -0700 | [diff] [blame] | 1598 | // A cancel() in repsonse to a remote input shouldn't be delayed, as it makes the |
| 1599 | // sending look longer than it takes. |
| 1600 | boolean ignoreEarliestRemovalTime = mRemoteInputController.isSpinning(key) |
| 1601 | && !FORCE_REMOTE_INPUT_HISTORY; |
| 1602 | deferRemoval = !mHeadsUpManager.removeNotification(key, ignoreEarliestRemovalTime); |
Chris Wren | a4ef620 | 2014-06-09 18:07:30 -0400 | [diff] [blame] | 1603 | } |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1604 | if (key.equals(mMediaNotificationKey)) { |
| 1605 | clearCurrentMediaNotification(); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 1606 | updateMediaMetaData(true, true); |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1607 | } |
Adrian Roos | c0a579e | 2016-03-30 16:43:58 -0700 | [diff] [blame] | 1608 | if (FORCE_REMOTE_INPUT_HISTORY && mRemoteInputController.isSpinning(key)) { |
| 1609 | Entry entry = mNotificationData.get(key); |
| 1610 | StatusBarNotification sbn = entry.notification; |
| 1611 | |
| 1612 | Notification.Builder b = Notification.Builder |
| 1613 | .recoverBuilder(mContext, sbn.getNotification().clone()); |
| 1614 | CharSequence[] oldHistory = sbn.getNotification().extras |
| 1615 | .getCharSequenceArray(Notification.EXTRA_REMOTE_INPUT_HISTORY); |
| 1616 | CharSequence[] newHistory; |
| 1617 | if (oldHistory == null) { |
| 1618 | newHistory = new CharSequence[1]; |
| 1619 | } else { |
| 1620 | newHistory = new CharSequence[oldHistory.length + 1]; |
| 1621 | for (int i = 0; i < oldHistory.length; i++) { |
| 1622 | newHistory[i + 1] = oldHistory[i]; |
| 1623 | } |
| 1624 | } |
| 1625 | newHistory[0] = String.valueOf(entry.remoteInputText); |
| 1626 | b.setRemoteInputHistory(newHistory); |
| 1627 | |
| 1628 | Notification newNotification = b.build(); |
| 1629 | |
| 1630 | // Undo any compatibility view inflation |
| 1631 | newNotification.contentView = sbn.getNotification().contentView; |
| 1632 | newNotification.bigContentView = sbn.getNotification().bigContentView; |
| 1633 | newNotification.headsUpContentView = sbn.getNotification().headsUpContentView; |
| 1634 | |
| 1635 | StatusBarNotification newSbn = new StatusBarNotification(sbn.getPackageName(), |
| 1636 | sbn.getOpPkg(), |
| 1637 | sbn.getId(), sbn.getTag(), sbn.getUid(), sbn.getInitialPid(), |
| 1638 | 0, newNotification, sbn.getUser(), sbn.getPostTime()); |
| 1639 | |
| 1640 | updateNotification(newSbn, null); |
| 1641 | mKeysKeptForRemoteInput.add(entry.key); |
| 1642 | return; |
| 1643 | } |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1644 | if (deferRemoval) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1645 | mLatestRankingMap = ranking; |
| 1646 | mHeadsUpEntriesToRemoveOnSwitch.add(mHeadsUpManager.getEntry(key)); |
| 1647 | return; |
| 1648 | } |
Selim Cinek | a570318 | 2016-05-11 21:23:16 -0400 | [diff] [blame] | 1649 | Entry entry = mNotificationData.get(key); |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 1650 | |
Adrian Roos | 9550f2e | 2016-08-23 18:23:01 +0200 | [diff] [blame] | 1651 | if (entry != null && mRemoteInputController.isRemoteInputActive(entry) |
| 1652 | && (entry.row != null && !entry.row.isDismissed())) { |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 1653 | mLatestRankingMap = ranking; |
| 1654 | mRemoteInputEntriesToRemoveOnCollapse.add(entry); |
| 1655 | return; |
| 1656 | } |
| 1657 | |
Selim Cinek | a570318 | 2016-05-11 21:23:16 -0400 | [diff] [blame] | 1658 | if (entry != null && entry.row != null) { |
Adrian Roos | d009ab1 | 2016-05-20 17:58:53 -0700 | [diff] [blame] | 1659 | entry.row.setRemoved(); |
Selim Cinek | a570318 | 2016-05-11 21:23:16 -0400 | [diff] [blame] | 1660 | } |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1661 | // Let's remove the children if this was a summary |
| 1662 | handleGroupSummaryRemoved(key, ranking); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1663 | StatusBarNotification old = removeNotificationViews(key, ranking); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 1664 | if (SPEW) Log.d(TAG, "removeNotification key=" + key + " old=" + old); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1665 | |
| 1666 | if (old != null) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1667 | if (CLOSE_PANEL_WHEN_EMPTIED && !hasActiveNotifications() |
Jorim Jaggi | ba94f88 | 2014-08-20 19:23:55 +0200 | [diff] [blame] | 1668 | && !mNotificationPanel.isTracking() && !mNotificationPanel.isQsExpanded()) { |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 1669 | if (mState == StatusBarState.SHADE) { |
| 1670 | animateCollapsePanels(); |
Selim Cinek | 61b350c | 2016-08-05 14:26:51 -0700 | [diff] [blame] | 1671 | } else if (mState == StatusBarState.SHADE_LOCKED && !isCollapsing()) { |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 1672 | goToKeyguard(); |
| 1673 | } |
Daniel Sandler | 8cc36e5 | 2011-10-17 14:18:46 -0400 | [diff] [blame] | 1674 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1675 | } |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 1676 | setAreThereNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1677 | } |
| 1678 | |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1679 | /** |
| 1680 | * Ensures that the group children are cancelled immediately when the group summary is cancelled |
| 1681 | * instead of waiting for the notification manager to send all cancels. Otherwise this could |
| 1682 | * lead to flickers. |
| 1683 | * |
| 1684 | * This also ensures that the animation looks nice and only consists of a single disappear |
| 1685 | * animation instead of multiple. |
| 1686 | * |
| 1687 | * @param key the key of the notification was removed |
| 1688 | * @param ranking the current ranking |
| 1689 | */ |
| 1690 | private void handleGroupSummaryRemoved(String key, |
| 1691 | RankingMap ranking) { |
| 1692 | Entry entry = mNotificationData.get(key); |
| 1693 | if (entry != null && entry.row != null |
| 1694 | && entry.row.isSummaryWithChildren()) { |
| 1695 | if (entry.notification.getOverrideGroupKey() != null && !entry.row.isDismissed()) { |
| 1696 | // We don't want to remove children for autobundled notifications as they are not |
| 1697 | // always cancelled. We only remove them if they were dismissed by the user. |
| 1698 | return; |
| 1699 | } |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1700 | List<ExpandableNotificationRow> notificationChildren = |
| 1701 | entry.row.getNotificationChildren(); |
| 1702 | ArrayList<ExpandableNotificationRow> toRemove = new ArrayList<>(notificationChildren); |
| 1703 | for (int i = 0; i < toRemove.size(); i++) { |
| 1704 | toRemove.get(i).setKeepInParent(true); |
Selim Cinek | a570318 | 2016-05-11 21:23:16 -0400 | [diff] [blame] | 1705 | // we need to set this state earlier as otherwise we might generate some weird |
| 1706 | // animations |
Adrian Roos | d009ab1 | 2016-05-20 17:58:53 -0700 | [diff] [blame] | 1707 | toRemove.get(i).setRemoved(); |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1708 | } |
| 1709 | for (int i = 0; i < toRemove.size(); i++) { |
| 1710 | removeNotification(toRemove.get(i).getStatusBarNotification().getKey(), ranking); |
Selim Cinek | 7103fd4 | 2016-05-09 22:22:33 -0400 | [diff] [blame] | 1711 | // we need to ensure that the view is actually properly removed from the viewstate |
| 1712 | // as this won't happen anymore when kept in the parent. |
| 1713 | mStackScroller.removeViewStateForView(toRemove.get(i)); |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1714 | } |
| 1715 | } |
| 1716 | } |
| 1717 | |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 1718 | @Override |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 1719 | protected void performRemoveNotification(StatusBarNotification n, boolean removeView) { |
| 1720 | Entry entry = mNotificationData.get(n.getKey()); |
| 1721 | if (mRemoteInputController.isRemoteInputActive(entry)) { |
Adrian Roos | 7813dd7 | 2016-09-23 17:12:17 -0700 | [diff] [blame] | 1722 | mRemoteInputController.removeRemoteInput(entry, null); |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 1723 | } |
| 1724 | super.performRemoveNotification(n, removeView); |
| 1725 | } |
| 1726 | |
| 1727 | @Override |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 1728 | protected void refreshLayout(int layoutDirection) { |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 1729 | if (mNavigationBarView != null) { |
| 1730 | mNavigationBarView.setLayoutDirection(layoutDirection); |
| 1731 | } |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 1732 | } |
| 1733 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1734 | private void updateNotificationShade() { |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 1735 | if (mStackScroller == null) return; |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 1736 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1737 | // Do not modify the notifications during collapse. |
| 1738 | if (isCollapsing()) { |
| 1739 | addPostCollapseAction(new Runnable() { |
| 1740 | @Override |
| 1741 | public void run() { |
| 1742 | updateNotificationShade(); |
| 1743 | } |
| 1744 | }); |
| 1745 | return; |
| 1746 | } |
| 1747 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1748 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1749 | ArrayList<ExpandableNotificationRow> toShow = new ArrayList<>(activeNotifications.size()); |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1750 | final int N = activeNotifications.size(); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1751 | for (int i=0; i<N; i++) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1752 | Entry ent = activeNotifications.get(i); |
| 1753 | int vis = ent.notification.getNotification().visibility; |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 1754 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1755 | // Display public version of the notification if we need to redact. |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1756 | final boolean hideSensitive = |
| 1757 | !userAllowsPrivateNotificationsInPublic(ent.notification.getUserId()); |
Chris Wren | 3ad4e3a | 2014-09-02 17:23:51 -0400 | [diff] [blame] | 1758 | boolean sensitiveNote = vis == Notification.VISIBILITY_PRIVATE; |
| 1759 | boolean sensitivePackage = packageHasVisibilityOverride(ent.notification.getKey()); |
| 1760 | boolean sensitive = (sensitiveNote && hideSensitive) || sensitivePackage; |
| 1761 | boolean showingPublic = sensitive && isLockscreenPublicMode(); |
Sudheer Shanka | f5b850e | 2016-01-25 19:58:59 +0000 | [diff] [blame] | 1762 | if (showingPublic) { |
| 1763 | updatePublicContentView(ent, ent.notification); |
| 1764 | } |
Selim Cinek | 3c76d50 | 2016-02-19 15:16:33 -0800 | [diff] [blame] | 1765 | ent.row.setSensitive(sensitive, hideSensitive); |
Dan Sandler | 1b71878 | 2014-07-18 12:43:45 -0400 | [diff] [blame] | 1766 | if (ent.autoRedacted && ent.legacy) { |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1767 | // TODO: Also fade this? Or, maybe easier (and better), provide a dark redacted form |
| 1768 | // for legacy auto redacted notifications. |
Dan Sandler | 1b71878 | 2014-07-18 12:43:45 -0400 | [diff] [blame] | 1769 | if (showingPublic) { |
| 1770 | ent.row.setShowingLegacyBackground(false); |
| 1771 | } else { |
| 1772 | ent.row.setShowingLegacyBackground(true); |
| 1773 | } |
| 1774 | } |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1775 | if (mGroupManager.isChildInGroupWithSummary(ent.row.getStatusBarNotification())) { |
| 1776 | ExpandableNotificationRow summary = mGroupManager.getGroupSummary( |
| 1777 | ent.row.getStatusBarNotification()); |
| 1778 | List<ExpandableNotificationRow> orderedChildren = |
| 1779 | mTmpChildOrderMap.get(summary); |
| 1780 | if (orderedChildren == null) { |
| 1781 | orderedChildren = new ArrayList<>(); |
| 1782 | mTmpChildOrderMap.put(summary, orderedChildren); |
| 1783 | } |
| 1784 | orderedChildren.add(ent.row); |
| 1785 | } else { |
| 1786 | toShow.add(ent.row); |
| 1787 | } |
| 1788 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1789 | } |
| 1790 | |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1791 | ArrayList<ExpandableNotificationRow> toRemove = new ArrayList<>(); |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 1792 | for (int i=0; i< mStackScroller.getChildCount(); i++) { |
| 1793 | View child = mStackScroller.getChildAt(i); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1794 | if (!toShow.contains(child) && child instanceof ExpandableNotificationRow) { |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1795 | toRemove.add((ExpandableNotificationRow) child); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1796 | } |
| 1797 | } |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1798 | |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1799 | for (ExpandableNotificationRow remove : toRemove) { |
| 1800 | if (mGroupManager.isChildInGroupWithSummary(remove.getStatusBarNotification())) { |
| 1801 | // we are only transfering this notification to its parent, don't generate an animation |
| 1802 | mStackScroller.setChildTransferInProgress(true); |
| 1803 | } |
Selim Cinek | c1e389d | 2016-04-07 11:02:57 -0700 | [diff] [blame] | 1804 | if (remove.isSummaryWithChildren()) { |
| 1805 | remove.removeAllChildren(); |
| 1806 | } |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 1807 | mStackScroller.removeView(remove); |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1808 | mStackScroller.setChildTransferInProgress(false); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1809 | } |
Selim Cinek | 2b54242 | 2016-03-04 18:10:37 -0800 | [diff] [blame] | 1810 | |
| 1811 | removeNotificationChildren(); |
| 1812 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1813 | for (int i=0; i<toShow.size(); i++) { |
| 1814 | View v = toShow.get(i); |
| 1815 | if (v.getParent() == null) { |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1816 | mStackScroller.addView(v); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1817 | } |
| 1818 | } |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 1819 | |
Selim Cinek | 2b54242 | 2016-03-04 18:10:37 -0800 | [diff] [blame] | 1820 | addNotificationChildrenAndSort(); |
| 1821 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1822 | // So after all this work notifications still aren't sorted correctly. |
| 1823 | // Let's do that now by advancing through toShow and mStackScroller in |
| 1824 | // lock-step, making sure mStackScroller matches what we see in toShow. |
| 1825 | int j = 0; |
| 1826 | for (int i = 0; i < mStackScroller.getChildCount(); i++) { |
| 1827 | View child = mStackScroller.getChildAt(i); |
| 1828 | if (!(child instanceof ExpandableNotificationRow)) { |
| 1829 | // We don't care about non-notification views. |
| 1830 | continue; |
| 1831 | } |
| 1832 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1833 | ExpandableNotificationRow targetChild = toShow.get(j); |
| 1834 | if (child != targetChild) { |
| 1835 | // Oops, wrong notification at this position. Put the right one |
| 1836 | // here and advance both lists. |
| 1837 | mStackScroller.changeViewPosition(targetChild, i); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1838 | } |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1839 | j++; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1840 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1841 | } |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1842 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1843 | // clear the map again for the next usage |
| 1844 | mTmpChildOrderMap.clear(); |
| 1845 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1846 | updateRowStates(); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1847 | updateSpeedbump(); |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1848 | updateClearAll(); |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 1849 | updateEmptyShadeView(); |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1850 | |
Benjamin Franz | 27cf146 | 2015-04-23 19:36:42 +0100 | [diff] [blame] | 1851 | updateQsExpansionEnabled(); |
| 1852 | mShadeUpdates.check(); |
| 1853 | } |
| 1854 | |
| 1855 | /** |
| 1856 | * Disable QS if device not provisioned. |
| 1857 | * If the user switcher is simple then disable QS during setup because |
| 1858 | * the user intends to use the lock screen user switcher, QS in not needed. |
| 1859 | */ |
| 1860 | private void updateQsExpansionEnabled() { |
Jason Monk | 3ad242d | 2014-09-15 11:13:35 -0400 | [diff] [blame] | 1861 | mNotificationPanel.setQsExpansionEnabled(isDeviceProvisioned() |
Adrian Roos | 2b154a9 | 2014-11-17 15:18:39 +0100 | [diff] [blame] | 1862 | && (mUserSetup || mUserSwitcherController == null |
Benjamin Franz | 27cf146 | 2015-04-23 19:36:42 +0100 | [diff] [blame] | 1863 | || !mUserSwitcherController.isSimpleUserSwitcher()) |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 1864 | && ((mDisabled2 & StatusBarManager.DISABLE2_QUICK_SETTINGS) == 0) |
| 1865 | && !ONLY_CORE_APPS); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1866 | } |
| 1867 | |
Selim Cinek | 2b54242 | 2016-03-04 18:10:37 -0800 | [diff] [blame] | 1868 | private void addNotificationChildrenAndSort() { |
Selim Cinek | 322ec7e | 2016-02-11 14:47:06 -0800 | [diff] [blame] | 1869 | // Let's now add all notification children which are missing |
| 1870 | boolean orderChanged = false; |
| 1871 | for (int i = 0; i < mStackScroller.getChildCount(); i++) { |
| 1872 | View view = mStackScroller.getChildAt(i); |
| 1873 | if (!(view instanceof ExpandableNotificationRow)) { |
| 1874 | // We don't care about non-notification views. |
| 1875 | continue; |
| 1876 | } |
| 1877 | |
| 1878 | ExpandableNotificationRow parent = (ExpandableNotificationRow) view; |
| 1879 | List<ExpandableNotificationRow> children = parent.getNotificationChildren(); |
| 1880 | List<ExpandableNotificationRow> orderedChildren = mTmpChildOrderMap.get(parent); |
| 1881 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1882 | for (int childIndex = 0; orderedChildren != null && childIndex < orderedChildren.size(); |
| 1883 | childIndex++) { |
| 1884 | ExpandableNotificationRow childView = orderedChildren.get(childIndex); |
| 1885 | if (children == null || !children.contains(childView)) { |
| 1886 | parent.addChildNotification(childView, childIndex); |
| 1887 | mStackScroller.notifyGroupChildAdded(childView); |
| 1888 | } |
| 1889 | } |
| 1890 | |
| 1891 | // Finally after removing and adding has been beformed we can apply the order. |
| 1892 | orderChanged |= parent.applyChildOrder(orderedChildren); |
| 1893 | } |
| 1894 | if (orderChanged) { |
| 1895 | mStackScroller.generateChildOrderChangedEvent(); |
| 1896 | } |
| 1897 | } |
| 1898 | |
Selim Cinek | 2b54242 | 2016-03-04 18:10:37 -0800 | [diff] [blame] | 1899 | private void removeNotificationChildren() { |
| 1900 | // First let's remove all children which don't belong in the parents |
| 1901 | ArrayList<ExpandableNotificationRow> toRemove = new ArrayList<>(); |
| 1902 | for (int i = 0; i < mStackScroller.getChildCount(); i++) { |
| 1903 | View view = mStackScroller.getChildAt(i); |
| 1904 | if (!(view instanceof ExpandableNotificationRow)) { |
| 1905 | // We don't care about non-notification views. |
| 1906 | continue; |
| 1907 | } |
| 1908 | |
| 1909 | ExpandableNotificationRow parent = (ExpandableNotificationRow) view; |
| 1910 | List<ExpandableNotificationRow> children = parent.getNotificationChildren(); |
| 1911 | List<ExpandableNotificationRow> orderedChildren = mTmpChildOrderMap.get(parent); |
| 1912 | |
| 1913 | if (children != null) { |
| 1914 | toRemove.clear(); |
| 1915 | for (ExpandableNotificationRow childRow : children) { |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1916 | if ((orderedChildren == null |
| 1917 | || !orderedChildren.contains(childRow)) |
| 1918 | && !childRow.keepInParent()) { |
Selim Cinek | 2b54242 | 2016-03-04 18:10:37 -0800 | [diff] [blame] | 1919 | toRemove.add(childRow); |
| 1920 | } |
| 1921 | } |
| 1922 | for (ExpandableNotificationRow remove : toRemove) { |
| 1923 | parent.removeChildNotification(remove); |
| 1924 | if (mNotificationData.get(remove.getStatusBarNotification().getKey()) == null) { |
| 1925 | // We only want to add an animation if the view is completely removed |
| 1926 | // otherwise it's just a transfer |
Selim Cinek | d139564 | 2016-04-28 12:22:42 -0700 | [diff] [blame] | 1927 | mStackScroller.notifyGroupChildRemoved(remove, |
| 1928 | parent.getChildrenContainer()); |
Selim Cinek | 2b54242 | 2016-03-04 18:10:37 -0800 | [diff] [blame] | 1929 | } |
| 1930 | } |
| 1931 | } |
| 1932 | } |
| 1933 | } |
| 1934 | |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 1935 | @Override |
| 1936 | public void addQsTile(ComponentName tile) { |
| 1937 | mQSPanel.getHost().addTile(tile); |
| 1938 | } |
| 1939 | |
| 1940 | @Override |
| 1941 | public void remQsTile(ComponentName tile) { |
| 1942 | mQSPanel.getHost().removeTile(tile); |
| 1943 | } |
| 1944 | |
| 1945 | @Override |
| 1946 | public void clickTile(ComponentName tile) { |
| 1947 | mQSPanel.clickTile(tile); |
| 1948 | } |
| 1949 | |
Chris Wren | 3ad4e3a | 2014-09-02 17:23:51 -0400 | [diff] [blame] | 1950 | private boolean packageHasVisibilityOverride(String key) { |
Julia Reynolds | 26fa8a5 | 2016-02-24 08:31:22 -0500 | [diff] [blame] | 1951 | return mNotificationData.getVisibilityOverride(key) == Notification.VISIBILITY_PRIVATE; |
Chris Wren | 3ad4e3a | 2014-09-02 17:23:51 -0400 | [diff] [blame] | 1952 | } |
| 1953 | |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1954 | private void updateClearAll() { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1955 | boolean showDismissView = |
| 1956 | mState != StatusBarState.KEYGUARD && |
| 1957 | mNotificationData.hasActiveClearableNotifications(); |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1958 | mStackScroller.updateDismissView(showDismissView); |
| 1959 | } |
| 1960 | |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 1961 | private void updateEmptyShadeView() { |
| 1962 | boolean showEmptyShade = |
| 1963 | mState != StatusBarState.KEYGUARD && |
| 1964 | mNotificationData.getActiveNotifications().size() == 0; |
| 1965 | mNotificationPanel.setShadeEmpty(showEmptyShade); |
| 1966 | } |
| 1967 | |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1968 | private void updateSpeedbump() { |
| 1969 | int speedbumpIndex = -1; |
| 1970 | int currentIndex = 0; |
Selim Cinek | 2a73934 | 2016-03-17 10:28:55 -0700 | [diff] [blame] | 1971 | final int N = mStackScroller.getChildCount(); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1972 | for (int i = 0; i < N; i++) { |
Selim Cinek | 2a73934 | 2016-03-17 10:28:55 -0700 | [diff] [blame] | 1973 | View view = mStackScroller.getChildAt(i); |
| 1974 | if (view.getVisibility() == View.GONE || !(view instanceof ExpandableNotificationRow)) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1975 | continue; |
| 1976 | } |
Selim Cinek | 2a73934 | 2016-03-17 10:28:55 -0700 | [diff] [blame] | 1977 | ExpandableNotificationRow row = (ExpandableNotificationRow) view; |
| 1978 | if (mNotificationData.isAmbient(row.getStatusBarNotification().getKey())) { |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1979 | speedbumpIndex = currentIndex; |
| 1980 | break; |
| 1981 | } |
| 1982 | currentIndex++; |
| 1983 | } |
| 1984 | mStackScroller.updateSpeedBumpIndex(speedbumpIndex); |
| 1985 | } |
| 1986 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1987 | public static boolean isTopLevelChild(Entry entry) { |
| 1988 | return entry.row.getParent() instanceof NotificationStackScrollLayout; |
| 1989 | } |
| 1990 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1991 | @Override |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1992 | protected void updateNotifications() { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1993 | mNotificationData.filterAndSort(); |
| 1994 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1995 | updateNotificationShade(); |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 1996 | mIconController.updateNotificationIcons(mNotificationData); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1997 | } |
| 1998 | |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1999 | public void requestNotificationUpdate() { |
| 2000 | updateNotifications(); |
| 2001 | } |
| 2002 | |
Jorim Jaggi | 5404542 | 2014-07-03 18:30:40 +0200 | [diff] [blame] | 2003 | @Override |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2004 | protected void setAreThereNotifications() { |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 2005 | |
Chris Wren | 6d15a36 | 2013-08-20 18:46:29 -0400 | [diff] [blame] | 2006 | if (SPEW) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 2007 | final boolean clearable = hasActiveNotifications() && |
| 2008 | mNotificationData.hasActiveClearableNotifications(); |
| 2009 | Log.d(TAG, "setAreThereNotifications: N=" + |
| 2010 | mNotificationData.getActiveNotifications().size() + " any=" + |
| 2011 | hasActiveNotifications() + " clearable=" + clearable); |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 2012 | } |
| 2013 | |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 2014 | final View nlo = mStatusBarView.findViewById(R.id.notification_lights_out); |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 2015 | final boolean showDot = hasActiveNotifications() && !areLightsOn(); |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 2016 | if (showDot != (nlo.getAlpha() == 1.0f)) { |
| 2017 | if (showDot) { |
| 2018 | nlo.setAlpha(0f); |
| 2019 | nlo.setVisibility(View.VISIBLE); |
| 2020 | } |
| 2021 | nlo.animate() |
| 2022 | .alpha(showDot?1:0) |
| 2023 | .setDuration(showDot?750:250) |
| 2024 | .setInterpolator(new AccelerateInterpolator(2.0f)) |
| 2025 | .setListener(showDot ? null : new AnimatorListenerAdapter() { |
| 2026 | @Override |
| 2027 | public void onAnimationEnd(Animator _a) { |
| 2028 | nlo.setVisibility(View.GONE); |
| 2029 | } |
| 2030 | }) |
| 2031 | .start(); |
| 2032 | } |
Daniel Sandler | 3d32a24 | 2012-06-05 13:44:14 -0400 | [diff] [blame] | 2033 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2034 | findAndUpdateMediaNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2035 | } |
| 2036 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2037 | public void findAndUpdateMediaNotifications() { |
| 2038 | boolean metaDataChanged = false; |
| 2039 | |
| 2040 | synchronized (mNotificationData) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 2041 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
| 2042 | final int N = activeNotifications.size(); |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2043 | |
| 2044 | // Promote the media notification with a controller in 'playing' state, if any. |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2045 | Entry mediaNotification = null; |
| 2046 | MediaController controller = null; |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 2047 | for (int i = 0; i < N; i++) { |
| 2048 | final Entry entry = activeNotifications.get(i); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2049 | if (isMediaNotification(entry)) { |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2050 | final MediaSession.Token token = |
| 2051 | entry.notification.getNotification().extras |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2052 | .getParcelable(Notification.EXTRA_MEDIA_SESSION); |
| 2053 | if (token != null) { |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2054 | MediaController aController = new MediaController(mContext, token); |
| 2055 | if (PlaybackState.STATE_PLAYING == |
| 2056 | getMediaControllerPlaybackState(aController)) { |
| 2057 | if (DEBUG_MEDIA) { |
| 2058 | Log.v(TAG, "DEBUG_MEDIA: found mediastyle controller matching " |
| 2059 | + entry.notification.getKey()); |
| 2060 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2061 | mediaNotification = entry; |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2062 | controller = aController; |
| 2063 | break; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2064 | } |
| 2065 | } |
| 2066 | } |
| 2067 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2068 | if (mediaNotification == null) { |
| 2069 | // Still nothing? OK, let's just look for live media sessions and see if they match |
| 2070 | // one of our notifications. This will catch apps that aren't (yet!) using media |
| 2071 | // notifications. |
| 2072 | |
| 2073 | if (mMediaSessionManager != null) { |
| 2074 | final List<MediaController> sessions |
| 2075 | = mMediaSessionManager.getActiveSessionsForUser( |
| 2076 | null, |
| 2077 | UserHandle.USER_ALL); |
| 2078 | |
| 2079 | for (MediaController aController : sessions) { |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2080 | if (PlaybackState.STATE_PLAYING == |
| 2081 | getMediaControllerPlaybackState(aController)) { |
| 2082 | // now to see if we have one like this |
| 2083 | final String pkg = aController.getPackageName(); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2084 | |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2085 | for (int i = 0; i < N; i++) { |
| 2086 | final Entry entry = activeNotifications.get(i); |
| 2087 | if (entry.notification.getPackageName().equals(pkg)) { |
| 2088 | if (DEBUG_MEDIA) { |
| 2089 | Log.v(TAG, "DEBUG_MEDIA: found controller matching " |
| 2090 | + entry.notification.getKey()); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2091 | } |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2092 | controller = aController; |
| 2093 | mediaNotification = entry; |
| 2094 | break; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2095 | } |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2096 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2097 | } |
| 2098 | } |
| 2099 | } |
| 2100 | } |
| 2101 | |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2102 | if (controller != null && !sameSessions(mMediaController, controller)) { |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2103 | // We have a new media session |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2104 | clearCurrentMediaNotification(); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2105 | mMediaController = controller; |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2106 | mMediaController.registerCallback(mMediaListener); |
| 2107 | mMediaMetadata = mMediaController.getMetadata(); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2108 | if (DEBUG_MEDIA) { |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2109 | Log.v(TAG, "DEBUG_MEDIA: insert listener, receive metadata: " |
| 2110 | + mMediaMetadata); |
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 | |
| 2113 | if (mediaNotification != null) { |
| 2114 | mMediaNotificationKey = mediaNotification.notification.getKey(); |
| 2115 | if (DEBUG_MEDIA) { |
| 2116 | Log.v(TAG, "DEBUG_MEDIA: Found new media notification: key=" |
| 2117 | + mMediaNotificationKey + " controller=" + mMediaController); |
| 2118 | } |
| 2119 | } |
| 2120 | metaDataChanged = true; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2121 | } |
| 2122 | } |
| 2123 | |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2124 | if (metaDataChanged) { |
| 2125 | updateNotifications(); |
| 2126 | } |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 2127 | updateMediaMetaData(metaDataChanged, true); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2128 | } |
| 2129 | |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 2130 | private int getMediaControllerPlaybackState(MediaController controller) { |
| 2131 | if (controller != null) { |
| 2132 | final PlaybackState playbackState = controller.getPlaybackState(); |
| 2133 | if (playbackState != null) { |
| 2134 | return playbackState.getState(); |
| 2135 | } |
| 2136 | } |
| 2137 | return PlaybackState.STATE_NONE; |
| 2138 | } |
| 2139 | |
| 2140 | private boolean isPlaybackActive(int state) { |
| 2141 | if (state != PlaybackState.STATE_STOPPED |
| 2142 | && state != PlaybackState.STATE_ERROR |
| 2143 | && state != PlaybackState.STATE_NONE) { |
| 2144 | return true; |
| 2145 | } |
| 2146 | return false; |
| 2147 | } |
| 2148 | |
| 2149 | private void clearCurrentMediaNotification() { |
| 2150 | mMediaNotificationKey = null; |
| 2151 | mMediaMetadata = null; |
| 2152 | if (mMediaController != null) { |
| 2153 | if (DEBUG_MEDIA) { |
| 2154 | Log.v(TAG, "DEBUG_MEDIA: Disconnecting from old controller: " |
| 2155 | + mMediaController.getPackageName()); |
| 2156 | } |
| 2157 | mMediaController.unregisterCallback(mMediaListener); |
| 2158 | } |
| 2159 | mMediaController = null; |
| 2160 | } |
| 2161 | |
Christoph Studer | b5245d8 | 2014-09-19 16:54:36 +0200 | [diff] [blame] | 2162 | private boolean sameSessions(MediaController a, MediaController b) { |
| 2163 | if (a == b) return true; |
| 2164 | if (a == null) return false; |
| 2165 | return a.controlsSameSession(b); |
| 2166 | } |
| 2167 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2168 | /** |
Dan Sandler | 7dea0ee | 2014-07-21 21:07:15 -0400 | [diff] [blame] | 2169 | * Hide the album artwork that is fading out and release its bitmap. |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2170 | */ |
| 2171 | private Runnable mHideBackdropFront = new Runnable() { |
| 2172 | @Override |
| 2173 | public void run() { |
| 2174 | if (DEBUG_MEDIA) { |
| 2175 | Log.v(TAG, "DEBUG_MEDIA: removing fade layer"); |
| 2176 | } |
| 2177 | mBackdropFront.setVisibility(View.INVISIBLE); |
Dan Sandler | 7dea0ee | 2014-07-21 21:07:15 -0400 | [diff] [blame] | 2178 | mBackdropFront.animate().cancel(); |
| 2179 | mBackdropFront.setImageDrawable(null); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2180 | } |
| 2181 | }; |
| 2182 | |
| 2183 | /** |
Adrian Roos | e381c16 | 2016-02-11 15:26:42 -0800 | [diff] [blame] | 2184 | * Refresh or remove lockscreen artwork from media metadata or the lockscreen wallpaper. |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2185 | */ |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 2186 | public void updateMediaMetaData(boolean metaDataChanged, boolean allowEnterAnimation) { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 2187 | Trace.beginSection("PhoneStatusBar#updateMediaMetaData"); |
| 2188 | if (!SHOW_LOCKSCREEN_MEDIA_ARTWORK) { |
| 2189 | Trace.endSection(); |
| 2190 | return; |
| 2191 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2192 | |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 2193 | if (mBackdrop == null) { |
| 2194 | Trace.endSection(); |
| 2195 | return; // called too early |
| 2196 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2197 | |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 2198 | if (mLaunchTransitionFadingAway) { |
| 2199 | mBackdrop.setVisibility(View.INVISIBLE); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 2200 | Trace.endSection(); |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 2201 | return; |
| 2202 | } |
| 2203 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2204 | if (DEBUG_MEDIA) { |
| 2205 | Log.v(TAG, "DEBUG_MEDIA: updating album art for notification " + mMediaNotificationKey |
Selim Cinek | 131c1e2 | 2015-05-11 19:04:49 -0700 | [diff] [blame] | 2206 | + " metadata=" + mMediaMetadata |
| 2207 | + " metaDataChanged=" + metaDataChanged |
| 2208 | + " state=" + mState); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2209 | } |
| 2210 | |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 2211 | Drawable artworkDrawable = null; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2212 | if (mMediaMetadata != null) { |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 2213 | Bitmap artworkBitmap = null; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2214 | artworkBitmap = mMediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ART); |
| 2215 | if (artworkBitmap == null) { |
| 2216 | artworkBitmap = mMediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART); |
| 2217 | // might still be null |
| 2218 | } |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 2219 | if (artworkBitmap != null) { |
| 2220 | artworkDrawable = new BitmapDrawable(mBackdropBack.getResources(), artworkBitmap); |
| 2221 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2222 | } |
Adrian Roos | a3760a4 | 2016-04-25 16:21:06 -0700 | [diff] [blame] | 2223 | boolean allowWhenShade = false; |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 2224 | if (ENABLE_LOCKSCREEN_WALLPAPER && artworkDrawable == null) { |
| 2225 | Bitmap lockWallpaper = mLockscreenWallpaper.getBitmap(); |
| 2226 | if (lockWallpaper != null) { |
| 2227 | artworkDrawable = new LockscreenWallpaper.WallpaperDrawable( |
| 2228 | mBackdropBack.getResources(), lockWallpaper); |
Adrian Roos | a3760a4 | 2016-04-25 16:21:06 -0700 | [diff] [blame] | 2229 | // We're in the SHADE mode on the SIM screen - yet we still need to show |
| 2230 | // the lockscreen wallpaper in that mode. |
| 2231 | allowWhenShade = mStatusBarKeyguardViewManager != null |
| 2232 | && mStatusBarKeyguardViewManager.isShowing(); |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 2233 | } |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 2234 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2235 | |
Adrian Roos | a3760a4 | 2016-04-25 16:21:06 -0700 | [diff] [blame] | 2236 | boolean hideBecauseOccluded = mStatusBarKeyguardViewManager != null |
| 2237 | && mStatusBarKeyguardViewManager.isOccluded(); |
| 2238 | |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 2239 | final boolean hasArtwork = artworkDrawable != null; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2240 | |
Adrian Roos | a3760a4 | 2016-04-25 16:21:06 -0700 | [diff] [blame] | 2241 | if ((hasArtwork || DEBUG_MEDIA_FAKE_ARTWORK) |
| 2242 | && (mState != StatusBarState.SHADE || allowWhenShade) |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2243 | && mFingerprintUnlockController.getMode() |
Adrian Roos | a3760a4 | 2016-04-25 16:21:06 -0700 | [diff] [blame] | 2244 | != FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING |
| 2245 | && !hideBecauseOccluded) { |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2246 | // time to show some art! |
| 2247 | if (mBackdrop.getVisibility() != View.VISIBLE) { |
| 2248 | mBackdrop.setVisibility(View.VISIBLE); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 2249 | if (allowEnterAnimation) { |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 2250 | mBackdrop.setAlpha(SRC_MIN_ALPHA); |
| 2251 | mBackdrop.animate().alpha(1f); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 2252 | } else { |
| 2253 | mBackdrop.animate().cancel(); |
| 2254 | mBackdrop.setAlpha(1f); |
| 2255 | } |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 2256 | mStatusBarWindowManager.setBackdropShowing(true); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2257 | metaDataChanged = true; |
| 2258 | if (DEBUG_MEDIA) { |
| 2259 | Log.v(TAG, "DEBUG_MEDIA: Fading in album artwork"); |
| 2260 | } |
| 2261 | } |
| 2262 | if (metaDataChanged) { |
| 2263 | if (mBackdropBack.getDrawable() != null) { |
Julia Reynolds | 4b9658a | 2015-07-22 17:07:42 -0400 | [diff] [blame] | 2264 | Drawable drawable = |
Adrian Roos | 751f33f | 2016-04-19 16:41:18 -0700 | [diff] [blame] | 2265 | mBackdropBack.getDrawable().getConstantState() |
| 2266 | .newDrawable(mBackdropFront.getResources()).mutate(); |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 2267 | mBackdropFront.setImageDrawable(drawable); |
Jorim Jaggi | 0e66439 | 2014-09-27 01:30:22 +0200 | [diff] [blame] | 2268 | if (mScrimSrcModeEnabled) { |
| 2269 | mBackdropFront.getDrawable().mutate().setXfermode(mSrcOverXferMode); |
| 2270 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2271 | mBackdropFront.setAlpha(1f); |
| 2272 | mBackdropFront.setVisibility(View.VISIBLE); |
| 2273 | } else { |
| 2274 | mBackdropFront.setVisibility(View.INVISIBLE); |
| 2275 | } |
| 2276 | |
| 2277 | if (DEBUG_MEDIA_FAKE_ARTWORK) { |
| 2278 | final int c = 0xFF000000 | (int)(Math.random() * 0xFFFFFF); |
| 2279 | Log.v(TAG, String.format("DEBUG_MEDIA: setting new color: 0x%08x", c)); |
| 2280 | mBackdropBack.setBackgroundColor(0xFFFFFFFF); |
| 2281 | mBackdropBack.setImageDrawable(new ColorDrawable(c)); |
| 2282 | } else { |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 2283 | mBackdropBack.setImageDrawable(artworkDrawable); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2284 | } |
Jorim Jaggi | 0e66439 | 2014-09-27 01:30:22 +0200 | [diff] [blame] | 2285 | if (mScrimSrcModeEnabled) { |
| 2286 | mBackdropBack.getDrawable().mutate().setXfermode(mSrcXferMode); |
| 2287 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2288 | |
| 2289 | if (mBackdropFront.getVisibility() == View.VISIBLE) { |
| 2290 | if (DEBUG_MEDIA) { |
| 2291 | Log.v(TAG, "DEBUG_MEDIA: Crossfading album artwork from " |
| 2292 | + mBackdropFront.getDrawable() |
| 2293 | + " to " |
| 2294 | + mBackdropBack.getDrawable()); |
| 2295 | } |
Jorim Jaggi | 4e0880e | 2014-07-25 14:51:50 +0200 | [diff] [blame] | 2296 | mBackdropFront.animate() |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2297 | .setDuration(250) |
| 2298 | .alpha(0f).withEndAction(mHideBackdropFront); |
| 2299 | } |
| 2300 | } |
| 2301 | } else { |
| 2302 | // need to hide the album art, either because we are unlocked or because |
| 2303 | // the metadata isn't there to support it |
| 2304 | if (mBackdrop.getVisibility() != View.GONE) { |
| 2305 | if (DEBUG_MEDIA) { |
| 2306 | Log.v(TAG, "DEBUG_MEDIA: Fading out album artwork"); |
| 2307 | } |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2308 | if (mFingerprintUnlockController.getMode() |
Adrian Roos | a3760a4 | 2016-04-25 16:21:06 -0700 | [diff] [blame] | 2309 | == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING |
| 2310 | || hideBecauseOccluded) { |
Jorim Jaggi | 4e0880e | 2014-07-25 14:51:50 +0200 | [diff] [blame] | 2311 | |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2312 | // We are unlocking directly - no animation! |
| 2313 | mBackdrop.setVisibility(View.GONE); |
Vadim Tryshev | e7d7d57 | 2016-03-09 16:44:30 -0800 | [diff] [blame] | 2314 | mBackdropBack.setImageDrawable(null); |
Adrian Roos | d5c2db6 | 2016-03-08 16:11:31 -0800 | [diff] [blame] | 2315 | mStatusBarWindowManager.setBackdropShowing(false); |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2316 | } else { |
Adrian Roos | d5c2db6 | 2016-03-08 16:11:31 -0800 | [diff] [blame] | 2317 | mStatusBarWindowManager.setBackdropShowing(false); |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2318 | mBackdrop.animate() |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 2319 | .alpha(SRC_MIN_ALPHA) |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 2320 | .setInterpolator(Interpolators.ACCELERATE_DECELERATE) |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2321 | .setDuration(300) |
| 2322 | .setStartDelay(0) |
| 2323 | .withEndAction(new Runnable() { |
| 2324 | @Override |
| 2325 | public void run() { |
| 2326 | mBackdrop.setVisibility(View.GONE); |
| 2327 | mBackdropFront.animate().cancel(); |
Vadim Tryshev | e7d7d57 | 2016-03-09 16:44:30 -0800 | [diff] [blame] | 2328 | mBackdropBack.setImageDrawable(null); |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2329 | mHandler.post(mHideBackdropFront); |
| 2330 | } |
| 2331 | }); |
| 2332 | if (mKeyguardFadingAway) { |
| 2333 | mBackdrop.animate() |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2334 | // Make it disappear faster, as the focus should be on the activity |
| 2335 | // behind. |
| 2336 | .setDuration(mKeyguardFadingAwayDuration / 2) |
| 2337 | .setStartDelay(mKeyguardFadingAwayDelay) |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 2338 | .setInterpolator(Interpolators.LINEAR) |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2339 | .start(); |
| 2340 | } |
Jorim Jaggi | 4e0880e | 2014-07-25 14:51:50 +0200 | [diff] [blame] | 2341 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2342 | } |
| 2343 | } |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 2344 | Trace.endSection(); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2345 | } |
| 2346 | |
Adrian Roos | 7bb38a9 | 2016-07-21 11:44:01 -0700 | [diff] [blame] | 2347 | private void updateReportRejectedTouchVisibility() { |
| 2348 | if (mReportRejectedTouch == null) { |
| 2349 | return; |
| 2350 | } |
| 2351 | mReportRejectedTouch.setVisibility(mState == StatusBarState.KEYGUARD |
| 2352 | && mFalsingManager.isReportingEnabled() ? View.VISIBLE : View.INVISIBLE); |
| 2353 | } |
| 2354 | |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 2355 | protected int adjustDisableFlags(int state) { |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 2356 | if (!mLaunchTransitionFadingAway && !mKeyguardFadingAway |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 2357 | && (mExpandedVisible || mBouncerShowing || mWaitingForKeyguardExit)) { |
Jorim Jaggi | b13d36d | 2014-06-06 18:03:52 +0200 | [diff] [blame] | 2358 | state |= StatusBarManager.DISABLE_NOTIFICATION_ICONS; |
| 2359 | state |= StatusBarManager.DISABLE_SYSTEM_INFO; |
| 2360 | } |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 2361 | if (mNetworkController != null && EncryptionHelper.IS_DATA_ENCRYPTED) { |
| 2362 | if (mNetworkController.hasEmergencyCryptKeeperText()) { |
| 2363 | state |= StatusBarManager.DISABLE_NOTIFICATION_ICONS; |
| 2364 | } |
| 2365 | if (!mNetworkController.isRadioOn()) { |
| 2366 | state |= StatusBarManager.DISABLE_SYSTEM_INFO; |
| 2367 | } |
| 2368 | } |
Jorim Jaggi | b13d36d | 2014-06-06 18:03:52 +0200 | [diff] [blame] | 2369 | return state; |
| 2370 | } |
| 2371 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2372 | /** |
| 2373 | * State is one or more of the DISABLE constants from StatusBarManager. |
| 2374 | */ |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2375 | @Override |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2376 | public void disable(int state1, int state2, boolean animate) { |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2377 | animate &= mStatusBarWindowState != WINDOW_STATE_HIDDEN; |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2378 | mDisabledUnmodified1 = state1; |
| 2379 | mDisabledUnmodified2 = state2; |
| 2380 | state1 = adjustDisableFlags(state1); |
| 2381 | final int old1 = mDisabled1; |
| 2382 | final int diff1 = state1 ^ old1; |
| 2383 | mDisabled1 = state1; |
| 2384 | |
| 2385 | final int old2 = mDisabled2; |
| 2386 | final int diff2 = state2 ^ old2; |
| 2387 | mDisabled2 = state2; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2388 | |
Daniel Sandler | e21f288 | 2011-08-18 10:14:59 -0400 | [diff] [blame] | 2389 | if (DEBUG) { |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2390 | Log.d(TAG, String.format("disable1: 0x%08x -> 0x%08x (diff1: 0x%08x)", |
| 2391 | old1, state1, diff1)); |
| 2392 | Log.d(TAG, String.format("disable2: 0x%08x -> 0x%08x (diff2: 0x%08x)", |
| 2393 | old2, state2, diff2)); |
Daniel Sandler | e21f288 | 2011-08-18 10:14:59 -0400 | [diff] [blame] | 2394 | } |
| 2395 | |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2396 | StringBuilder flagdbg = new StringBuilder(); |
| 2397 | flagdbg.append("disable: < "); |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2398 | flagdbg.append(((state1 & StatusBarManager.DISABLE_EXPAND) != 0) ? "EXPAND" : "expand"); |
| 2399 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_EXPAND) != 0) ? "* " : " "); |
| 2400 | flagdbg.append(((state1 & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) ? "ICONS" : "icons"); |
| 2401 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) ? "* " : " "); |
| 2402 | flagdbg.append(((state1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) ? "ALERTS" : "alerts"); |
| 2403 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) ? "* " : " "); |
| 2404 | flagdbg.append(((state1 & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) ? "SYSTEM_INFO" : "system_info"); |
| 2405 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) ? "* " : " "); |
| 2406 | flagdbg.append(((state1 & StatusBarManager.DISABLE_BACK) != 0) ? "BACK" : "back"); |
| 2407 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_BACK) != 0) ? "* " : " "); |
| 2408 | flagdbg.append(((state1 & StatusBarManager.DISABLE_HOME) != 0) ? "HOME" : "home"); |
| 2409 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_HOME) != 0) ? "* " : " "); |
| 2410 | flagdbg.append(((state1 & StatusBarManager.DISABLE_RECENT) != 0) ? "RECENT" : "recent"); |
| 2411 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_RECENT) != 0) ? "* " : " "); |
| 2412 | flagdbg.append(((state1 & StatusBarManager.DISABLE_CLOCK) != 0) ? "CLOCK" : "clock"); |
| 2413 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_CLOCK) != 0) ? "* " : " "); |
| 2414 | flagdbg.append(((state1 & StatusBarManager.DISABLE_SEARCH) != 0) ? "SEARCH" : "search"); |
| 2415 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_SEARCH) != 0) ? "* " : " "); |
Benjamin Franz | 27cf146 | 2015-04-23 19:36:42 +0100 | [diff] [blame] | 2416 | flagdbg.append(((state2 & StatusBarManager.DISABLE2_QUICK_SETTINGS) != 0) ? "QUICK_SETTINGS" |
| 2417 | : "quick_settings"); |
| 2418 | flagdbg.append(((diff2 & StatusBarManager.DISABLE2_QUICK_SETTINGS) != 0) ? "* " : " "); |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2419 | flagdbg.append(">"); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2420 | Log.d(TAG, flagdbg.toString()); |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 2421 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2422 | if ((diff1 & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) { |
| 2423 | if ((state1 & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) { |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 2424 | mIconController.hideSystemIconArea(animate); |
Daniel Sandler | 8e18dc7 | 2012-05-17 00:44:59 -0400 | [diff] [blame] | 2425 | } else { |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 2426 | mIconController.showSystemIconArea(animate); |
Daniel Sandler | 8e18dc7 | 2012-05-17 00:44:59 -0400 | [diff] [blame] | 2427 | } |
| 2428 | } |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2429 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2430 | if ((diff1 & StatusBarManager.DISABLE_CLOCK) != 0) { |
| 2431 | boolean visible = (state1 & StatusBarManager.DISABLE_CLOCK) == 0; |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 2432 | mIconController.setClockVisibility(visible); |
Jeff Sharkey | f52c70b | 2011-08-30 22:05:47 -0700 | [diff] [blame] | 2433 | } |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2434 | if ((diff1 & StatusBarManager.DISABLE_EXPAND) != 0) { |
| 2435 | if ((state1 & StatusBarManager.DISABLE_EXPAND) != 0) { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2436 | animateCollapsePanels(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2437 | } |
| 2438 | } |
Daniel Sandler | e21f288 | 2011-08-18 10:14:59 -0400 | [diff] [blame] | 2439 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2440 | if ((diff1 & (StatusBarManager.DISABLE_HOME |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 2441 | | StatusBarManager.DISABLE_RECENT |
Daniel Sandler | d5483c3 | 2012-10-19 16:44:15 -0400 | [diff] [blame] | 2442 | | StatusBarManager.DISABLE_BACK |
| 2443 | | StatusBarManager.DISABLE_SEARCH)) != 0) { |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame] | 2444 | // the nav bar will take care of these |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2445 | if (mNavigationBarView != null) mNavigationBarView.setDisabledFlags(state1); |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2446 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2447 | if ((state1 & StatusBarManager.DISABLE_RECENT) != 0) { |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2448 | // close recents if it's visible |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2449 | mHandler.removeMessages(MSG_HIDE_RECENT_APPS); |
| 2450 | mHandler.sendEmptyMessage(MSG_HIDE_RECENT_APPS); |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2451 | } |
Daniel Sandler | e21f288 | 2011-08-18 10:14:59 -0400 | [diff] [blame] | 2452 | } |
| 2453 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2454 | if ((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { |
| 2455 | if ((state1 & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 2456 | mIconController.hideNotificationIconArea(animate); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2457 | } else { |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 2458 | mIconController.showNotificationIconArea(animate); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2459 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2460 | } |
Jason Monk | f701954 | 2014-07-31 12:42:25 -0400 | [diff] [blame] | 2461 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2462 | if ((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) { |
Jason Monk | f701954 | 2014-07-31 12:42:25 -0400 | [diff] [blame] | 2463 | mDisableNotificationAlerts = |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2464 | (state1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0; |
Jason Monk | f701954 | 2014-07-31 12:42:25 -0400 | [diff] [blame] | 2465 | mHeadsUpObserver.onChange(true); |
| 2466 | } |
Benjamin Franz | 27cf146 | 2015-04-23 19:36:42 +0100 | [diff] [blame] | 2467 | |
| 2468 | if ((diff2 & StatusBarManager.DISABLE2_QUICK_SETTINGS) != 0) { |
| 2469 | updateQsExpansionEnabled(); |
| 2470 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2471 | } |
| 2472 | |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 2473 | /** |
| 2474 | * Reapplies the disable flags as last requested by StatusBarManager. |
| 2475 | * |
| 2476 | * This needs to be called if state used by {@link #adjustDisableFlags} changes. |
| 2477 | */ |
| 2478 | private void recomputeDisableFlags(boolean animate) { |
| 2479 | disable(mDisabledUnmodified1, mDisabledUnmodified2, animate); |
| 2480 | } |
| 2481 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2482 | @Override |
Michael Jurka | ecc395a | 2012-03-30 05:31:46 -0700 | [diff] [blame] | 2483 | protected BaseStatusBar.H createHandler() { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2484 | return new PhoneStatusBar.H(); |
| 2485 | } |
| 2486 | |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 2487 | @Override |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 2488 | public void startActivity(Intent intent, boolean dismissShade) { |
| 2489 | startActivityDismissingKeyguard(intent, false, dismissShade); |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 2490 | } |
| 2491 | |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 2492 | @Override |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 2493 | public void startActivity(Intent intent, boolean dismissShade, Callback callback) { |
| 2494 | startActivityDismissingKeyguard(intent, false, dismissShade, callback); |
| 2495 | } |
| 2496 | |
| 2497 | @Override |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 2498 | public void preventNextAnimation() { |
| 2499 | overrideActivityPendingAppTransition(true /* keyguardShowing */); |
| 2500 | } |
| 2501 | |
Jorim Jaggi | b690f0d | 2014-07-03 23:25:44 +0200 | [diff] [blame] | 2502 | public void setQsExpanded(boolean expanded) { |
| 2503 | mStatusBarWindowManager.setQsExpanded(expanded); |
Adrian Roos | 4c7d960 | 2015-06-10 13:44:48 -0700 | [diff] [blame] | 2504 | mKeyguardStatusView.setImportantForAccessibility(expanded |
| 2505 | ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS |
| 2506 | : View.IMPORTANT_FOR_ACCESSIBILITY_AUTO); |
Jorim Jaggi | b690f0d | 2014-07-03 23:25:44 +0200 | [diff] [blame] | 2507 | } |
| 2508 | |
Jorim Jaggi | 84a3e7a | 2014-08-13 17:58:58 +0200 | [diff] [blame] | 2509 | public boolean isGoingToNotificationShade() { |
| 2510 | return mLeaveOpenOnKeyguardHide; |
| 2511 | } |
| 2512 | |
Jorim Jaggi | d692dd0 | 2014-08-14 20:57:42 +0200 | [diff] [blame] | 2513 | public boolean isQsExpanded() { |
| 2514 | return mNotificationPanel.isQsExpanded(); |
| 2515 | } |
| 2516 | |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 2517 | public boolean isWakeUpComingFromTouch() { |
| 2518 | return mWakeUpComingFromTouch; |
Selim Cinek | 29ed3c9 | 2014-09-23 20:44:35 +0200 | [diff] [blame] | 2519 | } |
| 2520 | |
Selim Cinek | 19c8c70 | 2014-08-25 22:09:19 +0200 | [diff] [blame] | 2521 | public boolean isFalsingThresholdNeeded() { |
Selim Cinek | 9db7105 | 2015-04-24 18:54:30 -0700 | [diff] [blame] | 2522 | return getBarState() == StatusBarState.KEYGUARD; |
Selim Cinek | 19c8c70 | 2014-08-25 22:09:19 +0200 | [diff] [blame] | 2523 | } |
| 2524 | |
John Spurlock | 0b99ea9 | 2014-10-01 15:32:22 -0400 | [diff] [blame] | 2525 | public boolean isDozing() { |
| 2526 | return mDozing; |
| 2527 | } |
| 2528 | |
Christoph Studer | 2e731b5 | 2014-08-22 16:01:51 +0200 | [diff] [blame] | 2529 | @Override // NotificationData.Environment |
| 2530 | public String getCurrentMediaNotificationKey() { |
| 2531 | return mMediaNotificationKey; |
| 2532 | } |
| 2533 | |
Jorim Jaggi | 0e66439 | 2014-09-27 01:30:22 +0200 | [diff] [blame] | 2534 | public boolean isScrimSrcModeEnabled() { |
| 2535 | return mScrimSrcModeEnabled; |
| 2536 | } |
| 2537 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2538 | /** |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 2539 | * To be called when there's a state change in StatusBarKeyguardViewManager. |
| 2540 | */ |
| 2541 | public void onKeyguardViewManagerStatesUpdated() { |
| 2542 | logStateToEventlog(); |
| 2543 | } |
| 2544 | |
| 2545 | @Override // UnlockMethodCache.OnUnlockMethodChangedListener |
| 2546 | public void onUnlockMethodStateChanged() { |
| 2547 | logStateToEventlog(); |
| 2548 | } |
| 2549 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2550 | @Override |
John Spurlock | b349af57 | 2015-04-29 12:24:19 -0400 | [diff] [blame] | 2551 | public void onHeadsUpPinnedModeChanged(boolean inPinnedMode) { |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2552 | if (inPinnedMode) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2553 | mStatusBarWindowManager.setHeadsUpShowing(true); |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2554 | mStatusBarWindowManager.setForceStatusBarVisible(true); |
Selim Cinek | 131c1e2 | 2015-05-11 19:04:49 -0700 | [diff] [blame] | 2555 | if (mNotificationPanel.isFullyCollapsed()) { |
| 2556 | // We need to ensure that the touchable region is updated before the window will be |
| 2557 | // resized, in order to not catch any touches. A layout will ensure that |
| 2558 | // onComputeInternalInsets will be called and after that we can resize the layout. Let's |
| 2559 | // make sure that the window stays small for one frame until the touchableRegion is set. |
| 2560 | mNotificationPanel.requestLayout(); |
| 2561 | mStatusBarWindowManager.setForceWindowCollapsed(true); |
| 2562 | mNotificationPanel.post(new Runnable() { |
| 2563 | @Override |
| 2564 | public void run() { |
| 2565 | mStatusBarWindowManager.setForceWindowCollapsed(false); |
| 2566 | } |
| 2567 | }); |
| 2568 | } |
Selim Cinek | 737bff3 | 2015-05-08 16:08:35 -0700 | [diff] [blame] | 2569 | } else { |
Selim Cinek | 131c1e2 | 2015-05-11 19:04:49 -0700 | [diff] [blame] | 2570 | if (!mNotificationPanel.isFullyCollapsed() || mNotificationPanel.isTracking()) { |
| 2571 | // We are currently tracking or is open and the shade doesn't need to be kept |
| 2572 | // open artificially. |
Selim Cinek | 737bff3 | 2015-05-08 16:08:35 -0700 | [diff] [blame] | 2573 | mStatusBarWindowManager.setHeadsUpShowing(false); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2574 | } else { |
Selim Cinek | 131c1e2 | 2015-05-11 19:04:49 -0700 | [diff] [blame] | 2575 | // we need to keep the panel open artificially, let's wait until the animation |
| 2576 | // is finished. |
Selim Cinek | 737bff3 | 2015-05-08 16:08:35 -0700 | [diff] [blame] | 2577 | mHeadsUpManager.setHeadsUpGoingAway(true); |
| 2578 | mStackScroller.runAfterAnimationFinished(new Runnable() { |
| 2579 | @Override |
| 2580 | public void run() { |
| 2581 | if (!mHeadsUpManager.hasPinnedHeadsUp()) { |
| 2582 | mStatusBarWindowManager.setHeadsUpShowing(false); |
| 2583 | mHeadsUpManager.setHeadsUpGoingAway(false); |
| 2584 | } |
Adrian Roos | 9550f2e | 2016-08-23 18:23:01 +0200 | [diff] [blame] | 2585 | removeRemoteInputEntriesKeptUntilCollapsed(); |
Selim Cinek | 737bff3 | 2015-05-08 16:08:35 -0700 | [diff] [blame] | 2586 | } |
| 2587 | }); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2588 | } |
| 2589 | } |
| 2590 | } |
| 2591 | |
| 2592 | @Override |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2593 | public void onHeadsUpPinned(ExpandableNotificationRow headsUp) { |
John Spurlock | b349af57 | 2015-04-29 12:24:19 -0400 | [diff] [blame] | 2594 | dismissVolumeDialog(); |
Selim Cinek | 1f3f544 | 2015-04-10 17:54:46 -0700 | [diff] [blame] | 2595 | } |
| 2596 | |
| 2597 | @Override |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2598 | public void onHeadsUpUnPinned(ExpandableNotificationRow headsUp) { |
| 2599 | } |
| 2600 | |
| 2601 | @Override |
| 2602 | public void onHeadsUpStateChanged(Entry entry, boolean isHeadsUp) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2603 | if (!isHeadsUp && mHeadsUpEntriesToRemoveOnSwitch.contains(entry)) { |
| 2604 | removeNotification(entry.key, mLatestRankingMap); |
| 2605 | mHeadsUpEntriesToRemoveOnSwitch.remove(entry); |
| 2606 | if (mHeadsUpEntriesToRemoveOnSwitch.isEmpty()) { |
| 2607 | mLatestRankingMap = null; |
| 2608 | } |
Selim Cinek | fbe9a44 | 2015-04-13 16:09:49 -0700 | [diff] [blame] | 2609 | } else { |
| 2610 | updateNotificationRanking(null); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2611 | } |
Selim Cinek | fbe9a44 | 2015-04-13 16:09:49 -0700 | [diff] [blame] | 2612 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2613 | } |
| 2614 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2615 | @Override |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 2616 | protected void updateHeadsUp(String key, Entry entry, boolean shouldPeek, |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 2617 | boolean alertAgain) { |
| 2618 | final boolean wasHeadsUp = isHeadsUp(key); |
| 2619 | if (wasHeadsUp) { |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 2620 | if (!shouldPeek) { |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 2621 | // We don't want this to be interrupting anymore, lets remove it |
Adrian Roos | c721fcc5 | 2016-04-29 11:28:37 -0700 | [diff] [blame] | 2622 | mHeadsUpManager.removeNotification(key, false /* ignoreEarliestRemovalTime */); |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2623 | } else { |
| 2624 | mHeadsUpManager.updateNotification(entry, alertAgain); |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 2625 | } |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 2626 | } else if (shouldPeek && alertAgain) { |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 2627 | // This notification was updated to be a heads-up, show it! |
| 2628 | mHeadsUpManager.showNotification(entry); |
| 2629 | } |
| 2630 | } |
| 2631 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2632 | @Override |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 2633 | protected void setHeadsUpUser(int newUserId) { |
| 2634 | if (mHeadsUpManager != null) { |
| 2635 | mHeadsUpManager.setUser(newUserId); |
| 2636 | } |
| 2637 | } |
| 2638 | |
| 2639 | public boolean isHeadsUp(String key) { |
| 2640 | return mHeadsUpManager.isHeadsUp(key); |
| 2641 | } |
| 2642 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2643 | @Override |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 2644 | protected boolean isSnoozedPackage(StatusBarNotification sbn) { |
| 2645 | return mHeadsUpManager.isSnoozed(sbn.getPackageName()); |
| 2646 | } |
| 2647 | |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 2648 | public boolean isKeyguardCurrentlySecure() { |
Selim Cinek | e8bae62 | 2015-07-15 13:24:06 -0700 | [diff] [blame] | 2649 | return !mUnlockMethodCache.canSkipBouncer(); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 2650 | } |
| 2651 | |
Selim Cinek | 4a21a7f | 2015-05-19 11:00:38 -0700 | [diff] [blame] | 2652 | public void setPanelExpanded(boolean isExpanded) { |
| 2653 | mStatusBarWindowManager.setPanelExpanded(isExpanded); |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 2654 | |
| 2655 | if (isExpanded && getBarState() != StatusBarState.KEYGUARD) { |
| 2656 | if (DEBUG) { |
| 2657 | Log.v(TAG, "clearing notification effects from setPanelExpanded"); |
| 2658 | } |
| 2659 | clearNotificationEffects(); |
| 2660 | } |
| 2661 | |
| 2662 | if (!isExpanded) { |
| 2663 | removeRemoteInputEntriesKeptUntilCollapsed(); |
| 2664 | } |
| 2665 | } |
| 2666 | |
| 2667 | private void removeRemoteInputEntriesKeptUntilCollapsed() { |
| 2668 | for (int i = 0; i < mRemoteInputEntriesToRemoveOnCollapse.size(); i++) { |
| 2669 | Entry entry = mRemoteInputEntriesToRemoveOnCollapse.valueAt(i); |
Adrian Roos | 7813dd7 | 2016-09-23 17:12:17 -0700 | [diff] [blame] | 2670 | mRemoteInputController.removeRemoteInput(entry, null); |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 2671 | removeNotification(entry.key, mLatestRankingMap); |
| 2672 | } |
| 2673 | mRemoteInputEntriesToRemoveOnCollapse.clear(); |
Selim Cinek | 4a21a7f | 2015-05-19 11:00:38 -0700 | [diff] [blame] | 2674 | } |
| 2675 | |
Adrian Roos | 401caae | 2016-03-04 13:35:21 -0800 | [diff] [blame] | 2676 | public void onScreenTurnedOff() { |
| 2677 | mFalsingManager.onScreenOff(); |
| 2678 | } |
| 2679 | |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 2680 | /** |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2681 | * All changes to the status bar and notifications funnel through here and are batched. |
| 2682 | */ |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2683 | private class H extends BaseStatusBar.H { |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2684 | @Override |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2685 | public void handleMessage(Message m) { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2686 | super.handleMessage(m); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2687 | switch (m.what) { |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2688 | case MSG_OPEN_NOTIFICATION_PANEL: |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2689 | animateExpandNotificationsPanel(); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2690 | break; |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2691 | case MSG_OPEN_SETTINGS_PANEL: |
Jason Monk | a992732 | 2015-12-13 16:22:37 -0500 | [diff] [blame] | 2692 | animateExpandSettingsPanel((String) m.obj); |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2693 | break; |
| 2694 | case MSG_CLOSE_PANELS: |
| 2695 | animateCollapsePanels(); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2696 | break; |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 2697 | case MSG_LAUNCH_TRANSITION_TIMEOUT: |
| 2698 | onLaunchTransitionTimeout(); |
| 2699 | break; |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2700 | } |
| 2701 | } |
| 2702 | } |
| 2703 | |
Chris Wren | 930ecca | 2014-11-12 17:43:41 -0500 | [diff] [blame] | 2704 | @Override |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2705 | public void maybeEscalateHeadsUp() { |
Selim Cinek | 3362c13 | 2016-02-11 15:43:03 -0800 | [diff] [blame] | 2706 | Collection<HeadsUpManager.HeadsUpEntry> entries = mHeadsUpManager.getAllEntries(); |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 2707 | for (HeadsUpManager.HeadsUpEntry entry : entries) { |
| 2708 | final StatusBarNotification sbn = entry.entry.notification; |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2709 | final Notification notification = sbn.getNotification(); |
| 2710 | if (notification.fullScreenIntent != null) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2711 | if (DEBUG) { |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2712 | Log.d(TAG, "converting a heads up to fullScreen"); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2713 | } |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2714 | try { |
Chris Wren | 223c66b6 | 2014-11-10 16:00:09 -0500 | [diff] [blame] | 2715 | EventLog.writeEvent(EventLogTags.SYSUI_HEADS_UP_ESCALATION, |
| 2716 | sbn.getKey()); |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2717 | notification.fullScreenIntent.send(); |
Selim Cinek | b18a20f | 2015-06-04 17:08:35 +0200 | [diff] [blame] | 2718 | entry.entry.notifyFullScreenIntentLaunched(); |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2719 | } catch (PendingIntent.CanceledException e) { |
| 2720 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2721 | } |
| 2722 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2723 | mHeadsUpManager.releaseAllImmediately(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2724 | } |
| 2725 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2726 | /** |
| 2727 | * Called for system navigation gestures. First action opens the panel, second opens |
| 2728 | * settings. Down action closes the entire panel. |
| 2729 | */ |
| 2730 | @Override |
| 2731 | public void handleSystemNavigationKey(int key) { |
| 2732 | if (SPEW) Log.d(TAG, "handleSystemNavigationKey: " + key); |
Jim Miller | 1c21fc5 | 2016-08-02 16:12:58 -0700 | [diff] [blame] | 2733 | if (!panelsEnabled() || !mKeyguardMonitor.isDeviceInteractive() |
Jim Miller | 69c1241 | 2016-10-06 19:11:03 -0700 | [diff] [blame] | 2734 | || mKeyguardMonitor.isShowing() && !mKeyguardMonitor.isOccluded()) { |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2735 | return; |
| 2736 | } |
| 2737 | |
| 2738 | // Panels are not available in setup |
| 2739 | if (!mUserSetup) return; |
| 2740 | |
| 2741 | if (KeyEvent.KEYCODE_SYSTEM_NAVIGATION_UP == key) { |
Doris Ling | 3c00afb | 2016-07-19 17:04:21 -0700 | [diff] [blame] | 2742 | MetricsLogger.action(mContext, MetricsEvent.ACTION_SYSTEM_NAVIGATION_KEY_UP); |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2743 | mNotificationPanel.collapse(false /* delayed */, 1.0f /* speedUpFactor */); |
| 2744 | } else if (KeyEvent.KEYCODE_SYSTEM_NAVIGATION_DOWN == key) { |
Doris Ling | 3c00afb | 2016-07-19 17:04:21 -0700 | [diff] [blame] | 2745 | MetricsLogger.action(mContext, MetricsEvent.ACTION_SYSTEM_NAVIGATION_KEY_DOWN); |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2746 | if (mNotificationPanel.isFullyCollapsed()) { |
| 2747 | mNotificationPanel.expand(true /* animate */); |
Doris Ling | 3c00afb | 2016-07-19 17:04:21 -0700 | [diff] [blame] | 2748 | MetricsLogger.count(mContext, NotificationPanelView.COUNTER_PANEL_OPEN, 1); |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2749 | } else if (!mNotificationPanel.isInSettings() && !mNotificationPanel.isExpanding()){ |
| 2750 | mNotificationPanel.flingSettings(0 /* velocity */, true /* expand */); |
Doris Ling | 3c00afb | 2016-07-19 17:04:21 -0700 | [diff] [blame] | 2751 | MetricsLogger.count(mContext, NotificationPanelView.COUNTER_PANEL_OPEN_QS, 1); |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2752 | } |
| 2753 | } |
| 2754 | |
| 2755 | } |
| 2756 | |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2757 | boolean panelsEnabled() { |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 2758 | return (mDisabled1 & StatusBarManager.DISABLE_EXPAND) == 0 && !ONLY_CORE_APPS; |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2759 | } |
| 2760 | |
Jorim Jaggi | fa505a7 | 2014-04-28 20:04:11 +0200 | [diff] [blame] | 2761 | void makeExpandedVisible(boolean force) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2762 | if (SPEW) Log.d(TAG, "Make expanded visible: expanded visible=" + mExpandedVisible); |
Jorim Jaggi | fa505a7 | 2014-04-28 20:04:11 +0200 | [diff] [blame] | 2763 | if (!force && (mExpandedVisible || !panelsEnabled())) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2764 | return; |
| 2765 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 2766 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2767 | mExpandedVisible = true; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2768 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 2769 | // Expand the window to encompass the full screen in anticipation of the drag. |
| 2770 | // 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] | 2771 | mStatusBarWindowManager.setPanelVisible(true); |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 2772 | |
| 2773 | visibilityChanged(true); |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 2774 | mWaitingForKeyguardExit = false; |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 2775 | recomputeDisableFlags(!force /* animate */); |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 2776 | setInteracting(StatusBarManager.WINDOW_STATUS_BAR, true); |
| 2777 | } |
| 2778 | |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2779 | public void animateCollapsePanels() { |
| 2780 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 2781 | } |
| 2782 | |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 2783 | private final Runnable mAnimateCollapsePanels = new Runnable() { |
| 2784 | @Override |
| 2785 | public void run() { |
| 2786 | animateCollapsePanels(); |
| 2787 | } |
| 2788 | }; |
| 2789 | |
| 2790 | public void postAnimateCollapsePanels() { |
| 2791 | mHandler.post(mAnimateCollapsePanels); |
| 2792 | } |
| 2793 | |
Jason Monk | ba2318e | 2015-12-08 09:04:23 -0500 | [diff] [blame] | 2794 | public void postAnimateOpenPanels() { |
| 2795 | mHandler.sendEmptyMessage(MSG_OPEN_SETTINGS_PANEL); |
| 2796 | } |
| 2797 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2798 | @Override |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2799 | public void animateCollapsePanels(int flags) { |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 2800 | animateCollapsePanels(flags, false /* force */, false /* delayed */, |
| 2801 | 1.0f /* speedUpFactor */); |
Jorim Jaggi | 3425076 | 2014-07-03 23:51:19 +0200 | [diff] [blame] | 2802 | } |
| 2803 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2804 | @Override |
Jorim Jaggi | 3425076 | 2014-07-03 23:51:19 +0200 | [diff] [blame] | 2805 | public void animateCollapsePanels(int flags, boolean force) { |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 2806 | animateCollapsePanels(flags, force, false /* delayed */, 1.0f /* speedUpFactor */); |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 2807 | } |
| 2808 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 2809 | @Override |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 2810 | public void animateCollapsePanels(int flags, boolean force, boolean delayed) { |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 2811 | animateCollapsePanels(flags, force, delayed, 1.0f /* speedUpFactor */); |
| 2812 | } |
| 2813 | |
| 2814 | public void animateCollapsePanels(int flags, boolean force, boolean delayed, |
| 2815 | float speedUpFactor) { |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 2816 | if (!force && mState != StatusBarState.SHADE) { |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2817 | runPostCollapseRunnables(); |
Jorim Jaggi | c1cf1ae | 2014-05-02 21:19:17 +0200 | [diff] [blame] | 2818 | return; |
| 2819 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2820 | if (SPEW) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2821 | Log.d(TAG, "animateCollapse():" |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2822 | + " mExpandedVisible=" + mExpandedVisible |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 2823 | + " flags=" + flags); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2824 | } |
| 2825 | |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 2826 | if ((flags & CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL) == 0) { |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame] | 2827 | if (!mHandler.hasMessages(MSG_HIDE_RECENT_APPS)) { |
| 2828 | mHandler.removeMessages(MSG_HIDE_RECENT_APPS); |
| 2829 | mHandler.sendEmptyMessage(MSG_HIDE_RECENT_APPS); |
| 2830 | } |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 2831 | } |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 2832 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 2833 | if (mStatusBarWindow != null) { |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 2834 | // release focus immediately to kick off focus change transition |
| 2835 | mStatusBarWindowManager.setStatusBarFocusable(false); |
| 2836 | |
John Spurlock | ab847cf | 2014-01-15 14:13:59 -0500 | [diff] [blame] | 2837 | mStatusBarWindow.cancelExpandHelper(); |
Xiaohui Chen | 9f96711 | 2016-01-07 14:14:06 -0800 | [diff] [blame] | 2838 | mStatusBarView.collapsePanel(true /* animate */, delayed, speedUpFactor); |
John Spurlock | ab847cf | 2014-01-15 14:13:59 -0500 | [diff] [blame] | 2839 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2840 | } |
| 2841 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2842 | private void runPostCollapseRunnables() { |
Selim Cinek | ae77f8e | 2015-07-07 18:43:59 -0700 | [diff] [blame] | 2843 | ArrayList<Runnable> clonedList = new ArrayList<>(mPostCollapseRunnables); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2844 | mPostCollapseRunnables.clear(); |
Selim Cinek | ae77f8e | 2015-07-07 18:43:59 -0700 | [diff] [blame] | 2845 | int size = clonedList.size(); |
| 2846 | for (int i = 0; i < size; i++) { |
| 2847 | clonedList.get(i).run(); |
| 2848 | } |
| 2849 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2850 | } |
| 2851 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 2852 | @Override |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2853 | public void animateExpandNotificationsPanel() { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2854 | if (SPEW) Log.d(TAG, "animateExpand: mExpandedVisible=" + mExpandedVisible); |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2855 | if (!panelsEnabled()) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2856 | return ; |
| 2857 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2858 | |
Oren Blasberg | 8d3fea1 | 2015-07-10 14:21:44 -0700 | [diff] [blame] | 2859 | mNotificationPanel.expand(true /* animate */); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2860 | |
| 2861 | if (false) postStartTracing(); |
| 2862 | } |
| 2863 | |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 2864 | @Override |
Jason Monk | a992732 | 2015-12-13 16:22:37 -0500 | [diff] [blame] | 2865 | public void animateExpandSettingsPanel(String subPanel) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2866 | if (SPEW) Log.d(TAG, "animateExpand: mExpandedVisible=" + mExpandedVisible); |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2867 | if (!panelsEnabled()) { |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 2868 | return; |
| 2869 | } |
| 2870 | |
Daniel Sandler | a8ef3b0 | 2012-11-29 15:52:39 -0500 | [diff] [blame] | 2871 | // Settings are not available in setup |
| 2872 | if (!mUserSetup) return; |
| 2873 | |
Jason Monk | a992732 | 2015-12-13 16:22:37 -0500 | [diff] [blame] | 2874 | |
| 2875 | if (subPanel != null) { |
| 2876 | mQSPanel.openDetails(subPanel); |
| 2877 | } |
Jason Monk | 3c68ca2 | 2015-01-30 11:30:29 -0500 | [diff] [blame] | 2878 | mNotificationPanel.expandWithQs(); |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 2879 | |
| 2880 | if (false) postStartTracing(); |
| 2881 | } |
| 2882 | |
| 2883 | public void animateCollapseQuickSettings() { |
Jorim Jaggi | 449981b | 2014-10-03 14:24:55 -0700 | [diff] [blame] | 2884 | if (mState == StatusBarState.SHADE) { |
Xiaohui Chen | 9f96711 | 2016-01-07 14:14:06 -0800 | [diff] [blame] | 2885 | mStatusBarView.collapsePanel(true, false /* delayed */, 1.0f /* speedUpFactor */); |
Jorim Jaggi | 449981b | 2014-10-03 14:24:55 -0700 | [diff] [blame] | 2886 | } |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 2887 | } |
| 2888 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 2889 | void makeExpandedInvisible() { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2890 | if (SPEW) Log.d(TAG, "makeExpandedInvisible: mExpandedVisible=" + mExpandedVisible |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2891 | + " mExpandedVisible=" + mExpandedVisible); |
| 2892 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 2893 | if (!mExpandedVisible || mStatusBarWindow == null) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2894 | return; |
| 2895 | } |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 2896 | |
Daniel Sandler | c38bbc3 | 2012-10-05 12:21:38 -0400 | [diff] [blame] | 2897 | // Ensure the panel is fully collapsed (just in case; bug 6765842, 7260868) |
Xiaohui Chen | 9f96711 | 2016-01-07 14:14:06 -0800 | [diff] [blame] | 2898 | mStatusBarView.collapsePanel(/*animate=*/ false, false /* delayed*/, |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 2899 | 1.0f /* speedUpFactor */); |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 2900 | |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 2901 | mNotificationPanel.closeQs(); |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 2902 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2903 | mExpandedVisible = false; |
Jorim Jaggi | c59a23f | 2016-05-24 14:53:36 -0700 | [diff] [blame] | 2904 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2905 | visibilityChanged(false); |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 2906 | |
| 2907 | // Shrink the window to the size of the status bar only |
Selim Cinek | 4a21a7f | 2015-05-19 11:00:38 -0700 | [diff] [blame] | 2908 | mStatusBarWindowManager.setPanelVisible(false); |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2909 | mStatusBarWindowManager.setForceStatusBarVisible(false); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2910 | |
Daniel Sandler | 469e96e | 2012-05-04 15:56:19 -0400 | [diff] [blame] | 2911 | // Close any "App info" popups that might have snuck on-screen |
| 2912 | dismissPopups(); |
| 2913 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2914 | runPostCollapseRunnables(); |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 2915 | setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 2916 | showBouncer(); |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 2917 | recomputeDisableFlags(true /* animate */); |
Jorim Jaggi | 786afcb | 2014-09-25 02:41:29 +0200 | [diff] [blame] | 2918 | |
| 2919 | // Trimming will happen later if Keyguard is showing - doing it here might cause a jank in |
| 2920 | // the bouncer appear animation. |
| 2921 | if (!mStatusBarKeyguardViewManager.isShowing()) { |
| 2922 | WindowManagerGlobal.getInstance().trimMemory(ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN); |
| 2923 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2924 | } |
| 2925 | |
Daniel Sandler | b17a726 | 2012-10-05 14:32:50 -0400 | [diff] [blame] | 2926 | public boolean interceptTouchEvent(MotionEvent event) { |
Chris Wren | 64161cc | 2012-12-17 16:49:30 -0500 | [diff] [blame] | 2927 | if (DEBUG_GESTURES) { |
| 2928 | if (event.getActionMasked() != MotionEvent.ACTION_MOVE) { |
| 2929 | EventLog.writeEvent(EventLogTags.SYSUI_STATUSBAR_TOUCH, |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2930 | event.getActionMasked(), (int) event.getX(), (int) event.getY(), |
| 2931 | mDisabled1, mDisabled2); |
Chris Wren | 64161cc | 2012-12-17 16:49:30 -0500 | [diff] [blame] | 2932 | } |
| 2933 | |
| 2934 | } |
| 2935 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2936 | if (SPEW) { |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2937 | Log.d(TAG, "Touch: rawY=" + event.getRawY() + " event=" + event + " mDisabled1=" |
| 2938 | + mDisabled1 + " mDisabled2=" + mDisabled2 + " mTracking=" + mTracking); |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 2939 | } else if (CHATTY) { |
Daniel Sandler | fe172cc | 2011-09-12 13:47:25 -0400 | [diff] [blame] | 2940 | if (event.getAction() != MotionEvent.ACTION_MOVE) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2941 | Log.d(TAG, String.format( |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2942 | "panel: %s at (%f, %f) mDisabled1=0x%08x mDisabled2=0x%08x", |
Daniel Sandler | fe172cc | 2011-09-12 13:47:25 -0400 | [diff] [blame] | 2943 | MotionEvent.actionToString(event.getAction()), |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2944 | event.getRawX(), event.getRawY(), mDisabled1, mDisabled2)); |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 2945 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2946 | } |
| 2947 | |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 2948 | if (DEBUG_GESTURES) { |
| 2949 | mGestureRec.add(event); |
| 2950 | } |
Daniel Sandler | 3380534 | 2012-07-23 15:45:12 -0400 | [diff] [blame] | 2951 | |
John Spurlock | 686820a | 2013-09-03 14:44:16 -0400 | [diff] [blame] | 2952 | if (mStatusBarWindowState == WINDOW_STATE_SHOWING) { |
John Spurlock | 5fee836 | 2013-09-12 10:34:33 -0400 | [diff] [blame] | 2953 | final boolean upOrCancel = |
| 2954 | event.getAction() == MotionEvent.ACTION_UP || |
| 2955 | event.getAction() == MotionEvent.ACTION_CANCEL; |
| 2956 | if (upOrCancel && !mExpandedVisible) { |
| 2957 | setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false); |
| 2958 | } else { |
| 2959 | setInteracting(StatusBarManager.WINDOW_STATUS_BAR, true); |
| 2960 | } |
John Spurlock | 686820a | 2013-09-03 14:44:16 -0400 | [diff] [blame] | 2961 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2962 | return false; |
| 2963 | } |
| 2964 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 2965 | public GestureRecorder getGestureRecorder() { |
| 2966 | return mGestureRec; |
Jeff Brown | 911fe30 | 2011-09-12 14:21:17 -0700 | [diff] [blame] | 2967 | } |
| 2968 | |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 2969 | private void setNavigationIconHints(int hints) { |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 2970 | if (hints == mNavigationIconHints) return; |
| 2971 | |
| 2972 | mNavigationIconHints = hints; |
| 2973 | |
| 2974 | if (mNavigationBarView != null) { |
| 2975 | mNavigationBarView.setNavigationIconHints(hints); |
| 2976 | } |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2977 | checkBarModes(); |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 2978 | } |
| 2979 | |
| 2980 | @Override // CommandQueue |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2981 | public void setWindowState(int window, int state) { |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2982 | boolean showing = state == WINDOW_STATE_SHOWING; |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2983 | if (mStatusBarWindow != null |
| 2984 | && window == StatusBarManager.WINDOW_STATUS_BAR |
| 2985 | && mStatusBarWindowState != state) { |
| 2986 | mStatusBarWindowState = state; |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 2987 | if (DEBUG_WINDOW_STATE) Log.d(TAG, "Status bar " + windowStateToString(state)); |
Jorim Jaggi | 449981b | 2014-10-03 14:24:55 -0700 | [diff] [blame] | 2988 | if (!showing && mState == StatusBarState.SHADE) { |
Xiaohui Chen | 9f96711 | 2016-01-07 14:14:06 -0800 | [diff] [blame] | 2989 | mStatusBarView.collapsePanel(false /* animate */, false /* delayed */, |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 2990 | 1.0f /* speedUpFactor */); |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2991 | } |
| 2992 | } |
| 2993 | if (mNavigationBarView != null |
| 2994 | && window == StatusBarManager.WINDOW_NAVIGATION_BAR |
| 2995 | && mNavigationBarWindowState != state) { |
| 2996 | mNavigationBarWindowState = state; |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 2997 | if (DEBUG_WINDOW_STATE) Log.d(TAG, "Navigation bar " + windowStateToString(state)); |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2998 | } |
| 2999 | } |
| 3000 | |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 3001 | @Override // CommandQueue |
John Spurlock | cad5768 | 2014-07-26 17:09:56 -0400 | [diff] [blame] | 3002 | public void buzzBeepBlinked() { |
| 3003 | if (mDozeServiceHost != null) { |
| 3004 | mDozeServiceHost.fireBuzzBeepBlinked(); |
| 3005 | } |
| 3006 | } |
| 3007 | |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 3008 | @Override |
| 3009 | public void notificationLightOff() { |
| 3010 | if (mDozeServiceHost != null) { |
| 3011 | mDozeServiceHost.fireNotificationLight(false); |
| 3012 | } |
| 3013 | } |
| 3014 | |
| 3015 | @Override |
| 3016 | public void notificationLightPulse(int argb, int onMillis, int offMillis) { |
| 3017 | if (mDozeServiceHost != null) { |
| 3018 | mDozeServiceHost.fireNotificationLight(true); |
| 3019 | } |
| 3020 | } |
| 3021 | |
John Spurlock | cad5768 | 2014-07-26 17:09:56 -0400 | [diff] [blame] | 3022 | @Override // CommandQueue |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 3023 | public void setSystemUiVisibility(int vis, int fullscreenStackVis, int dockedStackVis, |
| 3024 | int mask, Rect fullscreenStackBounds, Rect dockedStackBounds) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3025 | final int oldVal = mSystemUiVisibility; |
| 3026 | final int newVal = (oldVal&~mask) | (vis&mask); |
| 3027 | final int diff = newVal ^ oldVal; |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 3028 | if (DEBUG) Log.d(TAG, String.format( |
John Spurlock | dcf4f21 | 2013-05-21 17:19:53 -0400 | [diff] [blame] | 3029 | "setSystemUiVisibility vis=%s mask=%s oldVal=%s newVal=%s diff=%s", |
| 3030 | Integer.toHexString(vis), Integer.toHexString(mask), |
| 3031 | Integer.toHexString(oldVal), Integer.toHexString(newVal), |
| 3032 | Integer.toHexString(diff))); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 3033 | boolean sbModeChanged = false; |
Daniel Sandler | e137a1e | 2011-08-17 16:47:19 -0400 | [diff] [blame] | 3034 | if (diff != 0) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3035 | mSystemUiVisibility = newVal; |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 3036 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3037 | // update low profile |
| 3038 | if ((diff & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) { |
John Spurlock | 7edfbca | 2013-09-14 11:58:55 -0400 | [diff] [blame] | 3039 | setAreThereNotifications(); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 3040 | } |
| 3041 | |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 3042 | // ready to unhide |
| 3043 | if ((vis & View.STATUS_BAR_UNHIDE) != 0) { |
| 3044 | mSystemUiVisibility &= ~View.STATUS_BAR_UNHIDE; |
| 3045 | mNoAnimationOnNextBarModeChange = true; |
| 3046 | } |
| 3047 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3048 | // update status bar mode |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3049 | final int sbMode = computeBarMode(oldVal, newVal, mStatusBarView.getBarTransitions(), |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 3050 | View.STATUS_BAR_TRANSIENT, View.STATUS_BAR_TRANSLUCENT, |
| 3051 | View.STATUS_BAR_TRANSPARENT); |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3052 | |
| 3053 | // update navigation bar mode |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3054 | final int nbMode = mNavigationBarView == null ? -1 : computeBarMode( |
John Spurlock | f6b6397 | 2013-08-27 16:08:28 -0400 | [diff] [blame] | 3055 | oldVal, newVal, mNavigationBarView.getBarTransitions(), |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 3056 | View.NAVIGATION_BAR_TRANSIENT, View.NAVIGATION_BAR_TRANSLUCENT, |
| 3057 | View.NAVIGATION_BAR_TRANSPARENT); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 3058 | sbModeChanged = sbMode != -1; |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3059 | final boolean nbModeChanged = nbMode != -1; |
| 3060 | boolean checkBarModes = false; |
| 3061 | if (sbModeChanged && sbMode != mStatusBarMode) { |
| 3062 | mStatusBarMode = sbMode; |
| 3063 | checkBarModes = true; |
| 3064 | } |
| 3065 | if (nbModeChanged && nbMode != mNavigationBarMode) { |
| 3066 | mNavigationBarMode = nbMode; |
| 3067 | checkBarModes = true; |
| 3068 | } |
| 3069 | if (checkBarModes) { |
| 3070 | checkBarModes(); |
| 3071 | } |
| 3072 | if (sbModeChanged || nbModeChanged) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3073 | // update transient bar autohide |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3074 | if (mStatusBarMode == MODE_SEMI_TRANSPARENT || mNavigationBarMode == MODE_SEMI_TRANSPARENT) { |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3075 | scheduleAutohide(); |
| 3076 | } else { |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3077 | cancelAutohide(); |
| 3078 | } |
| 3079 | } |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3080 | |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 3081 | if ((vis & View.NAVIGATION_BAR_UNHIDE) != 0) { |
| 3082 | mSystemUiVisibility &= ~View.NAVIGATION_BAR_UNHIDE; |
| 3083 | } |
| 3084 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3085 | // send updated sysui visibility to window manager |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3086 | notifyUiVisibilityChanged(mSystemUiVisibility); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3087 | } |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 3088 | |
| 3089 | mLightStatusBarController.onSystemUiVisibilityChanged(fullscreenStackVis, dockedStackVis, |
| 3090 | mask, fullscreenStackBounds, dockedStackBounds, sbModeChanged, mStatusBarMode); |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 3091 | } |
| 3092 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3093 | private int computeBarMode(int oldVis, int newVis, BarTransitions transitions, |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 3094 | int transientFlag, int translucentFlag, int transparentFlag) { |
| 3095 | final int oldMode = barMode(oldVis, transientFlag, translucentFlag, transparentFlag); |
| 3096 | final int newMode = barMode(newVis, transientFlag, translucentFlag, transparentFlag); |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3097 | if (oldMode == newMode) { |
| 3098 | return -1; // no mode change |
| 3099 | } |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3100 | return newMode; |
| 3101 | } |
| 3102 | |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 3103 | private int barMode(int vis, int transientFlag, int translucentFlag, int transparentFlag) { |
| 3104 | int lightsOutTransparent = View.SYSTEM_UI_FLAG_LOW_PROFILE | transparentFlag; |
John Spurlock | 89835dd | 2013-08-16 15:06:51 -0400 | [diff] [blame] | 3105 | return (vis & transientFlag) != 0 ? MODE_SEMI_TRANSPARENT |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3106 | : (vis & translucentFlag) != 0 ? MODE_TRANSLUCENT |
Adrian Roos | c0f0a74 | 2014-10-28 16:39:56 +0100 | [diff] [blame] | 3107 | : (vis & lightsOutTransparent) == lightsOutTransparent ? MODE_LIGHTS_OUT_TRANSPARENT |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 3108 | : (vis & transparentFlag) != 0 ? MODE_TRANSPARENT |
John Spurlock | 7edfbca | 2013-09-14 11:58:55 -0400 | [diff] [blame] | 3109 | : (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0 ? MODE_LIGHTS_OUT |
John Spurlock | 3b139a9 | 2013-08-17 17:18:08 -0400 | [diff] [blame] | 3110 | : MODE_OPAQUE; |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3111 | } |
| 3112 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3113 | private void checkBarModes() { |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3114 | if (mDemoMode) return; |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 3115 | checkBarMode(mStatusBarMode, mStatusBarWindowState, mStatusBarView.getBarTransitions(), |
| 3116 | mNoAnimationOnNextBarModeChange); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3117 | if (mNavigationBarView != null) { |
| 3118 | checkBarMode(mNavigationBarMode, |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 3119 | mNavigationBarWindowState, mNavigationBarView.getBarTransitions(), |
| 3120 | mNoAnimationOnNextBarModeChange); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3121 | } |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 3122 | mNoAnimationOnNextBarModeChange = false; |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3123 | } |
| 3124 | |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 3125 | private void checkBarMode(int mode, int windowState, BarTransitions transitions, |
| 3126 | boolean noAnimation) { |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 3127 | final boolean powerSave = mBatteryController.isPowerSave(); |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 3128 | final boolean anim = !noAnimation && mDeviceInteractive |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 3129 | && windowState != WINDOW_STATE_HIDDEN && !powerSave; |
John Spurlock | 1bb480a | 2014-08-02 17:12:43 -0400 | [diff] [blame] | 3130 | if (powerSave && getBarState() == StatusBarState.SHADE) { |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 3131 | mode = MODE_WARNING; |
| 3132 | } |
John Spurlock | c68d577 | 2013-10-08 11:47:58 -0400 | [diff] [blame] | 3133 | transitions.transitionTo(mode, anim); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3134 | } |
| 3135 | |
John Spurlock | 4219726 | 2013-10-21 09:32:25 -0400 | [diff] [blame] | 3136 | private void finishBarAnimations() { |
| 3137 | mStatusBarView.getBarTransitions().finishAnimations(); |
| 3138 | if (mNavigationBarView != null) { |
| 3139 | mNavigationBarView.getBarTransitions().finishAnimations(); |
| 3140 | } |
| 3141 | } |
| 3142 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3143 | private final Runnable mCheckBarModes = new Runnable() { |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 3144 | @Override |
| 3145 | public void run() { |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3146 | checkBarModes(); |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 3147 | } |
| 3148 | }; |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 3149 | |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3150 | @Override |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 3151 | public void setInteracting(int barWindow, boolean interacting) { |
John Spurlock | 7fbf573 | 2014-11-18 11:40:22 -0500 | [diff] [blame] | 3152 | final boolean changing = ((mInteractingWindows & barWindow) != 0) != interacting; |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 3153 | mInteractingWindows = interacting |
| 3154 | ? (mInteractingWindows | barWindow) |
| 3155 | : (mInteractingWindows & ~barWindow); |
| 3156 | if (mInteractingWindows != 0) { |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3157 | suspendAutohide(); |
| 3158 | } else { |
| 3159 | resumeSuspendedAutohide(); |
| 3160 | } |
John Spurlock | 7fbf573 | 2014-11-18 11:40:22 -0500 | [diff] [blame] | 3161 | // manually dismiss the volume panel when interacting with the nav bar |
| 3162 | if (changing && interacting && barWindow == StatusBarManager.WINDOW_NAVIGATION_BAR) { |
John Spurlock | b349af57 | 2015-04-29 12:24:19 -0400 | [diff] [blame] | 3163 | dismissVolumeDialog(); |
John Spurlock | 7fbf573 | 2014-11-18 11:40:22 -0500 | [diff] [blame] | 3164 | } |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3165 | checkBarModes(); |
| 3166 | } |
| 3167 | |
John Spurlock | b349af57 | 2015-04-29 12:24:19 -0400 | [diff] [blame] | 3168 | private void dismissVolumeDialog() { |
| 3169 | if (mVolumeComponent != null) { |
| 3170 | mVolumeComponent.dismissNow(); |
| 3171 | } |
| 3172 | } |
| 3173 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3174 | private void resumeSuspendedAutohide() { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3175 | if (mAutohideSuspended) { |
| 3176 | scheduleAutohide(); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3177 | mHandler.postDelayed(mCheckBarModes, 500); // longer than home -> launcher |
John Spurlock | 3b139a9 | 2013-08-17 17:18:08 -0400 | [diff] [blame] | 3178 | } |
| 3179 | } |
| 3180 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3181 | private void suspendAutohide() { |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3182 | mHandler.removeCallbacks(mAutohide); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3183 | mHandler.removeCallbacks(mCheckBarModes); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 3184 | mAutohideSuspended = (mSystemUiVisibility & STATUS_OR_NAV_TRANSIENT) != 0; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3185 | } |
| 3186 | |
| 3187 | private void cancelAutohide() { |
| 3188 | mAutohideSuspended = false; |
| 3189 | mHandler.removeCallbacks(mAutohide); |
| 3190 | } |
| 3191 | |
| 3192 | private void scheduleAutohide() { |
| 3193 | cancelAutohide(); |
| 3194 | mHandler.postDelayed(mAutohide, AUTOHIDE_TIMEOUT_MS); |
| 3195 | } |
| 3196 | |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 3197 | private void checkUserAutohide(View v, MotionEvent event) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3198 | if ((mSystemUiVisibility & STATUS_OR_NAV_TRANSIENT) != 0 // a transient bar is revealed |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 3199 | && event.getAction() == MotionEvent.ACTION_OUTSIDE // touch outside the source bar |
| 3200 | && event.getX() == 0 && event.getY() == 0 // a touch outside both bars |
Adrian Roos | 5e47645 | 2016-05-27 12:07:33 -0700 | [diff] [blame] | 3201 | && !mRemoteInputController.isRemoteInputActive()) { // not due to typing in IME |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 3202 | userAutohide(); |
| 3203 | } |
| 3204 | } |
| 3205 | |
| 3206 | private void userAutohide() { |
| 3207 | cancelAutohide(); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 3208 | mHandler.postDelayed(mAutohide, 350); // longer than app gesture -> flag clear |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 3209 | } |
| 3210 | |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 3211 | private boolean areLightsOn() { |
| 3212 | return 0 == (mSystemUiVisibility & View.SYSTEM_UI_FLAG_LOW_PROFILE); |
| 3213 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 3214 | |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 3215 | public void setLightsOn(boolean on) { |
| 3216 | Log.v(TAG, "setLightsOn(" + on + ")"); |
| 3217 | if (on) { |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 3218 | setSystemUiVisibility(0, 0, 0, View.SYSTEM_UI_FLAG_LOW_PROFILE, |
| 3219 | mLastFullscreenStackBounds, mLastDockedStackBounds); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 3220 | } else { |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 3221 | setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE, 0, 0, |
| 3222 | View.SYSTEM_UI_FLAG_LOW_PROFILE, mLastFullscreenStackBounds, |
| 3223 | mLastDockedStackBounds); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 3224 | } |
| 3225 | } |
| 3226 | |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3227 | private void notifyUiVisibilityChanged(int vis) { |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 3228 | try { |
Adrian Roos | 389beec | 2015-05-12 13:33:25 -0700 | [diff] [blame] | 3229 | if (mLastDispatchedSystemUiVisibility != vis) { |
| 3230 | mWindowManagerService.statusBarVisibilityChanged(vis); |
| 3231 | mLastDispatchedSystemUiVisibility = vis; |
| 3232 | } |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 3233 | } catch (RemoteException ex) { |
| 3234 | } |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3235 | } |
| 3236 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 3237 | @Override |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 3238 | public void topAppWindowChanged(boolean showMenu) { |
Chris Wren | 8a1638f | 2016-05-02 16:19:14 -0400 | [diff] [blame] | 3239 | if (SPEW) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 3240 | Log.d(TAG, (showMenu?"showing":"hiding") + " the MENU button"); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 3241 | } |
| 3242 | if (mNavigationBarView != null) { |
Daniel Sandler | f1ebcee | 2011-09-15 16:02:56 -0400 | [diff] [blame] | 3243 | mNavigationBarView.setMenuVisibility(showMenu); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 3244 | } |
| 3245 | |
| 3246 | // See above re: lights-out policy for legacy apps. |
| 3247 | if (showMenu) setLightsOn(true); |
| 3248 | } |
| 3249 | |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 3250 | @Override |
Jason Monk | b605fec | 2014-05-02 17:04:10 -0400 | [diff] [blame] | 3251 | public void setImeWindowStatus(IBinder token, int vis, int backDisposition, |
| 3252 | boolean showImeSwitcher) { |
Jason Monk | f1ff209 | 2014-04-29 16:50:53 -0400 | [diff] [blame] | 3253 | boolean imeShown = (vis & InputMethodService.IME_VISIBLE) != 0; |
| 3254 | int flags = mNavigationIconHints; |
| 3255 | if ((backDisposition == InputMethodService.BACK_DISPOSITION_WILL_DISMISS) || imeShown) { |
| 3256 | flags |= NAVIGATION_HINT_BACK_ALT; |
| 3257 | } else { |
| 3258 | flags &= ~NAVIGATION_HINT_BACK_ALT; |
| 3259 | } |
Jason Monk | b605fec | 2014-05-02 17:04:10 -0400 | [diff] [blame] | 3260 | if (showImeSwitcher) { |
Jason Monk | f1ff209 | 2014-04-29 16:50:53 -0400 | [diff] [blame] | 3261 | flags |= NAVIGATION_HINT_IME_SHOWN; |
| 3262 | } else { |
| 3263 | flags &= ~NAVIGATION_HINT_IME_SHOWN; |
| 3264 | } |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 3265 | |
Jason Monk | f1ff209 | 2014-04-29 16:50:53 -0400 | [diff] [blame] | 3266 | setNavigationIconHints(flags); |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 3267 | } |
| 3268 | |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 3269 | public static String viewInfo(View v) { |
| 3270 | return "[(" + v.getLeft() + "," + v.getTop() + ")(" + v.getRight() + "," + v.getBottom() |
| 3271 | + ") " + v.getWidth() + "x" + v.getHeight() + "]"; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3272 | } |
| 3273 | |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 3274 | @Override |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 3275 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3276 | synchronized (mQueueLock) { |
| 3277 | pw.println("Current Status Bar state:"); |
Daniel Sandler | e7237fc | 2012-08-14 16:08:27 -0400 | [diff] [blame] | 3278 | pw.println(" mExpandedVisible=" + mExpandedVisible |
Daniel Sandler | fdbac77 | 2012-07-03 14:30:10 -0400 | [diff] [blame] | 3279 | + ", mTrackingPosition=" + mTrackingPosition); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3280 | pw.println(" mTracking=" + mTracking); |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 3281 | pw.println(" mDisplayMetrics=" + mDisplayMetrics); |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 3282 | pw.println(" mStackScroller: " + viewInfo(mStackScroller)); |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 3283 | pw.println(" mStackScroller: " + viewInfo(mStackScroller) |
| 3284 | + " scroll " + mStackScroller.getScrollX() |
| 3285 | + "," + mStackScroller.getScrollY()); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3286 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3287 | |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 3288 | pw.print(" mInteractingWindows="); pw.println(mInteractingWindows); |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 3289 | pw.print(" mStatusBarWindowState="); |
| 3290 | pw.println(windowStateToString(mStatusBarWindowState)); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3291 | pw.print(" mStatusBarMode="); |
| 3292 | pw.println(BarTransitions.modeToString(mStatusBarMode)); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 3293 | pw.print(" mDozing="); pw.println(mDozing); |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 3294 | pw.print(" mZenMode="); |
| 3295 | pw.println(Settings.Global.zenModeToString(mZenMode)); |
Chris Wren | 3b6745b | 2014-03-07 14:34:35 -0500 | [diff] [blame] | 3296 | pw.print(" mUseHeadsUp="); |
| 3297 | pw.println(mUseHeadsUp); |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 3298 | dumpBarTransitions(pw, "mStatusBarView", mStatusBarView.getBarTransitions()); |
| 3299 | if (mNavigationBarView != null) { |
| 3300 | pw.print(" mNavigationBarWindowState="); |
| 3301 | pw.println(windowStateToString(mNavigationBarWindowState)); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3302 | pw.print(" mNavigationBarMode="); |
| 3303 | pw.println(BarTransitions.modeToString(mNavigationBarMode)); |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 3304 | dumpBarTransitions(pw, "mNavigationBarView", mNavigationBarView.getBarTransitions()); |
| 3305 | } |
| 3306 | |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 3307 | pw.print(" mNavigationBarView="); |
| 3308 | if (mNavigationBarView == null) { |
| 3309 | pw.println("null"); |
| 3310 | } else { |
| 3311 | mNavigationBarView.dump(fd, pw, args); |
| 3312 | } |
| 3313 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 3314 | pw.print(" mMediaSessionManager="); |
| 3315 | pw.println(mMediaSessionManager); |
| 3316 | pw.print(" mMediaNotificationKey="); |
| 3317 | pw.println(mMediaNotificationKey); |
| 3318 | pw.print(" mMediaController="); |
| 3319 | pw.print(mMediaController); |
| 3320 | if (mMediaController != null) { |
| 3321 | pw.print(" state=" + mMediaController.getPlaybackState()); |
| 3322 | } |
| 3323 | pw.println(); |
| 3324 | pw.print(" mMediaMetadata="); |
| 3325 | pw.print(mMediaMetadata); |
| 3326 | if (mMediaMetadata != null) { |
RoboErik | 75847b9 | 2014-07-29 13:10:17 -0700 | [diff] [blame] | 3327 | pw.print(" title=" + mMediaMetadata.getText(MediaMetadata.METADATA_KEY_TITLE)); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 3328 | } |
| 3329 | pw.println(); |
| 3330 | |
Daniel Sandler | 37a38aa | 2013-02-13 17:15:57 -0500 | [diff] [blame] | 3331 | pw.println(" Panels: "); |
| 3332 | if (mNotificationPanel != null) { |
| 3333 | pw.println(" mNotificationPanel=" + |
| 3334 | mNotificationPanel + " params=" + mNotificationPanel.getLayoutParams().debug("")); |
| 3335 | pw.print (" "); |
| 3336 | mNotificationPanel.dump(fd, pw, args); |
| 3337 | } |
Daniel Sandler | 37a38aa | 2013-02-13 17:15:57 -0500 | [diff] [blame] | 3338 | |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 3339 | DozeLog.dump(pw); |
| 3340 | |
Daniel Sandler | 7579bca | 2011-08-18 15:47:26 -0400 | [diff] [blame] | 3341 | if (DUMPTRUCK) { |
| 3342 | synchronized (mNotificationData) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 3343 | mNotificationData.dump(pw, " "); |
Daniel Sandler | 7579bca | 2011-08-18 15:47:26 -0400 | [diff] [blame] | 3344 | } |
| 3345 | |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 3346 | mIconController.dump(pw); |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 3347 | |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 3348 | if (false) { |
| 3349 | pw.println("see the logcat for a dump of the views we have created."); |
| 3350 | // must happen on ui thread |
| 3351 | mHandler.post(new Runnable() { |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 3352 | @Override |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 3353 | public void run() { |
| 3354 | mStatusBarView.getLocationOnScreen(mAbsPos); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 3355 | Log.d(TAG, "mStatusBarView: ----- (" + mAbsPos[0] + "," + mAbsPos[1] |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 3356 | + ") " + mStatusBarView.getWidth() + "x" |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 3357 | + getStatusBarHeight()); |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 3358 | mStatusBarView.debug(); |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 3359 | } |
| 3360 | }); |
| 3361 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3362 | } |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 3363 | |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 3364 | if (DEBUG_GESTURES) { |
| 3365 | pw.print(" status bar gestures: "); |
| 3366 | mGestureRec.dump(fd, pw, args); |
| 3367 | } |
Selim Cinek | 7025f26 | 2015-07-13 16:22:48 -0700 | [diff] [blame] | 3368 | if (mStatusBarWindowManager != null) { |
| 3369 | mStatusBarWindowManager.dump(fd, pw, args); |
| 3370 | } |
John Spurlock | 486b78e | 2014-07-07 08:37:56 -0400 | [diff] [blame] | 3371 | if (mNetworkController != null) { |
| 3372 | mNetworkController.dump(fd, pw, args); |
| 3373 | } |
| 3374 | if (mBluetoothController != null) { |
| 3375 | mBluetoothController.dump(fd, pw, args); |
| 3376 | } |
Jason Monk | dd5bdc6 | 2015-07-20 12:18:38 -0400 | [diff] [blame] | 3377 | if (mHotspotController != null) { |
| 3378 | mHotspotController.dump(fd, pw, args); |
| 3379 | } |
John Spurlock | 1e6eb17 | 2014-07-13 11:59:50 -0400 | [diff] [blame] | 3380 | if (mCastController != null) { |
| 3381 | mCastController.dump(fd, pw, args); |
| 3382 | } |
Adrian Roos | 00a0b1f | 2014-07-16 16:44:49 +0200 | [diff] [blame] | 3383 | if (mUserSwitcherController != null) { |
| 3384 | mUserSwitcherController.dump(fd, pw, args); |
| 3385 | } |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 3386 | if (mBatteryController != null) { |
| 3387 | mBatteryController.dump(fd, pw, args); |
| 3388 | } |
Jorim Jaggi | c7dea6e | 2014-07-26 14:36:57 +0200 | [diff] [blame] | 3389 | if (mNextAlarmController != null) { |
| 3390 | mNextAlarmController.dump(fd, pw, args); |
| 3391 | } |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 3392 | if (mSecurityController != null) { |
| 3393 | mSecurityController.dump(fd, pw, args); |
| 3394 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 3395 | if (mHeadsUpManager != null) { |
| 3396 | mHeadsUpManager.dump(fd, pw, args); |
Chris Wren | 428c6b6 | 2014-12-05 16:07:06 -0500 | [diff] [blame] | 3397 | } else { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 3398 | pw.println(" mHeadsUpManager: null"); |
Chris Wren | 428c6b6 | 2014-12-05 16:07:06 -0500 | [diff] [blame] | 3399 | } |
Selim Cinek | 52941c5 | 2016-05-07 18:29:32 -0400 | [diff] [blame] | 3400 | if (mGroupManager != null) { |
| 3401 | mGroupManager.dump(fd, pw, args); |
| 3402 | } else { |
| 3403 | pw.println(" mGroupManager: null"); |
| 3404 | } |
Jason Monk | ab52527 | 2015-07-13 17:02:49 -0400 | [diff] [blame] | 3405 | if (KeyguardUpdateMonitor.getInstance(mContext) != null) { |
| 3406 | KeyguardUpdateMonitor.getInstance(mContext).dump(fd, pw, args); |
| 3407 | } |
Jason Monk | ad32c55 | 2016-10-04 14:50:11 -0400 | [diff] [blame] | 3408 | if (mFlashlightController != null) { |
| 3409 | mFlashlightController.dump(fd, pw, args); |
| 3410 | } |
Chris Wren | 428c6b6 | 2014-12-05 16:07:06 -0500 | [diff] [blame] | 3411 | |
Adrian Roos | 401caae | 2016-03-04 13:35:21 -0800 | [diff] [blame] | 3412 | FalsingManager.getInstance(mContext).dump(pw); |
| 3413 | FalsingLog.dump(pw); |
| 3414 | |
John Spurlock | 7bbb9f6 | 2014-10-21 12:15:28 -0400 | [diff] [blame] | 3415 | pw.println("SharedPreferences:"); |
Andrew Flynn | 8286257 | 2015-04-01 14:22:37 -0400 | [diff] [blame] | 3416 | for (Map.Entry<String, ?> entry : Prefs.getAll(mContext).entrySet()) { |
John Spurlock | 7bbb9f6 | 2014-10-21 12:15:28 -0400 | [diff] [blame] | 3417 | pw.print(" "); pw.print(entry.getKey()); pw.print("="); pw.println(entry.getValue()); |
| 3418 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3419 | } |
| 3420 | |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 3421 | private static void dumpBarTransitions(PrintWriter pw, String var, BarTransitions transitions) { |
| 3422 | pw.print(" "); pw.print(var); pw.print(".BarTransitions.mMode="); |
| 3423 | pw.println(BarTransitions.modeToString(transitions.getMode())); |
| 3424 | } |
| 3425 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 3426 | @Override |
| 3427 | public void createAndAddWindows() { |
| 3428 | addStatusBarWindow(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3429 | } |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 3430 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 3431 | private void addStatusBarWindow() { |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 3432 | makeStatusBarView(); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3433 | mStatusBarWindowManager = new StatusBarWindowManager(mContext); |
Adrian Roos | 1c0ca50 | 2015-10-07 12:20:42 -0700 | [diff] [blame] | 3434 | mRemoteInputController = new RemoteInputController(mStatusBarWindowManager, |
| 3435 | mHeadsUpManager); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3436 | mStatusBarWindowManager.add(mStatusBarWindow, getStatusBarHeight()); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3437 | } |
| 3438 | |
Daniel Sandler | 747a9e9 | 2012-08-10 16:39:19 -0400 | [diff] [blame] | 3439 | // called by makeStatusbar and also by PhoneStatusBarView |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 3440 | void updateDisplaySize() { |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 3441 | mDisplay.getMetrics(mDisplayMetrics); |
Daniel Sandler | 7e8ae50 | 2013-10-10 23:38:19 -0400 | [diff] [blame] | 3442 | mDisplay.getSize(mCurrentDisplaySize); |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 3443 | if (DEBUG_GESTURES) { |
John Spurlock | 209bede | 2013-07-17 12:23:27 -0400 | [diff] [blame] | 3444 | mGestureRec.tag("display", |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 3445 | String.format("%dx%d", mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels)); |
| 3446 | } |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 3447 | } |
| 3448 | |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 3449 | float getDisplayDensity() { |
| 3450 | return mDisplayMetrics.density; |
| 3451 | } |
| 3452 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 3453 | public void startActivityDismissingKeyguard(final Intent intent, boolean onlyProvisioned, |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3454 | boolean dismissShade) { |
| 3455 | startActivityDismissingKeyguard(intent, onlyProvisioned, dismissShade, null /* callback */); |
| 3456 | } |
| 3457 | |
| 3458 | public void startActivityDismissingKeyguard(final Intent intent, boolean onlyProvisioned, |
| 3459 | final boolean dismissShade, final Callback callback) { |
Daniel Sandler | 3679bf5 | 2012-10-16 21:30:28 -0400 | [diff] [blame] | 3460 | if (onlyProvisioned && !isDeviceProvisioned()) return; |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 3461 | |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 3462 | final boolean afterKeyguardGone = PreviewInflater.wouldLaunchResolverActivity( |
| 3463 | mContext, intent, mCurrentUserId); |
Jorim Jaggi | c7dea6e | 2014-07-26 14:36:57 +0200 | [diff] [blame] | 3464 | final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing(); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3465 | Runnable runnable = new Runnable() { |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 3466 | @Override |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3467 | public void run() { |
Jorim Jaggi | b835dd7 | 2015-06-08 12:28:42 -0700 | [diff] [blame] | 3468 | mAssistManager.hideAssist(); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3469 | intent.setFlags( |
| 3470 | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3471 | int result = ActivityManager.START_CANCELED; |
Robert Carr | fd10cd1 | 2016-06-29 16:41:50 -0700 | [diff] [blame] | 3472 | ActivityOptions options = new ActivityOptions(getActivityOptions()); |
| 3473 | if (intent == KeyguardBottomAreaView.INSECURE_CAMERA_INTENT) { |
| 3474 | // Normally an activity will set it's requested rotation |
| 3475 | // animation on its window. However when launching an activity |
| 3476 | // causes the orientation to change this is too late. In these cases |
| 3477 | // the default animation is used. This doesn't look good for |
| 3478 | // the camera (as it rotates the camera contents out of sync |
| 3479 | // with physical reality). So, we ask the WindowManager to |
| 3480 | // force the crossfade animation if an orientation change |
| 3481 | // happens to occur during the launch. |
| 3482 | options.setRotationAnimationHint( |
Robert Carr | 57d9fbd | 2016-08-15 12:00:35 -0700 | [diff] [blame] | 3483 | WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS); |
Robert Carr | fd10cd1 | 2016-06-29 16:41:50 -0700 | [diff] [blame] | 3484 | } |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3485 | try { |
| 3486 | result = ActivityManagerNative.getDefault().startActivityAsUser( |
| 3487 | null, mContext.getBasePackageName(), |
| 3488 | intent, |
| 3489 | intent.resolveTypeIfNeeded(mContext.getContentResolver()), |
Jorim Jaggi | e6e108e | 2016-03-28 13:38:45 -0700 | [diff] [blame] | 3490 | null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, |
Robert Carr | fd10cd1 | 2016-06-29 16:41:50 -0700 | [diff] [blame] | 3491 | options.toBundle(), UserHandle.CURRENT.getIdentifier()); |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3492 | } catch (RemoteException e) { |
| 3493 | Log.w(TAG, "Unable to start activity", e); |
| 3494 | } |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3495 | overrideActivityPendingAppTransition( |
| 3496 | keyguardShowing && !afterKeyguardGone); |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3497 | if (callback != null) { |
| 3498 | callback.onActivityStarted(result); |
| 3499 | } |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3500 | } |
| 3501 | }; |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3502 | Runnable cancelRunnable = new Runnable() { |
| 3503 | @Override |
| 3504 | public void run() { |
Jorim Jaggi | 5cc8659 | 2015-06-08 14:48:28 -0700 | [diff] [blame] | 3505 | if (callback != null) { |
| 3506 | callback.onActivityStarted(ActivityManager.START_CANCELED); |
| 3507 | } |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3508 | } |
| 3509 | }; |
Jorim Jaggi | b835dd7 | 2015-06-08 12:28:42 -0700 | [diff] [blame] | 3510 | executeRunnableDismissingKeyguard(runnable, cancelRunnable, dismissShade, |
Felipe Leme | ee5d630 | 2016-04-22 16:11:19 -0700 | [diff] [blame] | 3511 | afterKeyguardGone, true /* deferred */); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3512 | } |
| 3513 | |
| 3514 | public void executeRunnableDismissingKeyguard(final Runnable runnable, |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3515 | final Runnable cancelAction, |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3516 | final boolean dismissShade, |
Felipe Leme | ee5d630 | 2016-04-22 16:11:19 -0700 | [diff] [blame] | 3517 | final boolean afterKeyguardGone, |
| 3518 | final boolean deferred) { |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3519 | final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing(); |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 3520 | dismissKeyguardThenExecute(new OnDismissAction() { |
| 3521 | @Override |
| 3522 | public boolean onDismiss() { |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 3523 | AsyncTask.execute(new Runnable() { |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 3524 | @Override |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 3525 | public void run() { |
| 3526 | try { |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 3527 | if (keyguardShowing && !afterKeyguardGone) { |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 3528 | ActivityManagerNative.getDefault() |
| 3529 | .keyguardWaitingForActivityDrawn(); |
| 3530 | } |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3531 | if (runnable != null) { |
| 3532 | runnable.run(); |
| 3533 | } |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 3534 | } catch (RemoteException e) { |
| 3535 | } |
| 3536 | } |
| 3537 | }); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 3538 | if (dismissShade) { |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 3539 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */, |
| 3540 | true /* delayed*/); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 3541 | } |
Felipe Leme | ee5d630 | 2016-04-22 16:11:19 -0700 | [diff] [blame] | 3542 | return deferred; |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 3543 | } |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3544 | }, cancelAction, afterKeyguardGone); |
Daniel Sandler | 3679bf5 | 2012-10-16 21:30:28 -0400 | [diff] [blame] | 3545 | } |
| 3546 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3547 | private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 3548 | @Override |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3549 | public void onReceive(Context context, Intent intent) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 3550 | if (DEBUG) Log.v(TAG, "onReceive: " + intent); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3551 | String action = intent.getAction(); |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 3552 | if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) { |
Andrei Stingaceanu | f86bc97 | 2016-04-12 15:29:25 +0100 | [diff] [blame] | 3553 | KeyboardShortcuts.dismiss(); |
Adrian Roos | 0721535 | 2016-06-23 11:19:28 -0700 | [diff] [blame] | 3554 | if (mRemoteInputController != null) { |
| 3555 | mRemoteInputController.closeRemoteInputs(); |
| 3556 | } |
Kenny Guy | 44fc65f | 2014-11-28 22:18:14 +0000 | [diff] [blame] | 3557 | if (isCurrentProfile(getSendingUserId())) { |
| 3558 | int flags = CommandQueue.FLAG_EXCLUDE_NONE; |
| 3559 | String reason = intent.getStringExtra("reason"); |
| 3560 | if (reason != null && reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) { |
| 3561 | flags |= CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL; |
| 3562 | } |
| 3563 | animateCollapsePanels(flags); |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 3564 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3565 | } |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 3566 | else if (Intent.ACTION_SCREEN_OFF.equals(action)) { |
John Spurlock | 1bbd49d | 2012-10-19 11:09:32 -0400 | [diff] [blame] | 3567 | notifyNavigationBarScreenOn(false); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 3568 | notifyHeadsUpScreenOff(); |
John Spurlock | 4219726 | 2013-10-21 09:32:25 -0400 | [diff] [blame] | 3569 | finishBarAnimations(); |
Selim Cinek | ccd14fb | 2014-08-12 18:53:24 +0200 | [diff] [blame] | 3570 | resetUserExpandedStates(); |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 3571 | } |
Daniel Sandler | 7f3cf95 | 2012-08-31 14:57:09 -0400 | [diff] [blame] | 3572 | else if (Intent.ACTION_SCREEN_ON.equals(action)) { |
John Spurlock | 1bbd49d | 2012-10-19 11:09:32 -0400 | [diff] [blame] | 3573 | notifyNavigationBarScreenOn(true); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3574 | } |
Adrian Roos | 8e3e836 | 2015-07-16 19:42:22 -0700 | [diff] [blame] | 3575 | } |
| 3576 | }; |
| 3577 | |
| 3578 | private BroadcastReceiver mDemoReceiver = new BroadcastReceiver() { |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 3579 | @Override |
Adrian Roos | 8e3e836 | 2015-07-16 19:42:22 -0700 | [diff] [blame] | 3580 | public void onReceive(Context context, Intent intent) { |
| 3581 | if (DEBUG) Log.v(TAG, "onReceive: " + intent); |
| 3582 | String action = intent.getAction(); |
| 3583 | if (ACTION_DEMO.equals(action)) { |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3584 | Bundle bundle = intent.getExtras(); |
| 3585 | if (bundle != null) { |
| 3586 | String command = bundle.getString("command", "").trim().toLowerCase(); |
| 3587 | if (command.length() > 0) { |
| 3588 | try { |
| 3589 | dispatchDemoCommand(command, bundle); |
| 3590 | } catch (Throwable t) { |
| 3591 | Log.w(TAG, "Error running demo command, intent=" + intent, t); |
| 3592 | } |
| 3593 | } |
| 3594 | } |
Adrian Roos | 8e3e836 | 2015-07-16 19:42:22 -0700 | [diff] [blame] | 3595 | } else if (ACTION_FAKE_ARTWORK.equals(action)) { |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 3596 | if (DEBUG_MEDIA_FAKE_ARTWORK) { |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 3597 | updateMediaMetaData(true, true); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 3598 | } |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3599 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3600 | } |
| 3601 | }; |
| 3602 | |
Selim Cinek | 78f4008 | 2016-03-10 18:06:27 -0800 | [diff] [blame] | 3603 | public void resetUserExpandedStates() { |
Selim Cinek | ccd14fb | 2014-08-12 18:53:24 +0200 | [diff] [blame] | 3604 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
| 3605 | final int notificationCount = activeNotifications.size(); |
| 3606 | for (int i = 0; i < notificationCount; i++) { |
| 3607 | NotificationData.Entry entry = activeNotifications.get(i); |
| 3608 | if (entry.row != null) { |
| 3609 | entry.row.resetUserExpansion(); |
| 3610 | } |
| 3611 | } |
| 3612 | } |
| 3613 | |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 3614 | @Override |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3615 | protected void dismissKeyguardThenExecute(OnDismissAction action, boolean afterKeyguardGone) { |
| 3616 | dismissKeyguardThenExecute(action, null /* cancelRunnable */, afterKeyguardGone); |
| 3617 | } |
| 3618 | |
Jason Monk | abe1974 | 2015-09-29 09:47:06 -0400 | [diff] [blame] | 3619 | public void dismissKeyguard() { |
| 3620 | mStatusBarKeyguardViewManager.dismiss(); |
| 3621 | } |
| 3622 | |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3623 | private void dismissKeyguardThenExecute(OnDismissAction action, Runnable cancelAction, |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 3624 | boolean afterKeyguardGone) { |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 3625 | if (mStatusBarKeyguardViewManager.isShowing()) { |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3626 | mStatusBarKeyguardViewManager.dismissWithAction(action, cancelAction, |
| 3627 | afterKeyguardGone); |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 3628 | } else { |
| 3629 | action.onDismiss(); |
| 3630 | } |
| 3631 | } |
| 3632 | |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 3633 | // SystemUIService notifies SystemBars of configuration changes, which then calls down here |
| 3634 | @Override |
| 3635 | protected void onConfigurationChanged(Configuration newConfig) { |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 3636 | updateResources(); |
| 3637 | updateDisplaySize(); // populates mDisplayMetrics |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 3638 | super.onConfigurationChanged(newConfig); // calls refreshLayout |
| 3639 | |
| 3640 | if (DEBUG) { |
| 3641 | Log.v(TAG, "configuration changed: " + mContext.getResources().getConfiguration()); |
| 3642 | } |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 3643 | |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 3644 | repositionNavigationBar(); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 3645 | updateRowStates(); |
Jason Monk | 18f99d9 | 2014-09-11 13:36:42 -0400 | [diff] [blame] | 3646 | mScreenPinningRequest.onConfigurationChanged(); |
Jason Monk | 1c040db | 2015-07-20 09:45:54 -0400 | [diff] [blame] | 3647 | mNetworkController.onConfigurationChanged(); |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 3648 | } |
| 3649 | |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 3650 | @Override |
| 3651 | public void userSwitched(int newUserId) { |
Chris Wren | a6d4fb6 | 2014-11-20 14:46:23 -0500 | [diff] [blame] | 3652 | super.userSwitched(newUserId); |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 3653 | if (MULTIUSER_DEBUG) mNotificationPanelDebugText.setText("USER " + newUserId); |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 3654 | animateCollapsePanels(); |
Adrian Roos | 31b844b | 2014-11-21 13:55:09 +0100 | [diff] [blame] | 3655 | updatePublicMode(); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 3656 | updateNotifications(); |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 3657 | resetUserSetupObserver(); |
John Spurlock | 89f060a | 2014-07-16 21:03:15 -0400 | [diff] [blame] | 3658 | setControllerUsers(); |
Julia Reynolds | 86ef8e2 | 2015-09-09 16:42:38 -0400 | [diff] [blame] | 3659 | clearCurrentMediaNotification(); |
Vadim Tryshev | 12a30e8 | 2016-02-12 15:39:28 -0800 | [diff] [blame] | 3660 | mLockscreenWallpaper.setCurrentUser(newUserId); |
Jorim Jaggi | e31f6b8 | 2016-07-01 16:15:09 -0700 | [diff] [blame] | 3661 | mScrimController.setCurrentUser(newUserId); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 3662 | updateMediaMetaData(true, false); |
John Spurlock | 89f060a | 2014-07-16 21:03:15 -0400 | [diff] [blame] | 3663 | } |
| 3664 | |
| 3665 | private void setControllerUsers() { |
| 3666 | if (mZenModeController != null) { |
| 3667 | mZenModeController.setUserId(mCurrentUserId); |
| 3668 | } |
Robin Lee | 63204ee | 2015-06-04 01:53:01 +0100 | [diff] [blame] | 3669 | if (mSecurityController != null) { |
| 3670 | mSecurityController.onUserSwitched(mCurrentUserId); |
| 3671 | } |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 3672 | } |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 3673 | |
| 3674 | private void resetUserSetupObserver() { |
| 3675 | mContext.getContentResolver().unregisterContentObserver(mUserSetupObserver); |
| 3676 | mUserSetupObserver.onChange(false); |
| 3677 | mContext.getContentResolver().registerContentObserver( |
| 3678 | Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE), true, |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 3679 | mUserSetupObserver, mCurrentUserId); |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 3680 | } |
| 3681 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3682 | /** |
| 3683 | * Reload some of our resources when the configuration changes. |
| 3684 | * |
| 3685 | * We don't reload everything when the configuration changes -- we probably |
| 3686 | * should, but getting that smooth is tough. Someday we'll fix that. In the |
| 3687 | * meantime, just update the things that we know change. |
| 3688 | */ |
| 3689 | void updateResources() { |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 3690 | // Update the quick setting tiles |
John Spurlock | 7e6809a | 2014-08-06 16:03:14 -0400 | [diff] [blame] | 3691 | if (mQSPanel != null) { |
| 3692 | mQSPanel.updateResources(); |
| 3693 | } |
Winson Chung | d63c5978 | 2012-09-05 17:34:41 -0700 | [diff] [blame] | 3694 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 3695 | loadDimens(); |
John Spurlock | 7e6809a | 2014-08-06 16:03:14 -0400 | [diff] [blame] | 3696 | |
| 3697 | if (mNotificationPanel != null) { |
| 3698 | mNotificationPanel.updateResources(); |
| 3699 | } |
Adrian Roos | 5fd872e | 2014-08-12 17:28:58 +0200 | [diff] [blame] | 3700 | if (mBrightnessMirrorController != null) { |
| 3701 | mBrightnessMirrorController.updateResources(); |
| 3702 | } |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 3703 | } |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 3704 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 3705 | protected void loadDimens() { |
| 3706 | final Resources res = mContext.getResources(); |
| 3707 | |
Jorim Jaggi | 11c62e1 | 2016-04-05 20:41:21 -0700 | [diff] [blame] | 3708 | int oldBarHeight = mNaturalBarHeight; |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 3709 | mNaturalBarHeight = res.getDimensionPixelSize( |
| 3710 | com.android.internal.R.dimen.status_bar_height); |
Jorim Jaggi | 11c62e1 | 2016-04-05 20:41:21 -0700 | [diff] [blame] | 3711 | if (mStatusBarWindowManager != null && mNaturalBarHeight != oldBarHeight) { |
| 3712 | mStatusBarWindowManager.setBarHeight(mNaturalBarHeight); |
| 3713 | } |
| 3714 | mMaxAllowedKeyguardNotifications = res.getInteger( |
| 3715 | R.integer.keyguard_max_notification_count); |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 3716 | |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 3717 | if (DEBUG) Log.v(TAG, "defineSlots"); |
John Spurlock | 804df70 | 2012-06-01 15:34:27 -0400 | [diff] [blame] | 3718 | } |
| 3719 | |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3720 | // Visibility reporting |
| 3721 | |
| 3722 | @Override |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 3723 | protected void handleVisibleToUserChanged(boolean visibleToUser) { |
| 3724 | if (visibleToUser) { |
| 3725 | super.handleVisibleToUserChanged(visibleToUser); |
| 3726 | startNotificationLogging(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3727 | } else { |
Christoph Studer | 037e34c | 2014-04-30 20:06:04 +0200 | [diff] [blame] | 3728 | stopNotificationLogging(); |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 3729 | super.handleVisibleToUserChanged(visibleToUser); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3730 | } |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3731 | } |
| 3732 | |
Christoph Studer | 037e34c | 2014-04-30 20:06:04 +0200 | [diff] [blame] | 3733 | private void stopNotificationLogging() { |
| 3734 | // Report all notifications as invisible and turn down the |
| 3735 | // reporter. |
| 3736 | if (!mCurrentlyVisibleNotifications.isEmpty()) { |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 3737 | logNotificationVisibilityChanges(Collections.<NotificationVisibility>emptyList(), |
| 3738 | mCurrentlyVisibleNotifications); |
| 3739 | recycleAllVisibilityObjects(mCurrentlyVisibleNotifications); |
Christoph Studer | 037e34c | 2014-04-30 20:06:04 +0200 | [diff] [blame] | 3740 | } |
| 3741 | mHandler.removeCallbacks(mVisibilityReporter); |
| 3742 | mStackScroller.setChildLocationsChangedListener(null); |
| 3743 | } |
| 3744 | |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 3745 | private void startNotificationLogging() { |
| 3746 | mStackScroller.setChildLocationsChangedListener(mNotificationLocationsChangedListener); |
| 3747 | // Some transitions like mVisibleToUser=false -> mVisibleToUser=true don't |
| 3748 | // cause the scroller to emit child location events. Hence generate |
| 3749 | // one ourselves to guarantee that we're reporting visible |
| 3750 | // notifications. |
| 3751 | // (Note that in cases where the scroller does emit events, this |
| 3752 | // additional event doesn't break anything.) |
| 3753 | mNotificationLocationsChangedListener.onChildLocationsChanged(mStackScroller); |
Christoph Studer | 037e34c | 2014-04-30 20:06:04 +0200 | [diff] [blame] | 3754 | } |
| 3755 | |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3756 | private void logNotificationVisibilityChanges( |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 3757 | Collection<NotificationVisibility> newlyVisible, |
| 3758 | Collection<NotificationVisibility> noLongerVisible) { |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3759 | if (newlyVisible.isEmpty() && noLongerVisible.isEmpty()) { |
| 3760 | return; |
| 3761 | } |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 3762 | NotificationVisibility[] newlyVisibleAr = |
| 3763 | newlyVisible.toArray(new NotificationVisibility[newlyVisible.size()]); |
| 3764 | NotificationVisibility[] noLongerVisibleAr = |
| 3765 | noLongerVisible.toArray(new NotificationVisibility[noLongerVisible.size()]); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3766 | try { |
| 3767 | mBarService.onNotificationVisibilityChanged(newlyVisibleAr, noLongerVisibleAr); |
| 3768 | } catch (RemoteException e) { |
| 3769 | // Ignore. |
| 3770 | } |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 3771 | |
| 3772 | final int N = newlyVisible.size(); |
Amith Yamasani | 7649567 | 2015-07-07 15:22:54 -0700 | [diff] [blame] | 3773 | if (N > 0) { |
| 3774 | String[] newlyVisibleKeyAr = new String[N]; |
| 3775 | for (int i = 0; i < N; i++) { |
| 3776 | newlyVisibleKeyAr[i] = newlyVisibleAr[i].key; |
| 3777 | } |
| 3778 | |
| 3779 | setNotificationsShown(newlyVisibleKeyAr); |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 3780 | } |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3781 | } |
| 3782 | |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 3783 | // State logging |
| 3784 | |
| 3785 | private void logStateToEventlog() { |
| 3786 | boolean isShowing = mStatusBarKeyguardViewManager.isShowing(); |
| 3787 | boolean isOccluded = mStatusBarKeyguardViewManager.isOccluded(); |
| 3788 | boolean isBouncerShowing = mStatusBarKeyguardViewManager.isBouncerShowing(); |
| 3789 | boolean isSecure = mUnlockMethodCache.isMethodSecure(); |
Selim Cinek | e8bae62 | 2015-07-15 13:24:06 -0700 | [diff] [blame] | 3790 | boolean canSkipBouncer = mUnlockMethodCache.canSkipBouncer(); |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 3791 | int stateFingerprint = getLoggingFingerprint(mState, |
| 3792 | isShowing, |
| 3793 | isOccluded, |
| 3794 | isBouncerShowing, |
| 3795 | isSecure, |
Selim Cinek | e8bae62 | 2015-07-15 13:24:06 -0700 | [diff] [blame] | 3796 | canSkipBouncer); |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 3797 | if (stateFingerprint != mLastLoggedStateFingerprint) { |
| 3798 | EventLogTags.writeSysuiStatusBarState(mState, |
| 3799 | isShowing ? 1 : 0, |
| 3800 | isOccluded ? 1 : 0, |
| 3801 | isBouncerShowing ? 1 : 0, |
| 3802 | isSecure ? 1 : 0, |
Selim Cinek | e8bae62 | 2015-07-15 13:24:06 -0700 | [diff] [blame] | 3803 | canSkipBouncer ? 1 : 0); |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 3804 | mLastLoggedStateFingerprint = stateFingerprint; |
| 3805 | } |
| 3806 | } |
| 3807 | |
| 3808 | /** |
| 3809 | * Returns a fingerprint of fields logged to eventlog |
| 3810 | */ |
| 3811 | private static int getLoggingFingerprint(int statusBarState, boolean keyguardShowing, |
| 3812 | boolean keyguardOccluded, boolean bouncerShowing, boolean secure, |
| 3813 | boolean currentlyInsecure) { |
| 3814 | // Reserve 8 bits for statusBarState. We'll never go higher than |
| 3815 | // that, right? Riiiight. |
| 3816 | return (statusBarState & 0xFF) |
| 3817 | | ((keyguardShowing ? 1 : 0) << 8) |
| 3818 | | ((keyguardOccluded ? 1 : 0) << 9) |
| 3819 | | ((bouncerShowing ? 1 : 0) << 10) |
| 3820 | | ((secure ? 1 : 0) << 11) |
| 3821 | | ((currentlyInsecure ? 1 : 0) << 12); |
| 3822 | } |
| 3823 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3824 | // |
| 3825 | // tracing |
| 3826 | // |
| 3827 | |
| 3828 | void postStartTracing() { |
| 3829 | mHandler.postDelayed(mStartTracing, 3000); |
| 3830 | } |
| 3831 | |
| 3832 | void vibrate() { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 3833 | android.os.Vibrator vib = (android.os.Vibrator)mContext.getSystemService( |
| 3834 | Context.VIBRATOR_SERVICE); |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 3835 | vib.vibrate(250, VIBRATION_ATTRIBUTES); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3836 | } |
| 3837 | |
| 3838 | Runnable mStartTracing = new Runnable() { |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 3839 | @Override |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3840 | public void run() { |
| 3841 | vibrate(); |
| 3842 | SystemClock.sleep(250); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 3843 | Log.d(TAG, "startTracing"); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3844 | android.os.Debug.startMethodTracing("/data/statusbar-traces/trace"); |
| 3845 | mHandler.postDelayed(mStopTracing, 10000); |
| 3846 | } |
| 3847 | }; |
| 3848 | |
| 3849 | Runnable mStopTracing = new Runnable() { |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 3850 | @Override |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3851 | public void run() { |
| 3852 | android.os.Debug.stopMethodTracing(); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 3853 | Log.d(TAG, "stopTracing"); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3854 | vibrate(); |
| 3855 | } |
| 3856 | }; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 3857 | |
| 3858 | @Override |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 3859 | public boolean shouldDisableNavbarGestures() { |
Jorim Jaggi | 18976a5 | 2015-07-24 13:18:19 -0700 | [diff] [blame] | 3860 | return !isDeviceProvisioned() || (mDisabled1 & StatusBarManager.DISABLE_SEARCH) != 0; |
Jim Miller | 670d9dd | 2012-05-12 13:28:26 -0700 | [diff] [blame] | 3861 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3862 | |
Jason Monk | ba2318e | 2015-12-08 09:04:23 -0500 | [diff] [blame] | 3863 | public void postQSRunnableDismissingKeyguard(final Runnable runnable) { |
| 3864 | mHandler.post(new Runnable() { |
| 3865 | @Override |
| 3866 | public void run() { |
| 3867 | mLeaveOpenOnKeyguardHide = true; |
Felipe Leme | ee5d630 | 2016-04-22 16:11:19 -0700 | [diff] [blame] | 3868 | executeRunnableDismissingKeyguard(runnable, null, false, false, false); |
Jason Monk | ba2318e | 2015-12-08 09:04:23 -0500 | [diff] [blame] | 3869 | } |
| 3870 | }); |
| 3871 | } |
| 3872 | |
Adrian Roos | 62692b2 | 2015-09-11 17:46:23 -0700 | [diff] [blame] | 3873 | public void postStartActivityDismissingKeyguard(final PendingIntent intent) { |
| 3874 | mHandler.post(new Runnable() { |
| 3875 | @Override |
| 3876 | public void run() { |
| 3877 | startPendingIntentDismissingKeyguard(intent); |
| 3878 | } |
| 3879 | }); |
| 3880 | } |
| 3881 | |
Jason Monk | ee43cdf | 2015-06-19 14:20:46 -0400 | [diff] [blame] | 3882 | public void postStartActivityDismissingKeyguard(final Intent intent, int delay) { |
John Spurlock | d47a3f3 | 2014-05-18 19:14:14 -0400 | [diff] [blame] | 3883 | mHandler.postDelayed(new Runnable() { |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 3884 | @Override |
| 3885 | public void run() { |
Jason Monk | ee43cdf | 2015-06-19 14:20:46 -0400 | [diff] [blame] | 3886 | handleStartActivityDismissingKeyguard(intent, true /*onlyProvisioned*/); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 3887 | } |
John Spurlock | d47a3f3 | 2014-05-18 19:14:14 -0400 | [diff] [blame] | 3888 | }, delay); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 3889 | } |
| 3890 | |
Jason Monk | ee43cdf | 2015-06-19 14:20:46 -0400 | [diff] [blame] | 3891 | private void handleStartActivityDismissingKeyguard(Intent intent, boolean onlyProvisioned) { |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 3892 | startActivityDismissingKeyguard(intent, onlyProvisioned, true /* dismissShade */); |
John Spurlock | de54700 | 2014-02-28 17:50:39 -0500 | [diff] [blame] | 3893 | } |
| 3894 | |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 3895 | private static class FastColorDrawable extends Drawable { |
| 3896 | private final int mColor; |
| 3897 | |
| 3898 | public FastColorDrawable(int color) { |
| 3899 | mColor = 0xff000000 | color; |
| 3900 | } |
| 3901 | |
| 3902 | @Override |
| 3903 | public void draw(Canvas canvas) { |
| 3904 | canvas.drawColor(mColor, PorterDuff.Mode.SRC); |
| 3905 | } |
| 3906 | |
| 3907 | @Override |
| 3908 | public void setAlpha(int alpha) { |
| 3909 | } |
| 3910 | |
| 3911 | @Override |
Chris Craik | bd3bfc5 | 2015-03-02 10:43:29 -0800 | [diff] [blame] | 3912 | public void setColorFilter(ColorFilter colorFilter) { |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 3913 | } |
| 3914 | |
| 3915 | @Override |
| 3916 | public int getOpacity() { |
| 3917 | return PixelFormat.OPAQUE; |
| 3918 | } |
| 3919 | |
| 3920 | @Override |
| 3921 | public void setBounds(int left, int top, int right, int bottom) { |
| 3922 | } |
| 3923 | |
| 3924 | @Override |
| 3925 | public void setBounds(Rect bounds) { |
| 3926 | } |
| 3927 | } |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 3928 | |
| 3929 | @Override |
| 3930 | public void destroy() { |
| 3931 | super.destroy(); |
| 3932 | if (mStatusBarWindow != null) { |
| 3933 | mWindowManager.removeViewImmediate(mStatusBarWindow); |
John Spurlock | ab847cf | 2014-01-15 14:13:59 -0500 | [diff] [blame] | 3934 | mStatusBarWindow = null; |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 3935 | } |
| 3936 | if (mNavigationBarView != null) { |
| 3937 | mWindowManager.removeViewImmediate(mNavigationBarView); |
John Spurlock | ab847cf | 2014-01-15 14:13:59 -0500 | [diff] [blame] | 3938 | mNavigationBarView = null; |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 3939 | } |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 3940 | if (mHandlerThread != null) { |
| 3941 | mHandlerThread.quitSafely(); |
| 3942 | mHandlerThread = null; |
| 3943 | } |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 3944 | mContext.unregisterReceiver(mBroadcastReceiver); |
Adrian Roos | 8e3e836 | 2015-07-16 19:42:22 -0700 | [diff] [blame] | 3945 | mContext.unregisterReceiver(mDemoReceiver); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3946 | mAssistManager.destroy(); |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 3947 | |
| 3948 | final SignalClusterView signalCluster = |
| 3949 | (SignalClusterView) mStatusBarView.findViewById(R.id.signal_cluster); |
| 3950 | final SignalClusterView signalClusterKeyguard = |
| 3951 | (SignalClusterView) mKeyguardStatusBar.findViewById(R.id.signal_cluster); |
| 3952 | final SignalClusterView signalClusterQs = |
| 3953 | (SignalClusterView) mHeader.findViewById(R.id.signal_cluster); |
Jason Monk | 5e74517 | 2015-06-02 19:14:44 -0400 | [diff] [blame] | 3954 | mNetworkController.removeSignalCallback(signalCluster); |
| 3955 | mNetworkController.removeSignalCallback(signalClusterKeyguard); |
| 3956 | mNetworkController.removeSignalCallback(signalClusterQs); |
| 3957 | if (mQSPanel != null && mQSPanel.getHost() != null) { |
| 3958 | mQSPanel.getHost().destroy(); |
| 3959 | } |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 3960 | } |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3961 | |
| 3962 | private boolean mDemoModeAllowed; |
| 3963 | private boolean mDemoMode; |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3964 | |
| 3965 | @Override |
| 3966 | public void dispatchDemoCommand(String command, Bundle args) { |
| 3967 | if (!mDemoModeAllowed) { |
| 3968 | mDemoModeAllowed = Settings.Global.getInt(mContext.getContentResolver(), |
Jason Monk | 431ad73 | 2015-07-16 08:58:15 -0400 | [diff] [blame] | 3969 | DEMO_MODE_ALLOWED, 0) != 0; |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3970 | } |
| 3971 | if (!mDemoModeAllowed) return; |
| 3972 | if (command.equals(COMMAND_ENTER)) { |
| 3973 | mDemoMode = true; |
| 3974 | } else if (command.equals(COMMAND_EXIT)) { |
| 3975 | mDemoMode = false; |
| 3976 | checkBarModes(); |
| 3977 | } else if (!mDemoMode) { |
| 3978 | // automatically enter demo mode on first demo command |
| 3979 | dispatchDemoCommand(COMMAND_ENTER, new Bundle()); |
| 3980 | } |
| 3981 | boolean modeChange = command.equals(COMMAND_ENTER) || command.equals(COMMAND_EXIT); |
John Spurlock | bb4a702 | 2014-11-08 12:40:19 -0500 | [diff] [blame] | 3982 | if ((modeChange || command.equals(COMMAND_VOLUME)) && mVolumeComponent != null) { |
| 3983 | mVolumeComponent.dispatchDemoCommand(command, args); |
| 3984 | } |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3985 | if (modeChange || command.equals(COMMAND_CLOCK)) { |
| 3986 | dispatchDemoCommandToView(command, args, R.id.clock); |
| 3987 | } |
| 3988 | if (modeChange || command.equals(COMMAND_BATTERY)) { |
Jason Monk | 98d7c7a | 2016-04-12 13:08:31 -0400 | [diff] [blame] | 3989 | mBatteryController.dispatchDemoCommand(command, args); |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3990 | } |
| 3991 | if (modeChange || command.equals(COMMAND_STATUS)) { |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 3992 | mIconController.dispatchDemoCommand(command, args); |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3993 | } |
| 3994 | if (mNetworkController != null && (modeChange || command.equals(COMMAND_NETWORK))) { |
| 3995 | mNetworkController.dispatchDemoCommand(command, args); |
| 3996 | } |
John Spurlock | 7f42fc5 | 2014-01-14 16:20:39 -0500 | [diff] [blame] | 3997 | if (modeChange || command.equals(COMMAND_NOTIFICATIONS)) { |
| 3998 | View notifications = mStatusBarView == null ? null |
| 3999 | : mStatusBarView.findViewById(R.id.notification_icon_area); |
| 4000 | if (notifications != null) { |
| 4001 | String visible = args.getString("visible"); |
| 4002 | int vis = mDemoMode && "false".equals(visible) ? View.INVISIBLE : View.VISIBLE; |
| 4003 | notifications.setVisibility(vis); |
| 4004 | } |
| 4005 | } |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 4006 | if (command.equals(COMMAND_BARS)) { |
| 4007 | String mode = args.getString("mode"); |
| 4008 | int barMode = "opaque".equals(mode) ? MODE_OPAQUE : |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 4009 | "translucent".equals(mode) ? MODE_TRANSLUCENT : |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 4010 | "semi-transparent".equals(mode) ? MODE_SEMI_TRANSPARENT : |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 4011 | "transparent".equals(mode) ? MODE_TRANSPARENT : |
| 4012 | "warning".equals(mode) ? MODE_WARNING : |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 4013 | -1; |
| 4014 | if (barMode != -1) { |
| 4015 | boolean animate = true; |
| 4016 | if (mStatusBarView != null) { |
| 4017 | mStatusBarView.getBarTransitions().transitionTo(barMode, animate); |
| 4018 | } |
| 4019 | if (mNavigationBarView != null) { |
| 4020 | mNavigationBarView.getBarTransitions().transitionTo(barMode, animate); |
| 4021 | } |
| 4022 | } |
| 4023 | } |
| 4024 | } |
| 4025 | |
| 4026 | private void dispatchDemoCommandToView(String command, Bundle args, int id) { |
| 4027 | if (mStatusBarView == null) return; |
| 4028 | View v = mStatusBarView.findViewById(id); |
| 4029 | if (v instanceof DemoMode) { |
| 4030 | ((DemoMode)v).dispatchDemoCommand(command, args); |
| 4031 | } |
| 4032 | } |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4033 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4034 | /** |
| 4035 | * @return The {@link StatusBarState} the status bar is in. |
| 4036 | */ |
| 4037 | public int getBarState() { |
| 4038 | return mState; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4039 | } |
| 4040 | |
Chris Wren | 1689594 | 2015-06-23 11:22:20 -0400 | [diff] [blame] | 4041 | @Override |
Yorke Lee | e4ea6ab | 2016-03-03 14:51:49 -0800 | [diff] [blame] | 4042 | public boolean isPanelFullyCollapsed() { |
Chris Wren | 1689594 | 2015-06-23 11:22:20 -0400 | [diff] [blame] | 4043 | return mNotificationPanel.isFullyCollapsed(); |
| 4044 | } |
| 4045 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4046 | public void showKeyguard() { |
Jorim Jaggi | 5e08e69 | 2014-10-03 15:17:20 -0700 | [diff] [blame] | 4047 | if (mLaunchTransitionFadingAway) { |
| 4048 | mNotificationPanel.animate().cancel(); |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 4049 | onLaunchTransitionFadingEnded(); |
Jorim Jaggi | 5e08e69 | 2014-10-03 15:17:20 -0700 | [diff] [blame] | 4050 | } |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 4051 | mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 4052 | if (mUserSwitcherController != null && mUserSwitcherController.useFullscreenUserSwitcher()) { |
| 4053 | setBarState(StatusBarState.FULLSCREEN_USER_SWITCHER); |
| 4054 | } else { |
| 4055 | setBarState(StatusBarState.KEYGUARD); |
| 4056 | } |
Jorim Jaggi | 98f8530 | 2014-08-07 17:45:04 +0200 | [diff] [blame] | 4057 | updateKeyguardState(false /* goingToFullShade */, false /* fromShadeLocked */); |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4058 | if (!mDeviceInteractive) { |
Jorim Jaggi | d41083a | 2014-09-12 02:54:40 +0200 | [diff] [blame] | 4059 | |
| 4060 | // If the screen is off already, we need to disable touch events because these might |
| 4061 | // collapse the panel after we expanded it, and thus we would end up with a blank |
| 4062 | // Keyguard. |
| 4063 | mNotificationPanel.setTouchDisabled(true); |
| 4064 | } |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 4065 | if (mState == StatusBarState.KEYGUARD) { |
| 4066 | instantExpandNotificationsPanel(); |
| 4067 | } else if (mState == StatusBarState.FULLSCREEN_USER_SWITCHER) { |
| 4068 | instantCollapseNotificationPanel(); |
| 4069 | } |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4070 | mLeaveOpenOnKeyguardHide = false; |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4071 | if (mDraggedDownRow != null) { |
| 4072 | mDraggedDownRow.setUserLocked(false); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 4073 | mDraggedDownRow.notifyHeightChanged(false /* needsAnimation */); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4074 | mDraggedDownRow = null; |
| 4075 | } |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 4076 | mPendingRemoteInputView = null; |
Jorim Jaggi | 19695d9 | 2015-07-20 15:51:40 -0700 | [diff] [blame] | 4077 | mAssistManager.onLockscreenShown(); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4078 | } |
| 4079 | |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 4080 | private void onLaunchTransitionFadingEnded() { |
| 4081 | mNotificationPanel.setAlpha(1.0f); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4082 | mNotificationPanel.onAffordanceLaunchEnded(); |
| 4083 | releaseGestureWakeLock(); |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 4084 | runLaunchTransitionEndRunnable(); |
| 4085 | mLaunchTransitionFadingAway = false; |
| 4086 | mScrimController.forceHideScrims(false /* hide */); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 4087 | updateMediaMetaData(true /* metaDataChanged */, true); |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 4088 | } |
| 4089 | |
Selim Cinek | 36b0223 | 2016-05-11 23:07:05 -0400 | [diff] [blame] | 4090 | @Override |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 4091 | public boolean isCollapsing() { |
| 4092 | return mNotificationPanel.isCollapsing(); |
| 4093 | } |
| 4094 | |
Selim Cinek | 36b0223 | 2016-05-11 23:07:05 -0400 | [diff] [blame] | 4095 | @Override |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 4096 | public void addPostCollapseAction(Runnable r) { |
| 4097 | mPostCollapseRunnables.add(r); |
| 4098 | } |
| 4099 | |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 4100 | public boolean isInLaunchTransition() { |
| 4101 | return mNotificationPanel.isLaunchTransitionRunning() |
| 4102 | || mNotificationPanel.isLaunchTransitionFinished(); |
| 4103 | } |
| 4104 | |
| 4105 | /** |
| 4106 | * Fades the content of the keyguard away after the launch transition is done. |
| 4107 | * |
| 4108 | * @param beforeFading the runnable to be run when the circle is fully expanded and the fading |
| 4109 | * starts |
| 4110 | * @param endRunnable the runnable to be run when the transition is done |
| 4111 | */ |
| 4112 | public void fadeKeyguardAfterLaunchTransition(final Runnable beforeFading, |
Jorim Jaggi | 5e08e69 | 2014-10-03 15:17:20 -0700 | [diff] [blame] | 4113 | Runnable endRunnable) { |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 4114 | mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); |
Jorim Jaggi | 5e08e69 | 2014-10-03 15:17:20 -0700 | [diff] [blame] | 4115 | mLaunchTransitionEndRunnable = endRunnable; |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 4116 | Runnable hideRunnable = new Runnable() { |
| 4117 | @Override |
| 4118 | public void run() { |
| 4119 | mLaunchTransitionFadingAway = true; |
| 4120 | if (beforeFading != null) { |
| 4121 | beforeFading.run(); |
| 4122 | } |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 4123 | mScrimController.forceHideScrims(true /* hide */); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 4124 | updateMediaMetaData(false, true); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 4125 | mNotificationPanel.setAlpha(1); |
Selim Cinek | 07304f522 | 2016-05-19 18:31:36 -0700 | [diff] [blame] | 4126 | mStackScroller.setParentFadingOut(true); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 4127 | mNotificationPanel.animate() |
| 4128 | .alpha(0) |
| 4129 | .setStartDelay(FADE_KEYGUARD_START_DELAY) |
| 4130 | .setDuration(FADE_KEYGUARD_DURATION) |
| 4131 | .withLayer() |
| 4132 | .withEndAction(new Runnable() { |
| 4133 | @Override |
| 4134 | public void run() { |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 4135 | onLaunchTransitionFadingEnded(); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 4136 | } |
| 4137 | }); |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4138 | mIconController.appTransitionStarting(SystemClock.uptimeMillis(), |
| 4139 | StatusBarIconController.DEFAULT_TINT_ANIMATION_DURATION); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 4140 | } |
| 4141 | }; |
| 4142 | if (mNotificationPanel.isLaunchTransitionRunning()) { |
| 4143 | mNotificationPanel.setLaunchTransitionEndRunnable(hideRunnable); |
| 4144 | } else { |
| 4145 | hideRunnable.run(); |
| 4146 | } |
| 4147 | } |
| 4148 | |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4149 | /** |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 4150 | * Fades the content of the Keyguard while we are dozing and makes it invisible when finished |
| 4151 | * fading. |
| 4152 | */ |
| 4153 | public void fadeKeyguardWhilePulsing() { |
| 4154 | mNotificationPanel.animate() |
| 4155 | .alpha(0f) |
| 4156 | .setStartDelay(0) |
| 4157 | .setDuration(FADE_KEYGUARD_DURATION_PULSING) |
Jorim Jaggi | ab45a21 | 2015-08-20 16:59:44 -0700 | [diff] [blame] | 4158 | .setInterpolator(ScrimController.KEYGUARD_FADE_OUT_INTERPOLATOR) |
| 4159 | .start(); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 4160 | } |
| 4161 | |
| 4162 | /** |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 4163 | * Plays the animation when an activity that was occluding Keyguard goes away. |
| 4164 | */ |
| 4165 | public void animateKeyguardUnoccluding() { |
| 4166 | mScrimController.animateKeyguardUnoccluding(500); |
| 4167 | mNotificationPanel.setExpandedFraction(0f); |
| 4168 | animateExpandNotificationsPanel(); |
| 4169 | } |
| 4170 | |
| 4171 | /** |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 4172 | * Starts the timeout when we try to start the affordances on Keyguard. We usually rely that |
| 4173 | * Keyguard goes away via fadeKeyguardAfterLaunchTransition, however, that might not happen |
| 4174 | * because the launched app crashed or something else went wrong. |
| 4175 | */ |
| 4176 | public void startLaunchTransitionTimeout() { |
| 4177 | mHandler.sendEmptyMessageDelayed(MSG_LAUNCH_TRANSITION_TIMEOUT, |
| 4178 | LAUNCH_TRANSITION_TIMEOUT_MS); |
| 4179 | } |
| 4180 | |
| 4181 | private void onLaunchTransitionTimeout() { |
| 4182 | Log.w(TAG, "Launch transition: Timeout!"); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4183 | mNotificationPanel.onAffordanceLaunchEnded(); |
| 4184 | releaseGestureWakeLock(); |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 4185 | mNotificationPanel.resetViews(); |
| 4186 | } |
| 4187 | |
| 4188 | private void runLaunchTransitionEndRunnable() { |
| 4189 | if (mLaunchTransitionEndRunnable != null) { |
| 4190 | Runnable r = mLaunchTransitionEndRunnable; |
| 4191 | |
| 4192 | // mLaunchTransitionEndRunnable might call showKeyguard, which would execute it again, |
| 4193 | // which would lead to infinite recursion. Protect against it. |
| 4194 | mLaunchTransitionEndRunnable = null; |
| 4195 | r.run(); |
| 4196 | } |
| 4197 | } |
| 4198 | |
| 4199 | /** |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4200 | * @return true if we would like to stay in the shade, false if it should go away entirely |
| 4201 | */ |
| 4202 | public boolean hideKeyguard() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 4203 | Trace.beginSection("PhoneStatusBar#hideKeyguard"); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4204 | boolean staying = mLeaveOpenOnKeyguardHide; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4205 | setBarState(StatusBarState.SHADE); |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 4206 | View viewToClick = null; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4207 | if (mLeaveOpenOnKeyguardHide) { |
| 4208 | mLeaveOpenOnKeyguardHide = false; |
Jorim Jaggi | 37c1180 | 2015-08-18 20:27:54 -0700 | [diff] [blame] | 4209 | long delay = calculateGoingToFullShadeDelay(); |
| 4210 | mNotificationPanel.animateToFullShade(delay); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4211 | if (mDraggedDownRow != null) { |
| 4212 | mDraggedDownRow.setUserLocked(false); |
| 4213 | mDraggedDownRow = null; |
| 4214 | } |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 4215 | viewToClick = mPendingRemoteInputView; |
| 4216 | mPendingRemoteInputView = null; |
Jorim Jaggi | 37c1180 | 2015-08-18 20:27:54 -0700 | [diff] [blame] | 4217 | |
| 4218 | // Disable layout transitions in navbar for this transition because the load is just |
| 4219 | // too heavy for the CPU and GPU on any device. |
| 4220 | if (mNavigationBarView != null) { |
| 4221 | mNavigationBarView.setLayoutTransitionsEnabled(false); |
| 4222 | mNavigationBarView.postDelayed(new Runnable() { |
| 4223 | @Override |
| 4224 | public void run() { |
| 4225 | mNavigationBarView.setLayoutTransitionsEnabled(true); |
| 4226 | } |
| 4227 | }, delay + StackStateAnimator.ANIMATION_DURATION_GO_TO_FULL_SHADE); |
| 4228 | } |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4229 | } else { |
| 4230 | instantCollapseNotificationPanel(); |
| 4231 | } |
Jorim Jaggi | 98f8530 | 2014-08-07 17:45:04 +0200 | [diff] [blame] | 4232 | updateKeyguardState(staying, false /* fromShadeLocked */); |
Jorim Jaggi | 1ecd7cd | 2014-11-03 16:18:03 +0100 | [diff] [blame] | 4233 | |
Adrian Roos | b22665d | 2016-10-17 15:08:03 -0700 | [diff] [blame] | 4234 | if (viewToClick != null && viewToClick.isAttachedToWindow()) { |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 4235 | viewToClick.callOnClick(); |
| 4236 | } |
| 4237 | |
Jorim Jaggi | 1ecd7cd | 2014-11-03 16:18:03 +0100 | [diff] [blame] | 4238 | // Keyguard state has changed, but QS is not listening anymore. Make sure to update the tile |
| 4239 | // visibilities so next time we open the panel we know the correct height already. |
| 4240 | if (mQSPanel != null) { |
| 4241 | mQSPanel.refreshAllTiles(); |
| 4242 | } |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 4243 | mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4244 | releaseGestureWakeLock(); |
| 4245 | mNotificationPanel.onAffordanceLaunchEnded(); |
Jorim Jaggi | 52429b4 | 2015-09-03 19:58:19 -0700 | [diff] [blame] | 4246 | mNotificationPanel.animate().cancel(); |
Jorim Jaggi | 9097885 | 2015-08-18 19:55:53 -0700 | [diff] [blame] | 4247 | mNotificationPanel.setAlpha(1f); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 4248 | Trace.endSection(); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4249 | return staying; |
| 4250 | } |
| 4251 | |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4252 | private void releaseGestureWakeLock() { |
| 4253 | if (mGestureWakeLock.isHeld()) { |
| 4254 | mGestureWakeLock.release(); |
| 4255 | } |
| 4256 | } |
| 4257 | |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4258 | public long calculateGoingToFullShadeDelay() { |
| 4259 | return mKeyguardFadingAwayDelay + mKeyguardFadingAwayDuration; |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 4260 | } |
| 4261 | |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4262 | /** |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4263 | * Notifies the status bar that Keyguard is going away very soon. |
| 4264 | */ |
| 4265 | public void keyguardGoingAway() { |
| 4266 | |
| 4267 | // Treat Keyguard exit animation as an app transition to achieve nice transition for status |
| 4268 | // bar. |
Adrian Roos | 46df1ca | 2015-09-11 12:38:43 -0700 | [diff] [blame] | 4269 | mKeyguardGoingAway = true; |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4270 | mIconController.appTransitionPending(); |
| 4271 | } |
| 4272 | |
| 4273 | /** |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4274 | * Notifies the status bar the Keyguard is fading away with the specified timings. |
| 4275 | * |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4276 | * @param startTime the start time of the animations in uptime millis |
| 4277 | * @param delay the precalculated animation delay in miliseconds |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4278 | * @param fadeoutDuration the duration of the exit animation, in milliseconds |
| 4279 | */ |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4280 | public void setKeyguardFadingAway(long startTime, long delay, long fadeoutDuration) { |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4281 | mKeyguardFadingAway = true; |
| 4282 | mKeyguardFadingAwayDelay = delay; |
| 4283 | mKeyguardFadingAwayDuration = fadeoutDuration; |
| 4284 | mWaitingForKeyguardExit = false; |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4285 | mIconController.appTransitionStarting( |
| 4286 | startTime + fadeoutDuration |
| 4287 | - StatusBarIconController.DEFAULT_TINT_ANIMATION_DURATION, |
| 4288 | StatusBarIconController.DEFAULT_TINT_ANIMATION_DURATION); |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 4289 | recomputeDisableFlags(fadeoutDuration > 0 /* animate */); |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4290 | } |
| 4291 | |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 4292 | public boolean isKeyguardFadingAway() { |
| 4293 | return mKeyguardFadingAway; |
| 4294 | } |
| 4295 | |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4296 | /** |
| 4297 | * Notifies that the Keyguard fading away animation is done. |
| 4298 | */ |
| 4299 | public void finishKeyguardFadingAway() { |
| 4300 | mKeyguardFadingAway = false; |
Adrian Roos | 46df1ca | 2015-09-11 12:38:43 -0700 | [diff] [blame] | 4301 | mKeyguardGoingAway = false; |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4302 | } |
| 4303 | |
Adrian Roos | d322f1a | 2015-04-23 15:19:45 -0700 | [diff] [blame] | 4304 | public void stopWaitingForKeyguardExit() { |
| 4305 | mWaitingForKeyguardExit = false; |
| 4306 | } |
| 4307 | |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 4308 | private void updatePublicMode() { |
Tony Mak | 92c989d | 2016-04-19 14:02:44 +0100 | [diff] [blame] | 4309 | boolean isPublic = false; |
| 4310 | if (mStatusBarKeyguardViewManager.isShowing()) { |
| 4311 | for (int i = mCurrentProfiles.size() - 1; i >= 0; i--) { |
| 4312 | UserInfo userInfo = mCurrentProfiles.valueAt(i); |
| 4313 | if (mStatusBarKeyguardViewManager.isSecure(userInfo.id)) { |
| 4314 | isPublic = true; |
| 4315 | break; |
| 4316 | } |
| 4317 | } |
| 4318 | } |
| 4319 | setLockscreenPublicMode(isPublic); |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 4320 | } |
| 4321 | |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 4322 | protected void updateKeyguardState(boolean goingToFullShade, boolean fromShadeLocked) { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 4323 | Trace.beginSection("PhoneStatusBar#updateKeyguardState"); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4324 | if (mState == StatusBarState.KEYGUARD) { |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4325 | mKeyguardIndicationController.setVisible(true); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 4326 | mNotificationPanel.resetViews(); |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 4327 | if (mKeyguardUserSwitcher != null) { |
| 4328 | mKeyguardUserSwitcher.setKeyguard(true, fromShadeLocked); |
| 4329 | } |
Selim Cinek | 80c2abe | 2015-06-17 15:37:30 -0700 | [diff] [blame] | 4330 | mStatusBarView.removePendingHideExpandedRunnables(); |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 4331 | } else { |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4332 | mKeyguardIndicationController.setVisible(false); |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 4333 | if (mKeyguardUserSwitcher != null) { |
| 4334 | mKeyguardUserSwitcher.setKeyguard(false, |
| 4335 | goingToFullShade || |
| 4336 | mState == StatusBarState.SHADE_LOCKED || |
| 4337 | fromShadeLocked); |
| 4338 | } |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 4339 | } |
Jorim Jaggi | 2042ef2 | 2014-05-13 21:55:18 +0200 | [diff] [blame] | 4340 | if (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) { |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 4341 | mScrimController.setKeyguardShowing(true); |
Jorim Jaggi | 2042ef2 | 2014-05-13 21:55:18 +0200 | [diff] [blame] | 4342 | } else { |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 4343 | mScrimController.setKeyguardShowing(false); |
Jorim Jaggi | 2042ef2 | 2014-05-13 21:55:18 +0200 | [diff] [blame] | 4344 | } |
Nicolas Prevot | 1dbbe7d | 2016-05-17 12:52:54 +0100 | [diff] [blame] | 4345 | mIconPolicy.notifyKeyguardShowingChanged(); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4346 | mNotificationPanel.setBarState(mState, mKeyguardFadingAway, goingToFullShade); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4347 | updateDozingState(); |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 4348 | updatePublicMode(); |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 4349 | updateStackScrollerState(goingToFullShade, fromShadeLocked); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 4350 | updateNotifications(); |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 4351 | checkBarModes(); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 4352 | updateMediaMetaData(false, mState != StatusBarState.KEYGUARD); |
John Spurlock | 657c62c | 2014-07-22 12:18:09 -0400 | [diff] [blame] | 4353 | mKeyguardMonitor.notifyKeyguardState(mStatusBarKeyguardViewManager.isShowing(), |
Jim Miller | 69c1241 | 2016-10-06 19:11:03 -0700 | [diff] [blame] | 4354 | mStatusBarKeyguardViewManager.isSecure(), |
| 4355 | mStatusBarKeyguardViewManager.isOccluded()); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 4356 | Trace.endSection(); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4357 | } |
| 4358 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4359 | private void updateDozingState() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 4360 | Trace.beginSection("PhoneStatusBar#updateDozingState"); |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 4361 | boolean animate = !mDozing && mDozeScrimController.isPulsing(); |
| 4362 | mNotificationPanel.setDozing(mDozing, animate); |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4363 | mStackScroller.setDark(mDozing, animate, mWakeUpTouchLocation); |
Jorim Jaggi | 048af1f | 2014-11-11 22:51:10 +0100 | [diff] [blame] | 4364 | mScrimController.setDozing(mDozing); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 4365 | |
| 4366 | // Immediately abort the dozing from the doze scrim controller in case of wake-and-unlock |
| 4367 | // for pulsing so the Keyguard fade-out animation scrim can take over. |
| 4368 | mDozeScrimController.setDozing(mDozing && |
| 4369 | mFingerprintUnlockController.getMode() |
| 4370 | != FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING, animate); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 4371 | Trace.endSection(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4372 | } |
| 4373 | |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 4374 | public void updateStackScrollerState(boolean goingToFullShade, boolean fromShadeLocked) { |
John Spurlock | 4b3bda2 | 2014-05-22 14:32:20 -0400 | [diff] [blame] | 4375 | if (mStackScroller == null) return; |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 4376 | boolean onKeyguard = mState == StatusBarState.KEYGUARD; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 4377 | mStackScroller.setHideSensitive(isLockscreenPublicMode(), goingToFullShade); |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 4378 | mStackScroller.setDimmed(onKeyguard, fromShadeLocked /* animate */); |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 4379 | mStackScroller.setExpandingEnabled(!onKeyguard); |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 4380 | ActivatableNotificationView activatedChild = mStackScroller.getActivatedChild(); |
| 4381 | mStackScroller.setActivatedChild(null); |
| 4382 | if (activatedChild != null) { |
| 4383 | activatedChild.makeInactive(false /* animate */); |
| 4384 | } |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4385 | } |
| 4386 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4387 | public void userActivity() { |
Jorim Jaggi | b690f0d | 2014-07-03 23:25:44 +0200 | [diff] [blame] | 4388 | if (mState == StatusBarState.KEYGUARD) { |
| 4389 | mKeyguardViewMediatorCallback.userActivity(); |
| 4390 | } |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4391 | } |
| 4392 | |
Jorim Jaggi | df99351 | 2014-05-13 23:06:35 +0200 | [diff] [blame] | 4393 | public boolean interceptMediaKey(KeyEvent event) { |
| 4394 | return mState == StatusBarState.KEYGUARD |
| 4395 | && mStatusBarKeyguardViewManager.interceptMediaKey(event); |
| 4396 | } |
| 4397 | |
Jorim Jaggi | 8c8bcc1 | 2014-04-16 21:36:51 +0200 | [diff] [blame] | 4398 | public boolean onMenuPressed() { |
Selim Cinek | 2854019 | 2016-02-19 17:25:08 -0800 | [diff] [blame] | 4399 | if (mDeviceInteractive && mState != StatusBarState.SHADE |
| 4400 | && mStatusBarKeyguardViewManager.shouldDismissOnMenuPressed()) { |
| 4401 | animateCollapsePanels( |
| 4402 | CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL /* flags */, true /* force */); |
| 4403 | return true; |
| 4404 | } |
| 4405 | return false; |
Jorim Jaggi | 8c8bcc1 | 2014-04-16 21:36:51 +0200 | [diff] [blame] | 4406 | } |
| 4407 | |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4408 | public void endAffordanceLaunch() { |
| 4409 | releaseGestureWakeLock(); |
| 4410 | mNotificationPanel.onAffordanceLaunchEnded(); |
| 4411 | } |
| 4412 | |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 4413 | public boolean onBackPressed() { |
Adrian Roos | 0002a45 | 2014-07-03 13:46:07 +0200 | [diff] [blame] | 4414 | if (mStatusBarKeyguardViewManager.onBackPressed()) { |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 4415 | return true; |
| 4416 | } |
Adrian Roos | 0002a45 | 2014-07-03 13:46:07 +0200 | [diff] [blame] | 4417 | if (mNotificationPanel.isQsExpanded()) { |
John Spurlock | f7ae442 | 2014-08-01 12:45:18 -0400 | [diff] [blame] | 4418 | if (mNotificationPanel.isQsDetailShowing()) { |
| 4419 | mNotificationPanel.closeQsDetail(); |
| 4420 | } else { |
| 4421 | mNotificationPanel.animateCloseQs(); |
| 4422 | } |
Adrian Roos | 0002a45 | 2014-07-03 13:46:07 +0200 | [diff] [blame] | 4423 | return true; |
| 4424 | } |
| 4425 | if (mState != StatusBarState.KEYGUARD && mState != StatusBarState.SHADE_LOCKED) { |
| 4426 | animateCollapsePanels(); |
| 4427 | return true; |
| 4428 | } |
| 4429 | return false; |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 4430 | } |
| 4431 | |
Jorim Jaggi | 3425076 | 2014-07-03 23:51:19 +0200 | [diff] [blame] | 4432 | public boolean onSpacePressed() { |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 4433 | if (mDeviceInteractive && mState != StatusBarState.SHADE) { |
Jorim Jaggi | 4eedc1d | 2014-10-27 13:45:56 +0100 | [diff] [blame] | 4434 | animateCollapsePanels( |
| 4435 | CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL /* flags */, true /* force */); |
Jorim Jaggi | 3425076 | 2014-07-03 23:51:19 +0200 | [diff] [blame] | 4436 | return true; |
| 4437 | } |
| 4438 | return false; |
| 4439 | } |
| 4440 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4441 | private void showBouncer() { |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4442 | if (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) { |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 4443 | mWaitingForKeyguardExit = mStatusBarKeyguardViewManager.isShowing(); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4444 | mStatusBarKeyguardViewManager.dismiss(); |
| 4445 | } |
| 4446 | } |
| 4447 | |
| 4448 | private void instantExpandNotificationsPanel() { |
Jorim Jaggi | c357ca2 | 2014-04-25 14:56:15 +0200 | [diff] [blame] | 4449 | |
Jorim Jaggi | 0a27be8 | 2014-06-11 03:22:39 +0200 | [diff] [blame] | 4450 | // Make our window larger and the panel expanded. |
Jorim Jaggi | fa505a7 | 2014-04-28 20:04:11 +0200 | [diff] [blame] | 4451 | makeExpandedVisible(true); |
Oren Blasberg | 8d3fea1 | 2015-07-10 14:21:44 -0700 | [diff] [blame] | 4452 | mNotificationPanel.expand(false /* animate */); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4453 | } |
Adrian Roos | 5a46cd3 | 2014-04-03 16:51:58 +0200 | [diff] [blame] | 4454 | |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 4455 | private void instantCollapseNotificationPanel() { |
Selim Cinek | 6bb4a9b | 2014-10-09 17:48:05 -0700 | [diff] [blame] | 4456 | mNotificationPanel.instantCollapse(); |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 4457 | } |
| 4458 | |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 4459 | @Override |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 4460 | public void onActivated(ActivatableNotificationView view) { |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 4461 | EventLogTags.writeSysuiLockscreenGesture( |
| 4462 | EventLogConstants.SYSUI_LOCKSCREEN_GESTURE_TAP_NOTIFICATION_ACTIVATE, |
| 4463 | 0 /* lengthDp - N/A */, 0 /* velocityDp - N/A */); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4464 | mKeyguardIndicationController.showTransientIndication(R.string.notification_tap_again); |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 4465 | ActivatableNotificationView previousView = mStackScroller.getActivatedChild(); |
| 4466 | if (previousView != null) { |
| 4467 | previousView.makeInactive(true /* animate */); |
| 4468 | } |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4469 | mStackScroller.setActivatedChild(view); |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 4470 | } |
| 4471 | |
Annie Chin | edeb517 | 2016-06-24 17:07:08 -0700 | [diff] [blame] | 4472 | public ButtonDispatcher getHomeButton() { |
| 4473 | return mNavigationBarView.getHomeButton(); |
| 4474 | } |
| 4475 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4476 | /** |
| 4477 | * @param state The {@link StatusBarState} to set. |
| 4478 | */ |
| 4479 | public void setBarState(int state) { |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 4480 | // If we're visible and switched to SHADE_LOCKED (the user dragged |
| 4481 | // down on the lockscreen), clear notification LED, vibration, |
| 4482 | // ringing. |
| 4483 | // Other transitions are covered in handleVisibleToUserChanged(). |
Selim Cinek | 6577cae | 2015-08-31 16:15:49 -0700 | [diff] [blame] | 4484 | if (state != mState && mVisible && (state == StatusBarState.SHADE_LOCKED |
| 4485 | || (state == StatusBarState.SHADE && isGoingToNotificationShade()))) { |
| 4486 | clearNotificationEffects(); |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 4487 | } |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 4488 | if (state == StatusBarState.KEYGUARD) { |
| 4489 | removeRemoteInputEntriesKeptUntilCollapsed(); |
Selim Cinek | 9941539 | 2016-09-09 14:58:41 -0700 | [diff] [blame] | 4490 | maybeEscalateHeadsUp(); |
Adrian Roos | 18d099a | 2016-05-19 15:28:18 -0700 | [diff] [blame] | 4491 | } |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4492 | mState = state; |
Selim Cinek | 9c4c414 | 2015-12-04 16:44:56 -0800 | [diff] [blame] | 4493 | mGroupManager.setStatusBarState(state); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4494 | mFalsingManager.setStatusBarState(state); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4495 | mStatusBarWindowManager.setStatusBarState(state); |
Adrian Roos | 7bb38a9 | 2016-07-21 11:44:01 -0700 | [diff] [blame] | 4496 | updateReportRejectedTouchVisibility(); |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 4497 | updateDozing(); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4498 | } |
| 4499 | |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 4500 | @Override |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 4501 | public void onActivationReset(ActivatableNotificationView view) { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4502 | if (view == mStackScroller.getActivatedChild()) { |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4503 | mKeyguardIndicationController.hideTransientIndication(); |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4504 | mStackScroller.setActivatedChild(null); |
| 4505 | } |
Jorim Jaggi | e70d31f | 2014-04-24 22:08:30 +0200 | [diff] [blame] | 4506 | } |
| 4507 | |
| 4508 | public void onTrackingStarted() { |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 4509 | runPostCollapseRunnables(); |
Jorim Jaggi | 9012958 | 2014-06-02 14:44:49 +0200 | [diff] [blame] | 4510 | } |
| 4511 | |
Selim Cinek | dbbcfbe | 2014-10-24 17:52:35 +0200 | [diff] [blame] | 4512 | public void onClosingFinished() { |
| 4513 | runPostCollapseRunnables(); |
| 4514 | } |
| 4515 | |
Jorim Jaggi | 9012958 | 2014-06-02 14:44:49 +0200 | [diff] [blame] | 4516 | public void onUnlockHintStarted() { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4517 | mFalsingManager.onUnlockHintStarted(); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4518 | mKeyguardIndicationController.showTransientIndication(R.string.keyguard_unlock); |
Jorim Jaggi | 9012958 | 2014-06-02 14:44:49 +0200 | [diff] [blame] | 4519 | } |
| 4520 | |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 4521 | public void onHintFinished() { |
Jorim Jaggi | 93a2bb2 | 2014-06-02 19:57:28 +0200 | [diff] [blame] | 4522 | // Delay the reset a bit so the user can read the text. |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4523 | mKeyguardIndicationController.hideTransientIndicationDelayed(HINT_RESET_DELAY_MS); |
Jorim Jaggi | e70d31f | 2014-04-24 22:08:30 +0200 | [diff] [blame] | 4524 | } |
| 4525 | |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 4526 | public void onCameraHintStarted() { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4527 | mFalsingManager.onCameraHintStarted(); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4528 | mKeyguardIndicationController.showTransientIndication(R.string.camera_hint); |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 4529 | } |
| 4530 | |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 4531 | public void onVoiceAssistHintStarted() { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4532 | mFalsingManager.onLeftAffordanceHintStarted(); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 4533 | mKeyguardIndicationController.showTransientIndication(R.string.voice_hint); |
| 4534 | } |
| 4535 | |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 4536 | public void onPhoneHintStarted() { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4537 | mFalsingManager.onLeftAffordanceHintStarted(); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4538 | mKeyguardIndicationController.showTransientIndication(R.string.phone_hint); |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 4539 | } |
| 4540 | |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 4541 | public void onTrackingStopped(boolean expand) { |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 4542 | if (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) { |
Selim Cinek | e8bae62 | 2015-07-15 13:24:06 -0700 | [diff] [blame] | 4543 | if (!expand && !mUnlockMethodCache.canSkipBouncer()) { |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 4544 | showBouncer(); |
| 4545 | } |
| 4546 | } |
Jorim Jaggi | e70d31f | 2014-04-24 22:08:30 +0200 | [diff] [blame] | 4547 | } |
| 4548 | |
| 4549 | @Override |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 4550 | protected int getMaxKeyguardNotifications(boolean recompute) { |
| 4551 | if (recompute) { |
| 4552 | mMaxKeyguardNotifications = Math.max(1, |
| 4553 | mNotificationPanel.computeMaxKeyguardNotifications( |
| 4554 | mMaxAllowedKeyguardNotifications)); |
| 4555 | return mMaxKeyguardNotifications; |
| 4556 | } |
| 4557 | return mMaxKeyguardNotifications; |
| 4558 | } |
| 4559 | |
| 4560 | public int getMaxKeyguardNotifications() { |
| 4561 | return getMaxKeyguardNotifications(false /* recompute */); |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 4562 | } |
| 4563 | |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 4564 | public NavigationBarView getNavigationBarView() { |
| 4565 | return mNavigationBarView; |
| 4566 | } |
| 4567 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4568 | // ---------------------- DragDownHelper.OnDragDownListener ------------------------------------ |
| 4569 | |
Chris Wren | 6abeeb9 | 2016-05-26 14:44:38 -0400 | [diff] [blame] | 4570 | |
| 4571 | /* Only ever called as a consequence of a lockscreen expansion gesture. */ |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4572 | @Override |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 4573 | public boolean onDraggedDown(View startingChild, int dragLengthY) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 4574 | if (hasActiveNotifications()) { |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 4575 | EventLogTags.writeSysuiLockscreenGesture( |
| 4576 | EventLogConstants.SYSUI_LOCKSCREEN_GESTURE_SWIPE_DOWN_FULL_SHADE, |
| 4577 | (int) (dragLengthY / mDisplayMetrics.density), |
| 4578 | 0 /* velocityDp - N/A */); |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 4579 | |
| 4580 | // We have notifications, go to locked shade. |
| 4581 | goToLockedShade(startingChild); |
Chris Wren | 6abeeb9 | 2016-05-26 14:44:38 -0400 | [diff] [blame] | 4582 | if (startingChild instanceof ExpandableNotificationRow) { |
| 4583 | ExpandableNotificationRow row = (ExpandableNotificationRow) startingChild; |
| 4584 | row.onExpandedByGesture(true /* drag down is always an open */); |
| 4585 | } |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 4586 | return true; |
| 4587 | } else { |
| 4588 | |
| 4589 | // No notifications - abort gesture. |
| 4590 | return false; |
| 4591 | } |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4592 | } |
| 4593 | |
| 4594 | @Override |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4595 | public void onDragDownReset() { |
| 4596 | mStackScroller.setDimmed(true /* dimmed */, true /* animated */); |
Selim Cinek | 177fd43 | 2015-11-18 11:53:47 -0800 | [diff] [blame] | 4597 | mStackScroller.resetScrollPosition(); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4598 | } |
| 4599 | |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 4600 | @Override |
Selim Cinek | 177fd43 | 2015-11-18 11:53:47 -0800 | [diff] [blame] | 4601 | public void onCrossedThreshold(boolean above) { |
| 4602 | mStackScroller.setDimmed(!above /* dimmed */, true /* animate */); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4603 | } |
| 4604 | |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 4605 | @Override |
| 4606 | public void onTouchSlopExceeded() { |
| 4607 | mStackScroller.removeLongPressCallback(); |
| 4608 | } |
| 4609 | |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 4610 | @Override |
| 4611 | public void setEmptyDragAmount(float amount) { |
| 4612 | mNotificationPanel.setEmptyDragAmount(amount); |
| 4613 | } |
| 4614 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4615 | /** |
| 4616 | * If secure with redaction: Show bouncer, go to unlocked shade. |
| 4617 | * |
Jorim Jaggi | 2042ef2 | 2014-05-13 21:55:18 +0200 | [diff] [blame] | 4618 | * <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] | 4619 | * |
| 4620 | * @param expandView The view to expand after going to the shade. |
| 4621 | */ |
| 4622 | public void goToLockedShade(View expandView) { |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4623 | ExpandableNotificationRow row = null; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4624 | if (expandView instanceof ExpandableNotificationRow) { |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4625 | row = (ExpandableNotificationRow) expandView; |
Selim Cinek | cb24ab8 | 2016-02-25 12:49:08 -0800 | [diff] [blame] | 4626 | row.setUserExpanded(true /* userExpanded */, true /* allowChildExpansion */); |
Mady Mellor | b0a8246 | 2016-04-30 17:31:02 -0700 | [diff] [blame] | 4627 | // Indicate that the group expansion is changing at this time -- this way the group |
| 4628 | // and children backgrounds / divider animations will look correct. |
| 4629 | row.setGroupExpansionChanging(true); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4630 | } |
Adrian Roos | aee7046 | 2014-09-03 16:27:39 +0200 | [diff] [blame] | 4631 | boolean fullShadeNeedsBouncer = !userAllowsPrivateNotificationsInPublic(mCurrentUserId) |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4632 | || !mShowLockscreenNotifications || mFalsingManager.shouldEnforceBouncer(); |
Adrian Roos | aee7046 | 2014-09-03 16:27:39 +0200 | [diff] [blame] | 4633 | if (isLockscreenPublicMode() && fullShadeNeedsBouncer) { |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4634 | mLeaveOpenOnKeyguardHide = true; |
| 4635 | showBouncer(); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4636 | mDraggedDownRow = row; |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 4637 | mPendingRemoteInputView = null; |
Jorim Jaggi | 2042ef2 | 2014-05-13 21:55:18 +0200 | [diff] [blame] | 4638 | } else { |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4639 | mNotificationPanel.animateToFullShade(0 /* delay */); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4640 | setBarState(StatusBarState.SHADE_LOCKED); |
Jorim Jaggi | 98f8530 | 2014-08-07 17:45:04 +0200 | [diff] [blame] | 4641 | updateKeyguardState(false /* goingToFullShade */, false /* fromShadeLocked */); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4642 | } |
| 4643 | } |
| 4644 | |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 4645 | @Override |
Mady Mellor | 8e8a69e | 2016-03-14 12:30:10 -0700 | [diff] [blame] | 4646 | public void onLockedNotificationImportanceChange(OnDismissAction dismissAction) { |
| 4647 | mLeaveOpenOnKeyguardHide = true; |
| 4648 | dismissKeyguardThenExecute(dismissAction, true /* afterKeyguardGone */); |
| 4649 | } |
| 4650 | |
| 4651 | @Override |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 4652 | protected void onLockedRemoteInput(ExpandableNotificationRow row, View clicked) { |
| 4653 | mLeaveOpenOnKeyguardHide = true; |
| 4654 | showBouncer(); |
| 4655 | mPendingRemoteInputView = clicked; |
| 4656 | } |
| 4657 | |
| 4658 | @Override |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 4659 | protected boolean startWorkChallengeIfNecessary(int userId, IntentSender intendSender, |
| 4660 | String notificationKey) { |
| 4661 | // Clear pending remote view, as we do not want to trigger pending remote input view when |
| 4662 | // it's called by other code |
| 4663 | mPendingWorkRemoteInputView = null; |
| 4664 | return super.startWorkChallengeIfNecessary(userId, intendSender, notificationKey); |
| 4665 | } |
| 4666 | |
| 4667 | @Override |
| 4668 | protected void onLockedWorkRemoteInput(int userId, ExpandableNotificationRow row, |
| 4669 | View clicked) { |
| 4670 | // Collapse notification and show work challenge |
| 4671 | animateCollapsePanels(); |
| 4672 | startWorkChallengeIfNecessary(userId, null, null); |
| 4673 | // Add pending remote input view after starting work challenge, as starting work challenge |
| 4674 | // will clear all previous pending review view |
| 4675 | mPendingWorkRemoteInputView = clicked; |
| 4676 | } |
| 4677 | |
| 4678 | @Override |
| 4679 | protected void onWorkChallengeUnlocked() { |
| 4680 | if (mPendingWorkRemoteInputView != null) { |
| 4681 | final View pendingWorkRemoteInputView = mPendingWorkRemoteInputView; |
| 4682 | // Expand notification panel and the notification row, then click on remote input view |
| 4683 | final Runnable clickPendingViewRunnable = new Runnable() { |
| 4684 | @Override |
| 4685 | public void run() { |
| 4686 | if (mPendingWorkRemoteInputView != null) { |
| 4687 | final View pendingWorkRemoteInputView = mPendingWorkRemoteInputView; |
| 4688 | ViewParent p = pendingWorkRemoteInputView.getParent(); |
| 4689 | while (p != null) { |
| 4690 | if (p instanceof ExpandableNotificationRow) { |
| 4691 | final ExpandableNotificationRow row = (ExpandableNotificationRow) p; |
| 4692 | ViewParent viewParent = row.getParent(); |
| 4693 | if (viewParent instanceof NotificationStackScrollLayout) { |
| 4694 | final NotificationStackScrollLayout scrollLayout = |
| 4695 | (NotificationStackScrollLayout) viewParent; |
| 4696 | row.makeActionsVisibile(); |
| 4697 | row.post(new Runnable() { |
| 4698 | @Override |
| 4699 | public void run() { |
| 4700 | final Runnable finishScrollingCallback = new Runnable() |
| 4701 | { |
| 4702 | @Override |
| 4703 | public void run() { |
| 4704 | mPendingWorkRemoteInputView.callOnClick(); |
| 4705 | mPendingWorkRemoteInputView = null; |
| 4706 | scrollLayout.setFinishScrollingCallback(null); |
| 4707 | } |
| 4708 | }; |
| 4709 | if (scrollLayout.scrollTo(row)) { |
| 4710 | // It scrolls! So call it when it's finished. |
| 4711 | scrollLayout.setFinishScrollingCallback( |
| 4712 | finishScrollingCallback); |
| 4713 | } else { |
| 4714 | // It does not scroll, so call it now! |
| 4715 | finishScrollingCallback.run(); |
| 4716 | } |
| 4717 | } |
| 4718 | }); |
| 4719 | } |
| 4720 | break; |
| 4721 | } |
| 4722 | p = p.getParent(); |
| 4723 | } |
| 4724 | } |
| 4725 | } |
| 4726 | }; |
| 4727 | mNotificationPanel.getViewTreeObserver().addOnGlobalLayoutListener( |
| 4728 | new ViewTreeObserver.OnGlobalLayoutListener() { |
| 4729 | @Override |
| 4730 | public void onGlobalLayout() { |
| 4731 | if (mNotificationPanel.mStatusBar.getStatusBarWindow() |
| 4732 | .getHeight() != mNotificationPanel.mStatusBar |
| 4733 | .getStatusBarHeight()) { |
| 4734 | mNotificationPanel.getViewTreeObserver() |
| 4735 | .removeOnGlobalLayoutListener(this); |
| 4736 | mNotificationPanel.post(clickPendingViewRunnable); |
| 4737 | } |
| 4738 | } |
| 4739 | }); |
| 4740 | instantExpandNotificationsPanel(); |
| 4741 | } |
| 4742 | } |
| 4743 | |
| 4744 | @Override |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 4745 | public void onExpandClicked(Entry clickedEntry, boolean nowExpanded) { |
| 4746 | mHeadsUpManager.setExpanded(clickedEntry, nowExpanded); |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 4747 | if (mState == StatusBarState.KEYGUARD && nowExpanded) { |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 4748 | goToLockedShade(clickedEntry.row); |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 4749 | } |
| 4750 | } |
| 4751 | |
Adrian Roos | 5a46cd3 | 2014-04-03 16:51:58 +0200 | [diff] [blame] | 4752 | /** |
Jorim Jaggi | 6539a83 | 2014-06-03 23:33:09 +0200 | [diff] [blame] | 4753 | * Goes back to the keyguard after hanging around in {@link StatusBarState#SHADE_LOCKED}. |
| 4754 | */ |
| 4755 | public void goToKeyguard() { |
| 4756 | if (mState == StatusBarState.SHADE_LOCKED) { |
Selim Cinek | d9acca5 | 2014-09-01 22:33:25 +0200 | [diff] [blame] | 4757 | mStackScroller.onGoToKeyguard(); |
Jorim Jaggi | 6539a83 | 2014-06-03 23:33:09 +0200 | [diff] [blame] | 4758 | setBarState(StatusBarState.KEYGUARD); |
Jorim Jaggi | 98f8530 | 2014-08-07 17:45:04 +0200 | [diff] [blame] | 4759 | updateKeyguardState(false /* goingToFullShade */, true /* fromShadeLocked*/); |
Jorim Jaggi | 6539a83 | 2014-06-03 23:33:09 +0200 | [diff] [blame] | 4760 | } |
| 4761 | } |
| 4762 | |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4763 | public long getKeyguardFadingAwayDelay() { |
| 4764 | return mKeyguardFadingAwayDelay; |
| 4765 | } |
| 4766 | |
| 4767 | public long getKeyguardFadingAwayDuration() { |
| 4768 | return mKeyguardFadingAwayDuration; |
| 4769 | } |
| 4770 | |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4771 | @Override |
| 4772 | public void setBouncerShowing(boolean bouncerShowing) { |
| 4773 | super.setBouncerShowing(bouncerShowing); |
Adrian Roos | d0b2f7d | 2015-04-29 13:36:12 -0700 | [diff] [blame] | 4774 | mStatusBarView.setBouncerShowing(bouncerShowing); |
Adrian Roos | 316bf54 | 2016-08-23 17:53:07 +0200 | [diff] [blame] | 4775 | recomputeDisableFlags(true /* animate */); |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4776 | } |
| 4777 | |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4778 | public void onStartedGoingToSleep() { |
| 4779 | mStartedGoingToSleep = true; |
| 4780 | } |
| 4781 | |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4782 | public void onFinishedGoingToSleep() { |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4783 | mNotificationPanel.onAffordanceLaunchEnded(); |
| 4784 | releaseGestureWakeLock(); |
| 4785 | mLaunchCameraOnScreenTurningOn = false; |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4786 | mStartedGoingToSleep = false; |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4787 | mDeviceInteractive = false; |
| 4788 | mWakeUpComingFromTouch = false; |
| 4789 | mWakeUpTouchLocation = null; |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 4790 | mStackScroller.setAnimationsEnabled(false); |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 4791 | updateVisibleToUser(); |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4792 | if (mLaunchCameraOnFinishedGoingToSleep) { |
| 4793 | mLaunchCameraOnFinishedGoingToSleep = false; |
| 4794 | |
| 4795 | // This gets executed before we will show Keyguard, so post it in order that the state |
| 4796 | // is correct. |
| 4797 | mHandler.post(new Runnable() { |
| 4798 | @Override |
| 4799 | public void run() { |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 4800 | onCameraLaunchGestureDetected(mLastCameraLaunchSource); |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4801 | } |
| 4802 | }); |
| 4803 | } |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 4804 | } |
| 4805 | |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4806 | public void onStartedWakingUp() { |
| 4807 | mDeviceInteractive = true; |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 4808 | mStackScroller.setAnimationsEnabled(true); |
Jorim Jaggi | d41083a | 2014-09-12 02:54:40 +0200 | [diff] [blame] | 4809 | mNotificationPanel.setTouchDisabled(false); |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 4810 | updateVisibleToUser(); |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 4811 | } |
John Spurlock | d08f91f | 2014-05-23 11:00:34 -0400 | [diff] [blame] | 4812 | |
Jorim Jaggi | 9373911 | 2015-08-13 15:53:14 -0700 | [diff] [blame] | 4813 | public void onScreenTurningOn() { |
Selim Cinek | 1b6f819 | 2015-09-03 16:01:53 -0700 | [diff] [blame] | 4814 | mScreenTurningOn = true; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4815 | mFalsingManager.onScreenTurningOn(); |
Jorim Jaggi | 9373911 | 2015-08-13 15:53:14 -0700 | [diff] [blame] | 4816 | mNotificationPanel.onScreenTurningOn(); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4817 | if (mLaunchCameraOnScreenTurningOn) { |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 4818 | mNotificationPanel.launchCamera(false, mLastCameraLaunchSource); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4819 | mLaunchCameraOnScreenTurningOn = false; |
| 4820 | } |
Jorim Jaggi | 9373911 | 2015-08-13 15:53:14 -0700 | [diff] [blame] | 4821 | } |
| 4822 | |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 4823 | private void vibrateForCameraGesture() { |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4824 | // 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] | 4825 | mVibrator.vibrate(new long[]{0, 400}, -1 /* repeat */); |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 4826 | } |
| 4827 | |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4828 | public void onScreenTurnedOn() { |
Selim Cinek | 1b6f819 | 2015-09-03 16:01:53 -0700 | [diff] [blame] | 4829 | mScreenTurningOn = false; |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4830 | mDozeScrimController.onScreenTurnedOn(); |
| 4831 | } |
| 4832 | |
Jason Monk | 815e057 | 2014-08-12 17:26:36 -0400 | [diff] [blame] | 4833 | /** |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 4834 | * Handles long press for back button. This exits screen pinning. |
Jason Monk | 815e057 | 2014-08-12 17:26:36 -0400 | [diff] [blame] | 4835 | */ |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 4836 | private boolean handleLongPressBack() { |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 4837 | try { |
| 4838 | IActivityManager activityManager = ActivityManagerNative.getDefault(); |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 4839 | if (activityManager.isInLockTaskMode()) { |
Andrii Kulian | 0f051f5 | 2016-04-14 00:41:51 -0700 | [diff] [blame] | 4840 | activityManager.stopSystemLockTaskMode(); |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 4841 | |
| 4842 | // When exiting refresh disabled flags. |
| 4843 | mNavigationBarView.setDisabledFlags(mDisabled1, true); |
| 4844 | return true; |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 4845 | } |
| 4846 | } catch (RemoteException e) { |
Jason Monk | 815e057 | 2014-08-12 17:26:36 -0400 | [diff] [blame] | 4847 | Log.d(TAG, "Unable to reach activity manager", e); |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 4848 | } |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 4849 | return false; |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 4850 | } |
| 4851 | |
Jason Monk | 5565cb4 | 2014-09-12 10:59:21 -0400 | [diff] [blame] | 4852 | @Override |
Andrii Kulian | 0f051f5 | 2016-04-14 00:41:51 -0700 | [diff] [blame] | 4853 | public void showScreenPinningRequest(int taskId) { |
Jason Monk | 18f99d9 | 2014-09-11 13:36:42 -0400 | [diff] [blame] | 4854 | if (mKeyguardMonitor.isShowing()) { |
| 4855 | // Don't allow apps to trigger this from keyguard. |
| 4856 | return; |
| 4857 | } |
| 4858 | // 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] | 4859 | showScreenPinningRequest(taskId, true); |
Jason Monk | 18f99d9 | 2014-09-11 13:36:42 -0400 | [diff] [blame] | 4860 | } |
| 4861 | |
Andrii Kulian | 0f051f5 | 2016-04-14 00:41:51 -0700 | [diff] [blame] | 4862 | public void showScreenPinningRequest(int taskId, boolean allowCancel) { |
| 4863 | mScreenPinningRequest.showPrompt(taskId, allowCancel); |
Jason Monk | 5565cb4 | 2014-09-12 10:59:21 -0400 | [diff] [blame] | 4864 | } |
| 4865 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 4866 | public boolean hasActiveNotifications() { |
| 4867 | return !mNotificationData.getActiveNotifications().isEmpty(); |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 4868 | } |
| 4869 | |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 4870 | public void wakeUpIfDozing(long time, MotionEvent event) { |
Jorim Jaggi | 048af1f | 2014-11-11 22:51:10 +0100 | [diff] [blame] | 4871 | if (mDozing && mDozeScrimController.isPulsing()) { |
John Spurlock | 8b12f22 | 2014-09-09 11:54:11 -0400 | [diff] [blame] | 4872 | PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); |
Dianne Hackborn | 280a64e | 2015-07-13 14:48:08 -0700 | [diff] [blame] | 4873 | pm.wakeUp(time, "com.android.systemui:NODOZE"); |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4874 | mWakeUpComingFromTouch = true; |
| 4875 | mWakeUpTouchLocation = new PointF(event.getX(), event.getY()); |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 4876 | mNotificationPanel.setTouchDisabled(false); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 4877 | mStatusBarKeyguardViewManager.notifyDeviceWakeUpRequested(); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4878 | mFalsingManager.onScreenOnFromTouch(); |
John Spurlock | 8b12f22 | 2014-09-09 11:54:11 -0400 | [diff] [blame] | 4879 | } |
| 4880 | } |
| 4881 | |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 4882 | @Override |
| 4883 | public void appTransitionPending() { |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4884 | |
| 4885 | // Use own timings when Keyguard is going away, see keyguardGoingAway and |
| 4886 | // setKeyguardFadingAway |
| 4887 | if (!mKeyguardFadingAway) { |
| 4888 | mIconController.appTransitionPending(); |
| 4889 | } |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 4890 | } |
| 4891 | |
| 4892 | @Override |
| 4893 | public void appTransitionCancelled() { |
| 4894 | mIconController.appTransitionCancelled(); |
Jorim Jaggi | 2adba07 | 2016-03-03 13:43:39 +0100 | [diff] [blame] | 4895 | EventBus.getDefault().send(new AppTransitionFinishedEvent()); |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 4896 | } |
| 4897 | |
| 4898 | @Override |
| 4899 | public void appTransitionStarting(long startTime, long duration) { |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4900 | |
| 4901 | // Use own timings when Keyguard is going away, see keyguardGoingAway and |
Adrian Roos | 46df1ca | 2015-09-11 12:38:43 -0700 | [diff] [blame] | 4902 | // setKeyguardFadingAway. |
| 4903 | if (!mKeyguardGoingAway) { |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4904 | mIconController.appTransitionStarting(startTime, duration); |
| 4905 | } |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 4906 | if (mIconPolicy != null) { |
| 4907 | mIconPolicy.appTransitionStarting(startTime, duration); |
| 4908 | } |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 4909 | } |
| 4910 | |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4911 | @Override |
Jorim Jaggi | 2adba07 | 2016-03-03 13:43:39 +0100 | [diff] [blame] | 4912 | public void appTransitionFinished() { |
| 4913 | EventBus.getDefault().send(new AppTransitionFinishedEvent()); |
| 4914 | } |
| 4915 | |
| 4916 | @Override |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 4917 | public void onCameraLaunchGestureDetected(int source) { |
| 4918 | mLastCameraLaunchSource = source; |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4919 | if (mStartedGoingToSleep) { |
| 4920 | mLaunchCameraOnFinishedGoingToSleep = true; |
| 4921 | return; |
| 4922 | } |
Zhentao Sun | 04f9740 | 2015-08-26 17:37:30 -0700 | [diff] [blame] | 4923 | if (!mNotificationPanel.canCameraGestureBeLaunched( |
| 4924 | mStatusBarKeyguardViewManager.isShowing() && mExpandedVisible)) { |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4925 | return; |
| 4926 | } |
| 4927 | if (!mDeviceInteractive) { |
| 4928 | PowerManager pm = mContext.getSystemService(PowerManager.class); |
| 4929 | pm.wakeUp(SystemClock.uptimeMillis(), "com.android.systemui:CAMERA_GESTURE"); |
| 4930 | mStatusBarKeyguardViewManager.notifyDeviceWakeUpRequested(); |
| 4931 | } |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 4932 | vibrateForCameraGesture(); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4933 | if (!mStatusBarKeyguardViewManager.isShowing()) { |
| 4934 | startActivity(KeyguardBottomAreaView.INSECURE_CAMERA_INTENT, |
| 4935 | true /* dismissShade */); |
| 4936 | } else { |
| 4937 | if (!mDeviceInteractive) { |
| 4938 | // Avoid flickering of the scrim when we instant launch the camera and the bouncer |
| 4939 | // comes on. |
| 4940 | mScrimController.dontAnimateBouncerChangesUntilNextFrame(); |
| 4941 | mGestureWakeLock.acquire(LAUNCH_TRANSITION_TIMEOUT_MS + 1000L); |
| 4942 | } |
Selim Cinek | 1b6f819 | 2015-09-03 16:01:53 -0700 | [diff] [blame] | 4943 | if (mScreenTurningOn || mStatusBarKeyguardViewManager.isScreenTurnedOn()) { |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 4944 | mNotificationPanel.launchCamera(mDeviceInteractive /* animate */, source); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4945 | } else { |
| 4946 | // We need to defer the camera launch until the screen comes on, since otherwise |
| 4947 | // we will dismiss us too early since we are waiting on an activity to be drawn and |
| 4948 | // incorrectly get notified because of the screen on event (which resumes and pauses |
| 4949 | // some activities) |
| 4950 | mLaunchCameraOnScreenTurningOn = true; |
| 4951 | } |
| 4952 | } |
| 4953 | } |
| 4954 | |
Jaewan Kim | c552b04 | 2016-01-18 16:08:45 +0900 | [diff] [blame] | 4955 | @Override |
Jaewan Kim | f0fd218 | 2016-04-20 21:17:58 +0900 | [diff] [blame] | 4956 | public void showTvPictureInPictureMenu() { |
Jaewan Kim | c552b04 | 2016-01-18 16:08:45 +0900 | [diff] [blame] | 4957 | // no-op. |
| 4958 | } |
| 4959 | |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 4960 | public void notifyFpAuthModeChanged() { |
| 4961 | updateDozing(); |
| 4962 | } |
| 4963 | |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 4964 | private void updateDozing() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 4965 | Trace.beginSection("PhoneStatusBar#updateDozing"); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 4966 | // When in wake-and-unlock while pulsing, keep dozing state until fully unlocked. |
| 4967 | mDozing = mDozingRequested && mState == StatusBarState.KEYGUARD |
| 4968 | || mFingerprintUnlockController.getMode() |
| 4969 | == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING; |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 4970 | updateDozingState(); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 4971 | Trace.endSection(); |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 4972 | } |
| 4973 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4974 | private final class ShadeUpdates { |
| 4975 | private final ArraySet<String> mVisibleNotifications = new ArraySet<String>(); |
| 4976 | private final ArraySet<String> mNewVisibleNotifications = new ArraySet<String>(); |
| 4977 | |
| 4978 | public void check() { |
| 4979 | mNewVisibleNotifications.clear(); |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 4980 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
| 4981 | for (int i = 0; i < activeNotifications.size(); i++) { |
| 4982 | final Entry entry = activeNotifications.get(i); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4983 | final boolean visible = entry.row != null |
| 4984 | && entry.row.getVisibility() == View.VISIBLE; |
| 4985 | if (visible) { |
| 4986 | mNewVisibleNotifications.add(entry.key + entry.notification.getPostTime()); |
| 4987 | } |
| 4988 | } |
| 4989 | final boolean updates = !mVisibleNotifications.containsAll(mNewVisibleNotifications); |
| 4990 | mVisibleNotifications.clear(); |
Dianne Hackborn | 497175b | 2014-07-01 12:56:08 -0700 | [diff] [blame] | 4991 | mVisibleNotifications.addAll(mNewVisibleNotifications); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4992 | |
| 4993 | // We have new notifications |
| 4994 | if (updates && mDozeServiceHost != null) { |
| 4995 | mDozeServiceHost.fireNewNotifications(); |
| 4996 | } |
| 4997 | } |
| 4998 | } |
| 4999 | |
Selim Cinek | 9941539 | 2016-09-09 14:58:41 -0700 | [diff] [blame] | 5000 | private final class DozeServiceHost implements DozeHost { |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5001 | // Amount of time to allow to update the time shown on the screen before releasing |
| 5002 | // the wakelock. This timeout is design to compensate for the fact that we don't |
| 5003 | // currently have a way to know when time display contents have actually been |
| 5004 | // refreshed once we've finished rendering a new frame. |
| 5005 | private static final long PROCESSING_TIME = 500; |
| 5006 | |
| 5007 | private final ArrayList<Callback> mCallbacks = new ArrayList<Callback>(); |
| 5008 | private final H mHandler = new H(); |
| 5009 | |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 5010 | // Keeps the last reported state by fireNotificationLight. |
| 5011 | private boolean mNotificationLightOn; |
| 5012 | |
John Spurlock | c6eed84 | 2014-08-25 12:19:41 -0400 | [diff] [blame] | 5013 | @Override |
| 5014 | public String toString() { |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 5015 | return "PSB.DozeServiceHost[mCallbacks=" + mCallbacks.size() + "]"; |
John Spurlock | 8b12f22 | 2014-09-09 11:54:11 -0400 | [diff] [blame] | 5016 | } |
| 5017 | |
John Spurlock | d96179e | 2014-08-21 16:43:45 -0400 | [diff] [blame] | 5018 | public void firePowerSaveChanged(boolean active) { |
| 5019 | for (Callback callback : mCallbacks) { |
| 5020 | callback.onPowerSaveChanged(active); |
| 5021 | } |
| 5022 | } |
| 5023 | |
John Spurlock | cad5768 | 2014-07-26 17:09:56 -0400 | [diff] [blame] | 5024 | public void fireBuzzBeepBlinked() { |
| 5025 | for (Callback callback : mCallbacks) { |
| 5026 | callback.onBuzzBeepBlinked(); |
| 5027 | } |
| 5028 | } |
| 5029 | |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 5030 | public void fireNotificationLight(boolean on) { |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 5031 | mNotificationLightOn = on; |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 5032 | for (Callback callback : mCallbacks) { |
| 5033 | callback.onNotificationLight(on); |
| 5034 | } |
| 5035 | } |
| 5036 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5037 | public void fireNewNotifications() { |
| 5038 | for (Callback callback : mCallbacks) { |
| 5039 | callback.onNewNotifications(); |
| 5040 | } |
| 5041 | } |
| 5042 | |
| 5043 | @Override |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 5044 | public void addCallback(@NonNull Callback callback) { |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5045 | mCallbacks.add(callback); |
| 5046 | } |
| 5047 | |
| 5048 | @Override |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 5049 | public void removeCallback(@NonNull Callback callback) { |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5050 | mCallbacks.remove(callback); |
| 5051 | } |
| 5052 | |
| 5053 | @Override |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 5054 | public void startDozing(@NonNull Runnable ready) { |
| 5055 | mHandler.obtainMessage(H.MSG_START_DOZING, ready).sendToTarget(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5056 | } |
| 5057 | |
| 5058 | @Override |
John Spurlock | eab28e6 | 2014-11-29 11:33:49 -0500 | [diff] [blame] | 5059 | public void pulseWhileDozing(@NonNull PulseCallback callback, int reason) { |
| 5060 | mHandler.obtainMessage(H.MSG_PULSE_WHILE_DOZING, reason, 0, callback).sendToTarget(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5061 | } |
| 5062 | |
| 5063 | @Override |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 5064 | public void stopDozing() { |
| 5065 | mHandler.obtainMessage(H.MSG_STOP_DOZING).sendToTarget(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5066 | } |
| 5067 | |
John Spurlock | d96179e | 2014-08-21 16:43:45 -0400 | [diff] [blame] | 5068 | @Override |
| 5069 | public boolean isPowerSaveActive() { |
| 5070 | return mBatteryController != null && mBatteryController.isPowerSave(); |
| 5071 | } |
| 5072 | |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 5073 | @Override |
Jorim Jaggi | 007f0e8 | 2015-08-14 13:56:01 -0700 | [diff] [blame] | 5074 | public boolean isPulsingBlocked() { |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 5075 | return mFingerprintUnlockController.getMode() |
| 5076 | == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK; |
Jorim Jaggi | 007f0e8 | 2015-08-14 13:56:01 -0700 | [diff] [blame] | 5077 | } |
| 5078 | |
| 5079 | @Override |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 5080 | public boolean isNotificationLightOn() { |
| 5081 | return mNotificationLightOn; |
| 5082 | } |
| 5083 | |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 5084 | private void handleStartDozing(@NonNull Runnable ready) { |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 5085 | if (!mDozingRequested) { |
| 5086 | mDozingRequested = true; |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 5087 | DozeLog.traceDozing(mContext, mDozing); |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 5088 | updateDozing(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5089 | } |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 5090 | ready.run(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5091 | } |
| 5092 | |
John Spurlock | eab28e6 | 2014-11-29 11:33:49 -0500 | [diff] [blame] | 5093 | private void handlePulseWhileDozing(@NonNull PulseCallback callback, int reason) { |
Selim Cinek | cd5b22f | 2016-03-08 16:15:41 -0800 | [diff] [blame] | 5094 | mDozeScrimController.pulse(new PulseCallback() { |
| 5095 | |
| 5096 | @Override |
| 5097 | public void onPulseStarted() { |
| 5098 | callback.onPulseStarted(); |
| 5099 | mStackScroller.setPulsing(true); |
| 5100 | } |
| 5101 | |
| 5102 | @Override |
| 5103 | public void onPulseFinished() { |
| 5104 | callback.onPulseFinished(); |
| 5105 | mStackScroller.setPulsing(false); |
| 5106 | } |
| 5107 | }, reason); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5108 | } |
| 5109 | |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 5110 | private void handleStopDozing() { |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 5111 | if (mDozingRequested) { |
| 5112 | mDozingRequested = false; |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 5113 | DozeLog.traceDozing(mContext, mDozing); |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 5114 | updateDozing(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5115 | } |
| 5116 | } |
| 5117 | |
| 5118 | private final class H extends Handler { |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 5119 | private static final int MSG_START_DOZING = 1; |
| 5120 | private static final int MSG_PULSE_WHILE_DOZING = 2; |
| 5121 | private static final int MSG_STOP_DOZING = 3; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5122 | |
| 5123 | @Override |
| 5124 | public void handleMessage(Message msg) { |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 5125 | switch (msg.what) { |
| 5126 | case MSG_START_DOZING: |
| 5127 | handleStartDozing((Runnable) msg.obj); |
| 5128 | break; |
| 5129 | case MSG_PULSE_WHILE_DOZING: |
John Spurlock | eab28e6 | 2014-11-29 11:33:49 -0500 | [diff] [blame] | 5130 | handlePulseWhileDozing((PulseCallback) msg.obj, msg.arg1); |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 5131 | break; |
| 5132 | case MSG_STOP_DOZING: |
| 5133 | handleStopDozing(); |
| 5134 | break; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 5135 | } |
| 5136 | } |
| 5137 | } |
| 5138 | } |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 5139 | } |