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 | |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 20 | import android.animation.Animator; |
| 21 | import android.animation.AnimatorListenerAdapter; |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 22 | import android.annotation.NonNull; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 23 | import android.app.ActivityManager; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 24 | import android.app.ActivityManagerNative; |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 25 | import android.app.IActivityManager; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 26 | import android.app.Notification; |
| 27 | import android.app.PendingIntent; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 28 | import android.app.StatusBarManager; |
| 29 | import android.content.BroadcastReceiver; |
Jorim Jaggi | 786afcb | 2014-09-25 02:41:29 +0200 | [diff] [blame] | 30 | import android.content.ComponentCallbacks2; |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 31 | import android.content.ComponentName; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 32 | import android.content.Context; |
| 33 | import android.content.Intent; |
| 34 | import android.content.IntentFilter; |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 35 | import android.content.IntentSender; |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 36 | import android.content.pm.IPackageManager; |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 37 | import android.content.pm.PackageManager; |
Tony Mak | 92c989d | 2016-04-19 14:02:44 +0100 | [diff] [blame] | 38 | import android.content.pm.UserInfo; |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 39 | import android.content.res.Configuration; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 40 | import android.content.res.Resources; |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 41 | import android.database.ContentObserver; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 42 | import android.graphics.Bitmap; |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 43 | import android.graphics.Canvas; |
| 44 | import android.graphics.ColorFilter; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 45 | import android.graphics.PixelFormat; |
Daniel Sandler | e680f54 | 2012-09-28 12:22:27 -0400 | [diff] [blame] | 46 | import android.graphics.Point; |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 47 | import android.graphics.PointF; |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 48 | import android.graphics.PorterDuff; |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 49 | import android.graphics.PorterDuffXfermode; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 50 | import android.graphics.Rect; |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 51 | import android.graphics.drawable.BitmapDrawable; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 52 | import android.graphics.drawable.ColorDrawable; |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 53 | import android.graphics.drawable.Drawable; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 54 | import android.inputmethodservice.InputMethodService; |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 55 | import android.media.AudioAttributes; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 56 | import android.media.MediaMetadata; |
| 57 | import android.media.session.MediaController; |
| 58 | import android.media.session.MediaSession; |
| 59 | import android.media.session.MediaSessionManager; |
| 60 | import android.media.session.PlaybackState; |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 61 | import android.os.AsyncTask; |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 62 | import android.os.Bundle; |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 63 | import android.os.Handler; |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 64 | import android.os.HandlerThread; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 65 | import android.os.IBinder; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 66 | import android.os.Message; |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 67 | import android.os.PowerManager; |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 68 | import android.os.Process; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 69 | import android.os.RemoteException; |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 70 | import android.os.ServiceManager; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 71 | import android.os.SystemClock; |
Dianne Hackborn | f02b60a | 2012-08-16 10:48:27 -0700 | [diff] [blame] | 72 | import android.os.UserHandle; |
Adrian Roos | 2b154a9 | 2014-11-17 15:18:39 +0100 | [diff] [blame] | 73 | import android.os.UserManager; |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 74 | import android.os.Vibrator; |
Daniel Sandler | d309056 | 2011-08-09 00:28:44 -0400 | [diff] [blame] | 75 | import android.provider.Settings; |
Chris Wren | 3ad4e3a | 2014-09-02 17:23:51 -0400 | [diff] [blame] | 76 | import android.service.notification.NotificationListenerService; |
Christoph Studer | d0694b6 | 2014-06-04 16:36:01 +0200 | [diff] [blame] | 77 | import android.service.notification.NotificationListenerService.RankingMap; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 78 | import android.service.notification.StatusBarNotification; |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 79 | import android.util.ArraySet; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 80 | import android.util.DisplayMetrics; |
Chris Wren | 64161cc | 2012-12-17 16:49:30 -0500 | [diff] [blame] | 81 | import android.util.EventLog; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 82 | import android.util.Log; |
| 83 | import android.view.Display; |
Jorim Jaggi | df99351 | 2014-05-13 23:06:35 +0200 | [diff] [blame] | 84 | import android.view.KeyEvent; |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 85 | import android.view.LayoutInflater; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 86 | import android.view.MotionEvent; |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 87 | import android.view.ThreadedRenderer; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 88 | import android.view.View; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 89 | import android.view.ViewGroup; |
Jim Miller | f2a16b2 | 2011-07-06 17:32:48 -0700 | [diff] [blame] | 90 | import android.view.ViewGroup.LayoutParams; |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 91 | import android.view.ViewParent; |
Dan Sandler | 44c0dfd | 2014-06-09 11:26:16 -0400 | [diff] [blame] | 92 | import android.view.ViewStub; |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 93 | import android.view.ViewTreeObserver; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 94 | import android.view.WindowManager; |
Jorim Jaggi | 786afcb | 2014-09-25 02:41:29 +0200 | [diff] [blame] | 95 | import android.view.WindowManagerGlobal; |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 96 | import android.view.animation.AccelerateInterpolator; |
Jorim Jaggi | b13d36d | 2014-06-06 18:03:52 +0200 | [diff] [blame] | 97 | import android.view.animation.Interpolator; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 98 | import android.widget.ImageView; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 99 | import android.widget.TextView; |
Chris Wren | 9763d42 | 2015-04-30 15:24:05 -0400 | [diff] [blame] | 100 | import com.android.internal.logging.MetricsLogger; |
Chris Wren | f6e9228b | 2016-01-26 18:04:35 -0500 | [diff] [blame] | 101 | import com.android.internal.logging.MetricsProto.MetricsEvent; |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 102 | import com.android.internal.statusbar.NotificationVisibility; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 103 | import com.android.internal.statusbar.StatusBarIcon; |
Jorim Jaggi | 6b88cdf | 2014-12-22 20:56:50 +0100 | [diff] [blame] | 104 | import com.android.keyguard.KeyguardHostView.OnDismissAction; |
Jason Monk | ab52527 | 2015-07-13 17:02:49 -0400 | [diff] [blame] | 105 | import com.android.keyguard.KeyguardUpdateMonitor; |
Jorim Jaggi | 007f0e8 | 2015-08-14 13:56:01 -0700 | [diff] [blame] | 106 | import com.android.keyguard.KeyguardUpdateMonitorCallback; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 107 | import com.android.keyguard.ViewMediatorCallback; |
Clara Bayarri | 9b1fdff | 2016-04-21 14:28:47 +0100 | [diff] [blame] | 108 | import com.android.systemui.AutoReinflateContainer; |
| 109 | import com.android.systemui.AutoReinflateContainer.InflateListener; |
Jorim Jaggi | 708f772 | 2014-08-20 17:30:38 +0200 | [diff] [blame] | 110 | import com.android.systemui.BatteryMeterView; |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 111 | import com.android.systemui.DemoMode; |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 112 | import com.android.systemui.EventLogConstants; |
Chris Wren | 64161cc | 2012-12-17 16:49:30 -0500 | [diff] [blame] | 113 | import com.android.systemui.EventLogTags; |
Winson | c0d7058 | 2016-01-29 10:24:39 -0800 | [diff] [blame] | 114 | import com.android.systemui.Interpolators; |
Andrew Flynn | 8286257 | 2015-04-01 14:22:37 -0400 | [diff] [blame] | 115 | import com.android.systemui.Prefs; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 116 | import com.android.systemui.R; |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 117 | import com.android.systemui.SystemUIFactory; |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 118 | import com.android.systemui.assist.AssistManager; |
Adrian Roos | 401caae | 2016-03-04 13:35:21 -0800 | [diff] [blame] | 119 | import com.android.systemui.classifier.FalsingLog; |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 120 | import com.android.systemui.classifier.FalsingManager; |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 121 | import com.android.systemui.doze.DozeHost; |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 122 | import com.android.systemui.doze.DozeLog; |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 123 | import com.android.systemui.keyguard.KeyguardViewMediator; |
Jason Monk | 162011e | 2016-02-19 08:11:55 -0500 | [diff] [blame] | 124 | import com.android.systemui.qs.QSContainer; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 125 | import com.android.systemui.qs.QSPanel; |
Jorim Jaggi | d61f227 | 2014-12-19 20:35:35 +0100 | [diff] [blame] | 126 | import com.android.systemui.recents.ScreenPinningRequest; |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 127 | import com.android.systemui.recents.events.EventBus; |
Jorim Jaggi | 2adba07 | 2016-03-03 13:43:39 +0100 | [diff] [blame] | 128 | import com.android.systemui.recents.events.activity.AppTransitionFinishedEvent; |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 129 | import com.android.systemui.recents.events.activity.UndockingTaskEvent; |
Jorim Jaggi | dd98d41 | 2015-11-18 15:57:38 -0800 | [diff] [blame] | 130 | import com.android.systemui.stackdivider.Divider; |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 131 | import com.android.systemui.stackdivider.WindowManagerProxy; |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 132 | import com.android.systemui.statusbar.ActivatableNotificationView; |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 133 | import com.android.systemui.statusbar.BackDropView; |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 134 | import com.android.systemui.statusbar.BaseStatusBar; |
Michael Jurka | a600fd9 | 2012-06-25 15:57:05 -0700 | [diff] [blame] | 135 | import com.android.systemui.statusbar.CommandQueue; |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 136 | import com.android.systemui.statusbar.DismissView; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 137 | import com.android.systemui.statusbar.DragDownHelper; |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 138 | import com.android.systemui.statusbar.EmptyShadeView; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 139 | import com.android.systemui.statusbar.ExpandableNotificationRow; |
Daniel Sandler | 3380534 | 2012-07-23 15:45:12 -0400 | [diff] [blame] | 140 | import com.android.systemui.statusbar.GestureRecorder; |
Andrei Stingaceanu | f86bc97 | 2016-04-12 15:29:25 +0100 | [diff] [blame] | 141 | import com.android.systemui.statusbar.KeyboardShortcuts; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 142 | import com.android.systemui.statusbar.KeyguardIndicationController; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 143 | import com.android.systemui.statusbar.NotificationData; |
Daniel Sandler | 58b173b | 2012-05-03 11:25:29 -0400 | [diff] [blame] | 144 | import com.android.systemui.statusbar.NotificationData.Entry; |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 145 | import com.android.systemui.statusbar.NotificationOverflowContainer; |
Adrian Roos | 1c0ca50 | 2015-10-07 12:20:42 -0700 | [diff] [blame] | 146 | import com.android.systemui.statusbar.RemoteInputController; |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 147 | import com.android.systemui.statusbar.ScrimView; |
Christian Robertson | 2e34742 | 2011-08-11 14:01:04 -0700 | [diff] [blame] | 148 | import com.android.systemui.statusbar.SignalClusterView; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 149 | import com.android.systemui.statusbar.StatusBarState; |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 150 | import com.android.systemui.statusbar.phone.UnlockMethodCache.OnUnlockMethodChangedListener; |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 151 | import com.android.systemui.statusbar.policy.AccessibilityController; |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 152 | import com.android.systemui.statusbar.policy.BatteryController; |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 153 | import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback; |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 154 | import com.android.systemui.statusbar.policy.BatteryControllerImpl; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 155 | import com.android.systemui.statusbar.policy.BluetoothControllerImpl; |
Adrian Roos | 5fd872e | 2014-08-12 17:28:58 +0200 | [diff] [blame] | 156 | import com.android.systemui.statusbar.policy.BrightnessMirrorController; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 157 | import com.android.systemui.statusbar.policy.CastControllerImpl; |
Adrian Roos | b83777b | 2014-06-30 15:11:53 +0200 | [diff] [blame] | 158 | import com.android.systemui.statusbar.policy.FlashlightController; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 159 | import com.android.systemui.statusbar.policy.HeadsUpManager; |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 160 | import com.android.systemui.statusbar.policy.HotspotControllerImpl; |
John Spurlock | 657c62c | 2014-07-22 12:18:09 -0400 | [diff] [blame] | 161 | import com.android.systemui.statusbar.policy.KeyguardMonitor; |
Adrian Roos | 8ddb2da | 2014-06-16 18:56:22 -0700 | [diff] [blame] | 162 | import com.android.systemui.statusbar.policy.KeyguardUserSwitcher; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 163 | import com.android.systemui.statusbar.policy.LocationControllerImpl; |
| 164 | import com.android.systemui.statusbar.policy.NetworkControllerImpl; |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 165 | import com.android.systemui.statusbar.policy.NextAlarmController; |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 166 | import com.android.systemui.statusbar.policy.PreviewInflater; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 167 | import com.android.systemui.statusbar.policy.RotationLockControllerImpl; |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 168 | import com.android.systemui.statusbar.policy.SecurityControllerImpl; |
| 169 | import com.android.systemui.statusbar.policy.UserInfoController; |
Adrian Roos | 00a0b1f | 2014-07-16 16:44:49 +0200 | [diff] [blame] | 170 | import com.android.systemui.statusbar.policy.UserSwitcherController; |
John Spurlock | 8600534 | 2014-05-23 11:58:00 -0400 | [diff] [blame] | 171 | import com.android.systemui.statusbar.policy.ZenModeController; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 172 | import com.android.systemui.statusbar.stack.NotificationStackScrollLayout; |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 173 | import com.android.systemui.statusbar.stack.NotificationStackScrollLayout.OnChildLocationsChangedListener; |
Jorim Jaggi | 37c1180 | 2015-08-18 20:27:54 -0700 | [diff] [blame] | 174 | import com.android.systemui.statusbar.stack.StackStateAnimator; |
Selim Cinek | b036ca4 | 2015-02-20 15:56:28 +0100 | [diff] [blame] | 175 | import com.android.systemui.statusbar.stack.StackViewState; |
John Spurlock | 8600534 | 2014-05-23 11:58:00 -0400 | [diff] [blame] | 176 | import com.android.systemui.volume.VolumeComponent; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 177 | |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 178 | import java.io.FileDescriptor; |
| 179 | import java.io.PrintWriter; |
| 180 | import java.util.ArrayList; |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 181 | import java.util.Collection; |
| 182 | import java.util.Collections; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 183 | import java.util.HashMap; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 184 | import java.util.List; |
John Spurlock | 7bbb9f6 | 2014-10-21 12:15:28 -0400 | [diff] [blame] | 185 | import java.util.Map; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 186 | |
| 187 | import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_ALT; |
| 188 | import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SHOWN; |
| 189 | import static android.app.StatusBarManager.WINDOW_STATE_HIDDEN; |
| 190 | import static android.app.StatusBarManager.WINDOW_STATE_SHOWING; |
| 191 | import static android.app.StatusBarManager.windowStateToString; |
| 192 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT; |
| 193 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT_TRANSPARENT; |
| 194 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_OPAQUE; |
| 195 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_SEMI_TRANSPARENT; |
| 196 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSLUCENT; |
| 197 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARENT; |
| 198 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_WARNING; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 199 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 200 | public class PhoneStatusBar extends BaseStatusBar implements DemoMode, |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 201 | DragDownHelper.DragDownCallback, ActivityStarter, OnUnlockMethodChangedListener, |
| 202 | HeadsUpManager.OnHeadsUpChangedListener { |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 203 | static final String TAG = "PhoneStatusBar"; |
Daniel Sandler | 198a030 | 2012-08-17 16:04:31 -0400 | [diff] [blame] | 204 | public static final boolean DEBUG = BaseStatusBar.DEBUG; |
Chris Wren | 6d15a36 | 2013-08-20 18:46:29 -0400 | [diff] [blame] | 205 | public static final boolean SPEW = false; |
Daniel Sandler | 7579bca | 2011-08-18 15:47:26 -0400 | [diff] [blame] | 206 | public static final boolean DUMPTRUCK = true; // extra dumpsys info |
Daniel Sandler | fa027f5 | 2013-04-11 22:01:47 -0400 | [diff] [blame] | 207 | public static final boolean DEBUG_GESTURES = false; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 208 | public static final boolean DEBUG_MEDIA = false; |
| 209 | public static final boolean DEBUG_MEDIA_FAKE_ARTWORK = false; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 210 | |
John Spurlock | 342cad7 | 2013-10-08 09:36:50 -0400 | [diff] [blame] | 211 | public static final boolean DEBUG_WINDOW_STATE = false; |
Daniel Sandler | b17a726 | 2012-10-05 14:32:50 -0400 | [diff] [blame] | 212 | |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 213 | // additional instrumentation for testing purposes; intended to be left on during development |
Daniel Sandler | 7c35174 | 2011-10-17 10:48:06 -0400 | [diff] [blame] | 214 | public static final boolean CHATTY = DEBUG; |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 215 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 216 | public static final boolean SHOW_LOCKSCREEN_MEDIA_ARTWORK = true; |
| 217 | |
Adrian Roos | 8e3e836 | 2015-07-16 19:42:22 -0700 | [diff] [blame] | 218 | public static final String ACTION_FAKE_ARTWORK = "fake_artwork"; |
| 219 | |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 220 | private static final int MSG_OPEN_NOTIFICATION_PANEL = 1000; |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 221 | private static final int MSG_CLOSE_PANELS = 1001; |
| 222 | private static final int MSG_OPEN_SETTINGS_PANEL = 1002; |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 223 | private static final int MSG_LAUNCH_TRANSITION_TIMEOUT = 1003; |
Winson Chung | b1f7499 | 2014-08-08 12:53:09 -0700 | [diff] [blame] | 224 | // 1020-1040 reserved for BaseStatusBar |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 225 | |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 226 | // Time after we abort the launch transition. |
| 227 | private static final long LAUNCH_TRANSITION_TIMEOUT_MS = 5000; |
| 228 | |
Daniel Sandler | 8cc36e5 | 2011-10-17 14:18:46 -0400 | [diff] [blame] | 229 | private static final boolean CLOSE_PANEL_WHEN_EMPTIED = true; |
| 230 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 231 | private static final int STATUS_OR_NAV_TRANSIENT = |
| 232 | View.STATUS_BAR_TRANSIENT | View.NAVIGATION_BAR_TRANSIENT; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 233 | private static final long AUTOHIDE_TIMEOUT_MS = 3000; |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 234 | |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 235 | /** The minimum delay in ms between reports of notification visibility. */ |
| 236 | private static final int VISIBILITY_REPORT_MIN_DELAY_MS = 500; |
| 237 | |
Jorim Jaggi | 93a2bb2 | 2014-06-02 19:57:28 +0200 | [diff] [blame] | 238 | /** |
| 239 | * The delay to reset the hint text when the hint animation is finished running. |
| 240 | */ |
| 241 | private static final int HINT_RESET_DELAY_MS = 1200; |
| 242 | |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 243 | private static final AudioAttributes VIBRATION_ATTRIBUTES = new AudioAttributes.Builder() |
| 244 | .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) |
| 245 | .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) |
| 246 | .build(); |
| 247 | |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 248 | public static final int FADE_KEYGUARD_START_DELAY = 100; |
| 249 | public static final int FADE_KEYGUARD_DURATION = 300; |
Jorim Jaggi | 9097885 | 2015-08-18 19:55:53 -0700 | [diff] [blame] | 250 | public static final int FADE_KEYGUARD_DURATION_PULSING = 96; |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 251 | |
Jason Monk | 815e057 | 2014-08-12 17:26:36 -0400 | [diff] [blame] | 252 | /** Allow some time inbetween the long press for back and recents. */ |
| 253 | private static final int LOCK_TO_APP_GESTURE_TOLERENCE = 200; |
| 254 | |
Adrian Roos | 2f2bd9a | 2015-06-04 18:11:14 -0700 | [diff] [blame] | 255 | /** If true, the system is in the half-boot-to-decryption-screen state. |
| 256 | * Prudently disable QS and notifications. */ |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 257 | private static final boolean ONLY_CORE_APPS; |
| 258 | |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 259 | /** If true, the lockscreen will show a distinct wallpaper */ |
Adrian Roos | e381c16 | 2016-02-11 15:26:42 -0800 | [diff] [blame] | 260 | private static final boolean ENABLE_LOCKSCREEN_WALLPAPER = true; |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 261 | |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 262 | /* If true, the device supports freeform window management. |
| 263 | * This affects the status bar UI. */ |
| 264 | private static final boolean FREEFORM_WINDOW_MANAGEMENT; |
| 265 | |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 266 | static { |
| 267 | boolean onlyCoreApps; |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 268 | boolean freeformWindowManagement; |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 269 | try { |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 270 | IPackageManager packageManager = |
| 271 | IPackageManager.Stub.asInterface(ServiceManager.getService("package")); |
| 272 | onlyCoreApps = packageManager.isOnlyCoreApps(); |
| 273 | freeformWindowManagement = packageManager.hasSystemFeature( |
Jeff Sharkey | 115d2c1 | 2016-02-15 17:25:57 -0700 | [diff] [blame] | 274 | PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT, 0); |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 275 | } catch (RemoteException e) { |
| 276 | onlyCoreApps = false; |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 277 | freeformWindowManagement = false; |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 278 | } |
| 279 | ONLY_CORE_APPS = onlyCoreApps; |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 280 | FREEFORM_WINDOW_MANAGEMENT = freeformWindowManagement; |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 281 | } |
| 282 | |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 283 | PhoneStatusBarPolicy mIconPolicy; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 284 | |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 285 | // 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] | 286 | BluetoothControllerImpl mBluetoothController; |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 287 | SecurityControllerImpl mSecurityController; |
Xiaohui Chen | 8bdcd1f | 2016-01-19 13:52:07 -0800 | [diff] [blame] | 288 | protected BatteryController mBatteryController; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 289 | LocationControllerImpl mLocationController; |
| 290 | NetworkControllerImpl mNetworkController; |
Jason Monk | 51e4dc0 | 2014-07-22 12:00:47 -0400 | [diff] [blame] | 291 | HotspotControllerImpl mHotspotController; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 292 | RotationLockControllerImpl mRotationLockController; |
Jorim Jaggi | 3d878be | 2014-05-10 03:22:32 +0200 | [diff] [blame] | 293 | UserInfoController mUserInfoController; |
Muyuan Li | 40e1135 | 2016-03-23 11:43:58 -0700 | [diff] [blame] | 294 | protected ZenModeController mZenModeController; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 295 | CastControllerImpl mCastController; |
John Spurlock | 8600534 | 2014-05-23 11:58:00 -0400 | [diff] [blame] | 296 | VolumeComponent mVolumeComponent; |
Adrian Roos | 8ddb2da | 2014-06-16 18:56:22 -0700 | [diff] [blame] | 297 | KeyguardUserSwitcher mKeyguardUserSwitcher; |
Adrian Roos | b83777b | 2014-06-30 15:11:53 +0200 | [diff] [blame] | 298 | FlashlightController mFlashlightController; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 299 | protected UserSwitcherController mUserSwitcherController; |
Jorim Jaggi | c7dea6e | 2014-07-26 14:36:57 +0200 | [diff] [blame] | 300 | NextAlarmController mNextAlarmController; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 301 | protected KeyguardMonitor mKeyguardMonitor; |
Adrian Roos | 5fd872e | 2014-08-12 17:28:58 +0200 | [diff] [blame] | 302 | BrightnessMirrorController mBrightnessMirrorController; |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 303 | AccessibilityController mAccessibilityController; |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 304 | FingerprintUnlockController mFingerprintUnlockController; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 305 | LightStatusBarController mLightStatusBarController; |
Vadim Tryshev | 12a30e8 | 2016-02-12 15:39:28 -0800 | [diff] [blame] | 306 | protected LockscreenWallpaper mLockscreenWallpaper; |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 307 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 308 | int mNaturalBarHeight = -1; |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 309 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 310 | Display mDisplay; |
Daniel Sandler | e680f54 | 2012-09-28 12:22:27 -0400 | [diff] [blame] | 311 | Point mCurrentDisplaySize = new Point(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 312 | |
Xiaohui Chen | d839d1a | 2016-01-21 13:05:02 -0800 | [diff] [blame] | 313 | protected StatusBarWindowView mStatusBarWindow; |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 314 | protected PhoneStatusBarView mStatusBarView; |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 315 | private int mStatusBarWindowState = WINDOW_STATE_SHOWING; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 316 | protected StatusBarWindowManager mStatusBarWindowManager; |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 317 | private UnlockMethodCache mUnlockMethodCache; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 318 | private DozeServiceHost mDozeServiceHost; |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 319 | private boolean mWakeUpComingFromTouch; |
| 320 | private PointF mWakeUpTouchLocation; |
Selim Cinek | 1b6f819 | 2015-09-03 16:01:53 -0700 | [diff] [blame] | 321 | private boolean mScreenTurningOn; |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 322 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 323 | int mPixelFormat; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 324 | Object mQueueLock = new Object(); |
| 325 | |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 326 | protected StatusBarIconController mIconController; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 327 | |
| 328 | // expanded notifications |
Xiaohui Chen | ea4b6ba | 2016-02-18 10:53:17 -0800 | [diff] [blame] | 329 | protected NotificationPanelView mNotificationPanel; // the sliding/resizing panel within the notification window |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 330 | View mExpandedContents; |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 331 | TextView mNotificationPanelDebugText; |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 332 | |
Daniel Sandler | 8e72c9e | 2012-08-15 00:09:26 -0400 | [diff] [blame] | 333 | // settings |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 334 | private QSPanel mQSPanel; |
Daniel Sandler | 8e72c9e | 2012-08-15 00:09:26 -0400 | [diff] [blame] | 335 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 336 | // top bar |
Jason Monk | 0e1101d | 2015-10-07 13:06:09 -0400 | [diff] [blame] | 337 | BaseStatusBarHeader mHeader; |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 338 | protected KeyguardStatusBarView mKeyguardStatusBar; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 339 | View mKeyguardStatusView; |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 340 | KeyguardBottomAreaView mKeyguardBottomArea; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 341 | boolean mLeaveOpenOnKeyguardHide; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 342 | KeyguardIndicationController mKeyguardIndicationController; |
Jorim Jaggi | e70d31f | 2014-04-24 22:08:30 +0200 | [diff] [blame] | 343 | |
Adrian Roos | 46df1ca | 2015-09-11 12:38:43 -0700 | [diff] [blame] | 344 | // Keyguard is going away soon. |
| 345 | private boolean mKeyguardGoingAway; |
| 346 | // Keyguard is actually fading away now. |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 347 | private boolean mKeyguardFadingAway; |
| 348 | private long mKeyguardFadingAwayDelay; |
| 349 | private long mKeyguardFadingAwayDuration; |
| 350 | |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 351 | // RemoteInputView to be activated after unlock |
| 352 | private View mPendingRemoteInputView; |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 353 | private View mPendingWorkRemoteInputView; |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 354 | |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 355 | int mMaxAllowedKeyguardNotifications; |
Daniel Sandler | d309056 | 2011-08-09 00:28:44 -0400 | [diff] [blame] | 356 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 357 | boolean mExpandedVisible; |
| 358 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 359 | private int mNavigationBarWindowState = WINDOW_STATE_SHOWING; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 360 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 361 | // the tracker view |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 362 | int mTrackingPosition; // the position of the top of the tracking view. |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 363 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 364 | // Tracking finger for opening/closing. |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 365 | boolean mTracking; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 366 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 367 | int[] mAbsPos = new int[2]; |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 368 | ArrayList<Runnable> mPostCollapseRunnables = new ArrayList<>(); |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 369 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 370 | // for disabling the status bar |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 371 | int mDisabled1 = 0; |
| 372 | int mDisabled2 = 0; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 373 | |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 374 | // tracking calls to View.setSystemUiVisibility() |
| 375 | int mSystemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 376 | private final Rect mLastFullscreenStackBounds = new Rect(); |
| 377 | private final Rect mLastDockedStackBounds = new Rect(); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 378 | |
Adrian Roos | 389beec | 2015-05-12 13:33:25 -0700 | [diff] [blame] | 379 | // last value sent to window manager |
| 380 | private int mLastDispatchedSystemUiVisibility = ~View.SYSTEM_UI_FLAG_VISIBLE; |
| 381 | |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 382 | DisplayMetrics mDisplayMetrics = new DisplayMetrics(); |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 383 | |
Daniel Sandler | 3380534 | 2012-07-23 15:45:12 -0400 | [diff] [blame] | 384 | // XXX: gesture research |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 385 | private final GestureRecorder mGestureRec = DEBUG_GESTURES |
John Spurlock | 209bede | 2013-07-17 12:23:27 -0400 | [diff] [blame] | 386 | ? new GestureRecorder("/sdcard/statusbar_gestures.dat") |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 387 | : null; |
Daniel Sandler | 3380534 | 2012-07-23 15:45:12 -0400 | [diff] [blame] | 388 | |
Jason Monk | 18f99d9 | 2014-09-11 13:36:42 -0400 | [diff] [blame] | 389 | private ScreenPinningRequest mScreenPinningRequest; |
| 390 | |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 391 | private int mNavigationIconHints = 0; |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 392 | private HandlerThread mHandlerThread; |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 393 | |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 394 | // ensure quick settings is disabled until the current user makes it through the setup wizard |
| 395 | private boolean mUserSetup = false; |
| 396 | private ContentObserver mUserSetupObserver = new ContentObserver(new Handler()) { |
| 397 | @Override |
| 398 | public void onChange(boolean selfChange) { |
| 399 | final boolean userSetup = 0 != Settings.Secure.getIntForUser( |
| 400 | mContext.getContentResolver(), |
| 401 | Settings.Secure.USER_SETUP_COMPLETE, |
| 402 | 0 /*default */, |
| 403 | mCurrentUserId); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 404 | if (MULTIUSER_DEBUG) Log.d(TAG, String.format("User setup changed: " + |
John Spurlock | e4e8c56 | 2012-10-04 09:55:01 -0400 | [diff] [blame] | 405 | "selfChange=%s userSetup=%s mUserSetup=%s", |
| 406 | selfChange, userSetup, mUserSetup)); |
John Spurlock | 73203eb | 2014-04-15 16:14:46 -0400 | [diff] [blame] | 407 | |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 408 | if (userSetup != mUserSetup) { |
| 409 | mUserSetup = userSetup; |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 410 | if (!mUserSetup && mStatusBarView != null) |
| 411 | animateCollapseQuickSettings(); |
Adrian Roos | a4eba9f | 2015-07-22 18:13:04 -0700 | [diff] [blame] | 412 | if (mKeyguardBottomArea != null) { |
| 413 | mKeyguardBottomArea.setUserSetupComplete(mUserSetup); |
| 414 | } |
Jason Monk | fd57ea7 | 2016-04-29 13:37:58 -0400 | [diff] [blame] | 415 | if (mNetworkController != null) { |
| 416 | mNetworkController.setUserSetupComplete(mUserSetup); |
| 417 | } |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 418 | } |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 419 | if (mIconPolicy != null) { |
| 420 | mIconPolicy.setCurrentUserSetup(mUserSetup); |
| 421 | } |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 422 | } |
| 423 | }; |
| 424 | |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 425 | final private ContentObserver mHeadsUpObserver = new ContentObserver(mHandler) { |
| 426 | @Override |
| 427 | public void onChange(boolean selfChange) { |
| 428 | boolean wasUsing = mUseHeadsUp; |
Jason Monk | f701954 | 2014-07-31 12:42:25 -0400 | [diff] [blame] | 429 | mUseHeadsUp = ENABLE_HEADS_UP && !mDisableNotificationAlerts |
| 430 | && Settings.Global.HEADS_UP_OFF != Settings.Global.getInt( |
Chris Wren | 10d82df | 2014-03-01 10:34:51 -0500 | [diff] [blame] | 431 | mContext.getContentResolver(), Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED, |
Chris Wren | 7bd24123 | 2014-02-28 16:25:05 -0500 | [diff] [blame] | 432 | Settings.Global.HEADS_UP_OFF); |
Chris Wren | 22ae46e | 2014-02-26 18:08:09 -0500 | [diff] [blame] | 433 | mHeadsUpTicker = mUseHeadsUp && 0 != Settings.Global.getInt( |
| 434 | mContext.getContentResolver(), SETTING_HEADS_UP_TICKER, 0); |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 435 | Log.d(TAG, "heads up is " + (mUseHeadsUp ? "enabled" : "disabled")); |
| 436 | if (wasUsing != mUseHeadsUp) { |
| 437 | if (!mUseHeadsUp) { |
| 438 | Log.d(TAG, "dismissing any existing heads up notification on disable event"); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 439 | mHeadsUpManager.releaseAllImmediately(); |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 440 | } |
| 441 | } |
| 442 | } |
| 443 | }; |
| 444 | |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 445 | private int mInteractingWindows; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 446 | private boolean mAutohideSuspended; |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 447 | private int mStatusBarMode; |
| 448 | private int mNavigationBarMode; |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 449 | private int mMaxKeyguardNotifications; |
Jorim Jaggi | d41083a | 2014-09-12 02:54:40 +0200 | [diff] [blame] | 450 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 451 | private ViewMediatorCallback mKeyguardViewMediatorCallback; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 452 | protected ScrimController mScrimController; |
| 453 | protected DozeScrimController mDozeScrimController; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 454 | |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 455 | private final Runnable mAutohide = new Runnable() { |
| 456 | @Override |
| 457 | public void run() { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 458 | int requested = mSystemUiVisibility & ~STATUS_OR_NAV_TRANSIENT; |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 459 | if (mSystemUiVisibility != requested) { |
| 460 | notifyUiVisibilityChanged(requested); |
| 461 | } |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 462 | }}; |
| 463 | |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 464 | private boolean mWaitingForKeyguardExit; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 465 | private boolean mDozing; |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 466 | private boolean mDozingRequested; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 467 | protected boolean mScrimSrcModeEnabled; |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 468 | |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 469 | public static final Interpolator ALPHA_IN = Interpolators.ALPHA_IN; |
| 470 | public static final Interpolator ALPHA_OUT = Interpolators.ALPHA_OUT; |
Jorim Jaggi | b13d36d | 2014-06-06 18:03:52 +0200 | [diff] [blame] | 471 | |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 472 | private BackDropView mBackdrop; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 473 | private ImageView mBackdropFront, mBackdropBack; |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 474 | private PorterDuffXfermode mSrcXferMode = new PorterDuffXfermode(PorterDuff.Mode.SRC); |
| 475 | private PorterDuffXfermode mSrcOverXferMode = new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 476 | |
| 477 | private MediaSessionManager mMediaSessionManager; |
| 478 | private MediaController mMediaController; |
| 479 | private String mMediaNotificationKey; |
| 480 | private MediaMetadata mMediaMetadata; |
| 481 | private MediaController.Callback mMediaListener |
| 482 | = new MediaController.Callback() { |
| 483 | @Override |
| 484 | public void onPlaybackStateChanged(PlaybackState state) { |
| 485 | super.onPlaybackStateChanged(state); |
| 486 | if (DEBUG_MEDIA) Log.v(TAG, "DEBUG_MEDIA: onPlaybackStateChanged: " + state); |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 487 | if (state != null) { |
| 488 | if (!isPlaybackActive(state.getState())) { |
| 489 | clearCurrentMediaNotification(); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 490 | updateMediaMetaData(true, true); |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 491 | } |
| 492 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 493 | } |
| 494 | |
| 495 | @Override |
| 496 | public void onMetadataChanged(MediaMetadata metadata) { |
| 497 | super.onMetadataChanged(metadata); |
| 498 | if (DEBUG_MEDIA) Log.v(TAG, "DEBUG_MEDIA: onMetadataChanged: " + metadata); |
| 499 | mMediaMetadata = metadata; |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 500 | updateMediaMetaData(true, true); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 501 | } |
| 502 | }; |
| 503 | |
| 504 | private final OnChildLocationsChangedListener mOnChildLocationsChangedListener = |
| 505 | new OnChildLocationsChangedListener() { |
| 506 | @Override |
| 507 | public void onChildLocationsChanged(NotificationStackScrollLayout stackScrollLayout) { |
| 508 | userActivity(); |
| 509 | } |
| 510 | }; |
| 511 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 512 | private int mDisabledUnmodified1; |
| 513 | private int mDisabledUnmodified2; |
Jorim Jaggi | b13d36d | 2014-06-06 18:03:52 +0200 | [diff] [blame] | 514 | |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 515 | /** Keys of notifications currently visible to the user. */ |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 516 | private final ArraySet<NotificationVisibility> mCurrentlyVisibleNotifications = |
| 517 | new ArraySet<>(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 518 | private long mLastVisibilityReportUptimeMs; |
| 519 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 520 | private final ShadeUpdates mShadeUpdates = new ShadeUpdates(); |
| 521 | |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 522 | private Runnable mLaunchTransitionEndRunnable; |
| 523 | private boolean mLaunchTransitionFadingAway; |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 524 | private ExpandableNotificationRow mDraggedDownRow; |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 525 | private boolean mLaunchCameraOnScreenTurningOn; |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 526 | private boolean mLaunchCameraOnFinishedGoingToSleep; |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 527 | private int mLastCameraLaunchSource; |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 528 | private PowerManager.WakeLock mGestureWakeLock; |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 529 | private Vibrator mVibrator; |
Jorim Jaggi | 362dd6d | 2014-07-09 19:04:07 +0200 | [diff] [blame] | 530 | |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 531 | // Fingerprint (as computed by getLoggingFingerprint() of the last logged state. |
| 532 | private int mLastLoggedStateFingerprint; |
| 533 | |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 534 | /** |
| 535 | * If set, the device has started going to sleep but isn't fully non-interactive yet. |
| 536 | */ |
| 537 | protected boolean mStartedGoingToSleep; |
| 538 | |
Selim Cinek | 3776fe0 | 2016-02-04 13:32:43 -0800 | [diff] [blame] | 539 | private static final int VISIBLE_LOCATIONS = StackViewState.LOCATION_FIRST_HUN |
Chris Wren | 35a7c92 | 2015-06-22 16:31:01 -0400 | [diff] [blame] | 540 | | StackViewState.LOCATION_MAIN_AREA; |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 541 | |
| 542 | private final OnChildLocationsChangedListener mNotificationLocationsChangedListener = |
| 543 | new OnChildLocationsChangedListener() { |
| 544 | @Override |
| 545 | public void onChildLocationsChanged( |
| 546 | NotificationStackScrollLayout stackScrollLayout) { |
| 547 | if (mHandler.hasCallbacks(mVisibilityReporter)) { |
| 548 | // Visibilities will be reported when the existing |
| 549 | // callback is executed. |
| 550 | return; |
| 551 | } |
| 552 | // Calculate when we're allowed to run the visibility |
| 553 | // reporter. Note that this timestamp might already have |
| 554 | // passed. That's OK, the callback will just be executed |
| 555 | // ASAP. |
| 556 | long nextReportUptimeMs = |
| 557 | mLastVisibilityReportUptimeMs + VISIBILITY_REPORT_MIN_DELAY_MS; |
| 558 | mHandler.postAtTime(mVisibilityReporter, nextReportUptimeMs); |
| 559 | } |
| 560 | }; |
| 561 | |
| 562 | // Tracks notifications currently visible in mNotificationStackScroller and |
| 563 | // emits visibility events via NoMan on changes. |
| 564 | private final Runnable mVisibilityReporter = new Runnable() { |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 565 | private final ArraySet<NotificationVisibility> mTmpNewlyVisibleNotifications = |
| 566 | new ArraySet<>(); |
| 567 | private final ArraySet<NotificationVisibility> mTmpCurrentlyVisibleNotifications = |
| 568 | new ArraySet<>(); |
| 569 | private final ArraySet<NotificationVisibility> mTmpNoLongerVisibleNotifications = |
| 570 | new ArraySet<>(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 571 | |
| 572 | @Override |
| 573 | public void run() { |
| 574 | mLastVisibilityReportUptimeMs = SystemClock.uptimeMillis(); |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 575 | final String mediaKey = getCurrentMediaNotificationKey(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 576 | |
| 577 | // 1. Loop over mNotificationData entries: |
| 578 | // A. Keep list of visible notifications. |
| 579 | // B. Keep list of previously hidden, now visible notifications. |
| 580 | // 2. Compute no-longer visible notifications by removing currently |
| 581 | // visible notifications from the set of previously visible |
| 582 | // notifications. |
| 583 | // 3. Report newly visible and no-longer visible notifications. |
| 584 | // 4. Keep currently visible notifications for next report. |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 585 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
| 586 | int N = activeNotifications.size(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 587 | for (int i = 0; i < N; i++) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 588 | Entry entry = activeNotifications.get(i); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 589 | String key = entry.notification.getKey(); |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 590 | boolean isVisible = |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 591 | (mStackScroller.getChildLocation(entry.row) & VISIBLE_LOCATIONS) != 0; |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 592 | NotificationVisibility visObj = NotificationVisibility.obtain(key, i, isVisible); |
| 593 | boolean previouslyVisible = mCurrentlyVisibleNotifications.contains(visObj); |
| 594 | if (isVisible) { |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 595 | // Build new set of visible notifications. |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 596 | mTmpCurrentlyVisibleNotifications.add(visObj); |
| 597 | if (!previouslyVisible) { |
| 598 | mTmpNewlyVisibleNotifications.add(visObj); |
| 599 | } |
| 600 | } else { |
| 601 | // release object |
| 602 | visObj.recycle(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 603 | } |
| 604 | } |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 605 | mTmpNoLongerVisibleNotifications.addAll(mCurrentlyVisibleNotifications); |
| 606 | mTmpNoLongerVisibleNotifications.removeAll(mTmpCurrentlyVisibleNotifications); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 607 | |
| 608 | logNotificationVisibilityChanges( |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 609 | mTmpNewlyVisibleNotifications, mTmpNoLongerVisibleNotifications); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 610 | |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 611 | recycleAllVisibilityObjects(mCurrentlyVisibleNotifications); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 612 | mCurrentlyVisibleNotifications.addAll(mTmpCurrentlyVisibleNotifications); |
| 613 | |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 614 | recycleAllVisibilityObjects(mTmpNoLongerVisibleNotifications); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 615 | mTmpCurrentlyVisibleNotifications.clear(); |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 616 | mTmpNewlyVisibleNotifications.clear(); |
| 617 | mTmpNoLongerVisibleNotifications.clear(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 618 | } |
| 619 | }; |
| 620 | |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 621 | private void recycleAllVisibilityObjects(ArraySet<NotificationVisibility> array) { |
| 622 | final int N = array.size(); |
| 623 | for (int i = 0 ; i < N; i++) { |
| 624 | array.valueAt(i).recycle(); |
| 625 | } |
| 626 | array.clear(); |
| 627 | } |
| 628 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 629 | private final View.OnClickListener mOverflowClickListener = new View.OnClickListener() { |
| 630 | @Override |
| 631 | public void onClick(View v) { |
| 632 | goToLockedShade(null); |
| 633 | } |
| 634 | }; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 635 | private HashMap<ExpandableNotificationRow, List<ExpandableNotificationRow>> mTmpChildOrderMap |
| 636 | = new HashMap<>(); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 637 | private RankingMap mLatestRankingMap; |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 638 | private boolean mNoAnimationOnNextBarModeChange; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 639 | private FalsingManager mFalsingManager; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 640 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 641 | @Override |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 642 | public void start() { |
| 643 | mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)) |
| 644 | .getDefaultDisplay(); |
Daniel Sandler | 7e8ae50 | 2013-10-10 23:38:19 -0400 | [diff] [blame] | 645 | updateDisplaySize(); |
Jorim Jaggi | 0e66439 | 2014-09-27 01:30:22 +0200 | [diff] [blame] | 646 | mScrimSrcModeEnabled = mContext.getResources().getBoolean( |
| 647 | R.bool.config_status_bar_scrim_behind_use_src); |
Adrian Roos | 75fa385 | 2015-01-27 20:21:44 +0100 | [diff] [blame] | 648 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 649 | super.start(); // calls createAndAddWindows() |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 650 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 651 | mMediaSessionManager |
| 652 | = (MediaSessionManager) mContext.getSystemService(Context.MEDIA_SESSION_SERVICE); |
| 653 | // TODO: use MediaSessionManager.SessionListener to hook us up to future updates |
| 654 | // in session state |
| 655 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 656 | addNavigationBar(); |
| 657 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 658 | // Lastly, call to the icon policy to install/update all the icons. |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 659 | mIconPolicy = new PhoneStatusBarPolicy(mContext, mIconController, mCastController, |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 660 | mHotspotController, mUserInfoController, mBluetoothController, |
Julia Reynolds | 4e6024b | 2016-04-26 16:12:26 -0400 | [diff] [blame] | 661 | mRotationLockController, mNetworkController.getDataSaverController(), mNextAlarmController); |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 662 | mIconPolicy.setCurrentUserSetup(mUserSetup); |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 663 | mSettingsObserver.onChange(false); // set up |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 664 | |
| 665 | mHeadsUpObserver.onChange(true); // set up |
| 666 | if (ENABLE_HEADS_UP) { |
| 667 | mContext.getContentResolver().registerContentObserver( |
Chris Wren | 10d82df | 2014-03-01 10:34:51 -0500 | [diff] [blame] | 668 | Settings.Global.getUriFor(Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED), true, |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 669 | mHeadsUpObserver); |
Chris Wren | 22ae46e | 2014-02-26 18:08:09 -0500 | [diff] [blame] | 670 | mContext.getContentResolver().registerContentObserver( |
| 671 | Settings.Global.getUriFor(SETTING_HEADS_UP_TICKER), true, |
| 672 | mHeadsUpObserver); |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 673 | } |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 674 | mUnlockMethodCache = UnlockMethodCache.getInstance(mContext); |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 675 | mUnlockMethodCache.addListener(this); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 676 | startKeyguard(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 677 | |
| 678 | mDozeServiceHost = new DozeServiceHost(); |
Jorim Jaggi | 007f0e8 | 2015-08-14 13:56:01 -0700 | [diff] [blame] | 679 | KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mDozeServiceHost); |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 680 | putComponent(DozeHost.class, mDozeServiceHost); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 681 | putComponent(PhoneStatusBar.class, this); |
John Spurlock | 89f060a | 2014-07-16 21:03:15 -0400 | [diff] [blame] | 682 | |
| 683 | setControllerUsers(); |
Chris Wren | cd8f4f7 | 2014-08-27 18:48:13 -0400 | [diff] [blame] | 684 | |
| 685 | notifyUserAboutHiddenNotifications(); |
Jason Monk | 18f99d9 | 2014-09-11 13:36:42 -0400 | [diff] [blame] | 686 | |
| 687 | mScreenPinningRequest = new ScreenPinningRequest(mContext); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 688 | mFalsingManager = FalsingManager.getInstance(mContext); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 689 | } |
| 690 | |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 691 | protected void createIconController() { |
| 692 | mIconController = new StatusBarIconController( |
| 693 | mContext, mStatusBarView, mKeyguardStatusBar, this); |
| 694 | } |
| 695 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 696 | // ================================================================================ |
| 697 | // Constructing the view |
| 698 | // ================================================================================ |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 699 | protected PhoneStatusBarView makeStatusBarView() { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 700 | final Context context = mContext; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 701 | |
Daniel Sandler | 6e8db88 | 2011-10-26 15:40:51 -0400 | [diff] [blame] | 702 | updateDisplaySize(); // populates mDisplayMetrics |
Jorim Jaggi | 2e115c5 | 2014-07-01 21:27:58 +0200 | [diff] [blame] | 703 | updateResources(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 704 | |
Xiaohui Chen | d839d1a | 2016-01-21 13:05:02 -0800 | [diff] [blame] | 705 | inflateStatusBarWindow(context); |
Selim Cinek | 4e6b2d3 | 2015-06-25 20:15:33 -0400 | [diff] [blame] | 706 | mStatusBarWindow.setService(this); |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 707 | mStatusBarWindow.setOnTouchListener(new View.OnTouchListener() { |
| 708 | @Override |
| 709 | public boolean onTouch(View v, MotionEvent event) { |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 710 | checkUserAutohide(v, event); |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 711 | if (event.getAction() == MotionEvent.ACTION_DOWN) { |
Daniel Sandler | 37a38aa | 2013-02-13 17:15:57 -0500 | [diff] [blame] | 712 | if (mExpandedVisible) { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 713 | animateCollapsePanels(); |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 714 | } |
| 715 | } |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame] | 716 | return mStatusBarWindow.onTouchEvent(event); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 717 | } |
| 718 | }); |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 719 | |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 720 | mNotificationPanel = (NotificationPanelView) mStatusBarWindow.findViewById( |
| 721 | R.id.notification_panel); |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 722 | mNotificationPanel.setStatusBar(this); |
Selim Cinek | 53f8e7d | 2016-03-25 02:28:01 -0700 | [diff] [blame] | 723 | mNotificationPanel.setGroupManager(mGroupManager); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 724 | |
Xiaohui Chen | 9f96711 | 2016-01-07 14:14:06 -0800 | [diff] [blame] | 725 | mStatusBarView = (PhoneStatusBarView) mStatusBarWindow.findViewById(R.id.status_bar); |
| 726 | mStatusBarView.setBar(this); |
| 727 | mStatusBarView.setPanel(mNotificationPanel); |
| 728 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 729 | if (!ActivityManager.isHighEndGfx()) { |
Romain Guy | 328b358 | 2012-05-08 15:30:57 -0700 | [diff] [blame] | 730 | mStatusBarWindow.setBackground(null); |
Alan Viverette | 4a357cd | 2015-03-18 18:37:18 -0700 | [diff] [blame] | 731 | mNotificationPanel.setBackground(new FastColorDrawable(context.getColor( |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 732 | R.color.notification_panel_solid_background))); |
Romain Guy | 328b358 | 2012-05-08 15:30:57 -0700 | [diff] [blame] | 733 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 734 | |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 735 | mHeadsUpManager = new HeadsUpManager(context, mStatusBarWindow, mGroupManager); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 736 | mHeadsUpManager.setBar(this); |
| 737 | mHeadsUpManager.addListener(this); |
| 738 | mHeadsUpManager.addListener(mNotificationPanel); |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 739 | mHeadsUpManager.addListener(mGroupManager); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 740 | mNotificationPanel.setHeadsUpManager(mHeadsUpManager); |
Selim Cinek | fbe9a44 | 2015-04-13 16:09:49 -0700 | [diff] [blame] | 741 | mNotificationData.setHeadsUpManager(mHeadsUpManager); |
Selim Cinek | 967ed2a | 2016-04-08 18:29:11 -0700 | [diff] [blame] | 742 | mGroupManager.setHeadsUpManager(mHeadsUpManager); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 743 | |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 744 | if (MULTIUSER_DEBUG) { |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 745 | mNotificationPanelDebugText = (TextView) mNotificationPanel.findViewById( |
| 746 | R.id.header_debug_info); |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 747 | mNotificationPanelDebugText.setVisibility(View.VISIBLE); |
| 748 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 749 | |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 750 | try { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 751 | boolean showNav = mWindowManagerService.hasNavigationBar(); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 752 | if (DEBUG) Log.v(TAG, "hasNavigationBar=" + showNav); |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 753 | if (showNav) { |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 754 | createNavigationBarView(context); |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 755 | } |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 756 | } catch (RemoteException ex) { |
| 757 | // no window manager? good luck with that |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 758 | } |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 759 | |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 760 | mAssistManager = new AssistManager(this, context); |
| 761 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 762 | // figure out which pixel-format to use for the status bar. |
Daniel Sandler | f733c2a | 2011-09-25 15:03:40 -0400 | [diff] [blame] | 763 | mPixelFormat = PixelFormat.OPAQUE; |
Daniel Sandler | 173bae2 | 2012-09-25 14:37:42 -0400 | [diff] [blame] | 764 | |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 765 | mStackScroller = (NotificationStackScrollLayout) mStatusBarWindow.findViewById( |
| 766 | R.id.notification_stack_scroller); |
| 767 | mStackScroller.setLongPressListener(getNotificationLongClicker()); |
Selim Cinek | 19c8c70 | 2014-08-25 22:09:19 +0200 | [diff] [blame] | 768 | mStackScroller.setPhoneStatusBar(this); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 769 | mStackScroller.setGroupManager(mGroupManager); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 770 | mStackScroller.setHeadsUpManager(mHeadsUpManager); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 771 | mGroupManager.setOnGroupChangeListener(mStackScroller); |
Selim Cinek | 80a14e5 | 2014-03-27 16:58:04 +0100 | [diff] [blame] | 772 | |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 773 | inflateOverflowContainer(); |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 774 | inflateEmptyShadeView(); |
| 775 | inflateDismissView(); |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 776 | mExpandedContents = mStackScroller; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 777 | |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 778 | mBackdrop = (BackDropView) mStatusBarWindow.findViewById(R.id.backdrop); |
| 779 | mBackdropFront = (ImageView) mBackdrop.findViewById(R.id.backdrop_front); |
| 780 | mBackdropBack = (ImageView) mBackdrop.findViewById(R.id.backdrop_back); |
| 781 | |
| 782 | ScrimView scrimBehind = (ScrimView) mStatusBarWindow.findViewById(R.id.scrim_behind); |
| 783 | ScrimView scrimInFront = (ScrimView) mStatusBarWindow.findViewById(R.id.scrim_in_front); |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 784 | View headsUpScrim = mStatusBarWindow.findViewById(R.id.heads_up_scrim); |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 785 | mScrimController = SystemUIFactory.getInstance().createScrimController( |
Selim Cinek | 2550325 | 2016-03-03 15:31:43 -0800 | [diff] [blame] | 786 | scrimBehind, scrimInFront, headsUpScrim); |
| 787 | if (mScrimSrcModeEnabled) { |
| 788 | Runnable runnable = new Runnable() { |
| 789 | @Override |
| 790 | public void run() { |
| 791 | boolean asSrc = mBackdrop.getVisibility() != View.VISIBLE; |
| 792 | mScrimController.setDrawBehindAsSrc(asSrc); |
| 793 | mStackScroller.setDrawBackgroundAsSrc(asSrc); |
| 794 | } |
| 795 | }; |
| 796 | mBackdrop.setOnVisibilityChangedRunnable(runnable); |
| 797 | runnable.run(); |
| 798 | } |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 799 | mHeadsUpManager.addListener(mScrimController); |
| 800 | mStackScroller.setScrimController(mScrimController); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 801 | mStatusBarView.setScrimController(mScrimController); |
Jorim Jaggi | 048af1f | 2014-11-11 22:51:10 +0100 | [diff] [blame] | 802 | mDozeScrimController = new DozeScrimController(mScrimController, context); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 803 | |
Jorim Jaggi | 4538027d | 2014-07-30 15:43:13 +0200 | [diff] [blame] | 804 | mKeyguardStatusBar = (KeyguardStatusBarView) mStatusBarWindow.findViewById(R.id.keyguard_header); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 805 | mKeyguardStatusView = mStatusBarWindow.findViewById(R.id.keyguard_status_view); |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 806 | mKeyguardBottomArea = |
| 807 | (KeyguardBottomAreaView) mStatusBarWindow.findViewById(R.id.keyguard_bottom_area); |
| 808 | mKeyguardBottomArea.setActivityStarter(this); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 809 | mKeyguardBottomArea.setAssistManager(mAssistManager); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 810 | mKeyguardIndicationController = new KeyguardIndicationController(mContext, |
| 811 | (KeyguardIndicationTextView) mStatusBarWindow.findViewById( |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 812 | R.id.keyguard_indication_text), |
| 813 | mKeyguardBottomArea.getLockIcon()); |
Adrian Roos | 4ebcdfd | 2014-08-12 23:33:49 +0200 | [diff] [blame] | 814 | mKeyguardBottomArea.setKeyguardIndicationController(mKeyguardIndicationController); |
Daniel Sandler | e111ad3 | 2012-10-13 15:17:45 -0400 | [diff] [blame] | 815 | |
Adrian Roos | e381c16 | 2016-02-11 15:26:42 -0800 | [diff] [blame] | 816 | if (ENABLE_LOCKSCREEN_WALLPAPER) { |
| 817 | mLockscreenWallpaper = new LockscreenWallpaper(mContext, this, mHandler); |
| 818 | } |
| 819 | |
Xiaohui Chen | f43491f | 2016-02-01 12:19:35 -0800 | [diff] [blame] | 820 | // set the initial view visibility |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 821 | setAreThereNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 822 | |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 823 | createIconController(); |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 824 | |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 825 | // Background thread for any controllers that need it. |
| 826 | mHandlerThread = new HandlerThread(TAG, Process.THREAD_PRIORITY_BACKGROUND); |
| 827 | mHandlerThread.start(); |
| 828 | |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 829 | // Other icons |
Jason Monk | 05b86bc | 2015-05-19 14:21:28 -0400 | [diff] [blame] | 830 | mLocationController = new LocationControllerImpl(mContext, |
| 831 | mHandlerThread.getLooper()); // will post a notification |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 832 | mBatteryController = createBatteryController(); |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 833 | mBatteryController.addStateChangedCallback(new BatteryStateChangeCallback() { |
| 834 | @Override |
Jason Monk | c06fbb1 | 2016-01-08 14:12:18 -0500 | [diff] [blame] | 835 | public void onPowerSaveChanged(boolean isPowerSave) { |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 836 | mHandler.post(mCheckBarModes); |
John Spurlock | d96179e | 2014-08-21 16:43:45 -0400 | [diff] [blame] | 837 | if (mDozeServiceHost != null) { |
Jason Monk | c06fbb1 | 2016-01-08 14:12:18 -0500 | [diff] [blame] | 838 | mDozeServiceHost.firePowerSaveChanged(isPowerSave); |
John Spurlock | d96179e | 2014-08-21 16:43:45 -0400 | [diff] [blame] | 839 | } |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 840 | } |
| 841 | @Override |
| 842 | public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) { |
| 843 | // noop |
| 844 | } |
| 845 | }); |
Jason Monk | 30d8004 | 2015-05-08 16:54:18 -0400 | [diff] [blame] | 846 | mNetworkController = new NetworkControllerImpl(mContext, mHandlerThread.getLooper()); |
Jason Monk | fd57ea7 | 2016-04-29 13:37:58 -0400 | [diff] [blame] | 847 | mNetworkController.setUserSetupComplete(mUserSetup); |
Jason Monk | 51e4dc0 | 2014-07-22 12:00:47 -0400 | [diff] [blame] | 848 | mHotspotController = new HotspotControllerImpl(mContext); |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 849 | mBluetoothController = new BluetoothControllerImpl(mContext, mHandlerThread.getLooper()); |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 850 | mSecurityController = new SecurityControllerImpl(mContext); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 851 | if (mContext.getResources().getBoolean(R.bool.config_showRotationLock)) { |
| 852 | mRotationLockController = new RotationLockControllerImpl(mContext); |
John Spurlock | 8ab172e | 2013-12-19 16:39:23 -0500 | [diff] [blame] | 853 | } |
Jorim Jaggi | 3d878be | 2014-05-10 03:22:32 +0200 | [diff] [blame] | 854 | mUserInfoController = new UserInfoController(mContext); |
John Spurlock | 8600534 | 2014-05-23 11:58:00 -0400 | [diff] [blame] | 855 | mVolumeComponent = getComponent(VolumeComponent.class); |
John Spurlock | f2565a8 | 2014-10-23 20:16:22 -0400 | [diff] [blame] | 856 | if (mVolumeComponent != null) { |
| 857 | mZenModeController = mVolumeComponent.getZenController(); |
| 858 | } |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 859 | mCastController = new CastControllerImpl(mContext); |
Xiaohui Chen | 1094230 | 2015-12-16 16:38:13 -0800 | [diff] [blame] | 860 | |
| 861 | initSignalCluster(mStatusBarView); |
| 862 | initSignalCluster(mKeyguardStatusBar); |
Daniel Sandler | dd4ef49 | 2012-07-27 11:19:52 -0400 | [diff] [blame] | 863 | |
Adrian Roos | b83777b | 2014-06-30 15:11:53 +0200 | [diff] [blame] | 864 | mFlashlightController = new FlashlightController(mContext); |
Adrian Roos | 1e1d6ac | 2014-07-22 17:18:55 +0200 | [diff] [blame] | 865 | mKeyguardBottomArea.setFlashlightController(mFlashlightController); |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 866 | mKeyguardBottomArea.setPhoneStatusBar(this); |
Adrian Roos | a4eba9f | 2015-07-22 18:13:04 -0700 | [diff] [blame] | 867 | mKeyguardBottomArea.setUserSetupComplete(mUserSetup); |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 868 | mAccessibilityController = new AccessibilityController(mContext); |
| 869 | mKeyguardBottomArea.setAccessibilityController(mAccessibilityController); |
Jorim Jaggi | c7dea6e | 2014-07-26 14:36:57 +0200 | [diff] [blame] | 870 | mNextAlarmController = new NextAlarmController(mContext); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 871 | mLightStatusBarController = new LightStatusBarController(mIconController, |
| 872 | mBatteryController); |
Jason Monk | 8a3a964 | 2015-06-05 11:01:30 -0400 | [diff] [blame] | 873 | mKeyguardMonitor = new KeyguardMonitor(mContext); |
Fyodor Kupolov | cd86ebf | 2015-09-29 17:06:50 -0700 | [diff] [blame] | 874 | if (UserManager.get(mContext).isUserSwitcherEnabled()) { |
Adrian Roos | 88b1193 | 2015-07-22 14:59:48 -0700 | [diff] [blame] | 875 | mUserSwitcherController = new UserSwitcherController(mContext, mKeyguardMonitor, |
Sudheer Shanka | 1c7cda8 | 2015-12-31 14:46:02 +0000 | [diff] [blame] | 876 | mHandler, this); |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 877 | createUserSwitcher(); |
Adrian Roos | 2b154a9 | 2014-11-17 15:18:39 +0100 | [diff] [blame] | 878 | } |
Adrian Roos | 723632e | 2014-07-23 21:13:21 +0200 | [diff] [blame] | 879 | |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 880 | // Set up the quick settings tile panel |
Clara Bayarri | 9b1fdff | 2016-04-21 14:28:47 +0100 | [diff] [blame] | 881 | AutoReinflateContainer container = (AutoReinflateContainer) mStatusBarWindow.findViewById( |
| 882 | R.id.qs_auto_reinflate_container); |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 883 | if (container != null) { |
Xiaohui Chen | 311b98e | 2016-03-30 11:55:54 -0700 | [diff] [blame] | 884 | final QSTileHost qsh = SystemUIFactory.getInstance().createQSTileHost(mContext, this, |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 885 | mBluetoothController, mLocationController, mRotationLockController, |
Jason Monk | 51e4dc0 | 2014-07-22 12:00:47 -0400 | [diff] [blame] | 886 | mNetworkController, mZenModeController, mHotspotController, |
John Spurlock | 657c62c | 2014-07-22 12:18:09 -0400 | [diff] [blame] | 887 | mCastController, mFlashlightController, |
Jason Monk | abe1974 | 2015-09-29 09:47:06 -0400 | [diff] [blame] | 888 | mUserSwitcherController, mUserInfoController, mKeyguardMonitor, |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 889 | mSecurityController, mBatteryController, mIconController, |
| 890 | mNextAlarmController); |
Adrian Roos | 5fd872e | 2014-08-12 17:28:58 +0200 | [diff] [blame] | 891 | mBrightnessMirrorController = new BrightnessMirrorController(mStatusBarWindow); |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 892 | container.addInflateListener(new InflateListener() { |
John Spurlock | bceed06 | 2014-08-10 18:04:16 -0400 | [diff] [blame] | 893 | @Override |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 894 | public void onInflated(View v) { |
| 895 | QSContainer qsContainer = (QSContainer) v.findViewById( |
| 896 | R.id.quick_settings_container); |
| 897 | qsContainer.setHost(qsh); |
| 898 | mQSPanel = qsContainer.getQsPanel(); |
| 899 | mQSPanel.setBrightnessMirror(mBrightnessMirrorController); |
Kaori Katou | ccf08d7 | 2015-05-26 16:25:04 +0900 | [diff] [blame] | 900 | mKeyguardStatusBar.setQSPanel(mQSPanel); |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 901 | mHeader = qsContainer.getHeader(); |
| 902 | initSignalCluster(mHeader); |
| 903 | mHeader.setActivityStarter(PhoneStatusBar.this); |
John Spurlock | bceed06 | 2014-08-10 18:04:16 -0400 | [diff] [blame] | 904 | } |
| 905 | }); |
Siva Velusamy | 537421b | 2012-09-14 14:45:02 -0700 | [diff] [blame] | 906 | } |
| 907 | |
Jorim Jaggi | 3d878be | 2014-05-10 03:22:32 +0200 | [diff] [blame] | 908 | // User info. Trigger first load. |
Jorim Jaggi | 4538027d | 2014-07-30 15:43:13 +0200 | [diff] [blame] | 909 | mKeyguardStatusBar.setUserInfoController(mUserInfoController); |
Adrian Roos | ffc9097 | 2015-06-09 18:09:49 -0700 | [diff] [blame] | 910 | mKeyguardStatusBar.setUserSwitcherController(mUserSwitcherController); |
Jorim Jaggi | 3d878be | 2014-05-10 03:22:32 +0200 | [diff] [blame] | 911 | mUserInfoController.reloadUserInfo(); |
| 912 | |
Jorim Jaggi | 708f772 | 2014-08-20 17:30:38 +0200 | [diff] [blame] | 913 | ((BatteryMeterView) mStatusBarView.findViewById(R.id.battery)).setBatteryController( |
| 914 | mBatteryController); |
Jorim Jaggi | 4538027d | 2014-07-30 15:43:13 +0200 | [diff] [blame] | 915 | mKeyguardStatusBar.setBatteryController(mBatteryController); |
Jorim Jaggi | 853b070 | 2014-07-05 04:31:14 +0200 | [diff] [blame] | 916 | |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 917 | PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); |
| 918 | mBroadcastReceiver.onReceive(mContext, |
| 919 | new Intent(pm.isScreenOn() ? Intent.ACTION_SCREEN_ON : Intent.ACTION_SCREEN_OFF)); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 920 | mGestureWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, |
| 921 | "GestureWakeLock"); |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 922 | mVibrator = mContext.getSystemService(Vibrator.class); |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 923 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 924 | // receive broadcasts |
| 925 | IntentFilter filter = new IntentFilter(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 926 | filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); |
| 927 | filter.addAction(Intent.ACTION_SCREEN_OFF); |
Daniel Sandler | 7f3cf95 | 2012-08-31 14:57:09 -0400 | [diff] [blame] | 928 | filter.addAction(Intent.ACTION_SCREEN_ON); |
Kenny Guy | 44fc65f | 2014-11-28 22:18:14 +0000 | [diff] [blame] | 929 | context.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 930 | |
Adrian Roos | 8e3e836 | 2015-07-16 19:42:22 -0700 | [diff] [blame] | 931 | IntentFilter demoFilter = new IntentFilter(); |
| 932 | if (DEBUG_MEDIA_FAKE_ARTWORK) { |
| 933 | demoFilter.addAction(ACTION_FAKE_ARTWORK); |
| 934 | } |
| 935 | demoFilter.addAction(ACTION_DEMO); |
| 936 | context.registerReceiverAsUser(mDemoReceiver, UserHandle.ALL, demoFilter, |
| 937 | android.Manifest.permission.DUMP, null); |
| 938 | |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 939 | // listen for USER_SETUP_COMPLETE setting (per-user) |
| 940 | resetUserSetupObserver(); |
| 941 | |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 942 | // disable profiling bars, since they overlap and clutter the output on app windows |
| 943 | ThreadedRenderer.overrideProperty("disableProfileBars", "true"); |
| 944 | |
| 945 | // Private API call to make the shadows look better for Recents |
| 946 | ThreadedRenderer.overrideProperty("ambientRatio", String.valueOf(1.5f)); |
| 947 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 948 | return mStatusBarView; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 949 | } |
| 950 | |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 951 | protected BatteryController createBatteryController() { |
| 952 | return new BatteryControllerImpl(mContext); |
| 953 | } |
| 954 | |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 955 | private void inflateOverflowContainer() { |
| 956 | mKeyguardIconOverflowContainer = |
| 957 | (NotificationOverflowContainer) LayoutInflater.from(mContext).inflate( |
| 958 | R.layout.status_bar_notification_keyguard_overflow, mStackScroller, false); |
| 959 | mKeyguardIconOverflowContainer.setOnActivatedListener(this); |
| 960 | mKeyguardIconOverflowContainer.setOnClickListener(mOverflowClickListener); |
| 961 | mStackScroller.setOverflowContainer(mKeyguardIconOverflowContainer); |
| 962 | } |
| 963 | |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 964 | @Override |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 965 | protected void onDensityOrFontScaleChanged() { |
| 966 | super.onDensityOrFontScaleChanged(); |
| 967 | mScrimController.onDensityOrFontScaleChanged(); |
| 968 | mStatusBarView.onDensityOrFontScaleChanged(); |
Adrian Roos | d390b89 | 2016-05-05 10:50:49 -0400 | [diff] [blame] | 969 | if (mBrightnessMirrorController != null) { |
| 970 | mBrightnessMirrorController.onDensityOrFontScaleChanged(); |
| 971 | } |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 972 | inflateSignalClusters(); |
| 973 | mIconController.onDensityOrFontScaleChanged(); |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 974 | inflateDismissView(); |
| 975 | updateClearAll(); |
| 976 | inflateEmptyShadeView(); |
| 977 | updateEmptyShadeView(); |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 978 | inflateOverflowContainer(); |
Selim Cinek | aa8bbf1 | 2016-05-04 14:13:20 -0700 | [diff] [blame] | 979 | mStatusBarKeyguardViewManager.onDensityOrFontScaleChanged(); |
Adrian Roos | d390b89 | 2016-05-05 10:50:49 -0400 | [diff] [blame] | 980 | mUserInfoController.onDensityOrFontScaleChanged(); |
| 981 | if (mUserSwitcherController != null) { |
| 982 | mUserSwitcherController.onDensityOrFontScaleChanged(); |
| 983 | } |
| 984 | if (mKeyguardUserSwitcher != null) { |
| 985 | mKeyguardUserSwitcher.onDensityOrFontScaleChanged(); |
| 986 | } |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 987 | } |
| 988 | |
| 989 | private void inflateSignalClusters() { |
| 990 | SignalClusterView signalClusterView = reinflateSignalCluster(mStatusBarView); |
| 991 | mIconController.setSignalCluster(signalClusterView); |
| 992 | reinflateSignalCluster(mKeyguardStatusView); |
| 993 | } |
| 994 | |
| 995 | private SignalClusterView reinflateSignalCluster(View view) { |
| 996 | SignalClusterView signalCluster = |
| 997 | (SignalClusterView) view.findViewById(R.id.signal_cluster); |
| 998 | if (signalCluster != null) { |
| 999 | ViewParent parent = signalCluster.getParent(); |
| 1000 | if (parent instanceof ViewGroup) { |
| 1001 | ViewGroup viewParent = (ViewGroup) parent; |
| 1002 | int index = viewParent.indexOfChild(signalCluster); |
| 1003 | viewParent.removeView(signalCluster); |
| 1004 | SignalClusterView newCluster = (SignalClusterView) LayoutInflater.from(mContext) |
| 1005 | .inflate(R.layout.signal_cluster_view, viewParent, false); |
| 1006 | ViewGroup.MarginLayoutParams layoutParams = |
| 1007 | (ViewGroup.MarginLayoutParams) viewParent.getLayoutParams(); |
| 1008 | layoutParams.setMarginsRelative( |
| 1009 | mContext.getResources().getDimensionPixelSize( |
| 1010 | R.dimen.signal_cluster_margin_start), |
| 1011 | 0, 0, 0); |
| 1012 | newCluster.setLayoutParams(layoutParams); |
| 1013 | newCluster.setSecurityController(mSecurityController); |
| 1014 | newCluster.setNetworkController(mNetworkController); |
| 1015 | viewParent.addView(newCluster, index); |
| 1016 | return newCluster; |
| 1017 | } |
| 1018 | return signalCluster; |
| 1019 | } |
| 1020 | return null; |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 1021 | } |
| 1022 | |
| 1023 | private void inflateEmptyShadeView() { |
| 1024 | mEmptyShadeView = (EmptyShadeView) LayoutInflater.from(mContext).inflate( |
| 1025 | R.layout.status_bar_no_notifications, mStackScroller, false); |
| 1026 | mStackScroller.setEmptyShadeView(mEmptyShadeView); |
| 1027 | } |
| 1028 | |
| 1029 | private void inflateDismissView() { |
| 1030 | mDismissView = (DismissView) LayoutInflater.from(mContext).inflate( |
| 1031 | R.layout.status_bar_notification_dismiss_all, mStackScroller, false); |
| 1032 | mDismissView.setOnButtonClickListener(new View.OnClickListener() { |
| 1033 | @Override |
| 1034 | public void onClick(View v) { |
| 1035 | MetricsLogger.action(mContext, MetricsEvent.ACTION_DISMISS_ALL_NOTES); |
| 1036 | clearAllNotifications(); |
| 1037 | } |
| 1038 | }); |
| 1039 | mStackScroller.setDismissView(mDismissView); |
| 1040 | } |
| 1041 | |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 1042 | protected void createUserSwitcher() { |
| 1043 | mKeyguardUserSwitcher = new KeyguardUserSwitcher(mContext, |
| 1044 | (ViewStub) mStatusBarWindow.findViewById(R.id.keyguard_user_switcher), |
| 1045 | mKeyguardStatusBar, mNotificationPanel, mUserSwitcherController); |
| 1046 | } |
| 1047 | |
Xiaohui Chen | d839d1a | 2016-01-21 13:05:02 -0800 | [diff] [blame] | 1048 | protected void inflateStatusBarWindow(Context context) { |
| 1049 | mStatusBarWindow = (StatusBarWindowView) View.inflate(context, |
| 1050 | R.layout.super_status_bar, null); |
| 1051 | } |
| 1052 | |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 1053 | protected void createNavigationBarView(Context context) { |
Xiaohui Chen | 8bdcd1f | 2016-01-19 13:52:07 -0800 | [diff] [blame] | 1054 | inflateNavigationBarView(context); |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 1055 | mNavigationBarView.setDisabledFlags(mDisabled1); |
| 1056 | mNavigationBarView.setComponents(mRecents, getComponent(Divider.class)); |
| 1057 | mNavigationBarView.setOnVerticalChangedListener( |
| 1058 | new NavigationBarView.OnVerticalChangedListener() { |
| 1059 | @Override |
| 1060 | public void onVerticalChanged(boolean isVertical) { |
| 1061 | if (mAssistManager != null) { |
| 1062 | mAssistManager.onConfigurationChanged(); |
| 1063 | } |
| 1064 | mNotificationPanel.setQsScrimEnabled(!isVertical); |
| 1065 | } |
| 1066 | }); |
| 1067 | mNavigationBarView.setOnTouchListener(new View.OnTouchListener() { |
| 1068 | @Override |
| 1069 | public boolean onTouch(View v, MotionEvent event) { |
| 1070 | checkUserAutohide(v, event); |
| 1071 | return false; |
| 1072 | }}); |
| 1073 | } |
| 1074 | |
Xiaohui Chen | 8bdcd1f | 2016-01-19 13:52:07 -0800 | [diff] [blame] | 1075 | protected void inflateNavigationBarView(Context context) { |
Jason Monk | 4f878ef | 2016-01-23 14:37:38 -0500 | [diff] [blame] | 1076 | mNavigationBarView = (NavigationBarView) View.inflate( |
| 1077 | context, R.layout.navigation_bar, null); |
Xiaohui Chen | 8bdcd1f | 2016-01-19 13:52:07 -0800 | [diff] [blame] | 1078 | } |
| 1079 | |
| 1080 | protected void initSignalCluster(View containerView) { |
Xiaohui Chen | 1094230 | 2015-12-16 16:38:13 -0800 | [diff] [blame] | 1081 | SignalClusterView signalCluster = |
| 1082 | (SignalClusterView) containerView.findViewById(R.id.signal_cluster); |
| 1083 | if (signalCluster != null) { |
Xiaohui Chen | 1094230 | 2015-12-16 16:38:13 -0800 | [diff] [blame] | 1084 | signalCluster.setSecurityController(mSecurityController); |
| 1085 | signalCluster.setNetworkController(mNetworkController); |
| 1086 | } |
| 1087 | } |
| 1088 | |
Muyuan Li | c510b5e | 2016-03-09 17:15:05 -0800 | [diff] [blame] | 1089 | public void clearAllNotifications() { |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1090 | |
| 1091 | // animate-swipe all dismissable notifications, then animate the shade closed |
| 1092 | int numChildren = mStackScroller.getChildCount(); |
| 1093 | |
| 1094 | final ArrayList<View> viewsToHide = new ArrayList<View>(numChildren); |
| 1095 | for (int i = 0; i < numChildren; i++) { |
| 1096 | final View child = mStackScroller.getChildAt(i); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1097 | if (child instanceof ExpandableNotificationRow) { |
| 1098 | if (mStackScroller.canChildBeDismissed(child)) { |
| 1099 | if (child.getVisibility() == View.VISIBLE) { |
| 1100 | viewsToHide.add(child); |
| 1101 | } |
| 1102 | } |
| 1103 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
| 1104 | List<ExpandableNotificationRow> children = row.getNotificationChildren(); |
| 1105 | if (row.areChildrenExpanded() && children != null) { |
| 1106 | for (ExpandableNotificationRow childRow : children) { |
| 1107 | if (childRow.getVisibility() == View.VISIBLE) { |
| 1108 | viewsToHide.add(childRow); |
| 1109 | } |
| 1110 | } |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1111 | } |
| 1112 | } |
| 1113 | } |
| 1114 | if (viewsToHide.isEmpty()) { |
| 1115 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
| 1116 | return; |
| 1117 | } |
| 1118 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1119 | addPostCollapseAction(new Runnable() { |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1120 | @Override |
| 1121 | public void run() { |
Selim Cinek | 9c17b77 | 2015-07-07 20:37:09 -0700 | [diff] [blame] | 1122 | mStackScroller.setDismissAllInProgress(false); |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1123 | try { |
| 1124 | mBarService.onClearAllNotifications(mCurrentUserId); |
| 1125 | } catch (Exception ex) { } |
| 1126 | } |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1127 | }); |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1128 | |
| 1129 | performDismissAllAnimations(viewsToHide); |
| 1130 | |
| 1131 | } |
| 1132 | |
| 1133 | private void performDismissAllAnimations(ArrayList<View> hideAnimatedList) { |
| 1134 | Runnable animationFinishAction = new Runnable() { |
| 1135 | @Override |
| 1136 | public void run() { |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1137 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
| 1138 | } |
| 1139 | }; |
| 1140 | |
| 1141 | // let's disable our normal animations |
| 1142 | mStackScroller.setDismissAllInProgress(true); |
| 1143 | |
| 1144 | // Decrease the delay for every row we animate to give the sense of |
| 1145 | // accelerating the swipes |
| 1146 | int rowDelayDecrement = 10; |
| 1147 | int currentDelay = 140; |
Selim Cinek | 7d5f374 | 2014-11-07 18:07:49 +0100 | [diff] [blame] | 1148 | int totalDelay = 180; |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1149 | int numItems = hideAnimatedList.size(); |
Selim Cinek | 7d5f374 | 2014-11-07 18:07:49 +0100 | [diff] [blame] | 1150 | for (int i = numItems - 1; i >= 0; i--) { |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1151 | View view = hideAnimatedList.get(i); |
| 1152 | Runnable endRunnable = null; |
Selim Cinek | 7d5f374 | 2014-11-07 18:07:49 +0100 | [diff] [blame] | 1153 | if (i == 0) { |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1154 | endRunnable = animationFinishAction; |
| 1155 | } |
| 1156 | mStackScroller.dismissViewAnimated(view, endRunnable, totalDelay, 260); |
| 1157 | currentDelay = Math.max(50, currentDelay - rowDelayDecrement); |
| 1158 | totalDelay += currentDelay; |
| 1159 | } |
| 1160 | } |
| 1161 | |
John Spurlock | ae641c9 | 2014-06-30 18:11:40 -0400 | [diff] [blame] | 1162 | @Override |
| 1163 | protected void setZenMode(int mode) { |
| 1164 | super.setZenMode(mode); |
| 1165 | if (mIconPolicy != null) { |
| 1166 | mIconPolicy.setZenMode(mode); |
| 1167 | } |
| 1168 | } |
| 1169 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 1170 | protected void startKeyguard() { |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 1171 | KeyguardViewMediator keyguardViewMediator = getComponent(KeyguardViewMediator.class); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 1172 | mFingerprintUnlockController = new FingerprintUnlockController(mContext, |
| 1173 | mStatusBarWindowManager, mDozeScrimController, keyguardViewMediator, |
| 1174 | mScrimController, this); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 1175 | mStatusBarKeyguardViewManager = keyguardViewMediator.registerStatusBar(this, |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 1176 | getBouncerContainer(), mStatusBarWindowManager, mScrimController, |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 1177 | mFingerprintUnlockController); |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 1178 | mKeyguardIndicationController.setStatusBarKeyguardViewManager( |
| 1179 | mStatusBarKeyguardViewManager); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 1180 | mFingerprintUnlockController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager); |
Nicolas Prevot | 1dbbe7d | 2016-05-17 12:52:54 +0100 | [diff] [blame] | 1181 | mIconPolicy.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager); |
Adrian Roos | d28ccd7 | 2016-01-06 15:23:14 +0100 | [diff] [blame] | 1182 | mRemoteInputController.addCallback(mStatusBarKeyguardViewManager); |
Adrian Roos | c0a579e | 2016-03-30 16:43:58 -0700 | [diff] [blame] | 1183 | |
| 1184 | if (FORCE_REMOTE_INPUT_HISTORY) { |
| 1185 | mRemoteInputController.addCallback(new RemoteInputController.Callback() { |
| 1186 | @Override |
| 1187 | public void onRemoteInputSent(Entry entry) { |
| 1188 | if (mKeysKeptForRemoteInput.contains(entry.key)) { |
| 1189 | removeNotification(entry.key, null); |
| 1190 | } |
| 1191 | } |
| 1192 | }); |
| 1193 | } |
| 1194 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 1195 | mKeyguardViewMediatorCallback = keyguardViewMediator.getViewMediatorCallback(); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 1196 | mLightStatusBarController.setFingerprintUnlockController(mFingerprintUnlockController); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1197 | } |
| 1198 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1199 | @Override |
Michael Jurka | cb2522c | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 1200 | protected View getStatusBarView() { |
| 1201 | return mStatusBarView; |
| 1202 | } |
| 1203 | |
Jorim Jaggi | 0a27be8 | 2014-06-11 03:22:39 +0200 | [diff] [blame] | 1204 | public StatusBarWindowView getStatusBarWindow() { |
| 1205 | return mStatusBarWindow; |
| 1206 | } |
| 1207 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 1208 | protected ViewGroup getBouncerContainer() { |
| 1209 | return mStatusBarWindow; |
| 1210 | } |
| 1211 | |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 1212 | public int getStatusBarHeight() { |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1213 | if (mNaturalBarHeight < 0) { |
| 1214 | final Resources res = mContext.getResources(); |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 1215 | mNaturalBarHeight = |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1216 | res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); |
| 1217 | } |
| 1218 | return mNaturalBarHeight; |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 1219 | } |
| 1220 | |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1221 | private View.OnClickListener mRecentsClickListener = new View.OnClickListener() { |
| 1222 | public void onClick(View v) { |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 1223 | awakenDreams(); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1224 | toggleRecentApps(); |
| 1225 | } |
| 1226 | }; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1227 | |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 1228 | private View.OnLongClickListener mLongPressBackListener = new View.OnLongClickListener() { |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 1229 | @Override |
| 1230 | public boolean onLongClick(View v) { |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 1231 | return handleLongPressBack(); |
| 1232 | } |
| 1233 | }; |
| 1234 | |
| 1235 | private View.OnLongClickListener mRecentsLongClickListener = new View.OnLongClickListener() { |
| 1236 | |
| 1237 | @Override |
| 1238 | public boolean onLongClick(View v) { |
Jorim Jaggi | 19cf297 | 2016-04-07 23:26:10 -0700 | [diff] [blame] | 1239 | if (mRecents == null || !ActivityManager.supportsMultiWindow() |
| 1240 | || !getComponent(Divider.class).getView().getSnapAlgorithm() |
| 1241 | .isSplitScreenFeasible()) { |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1242 | return false; |
| 1243 | } |
Winson | c694a50 | 2016-03-10 16:35:03 -0800 | [diff] [blame] | 1244 | |
Jorim Jaggi | 29379ec | 2016-04-11 23:43:42 -0700 | [diff] [blame] | 1245 | toggleSplitScreenMode(MetricsEvent.ACTION_WINDOW_DOCK_LONGPRESS, |
| 1246 | MetricsEvent.ACTION_WINDOW_UNDOCK_LONGPRESS); |
| 1247 | return true; |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 1248 | } |
| 1249 | }; |
| 1250 | |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1251 | @Override |
Jorim Jaggi | 29379ec | 2016-04-11 23:43:42 -0700 | [diff] [blame] | 1252 | protected void toggleSplitScreenMode(int metricsDockAction, int metricsUndockAction) { |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1253 | if (mRecents == null) { |
Jorim Jaggi | 29379ec | 2016-04-11 23:43:42 -0700 | [diff] [blame] | 1254 | return; |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1255 | } |
| 1256 | int dockSide = WindowManagerProxy.getInstance().getDockSide(); |
| 1257 | if (dockSide == WindowManager.DOCKED_INVALID) { |
Jorim Jaggi | 29379ec | 2016-04-11 23:43:42 -0700 | [diff] [blame] | 1258 | mRecents.dockTopTask(NavigationBarGestureHelper.DRAG_MODE_NONE, |
| 1259 | ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT, null, metricsDockAction); |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1260 | } else { |
| 1261 | EventBus.getDefault().send(new UndockingTaskEvent()); |
Jorim Jaggi | 29379ec | 2016-04-11 23:43:42 -0700 | [diff] [blame] | 1262 | if (metricsUndockAction != -1) { |
| 1263 | MetricsLogger.action(mContext, metricsUndockAction); |
| 1264 | } |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1265 | } |
| 1266 | } |
| 1267 | |
Jorim Jaggi | 7e6571f | 2015-06-25 11:52:48 -0700 | [diff] [blame] | 1268 | private final View.OnLongClickListener mLongPressHomeListener |
| 1269 | = new View.OnLongClickListener() { |
| 1270 | @Override |
| 1271 | public boolean onLongClick(View v) { |
| 1272 | if (shouldDisableNavbarGestures()) { |
| 1273 | return false; |
| 1274 | } |
Chris Wren | f6e9228b | 2016-01-26 18:04:35 -0500 | [diff] [blame] | 1275 | MetricsLogger.action(mContext, MetricsEvent.ACTION_ASSIST_LONG_PRESS); |
Jorim Jaggi | 165ce06 | 2015-07-06 16:18:11 -0700 | [diff] [blame] | 1276 | mAssistManager.startAssist(new Bundle() /* args */); |
Daniel Sandler | a2fbe53 | 2012-08-10 01:19:03 -0400 | [diff] [blame] | 1277 | awakenDreams(); |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 1278 | if (mNavigationBarView != null) { |
Xiyuan Xia | ee7dd05 | 2015-05-15 09:46:27 -0700 | [diff] [blame] | 1279 | mNavigationBarView.abortCurrentGesture(); |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 1280 | } |
Jorim Jaggi | 7e6571f | 2015-06-25 11:52:48 -0700 | [diff] [blame] | 1281 | return true; |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 1282 | } |
| 1283 | }; |
| 1284 | |
Jorim Jaggi | 7e6571f | 2015-06-25 11:52:48 -0700 | [diff] [blame] | 1285 | private final View.OnTouchListener mHomeActionListener = new View.OnTouchListener() { |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 1286 | public boolean onTouch(View v, MotionEvent event) { |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 1287 | switch (event.getAction()) { |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 1288 | case MotionEvent.ACTION_UP: |
| 1289 | case MotionEvent.ACTION_CANCEL: |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 1290 | awakenDreams(); |
| 1291 | break; |
| 1292 | } |
| 1293 | return false; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 1294 | } |
| 1295 | }; |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1296 | |
Daniel Sandler | a2fbe53 | 2012-08-10 01:19:03 -0400 | [diff] [blame] | 1297 | private void awakenDreams() { |
| 1298 | if (mDreamManager != null) { |
| 1299 | try { |
| 1300 | mDreamManager.awaken(); |
| 1301 | } catch (RemoteException e) { |
| 1302 | // fine, stay asleep then |
| 1303 | } |
| 1304 | } |
| 1305 | } |
| 1306 | |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 1307 | private void prepareNavigationBarView() { |
| 1308 | mNavigationBarView.reorient(); |
| 1309 | |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 1310 | ButtonDispatcher recentsButton = mNavigationBarView.getRecentsButton(); |
| 1311 | recentsButton.setOnClickListener(mRecentsClickListener); |
| 1312 | recentsButton.setOnTouchListener(mRecentsPreloadOnTouchListener); |
| 1313 | recentsButton.setLongClickable(true); |
| 1314 | recentsButton.setOnLongClickListener(mRecentsLongClickListener); |
Anthony Chen | ada1304 | 2016-01-19 16:57:20 -0800 | [diff] [blame] | 1315 | |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 1316 | ButtonDispatcher backButton = mNavigationBarView.getBackButton(); |
| 1317 | backButton.setLongClickable(true); |
| 1318 | backButton.setOnLongClickListener(mLongPressBackListener); |
Anthony Chen | ada1304 | 2016-01-19 16:57:20 -0800 | [diff] [blame] | 1319 | |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 1320 | ButtonDispatcher homeButton = mNavigationBarView.getHomeButton(); |
| 1321 | homeButton.setOnTouchListener(mHomeActionListener); |
| 1322 | homeButton.setOnLongClickListener(mLongPressHomeListener); |
Anthony Chen | ada1304 | 2016-01-19 16:57:20 -0800 | [diff] [blame] | 1323 | |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 1324 | mAssistManager.onConfigurationChanged(); |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 1325 | } |
| 1326 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1327 | // For small-screen devices (read: phones) that lack hardware navigation buttons |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 1328 | protected void addNavigationBar() { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 1329 | if (DEBUG) Log.v(TAG, "addNavigationBar: about to add " + mNavigationBarView); |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 1330 | if (mNavigationBarView == null) return; |
Jim Miller | 17dfec7 | 2011-07-08 19:09:55 -0700 | [diff] [blame] | 1331 | |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 1332 | prepareNavigationBarView(); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1333 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1334 | mWindowManager.addView(mNavigationBarView, getNavigationBarLayoutParams()); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1335 | } |
| 1336 | |
Victor Chan | ecdb8b0 | 2016-01-07 18:32:43 -0800 | [diff] [blame] | 1337 | protected void repositionNavigationBar() { |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 1338 | if (mNavigationBarView == null || !mNavigationBarView.isAttachedToWindow()) return; |
Jim Miller | 17dfec7 | 2011-07-08 19:09:55 -0700 | [diff] [blame] | 1339 | |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 1340 | prepareNavigationBarView(); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1341 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1342 | mWindowManager.updateViewLayout(mNavigationBarView, getNavigationBarLayoutParams()); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1343 | } |
| 1344 | |
John Spurlock | 1bbd49d | 2012-10-19 11:09:32 -0400 | [diff] [blame] | 1345 | private void notifyNavigationBarScreenOn(boolean screenOn) { |
| 1346 | if (mNavigationBarView == null) return; |
| 1347 | mNavigationBarView.notifyScreenOn(screenOn); |
| 1348 | } |
| 1349 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1350 | private WindowManager.LayoutParams getNavigationBarLayoutParams() { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1351 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1352 | LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1353 | WindowManager.LayoutParams.TYPE_NAVIGATION_BAR, |
| 1354 | 0 |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1355 | | WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING |
| 1356 | | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 1357 | | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
Daniel Sandler | c26185b | 2012-08-29 15:49:53 -0400 | [diff] [blame] | 1358 | | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
Jim Miller | d99e7fd | 2012-05-08 16:30:42 -0700 | [diff] [blame] | 1359 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1360 | PixelFormat.TRANSLUCENT); |
Daniel Sandler | c638c1e | 2011-08-24 16:19:23 -0700 | [diff] [blame] | 1361 | // 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] | 1362 | if (ActivityManager.isHighEndGfx()) { |
Daniel Sandler | c638c1e | 2011-08-24 16:19:23 -0700 | [diff] [blame] | 1363 | lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
| 1364 | } |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1365 | |
| 1366 | lp.setTitle("NavigationBar"); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1367 | lp.windowAnimations = 0; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1368 | return lp; |
| 1369 | } |
| 1370 | |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 1371 | @Override |
| 1372 | public void setIcon(String slot, StatusBarIcon icon) { |
| 1373 | mIconController.setIcon(slot, icon); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1374 | } |
| 1375 | |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 1376 | @Override |
| 1377 | public void removeIcon(String slot) { |
| 1378 | mIconController.removeIcon(slot); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1379 | } |
| 1380 | |
John Spurlock | bf20eab | 2014-04-09 16:40:39 -0400 | [diff] [blame] | 1381 | public UserHandle getCurrentUserHandle() { |
| 1382 | return new UserHandle(mCurrentUserId); |
| 1383 | } |
| 1384 | |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 1385 | @Override |
Selim Cinek | 379ff8f | 2015-02-20 17:03:16 +0100 | [diff] [blame] | 1386 | public void addNotification(StatusBarNotification notification, RankingMap ranking, |
| 1387 | Entry oldEntry) { |
Chris Wren | aaa58d1 | 2014-06-03 14:29:12 -0400 | [diff] [blame] | 1388 | if (DEBUG) Log.d(TAG, "addNotification key=" + notification.getKey()); |
Chris Wren | d4db6cb | 2013-08-07 16:05:23 -0400 | [diff] [blame] | 1389 | |
Julia Reynolds | f612869ae | 2015-11-05 16:48:55 -0500 | [diff] [blame] | 1390 | mNotificationData.updateRanking(ranking); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1391 | Entry shadeEntry = createNotificationViews(notification); |
Chris Wren | a4ef620 | 2014-06-09 18:07:30 -0400 | [diff] [blame] | 1392 | if (shadeEntry == null) { |
| 1393 | return; |
| 1394 | } |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 1395 | boolean isHeadsUped = mUseHeadsUp && shouldPeek(shadeEntry); |
Selim Cinek | 31d9ef7 | 2015-04-15 19:29:49 -0700 | [diff] [blame] | 1396 | if (isHeadsUped) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1397 | mHeadsUpManager.showNotification(shadeEntry); |
Amith Yamasani | f47e51e | 2015-04-17 10:02:15 -0700 | [diff] [blame] | 1398 | // Mark as seen immediately |
| 1399 | setNotificationShown(notification); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1400 | } |
Chris Wren | a4ef620 | 2014-06-09 18:07:30 -0400 | [diff] [blame] | 1401 | |
Selim Cinek | 31d9ef7 | 2015-04-15 19:29:49 -0700 | [diff] [blame] | 1402 | if (!isHeadsUped && notification.getNotification().fullScreenIntent != null) { |
Julia Reynolds | d560729 | 2016-02-05 15:25:58 -0500 | [diff] [blame] | 1403 | if (shouldSuppressFullScreenIntent(notification.getKey())) { |
Julia Reynolds | 6172158 | 2016-01-05 08:35:25 -0500 | [diff] [blame] | 1404 | if (DEBUG) { |
| 1405 | Log.d(TAG, "No Fullscreen intent: suppressed by DND: " + notification.getKey()); |
| 1406 | } |
Julia Reynolds | f0f629f | 2016-02-25 09:34:04 -0500 | [diff] [blame] | 1407 | } else if (mNotificationData.getImportance(notification.getKey()) |
| 1408 | < NotificationListenerService.Ranking.IMPORTANCE_MAX) { |
| 1409 | if (DEBUG) { |
| 1410 | Log.d(TAG, "No Fullscreen intent: not important enough: " |
| 1411 | + notification.getKey()); |
| 1412 | } |
Julia Reynolds | 6172158 | 2016-01-05 08:35:25 -0500 | [diff] [blame] | 1413 | } else { |
| 1414 | // Stop screensaver if the notification has a full-screen intent. |
| 1415 | // (like an incoming phone call) |
| 1416 | awakenDreams(); |
Daniel Sandler | c9ce0ab | 2012-09-04 13:27:09 -0400 | [diff] [blame] | 1417 | |
Julia Reynolds | 6172158 | 2016-01-05 08:35:25 -0500 | [diff] [blame] | 1418 | // not immersive & a full-screen alert should be shown |
| 1419 | if (DEBUG) |
| 1420 | Log.d(TAG, "Notification has fullScreenIntent; sending fullScreenIntent"); |
| 1421 | try { |
| 1422 | EventLog.writeEvent(EventLogTags.SYSUI_FULLSCREEN_NOTIFICATION, |
| 1423 | notification.getKey()); |
| 1424 | notification.getNotification().fullScreenIntent.send(); |
| 1425 | shadeEntry.notifyFullScreenIntentLaunched(); |
| 1426 | MetricsLogger.count(mContext, "note_fullscreen", 1); |
| 1427 | } catch (PendingIntent.CanceledException e) { |
| 1428 | } |
John Spurlock | bf20eab | 2014-04-09 16:40:39 -0400 | [diff] [blame] | 1429 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1430 | } |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1431 | addNotificationViews(shadeEntry, ranking); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1432 | // Recalculate the position of the sliding windows and the titles. |
| 1433 | setAreThereNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1434 | } |
| 1435 | |
Julia Reynolds | d560729 | 2016-02-05 15:25:58 -0500 | [diff] [blame] | 1436 | private boolean shouldSuppressFullScreenIntent(String key) { |
Dan Sandler | dc34df5 | 2016-04-07 21:04:46 -0400 | [diff] [blame] | 1437 | if (isDeviceInVrMode()) { |
| 1438 | return true; |
| 1439 | } |
| 1440 | |
Julia Reynolds | 0971cb0 | 2016-01-26 17:00:22 -0500 | [diff] [blame] | 1441 | if (mPowerManager.isInteractive()) { |
Julia Reynolds | 0971cb0 | 2016-01-26 17:00:22 -0500 | [diff] [blame] | 1442 | return mNotificationData.shouldSuppressScreenOn(key); |
Julia Reynolds | d560729 | 2016-02-05 15:25:58 -0500 | [diff] [blame] | 1443 | } else { |
| 1444 | return mNotificationData.shouldSuppressScreenOff(key); |
Julia Reynolds | 0971cb0 | 2016-01-26 17:00:22 -0500 | [diff] [blame] | 1445 | } |
| 1446 | } |
| 1447 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1448 | @Override |
Christoph Studer | e71fefc | 2014-06-24 16:16:49 +0200 | [diff] [blame] | 1449 | protected void updateNotificationRanking(RankingMap ranking) { |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 1450 | mNotificationData.updateRanking(ranking); |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 1451 | updateNotifications(); |
| 1452 | } |
| 1453 | |
| 1454 | @Override |
Christoph Studer | e71fefc | 2014-06-24 16:16:49 +0200 | [diff] [blame] | 1455 | public void removeNotification(String key, RankingMap ranking) { |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1456 | boolean deferRemoval = false; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1457 | if (mHeadsUpManager.isHeadsUp(key)) { |
Adrian Roos | c721fcc5 | 2016-04-29 11:28:37 -0700 | [diff] [blame] | 1458 | // A cancel() in repsonse to a remote input shouldn't be delayed, as it makes the |
| 1459 | // sending look longer than it takes. |
| 1460 | boolean ignoreEarliestRemovalTime = mRemoteInputController.isSpinning(key) |
| 1461 | && !FORCE_REMOTE_INPUT_HISTORY; |
| 1462 | deferRemoval = !mHeadsUpManager.removeNotification(key, ignoreEarliestRemovalTime); |
Chris Wren | a4ef620 | 2014-06-09 18:07:30 -0400 | [diff] [blame] | 1463 | } |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1464 | if (key.equals(mMediaNotificationKey)) { |
| 1465 | clearCurrentMediaNotification(); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 1466 | updateMediaMetaData(true, true); |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1467 | } |
Adrian Roos | c0a579e | 2016-03-30 16:43:58 -0700 | [diff] [blame] | 1468 | if (FORCE_REMOTE_INPUT_HISTORY && mRemoteInputController.isSpinning(key)) { |
| 1469 | Entry entry = mNotificationData.get(key); |
| 1470 | StatusBarNotification sbn = entry.notification; |
| 1471 | |
| 1472 | Notification.Builder b = Notification.Builder |
| 1473 | .recoverBuilder(mContext, sbn.getNotification().clone()); |
| 1474 | CharSequence[] oldHistory = sbn.getNotification().extras |
| 1475 | .getCharSequenceArray(Notification.EXTRA_REMOTE_INPUT_HISTORY); |
| 1476 | CharSequence[] newHistory; |
| 1477 | if (oldHistory == null) { |
| 1478 | newHistory = new CharSequence[1]; |
| 1479 | } else { |
| 1480 | newHistory = new CharSequence[oldHistory.length + 1]; |
| 1481 | for (int i = 0; i < oldHistory.length; i++) { |
| 1482 | newHistory[i + 1] = oldHistory[i]; |
| 1483 | } |
| 1484 | } |
| 1485 | newHistory[0] = String.valueOf(entry.remoteInputText); |
| 1486 | b.setRemoteInputHistory(newHistory); |
| 1487 | |
| 1488 | Notification newNotification = b.build(); |
| 1489 | |
| 1490 | // Undo any compatibility view inflation |
| 1491 | newNotification.contentView = sbn.getNotification().contentView; |
| 1492 | newNotification.bigContentView = sbn.getNotification().bigContentView; |
| 1493 | newNotification.headsUpContentView = sbn.getNotification().headsUpContentView; |
| 1494 | |
| 1495 | StatusBarNotification newSbn = new StatusBarNotification(sbn.getPackageName(), |
| 1496 | sbn.getOpPkg(), |
| 1497 | sbn.getId(), sbn.getTag(), sbn.getUid(), sbn.getInitialPid(), |
| 1498 | 0, newNotification, sbn.getUser(), sbn.getPostTime()); |
| 1499 | |
| 1500 | updateNotification(newSbn, null); |
| 1501 | mKeysKeptForRemoteInput.add(entry.key); |
| 1502 | return; |
| 1503 | } |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1504 | if (deferRemoval) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1505 | mLatestRankingMap = ranking; |
| 1506 | mHeadsUpEntriesToRemoveOnSwitch.add(mHeadsUpManager.getEntry(key)); |
| 1507 | return; |
| 1508 | } |
Selim Cinek | a570318 | 2016-05-11 21:23:16 -0400 | [diff] [blame] | 1509 | Entry entry = mNotificationData.get(key); |
| 1510 | if (entry != null && entry.row != null) { |
| 1511 | entry.row.setRemoved(true); |
| 1512 | } |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1513 | // Let's remove the children if this was a summary |
| 1514 | handleGroupSummaryRemoved(key, ranking); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1515 | StatusBarNotification old = removeNotificationViews(key, ranking); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 1516 | if (SPEW) Log.d(TAG, "removeNotification key=" + key + " old=" + old); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1517 | |
| 1518 | if (old != null) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1519 | if (CLOSE_PANEL_WHEN_EMPTIED && !hasActiveNotifications() |
Jorim Jaggi | ba94f88 | 2014-08-20 19:23:55 +0200 | [diff] [blame] | 1520 | && !mNotificationPanel.isTracking() && !mNotificationPanel.isQsExpanded()) { |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 1521 | if (mState == StatusBarState.SHADE) { |
| 1522 | animateCollapsePanels(); |
| 1523 | } else if (mState == StatusBarState.SHADE_LOCKED) { |
| 1524 | goToKeyguard(); |
| 1525 | } |
Daniel Sandler | 8cc36e5 | 2011-10-17 14:18:46 -0400 | [diff] [blame] | 1526 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1527 | } |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 1528 | setAreThereNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1529 | } |
| 1530 | |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1531 | /** |
| 1532 | * Ensures that the group children are cancelled immediately when the group summary is cancelled |
| 1533 | * instead of waiting for the notification manager to send all cancels. Otherwise this could |
| 1534 | * lead to flickers. |
| 1535 | * |
| 1536 | * This also ensures that the animation looks nice and only consists of a single disappear |
| 1537 | * animation instead of multiple. |
| 1538 | * |
| 1539 | * @param key the key of the notification was removed |
| 1540 | * @param ranking the current ranking |
| 1541 | */ |
| 1542 | private void handleGroupSummaryRemoved(String key, |
| 1543 | RankingMap ranking) { |
| 1544 | Entry entry = mNotificationData.get(key); |
| 1545 | if (entry != null && entry.row != null |
| 1546 | && entry.row.isSummaryWithChildren()) { |
| 1547 | if (entry.notification.getOverrideGroupKey() != null && !entry.row.isDismissed()) { |
| 1548 | // We don't want to remove children for autobundled notifications as they are not |
| 1549 | // always cancelled. We only remove them if they were dismissed by the user. |
| 1550 | return; |
| 1551 | } |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1552 | List<ExpandableNotificationRow> notificationChildren = |
| 1553 | entry.row.getNotificationChildren(); |
| 1554 | ArrayList<ExpandableNotificationRow> toRemove = new ArrayList<>(notificationChildren); |
| 1555 | for (int i = 0; i < toRemove.size(); i++) { |
| 1556 | toRemove.get(i).setKeepInParent(true); |
Selim Cinek | a570318 | 2016-05-11 21:23:16 -0400 | [diff] [blame] | 1557 | // we need to set this state earlier as otherwise we might generate some weird |
| 1558 | // animations |
Selim Cinek | fa760d4 | 2016-05-10 15:50:53 -0400 | [diff] [blame] | 1559 | toRemove.get(i).setRemoved(true); |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1560 | } |
| 1561 | for (int i = 0; i < toRemove.size(); i++) { |
| 1562 | removeNotification(toRemove.get(i).getStatusBarNotification().getKey(), ranking); |
Selim Cinek | 7103fd4 | 2016-05-09 22:22:33 -0400 | [diff] [blame] | 1563 | // we need to ensure that the view is actually properly removed from the viewstate |
| 1564 | // as this won't happen anymore when kept in the parent. |
| 1565 | mStackScroller.removeViewStateForView(toRemove.get(i)); |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1566 | } |
| 1567 | } |
| 1568 | } |
| 1569 | |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 1570 | @Override |
| 1571 | protected void refreshLayout(int layoutDirection) { |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 1572 | if (mNavigationBarView != null) { |
| 1573 | mNavigationBarView.setLayoutDirection(layoutDirection); |
| 1574 | } |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 1575 | } |
| 1576 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1577 | private void updateNotificationShade() { |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 1578 | if (mStackScroller == null) return; |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 1579 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1580 | // Do not modify the notifications during collapse. |
| 1581 | if (isCollapsing()) { |
| 1582 | addPostCollapseAction(new Runnable() { |
| 1583 | @Override |
| 1584 | public void run() { |
| 1585 | updateNotificationShade(); |
| 1586 | } |
| 1587 | }); |
| 1588 | return; |
| 1589 | } |
| 1590 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1591 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1592 | ArrayList<ExpandableNotificationRow> toShow = new ArrayList<>(activeNotifications.size()); |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1593 | final int N = activeNotifications.size(); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1594 | for (int i=0; i<N; i++) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1595 | Entry ent = activeNotifications.get(i); |
| 1596 | int vis = ent.notification.getNotification().visibility; |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 1597 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1598 | // Display public version of the notification if we need to redact. |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1599 | final boolean hideSensitive = |
| 1600 | !userAllowsPrivateNotificationsInPublic(ent.notification.getUserId()); |
Chris Wren | 3ad4e3a | 2014-09-02 17:23:51 -0400 | [diff] [blame] | 1601 | boolean sensitiveNote = vis == Notification.VISIBILITY_PRIVATE; |
| 1602 | boolean sensitivePackage = packageHasVisibilityOverride(ent.notification.getKey()); |
| 1603 | boolean sensitive = (sensitiveNote && hideSensitive) || sensitivePackage; |
| 1604 | boolean showingPublic = sensitive && isLockscreenPublicMode(); |
Sudheer Shanka | f5b850e | 2016-01-25 19:58:59 +0000 | [diff] [blame] | 1605 | if (showingPublic) { |
| 1606 | updatePublicContentView(ent, ent.notification); |
| 1607 | } |
Selim Cinek | 3c76d50 | 2016-02-19 15:16:33 -0800 | [diff] [blame] | 1608 | ent.row.setSensitive(sensitive, hideSensitive); |
Dan Sandler | 1b71878 | 2014-07-18 12:43:45 -0400 | [diff] [blame] | 1609 | if (ent.autoRedacted && ent.legacy) { |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1610 | // TODO: Also fade this? Or, maybe easier (and better), provide a dark redacted form |
| 1611 | // for legacy auto redacted notifications. |
Dan Sandler | 1b71878 | 2014-07-18 12:43:45 -0400 | [diff] [blame] | 1612 | if (showingPublic) { |
| 1613 | ent.row.setShowingLegacyBackground(false); |
| 1614 | } else { |
| 1615 | ent.row.setShowingLegacyBackground(true); |
| 1616 | } |
| 1617 | } |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1618 | if (mGroupManager.isChildInGroupWithSummary(ent.row.getStatusBarNotification())) { |
| 1619 | ExpandableNotificationRow summary = mGroupManager.getGroupSummary( |
| 1620 | ent.row.getStatusBarNotification()); |
| 1621 | List<ExpandableNotificationRow> orderedChildren = |
| 1622 | mTmpChildOrderMap.get(summary); |
| 1623 | if (orderedChildren == null) { |
| 1624 | orderedChildren = new ArrayList<>(); |
| 1625 | mTmpChildOrderMap.put(summary, orderedChildren); |
| 1626 | } |
| 1627 | orderedChildren.add(ent.row); |
| 1628 | } else { |
| 1629 | toShow.add(ent.row); |
| 1630 | } |
| 1631 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1632 | } |
| 1633 | |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1634 | ArrayList<ExpandableNotificationRow> toRemove = new ArrayList<>(); |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 1635 | for (int i=0; i< mStackScroller.getChildCount(); i++) { |
| 1636 | View child = mStackScroller.getChildAt(i); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1637 | if (!toShow.contains(child) && child instanceof ExpandableNotificationRow) { |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1638 | toRemove.add((ExpandableNotificationRow) child); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1639 | } |
| 1640 | } |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1641 | |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1642 | for (ExpandableNotificationRow remove : toRemove) { |
| 1643 | if (mGroupManager.isChildInGroupWithSummary(remove.getStatusBarNotification())) { |
| 1644 | // we are only transfering this notification to its parent, don't generate an animation |
| 1645 | mStackScroller.setChildTransferInProgress(true); |
| 1646 | } |
Selim Cinek | c1e389d | 2016-04-07 11:02:57 -0700 | [diff] [blame] | 1647 | if (remove.isSummaryWithChildren()) { |
| 1648 | remove.removeAllChildren(); |
| 1649 | } |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 1650 | mStackScroller.removeView(remove); |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1651 | mStackScroller.setChildTransferInProgress(false); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1652 | } |
Selim Cinek | 2b54242 | 2016-03-04 18:10:37 -0800 | [diff] [blame] | 1653 | |
| 1654 | removeNotificationChildren(); |
| 1655 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1656 | for (int i=0; i<toShow.size(); i++) { |
| 1657 | View v = toShow.get(i); |
| 1658 | if (v.getParent() == null) { |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1659 | mStackScroller.addView(v); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1660 | } |
| 1661 | } |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 1662 | |
Selim Cinek | 2b54242 | 2016-03-04 18:10:37 -0800 | [diff] [blame] | 1663 | addNotificationChildrenAndSort(); |
| 1664 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1665 | // So after all this work notifications still aren't sorted correctly. |
| 1666 | // Let's do that now by advancing through toShow and mStackScroller in |
| 1667 | // lock-step, making sure mStackScroller matches what we see in toShow. |
| 1668 | int j = 0; |
| 1669 | for (int i = 0; i < mStackScroller.getChildCount(); i++) { |
| 1670 | View child = mStackScroller.getChildAt(i); |
| 1671 | if (!(child instanceof ExpandableNotificationRow)) { |
| 1672 | // We don't care about non-notification views. |
| 1673 | continue; |
| 1674 | } |
| 1675 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1676 | ExpandableNotificationRow targetChild = toShow.get(j); |
| 1677 | if (child != targetChild) { |
| 1678 | // Oops, wrong notification at this position. Put the right one |
| 1679 | // here and advance both lists. |
| 1680 | mStackScroller.changeViewPosition(targetChild, i); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1681 | } |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1682 | j++; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1683 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1684 | } |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1685 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1686 | // clear the map again for the next usage |
| 1687 | mTmpChildOrderMap.clear(); |
| 1688 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1689 | updateRowStates(); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1690 | updateSpeedbump(); |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1691 | updateClearAll(); |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 1692 | updateEmptyShadeView(); |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1693 | |
Benjamin Franz | 27cf146 | 2015-04-23 19:36:42 +0100 | [diff] [blame] | 1694 | updateQsExpansionEnabled(); |
| 1695 | mShadeUpdates.check(); |
| 1696 | } |
| 1697 | |
| 1698 | /** |
| 1699 | * Disable QS if device not provisioned. |
| 1700 | * If the user switcher is simple then disable QS during setup because |
| 1701 | * the user intends to use the lock screen user switcher, QS in not needed. |
| 1702 | */ |
| 1703 | private void updateQsExpansionEnabled() { |
Jason Monk | 3ad242d | 2014-09-15 11:13:35 -0400 | [diff] [blame] | 1704 | mNotificationPanel.setQsExpansionEnabled(isDeviceProvisioned() |
Adrian Roos | 2b154a9 | 2014-11-17 15:18:39 +0100 | [diff] [blame] | 1705 | && (mUserSetup || mUserSwitcherController == null |
Benjamin Franz | 27cf146 | 2015-04-23 19:36:42 +0100 | [diff] [blame] | 1706 | || !mUserSwitcherController.isSimpleUserSwitcher()) |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 1707 | && ((mDisabled2 & StatusBarManager.DISABLE2_QUICK_SETTINGS) == 0) |
| 1708 | && !ONLY_CORE_APPS); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1709 | } |
| 1710 | |
Selim Cinek | 2b54242 | 2016-03-04 18:10:37 -0800 | [diff] [blame] | 1711 | private void addNotificationChildrenAndSort() { |
Selim Cinek | 322ec7e | 2016-02-11 14:47:06 -0800 | [diff] [blame] | 1712 | // Let's now add all notification children which are missing |
| 1713 | boolean orderChanged = false; |
| 1714 | for (int i = 0; i < mStackScroller.getChildCount(); i++) { |
| 1715 | View view = mStackScroller.getChildAt(i); |
| 1716 | if (!(view instanceof ExpandableNotificationRow)) { |
| 1717 | // We don't care about non-notification views. |
| 1718 | continue; |
| 1719 | } |
| 1720 | |
| 1721 | ExpandableNotificationRow parent = (ExpandableNotificationRow) view; |
| 1722 | List<ExpandableNotificationRow> children = parent.getNotificationChildren(); |
| 1723 | List<ExpandableNotificationRow> orderedChildren = mTmpChildOrderMap.get(parent); |
| 1724 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1725 | for (int childIndex = 0; orderedChildren != null && childIndex < orderedChildren.size(); |
| 1726 | childIndex++) { |
| 1727 | ExpandableNotificationRow childView = orderedChildren.get(childIndex); |
| 1728 | if (children == null || !children.contains(childView)) { |
| 1729 | parent.addChildNotification(childView, childIndex); |
| 1730 | mStackScroller.notifyGroupChildAdded(childView); |
| 1731 | } |
| 1732 | } |
| 1733 | |
| 1734 | // Finally after removing and adding has been beformed we can apply the order. |
| 1735 | orderChanged |= parent.applyChildOrder(orderedChildren); |
| 1736 | } |
| 1737 | if (orderChanged) { |
| 1738 | mStackScroller.generateChildOrderChangedEvent(); |
| 1739 | } |
| 1740 | } |
| 1741 | |
Selim Cinek | 2b54242 | 2016-03-04 18:10:37 -0800 | [diff] [blame] | 1742 | private void removeNotificationChildren() { |
| 1743 | // First let's remove all children which don't belong in the parents |
| 1744 | ArrayList<ExpandableNotificationRow> toRemove = new ArrayList<>(); |
| 1745 | for (int i = 0; i < mStackScroller.getChildCount(); i++) { |
| 1746 | View view = mStackScroller.getChildAt(i); |
| 1747 | if (!(view instanceof ExpandableNotificationRow)) { |
| 1748 | // We don't care about non-notification views. |
| 1749 | continue; |
| 1750 | } |
| 1751 | |
| 1752 | ExpandableNotificationRow parent = (ExpandableNotificationRow) view; |
| 1753 | List<ExpandableNotificationRow> children = parent.getNotificationChildren(); |
| 1754 | List<ExpandableNotificationRow> orderedChildren = mTmpChildOrderMap.get(parent); |
| 1755 | |
| 1756 | if (children != null) { |
| 1757 | toRemove.clear(); |
| 1758 | for (ExpandableNotificationRow childRow : children) { |
Selim Cinek | 3f19f60 | 2016-05-02 18:01:56 -0700 | [diff] [blame] | 1759 | if ((orderedChildren == null |
| 1760 | || !orderedChildren.contains(childRow)) |
| 1761 | && !childRow.keepInParent()) { |
Selim Cinek | 2b54242 | 2016-03-04 18:10:37 -0800 | [diff] [blame] | 1762 | toRemove.add(childRow); |
| 1763 | } |
| 1764 | } |
| 1765 | for (ExpandableNotificationRow remove : toRemove) { |
| 1766 | parent.removeChildNotification(remove); |
| 1767 | if (mNotificationData.get(remove.getStatusBarNotification().getKey()) == null) { |
| 1768 | // We only want to add an animation if the view is completely removed |
| 1769 | // otherwise it's just a transfer |
Selim Cinek | d139564 | 2016-04-28 12:22:42 -0700 | [diff] [blame] | 1770 | mStackScroller.notifyGroupChildRemoved(remove, |
| 1771 | parent.getChildrenContainer()); |
Selim Cinek | 2b54242 | 2016-03-04 18:10:37 -0800 | [diff] [blame] | 1772 | } |
| 1773 | } |
| 1774 | } |
| 1775 | } |
| 1776 | } |
| 1777 | |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 1778 | @Override |
| 1779 | public void addQsTile(ComponentName tile) { |
| 1780 | mQSPanel.getHost().addTile(tile); |
| 1781 | } |
| 1782 | |
| 1783 | @Override |
| 1784 | public void remQsTile(ComponentName tile) { |
| 1785 | mQSPanel.getHost().removeTile(tile); |
| 1786 | } |
| 1787 | |
| 1788 | @Override |
| 1789 | public void clickTile(ComponentName tile) { |
| 1790 | mQSPanel.clickTile(tile); |
| 1791 | } |
| 1792 | |
Chris Wren | 3ad4e3a | 2014-09-02 17:23:51 -0400 | [diff] [blame] | 1793 | private boolean packageHasVisibilityOverride(String key) { |
Julia Reynolds | 26fa8a5 | 2016-02-24 08:31:22 -0500 | [diff] [blame] | 1794 | return mNotificationData.getVisibilityOverride(key) == Notification.VISIBILITY_PRIVATE; |
Chris Wren | 3ad4e3a | 2014-09-02 17:23:51 -0400 | [diff] [blame] | 1795 | } |
| 1796 | |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1797 | private void updateClearAll() { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1798 | boolean showDismissView = |
| 1799 | mState != StatusBarState.KEYGUARD && |
| 1800 | mNotificationData.hasActiveClearableNotifications(); |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1801 | mStackScroller.updateDismissView(showDismissView); |
| 1802 | } |
| 1803 | |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 1804 | private void updateEmptyShadeView() { |
| 1805 | boolean showEmptyShade = |
| 1806 | mState != StatusBarState.KEYGUARD && |
| 1807 | mNotificationData.getActiveNotifications().size() == 0; |
| 1808 | mNotificationPanel.setShadeEmpty(showEmptyShade); |
| 1809 | } |
| 1810 | |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1811 | private void updateSpeedbump() { |
| 1812 | int speedbumpIndex = -1; |
| 1813 | int currentIndex = 0; |
Selim Cinek | 2a73934 | 2016-03-17 10:28:55 -0700 | [diff] [blame] | 1814 | final int N = mStackScroller.getChildCount(); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1815 | for (int i = 0; i < N; i++) { |
Selim Cinek | 2a73934 | 2016-03-17 10:28:55 -0700 | [diff] [blame] | 1816 | View view = mStackScroller.getChildAt(i); |
| 1817 | if (view.getVisibility() == View.GONE || !(view instanceof ExpandableNotificationRow)) { |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1818 | continue; |
| 1819 | } |
Selim Cinek | 2a73934 | 2016-03-17 10:28:55 -0700 | [diff] [blame] | 1820 | ExpandableNotificationRow row = (ExpandableNotificationRow) view; |
| 1821 | if (mNotificationData.isAmbient(row.getStatusBarNotification().getKey())) { |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1822 | speedbumpIndex = currentIndex; |
| 1823 | break; |
| 1824 | } |
| 1825 | currentIndex++; |
| 1826 | } |
| 1827 | mStackScroller.updateSpeedBumpIndex(speedbumpIndex); |
| 1828 | } |
| 1829 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1830 | public static boolean isTopLevelChild(Entry entry) { |
| 1831 | return entry.row.getParent() instanceof NotificationStackScrollLayout; |
| 1832 | } |
| 1833 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1834 | @Override |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1835 | protected void updateNotifications() { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1836 | mNotificationData.filterAndSort(); |
| 1837 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1838 | updateNotificationShade(); |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 1839 | mIconController.updateNotificationIcons(mNotificationData); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1840 | } |
| 1841 | |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1842 | public void requestNotificationUpdate() { |
| 1843 | updateNotifications(); |
| 1844 | } |
| 1845 | |
Jorim Jaggi | 5404542 | 2014-07-03 18:30:40 +0200 | [diff] [blame] | 1846 | @Override |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1847 | protected void setAreThereNotifications() { |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 1848 | |
Chris Wren | 6d15a36 | 2013-08-20 18:46:29 -0400 | [diff] [blame] | 1849 | if (SPEW) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1850 | final boolean clearable = hasActiveNotifications() && |
| 1851 | mNotificationData.hasActiveClearableNotifications(); |
| 1852 | Log.d(TAG, "setAreThereNotifications: N=" + |
| 1853 | mNotificationData.getActiveNotifications().size() + " any=" + |
| 1854 | hasActiveNotifications() + " clearable=" + clearable); |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 1855 | } |
| 1856 | |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 1857 | final View nlo = mStatusBarView.findViewById(R.id.notification_lights_out); |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1858 | final boolean showDot = hasActiveNotifications() && !areLightsOn(); |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 1859 | if (showDot != (nlo.getAlpha() == 1.0f)) { |
| 1860 | if (showDot) { |
| 1861 | nlo.setAlpha(0f); |
| 1862 | nlo.setVisibility(View.VISIBLE); |
| 1863 | } |
| 1864 | nlo.animate() |
| 1865 | .alpha(showDot?1:0) |
| 1866 | .setDuration(showDot?750:250) |
| 1867 | .setInterpolator(new AccelerateInterpolator(2.0f)) |
| 1868 | .setListener(showDot ? null : new AnimatorListenerAdapter() { |
| 1869 | @Override |
| 1870 | public void onAnimationEnd(Animator _a) { |
| 1871 | nlo.setVisibility(View.GONE); |
| 1872 | } |
| 1873 | }) |
| 1874 | .start(); |
| 1875 | } |
Daniel Sandler | 3d32a24 | 2012-06-05 13:44:14 -0400 | [diff] [blame] | 1876 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1877 | findAndUpdateMediaNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1878 | } |
| 1879 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1880 | public void findAndUpdateMediaNotifications() { |
| 1881 | boolean metaDataChanged = false; |
| 1882 | |
| 1883 | synchronized (mNotificationData) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1884 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
| 1885 | final int N = activeNotifications.size(); |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1886 | |
| 1887 | // Promote the media notification with a controller in 'playing' state, if any. |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1888 | Entry mediaNotification = null; |
| 1889 | MediaController controller = null; |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1890 | for (int i = 0; i < N; i++) { |
| 1891 | final Entry entry = activeNotifications.get(i); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1892 | if (isMediaNotification(entry)) { |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1893 | final MediaSession.Token token = |
| 1894 | entry.notification.getNotification().extras |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1895 | .getParcelable(Notification.EXTRA_MEDIA_SESSION); |
| 1896 | if (token != null) { |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1897 | MediaController aController = new MediaController(mContext, token); |
| 1898 | if (PlaybackState.STATE_PLAYING == |
| 1899 | getMediaControllerPlaybackState(aController)) { |
| 1900 | if (DEBUG_MEDIA) { |
| 1901 | Log.v(TAG, "DEBUG_MEDIA: found mediastyle controller matching " |
| 1902 | + entry.notification.getKey()); |
| 1903 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1904 | mediaNotification = entry; |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1905 | controller = aController; |
| 1906 | break; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1907 | } |
| 1908 | } |
| 1909 | } |
| 1910 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1911 | if (mediaNotification == null) { |
| 1912 | // Still nothing? OK, let's just look for live media sessions and see if they match |
| 1913 | // one of our notifications. This will catch apps that aren't (yet!) using media |
| 1914 | // notifications. |
| 1915 | |
| 1916 | if (mMediaSessionManager != null) { |
| 1917 | final List<MediaController> sessions |
| 1918 | = mMediaSessionManager.getActiveSessionsForUser( |
| 1919 | null, |
| 1920 | UserHandle.USER_ALL); |
| 1921 | |
| 1922 | for (MediaController aController : sessions) { |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1923 | if (PlaybackState.STATE_PLAYING == |
| 1924 | getMediaControllerPlaybackState(aController)) { |
| 1925 | // now to see if we have one like this |
| 1926 | final String pkg = aController.getPackageName(); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1927 | |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1928 | for (int i = 0; i < N; i++) { |
| 1929 | final Entry entry = activeNotifications.get(i); |
| 1930 | if (entry.notification.getPackageName().equals(pkg)) { |
| 1931 | if (DEBUG_MEDIA) { |
| 1932 | Log.v(TAG, "DEBUG_MEDIA: found controller matching " |
| 1933 | + entry.notification.getKey()); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1934 | } |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1935 | controller = aController; |
| 1936 | mediaNotification = entry; |
| 1937 | break; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1938 | } |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1939 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1940 | } |
| 1941 | } |
| 1942 | } |
| 1943 | } |
| 1944 | |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1945 | if (controller != null && !sameSessions(mMediaController, controller)) { |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1946 | // We have a new media session |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1947 | clearCurrentMediaNotification(); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1948 | mMediaController = controller; |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1949 | mMediaController.registerCallback(mMediaListener); |
| 1950 | mMediaMetadata = mMediaController.getMetadata(); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1951 | if (DEBUG_MEDIA) { |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1952 | Log.v(TAG, "DEBUG_MEDIA: insert listener, receive metadata: " |
| 1953 | + mMediaMetadata); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1954 | } |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1955 | |
| 1956 | if (mediaNotification != null) { |
| 1957 | mMediaNotificationKey = mediaNotification.notification.getKey(); |
| 1958 | if (DEBUG_MEDIA) { |
| 1959 | Log.v(TAG, "DEBUG_MEDIA: Found new media notification: key=" |
| 1960 | + mMediaNotificationKey + " controller=" + mMediaController); |
| 1961 | } |
| 1962 | } |
| 1963 | metaDataChanged = true; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1964 | } |
| 1965 | } |
| 1966 | |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1967 | if (metaDataChanged) { |
| 1968 | updateNotifications(); |
| 1969 | } |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 1970 | updateMediaMetaData(metaDataChanged, true); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1971 | } |
| 1972 | |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1973 | private int getMediaControllerPlaybackState(MediaController controller) { |
| 1974 | if (controller != null) { |
| 1975 | final PlaybackState playbackState = controller.getPlaybackState(); |
| 1976 | if (playbackState != null) { |
| 1977 | return playbackState.getState(); |
| 1978 | } |
| 1979 | } |
| 1980 | return PlaybackState.STATE_NONE; |
| 1981 | } |
| 1982 | |
| 1983 | private boolean isPlaybackActive(int state) { |
| 1984 | if (state != PlaybackState.STATE_STOPPED |
| 1985 | && state != PlaybackState.STATE_ERROR |
| 1986 | && state != PlaybackState.STATE_NONE) { |
| 1987 | return true; |
| 1988 | } |
| 1989 | return false; |
| 1990 | } |
| 1991 | |
| 1992 | private void clearCurrentMediaNotification() { |
| 1993 | mMediaNotificationKey = null; |
| 1994 | mMediaMetadata = null; |
| 1995 | if (mMediaController != null) { |
| 1996 | if (DEBUG_MEDIA) { |
| 1997 | Log.v(TAG, "DEBUG_MEDIA: Disconnecting from old controller: " |
| 1998 | + mMediaController.getPackageName()); |
| 1999 | } |
| 2000 | mMediaController.unregisterCallback(mMediaListener); |
| 2001 | } |
| 2002 | mMediaController = null; |
| 2003 | } |
| 2004 | |
Christoph Studer | b5245d8 | 2014-09-19 16:54:36 +0200 | [diff] [blame] | 2005 | private boolean sameSessions(MediaController a, MediaController b) { |
| 2006 | if (a == b) return true; |
| 2007 | if (a == null) return false; |
| 2008 | return a.controlsSameSession(b); |
| 2009 | } |
| 2010 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2011 | /** |
Dan Sandler | 7dea0ee | 2014-07-21 21:07:15 -0400 | [diff] [blame] | 2012 | * Hide the album artwork that is fading out and release its bitmap. |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2013 | */ |
| 2014 | private Runnable mHideBackdropFront = new Runnable() { |
| 2015 | @Override |
| 2016 | public void run() { |
| 2017 | if (DEBUG_MEDIA) { |
| 2018 | Log.v(TAG, "DEBUG_MEDIA: removing fade layer"); |
| 2019 | } |
| 2020 | mBackdropFront.setVisibility(View.INVISIBLE); |
Dan Sandler | 7dea0ee | 2014-07-21 21:07:15 -0400 | [diff] [blame] | 2021 | mBackdropFront.animate().cancel(); |
| 2022 | mBackdropFront.setImageDrawable(null); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2023 | } |
| 2024 | }; |
| 2025 | |
| 2026 | /** |
Adrian Roos | e381c16 | 2016-02-11 15:26:42 -0800 | [diff] [blame] | 2027 | * Refresh or remove lockscreen artwork from media metadata or the lockscreen wallpaper. |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2028 | */ |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 2029 | public void updateMediaMetaData(boolean metaDataChanged, boolean allowEnterAnimation) { |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2030 | if (!SHOW_LOCKSCREEN_MEDIA_ARTWORK) return; |
| 2031 | |
| 2032 | if (mBackdrop == null) return; // called too early |
| 2033 | |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 2034 | if (mLaunchTransitionFadingAway) { |
| 2035 | mBackdrop.setVisibility(View.INVISIBLE); |
| 2036 | return; |
| 2037 | } |
| 2038 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2039 | if (DEBUG_MEDIA) { |
| 2040 | Log.v(TAG, "DEBUG_MEDIA: updating album art for notification " + mMediaNotificationKey |
Selim Cinek | 131c1e2 | 2015-05-11 19:04:49 -0700 | [diff] [blame] | 2041 | + " metadata=" + mMediaMetadata |
| 2042 | + " metaDataChanged=" + metaDataChanged |
| 2043 | + " state=" + mState); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2044 | } |
| 2045 | |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 2046 | Drawable artworkDrawable = null; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2047 | if (mMediaMetadata != null) { |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 2048 | Bitmap artworkBitmap = null; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2049 | artworkBitmap = mMediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ART); |
| 2050 | if (artworkBitmap == null) { |
| 2051 | artworkBitmap = mMediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART); |
| 2052 | // might still be null |
| 2053 | } |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 2054 | if (artworkBitmap != null) { |
| 2055 | artworkDrawable = new BitmapDrawable(mBackdropBack.getResources(), artworkBitmap); |
| 2056 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2057 | } |
Adrian Roos | a3760a4 | 2016-04-25 16:21:06 -0700 | [diff] [blame] | 2058 | boolean allowWhenShade = false; |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 2059 | if (ENABLE_LOCKSCREEN_WALLPAPER && artworkDrawable == null) { |
| 2060 | Bitmap lockWallpaper = mLockscreenWallpaper.getBitmap(); |
| 2061 | if (lockWallpaper != null) { |
| 2062 | artworkDrawable = new LockscreenWallpaper.WallpaperDrawable( |
| 2063 | mBackdropBack.getResources(), lockWallpaper); |
Adrian Roos | a3760a4 | 2016-04-25 16:21:06 -0700 | [diff] [blame] | 2064 | // We're in the SHADE mode on the SIM screen - yet we still need to show |
| 2065 | // the lockscreen wallpaper in that mode. |
| 2066 | allowWhenShade = mStatusBarKeyguardViewManager != null |
| 2067 | && mStatusBarKeyguardViewManager.isShowing(); |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 2068 | } |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 2069 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2070 | |
Adrian Roos | a3760a4 | 2016-04-25 16:21:06 -0700 | [diff] [blame] | 2071 | boolean hideBecauseOccluded = mStatusBarKeyguardViewManager != null |
| 2072 | && mStatusBarKeyguardViewManager.isOccluded(); |
| 2073 | |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 2074 | final boolean hasArtwork = artworkDrawable != null; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2075 | |
Adrian Roos | a3760a4 | 2016-04-25 16:21:06 -0700 | [diff] [blame] | 2076 | if ((hasArtwork || DEBUG_MEDIA_FAKE_ARTWORK) |
| 2077 | && (mState != StatusBarState.SHADE || allowWhenShade) |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2078 | && mFingerprintUnlockController.getMode() |
Adrian Roos | a3760a4 | 2016-04-25 16:21:06 -0700 | [diff] [blame] | 2079 | != FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING |
| 2080 | && !hideBecauseOccluded) { |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2081 | // time to show some art! |
| 2082 | if (mBackdrop.getVisibility() != View.VISIBLE) { |
| 2083 | mBackdrop.setVisibility(View.VISIBLE); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 2084 | if (allowEnterAnimation) { |
Adrian Roos | d5c2db6 | 2016-03-08 16:11:31 -0800 | [diff] [blame] | 2085 | mBackdrop.animate().alpha(1f).withEndAction(new Runnable() { |
| 2086 | @Override |
| 2087 | public void run() { |
| 2088 | mStatusBarWindowManager.setBackdropShowing(true); |
| 2089 | } |
| 2090 | }); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 2091 | } else { |
| 2092 | mBackdrop.animate().cancel(); |
| 2093 | mBackdrop.setAlpha(1f); |
Adrian Roos | d5c2db6 | 2016-03-08 16:11:31 -0800 | [diff] [blame] | 2094 | mStatusBarWindowManager.setBackdropShowing(true); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 2095 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2096 | metaDataChanged = true; |
| 2097 | if (DEBUG_MEDIA) { |
| 2098 | Log.v(TAG, "DEBUG_MEDIA: Fading in album artwork"); |
| 2099 | } |
| 2100 | } |
| 2101 | if (metaDataChanged) { |
| 2102 | if (mBackdropBack.getDrawable() != null) { |
Julia Reynolds | 4b9658a | 2015-07-22 17:07:42 -0400 | [diff] [blame] | 2103 | Drawable drawable = |
Adrian Roos | 751f33f | 2016-04-19 16:41:18 -0700 | [diff] [blame] | 2104 | mBackdropBack.getDrawable().getConstantState() |
| 2105 | .newDrawable(mBackdropFront.getResources()).mutate(); |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 2106 | mBackdropFront.setImageDrawable(drawable); |
Jorim Jaggi | 0e66439 | 2014-09-27 01:30:22 +0200 | [diff] [blame] | 2107 | if (mScrimSrcModeEnabled) { |
| 2108 | mBackdropFront.getDrawable().mutate().setXfermode(mSrcOverXferMode); |
| 2109 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2110 | mBackdropFront.setAlpha(1f); |
| 2111 | mBackdropFront.setVisibility(View.VISIBLE); |
| 2112 | } else { |
| 2113 | mBackdropFront.setVisibility(View.INVISIBLE); |
| 2114 | } |
| 2115 | |
| 2116 | if (DEBUG_MEDIA_FAKE_ARTWORK) { |
| 2117 | final int c = 0xFF000000 | (int)(Math.random() * 0xFFFFFF); |
| 2118 | Log.v(TAG, String.format("DEBUG_MEDIA: setting new color: 0x%08x", c)); |
| 2119 | mBackdropBack.setBackgroundColor(0xFFFFFFFF); |
| 2120 | mBackdropBack.setImageDrawable(new ColorDrawable(c)); |
| 2121 | } else { |
Adrian Roos | 3b777cb | 2016-04-14 12:04:28 -0700 | [diff] [blame] | 2122 | mBackdropBack.setImageDrawable(artworkDrawable); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2123 | } |
Jorim Jaggi | 0e66439 | 2014-09-27 01:30:22 +0200 | [diff] [blame] | 2124 | if (mScrimSrcModeEnabled) { |
| 2125 | mBackdropBack.getDrawable().mutate().setXfermode(mSrcXferMode); |
| 2126 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2127 | |
| 2128 | if (mBackdropFront.getVisibility() == View.VISIBLE) { |
| 2129 | if (DEBUG_MEDIA) { |
| 2130 | Log.v(TAG, "DEBUG_MEDIA: Crossfading album artwork from " |
| 2131 | + mBackdropFront.getDrawable() |
| 2132 | + " to " |
| 2133 | + mBackdropBack.getDrawable()); |
| 2134 | } |
Jorim Jaggi | 4e0880e | 2014-07-25 14:51:50 +0200 | [diff] [blame] | 2135 | mBackdropFront.animate() |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2136 | .setDuration(250) |
| 2137 | .alpha(0f).withEndAction(mHideBackdropFront); |
| 2138 | } |
| 2139 | } |
| 2140 | } else { |
| 2141 | // need to hide the album art, either because we are unlocked or because |
| 2142 | // the metadata isn't there to support it |
| 2143 | if (mBackdrop.getVisibility() != View.GONE) { |
| 2144 | if (DEBUG_MEDIA) { |
| 2145 | Log.v(TAG, "DEBUG_MEDIA: Fading out album artwork"); |
| 2146 | } |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2147 | if (mFingerprintUnlockController.getMode() |
Adrian Roos | a3760a4 | 2016-04-25 16:21:06 -0700 | [diff] [blame] | 2148 | == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING |
| 2149 | || hideBecauseOccluded) { |
Jorim Jaggi | 4e0880e | 2014-07-25 14:51:50 +0200 | [diff] [blame] | 2150 | |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2151 | // We are unlocking directly - no animation! |
| 2152 | mBackdrop.setVisibility(View.GONE); |
Vadim Tryshev | e7d7d57 | 2016-03-09 16:44:30 -0800 | [diff] [blame] | 2153 | mBackdropBack.setImageDrawable(null); |
Adrian Roos | d5c2db6 | 2016-03-08 16:11:31 -0800 | [diff] [blame] | 2154 | mStatusBarWindowManager.setBackdropShowing(false); |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2155 | } else { |
Adrian Roos | d5c2db6 | 2016-03-08 16:11:31 -0800 | [diff] [blame] | 2156 | mStatusBarWindowManager.setBackdropShowing(false); |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2157 | mBackdrop.animate() |
| 2158 | // Never let the alpha become zero - otherwise the RenderNode |
| 2159 | // won't draw anything and uninitialized memory will show through |
| 2160 | // if mScrimSrcModeEnabled. Note that 0.001 is rounded down to 0 in |
| 2161 | // libhwui. |
| 2162 | .alpha(0.002f) |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 2163 | .setInterpolator(Interpolators.ACCELERATE_DECELERATE) |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2164 | .setDuration(300) |
| 2165 | .setStartDelay(0) |
| 2166 | .withEndAction(new Runnable() { |
| 2167 | @Override |
| 2168 | public void run() { |
| 2169 | mBackdrop.setVisibility(View.GONE); |
| 2170 | mBackdropFront.animate().cancel(); |
Vadim Tryshev | e7d7d57 | 2016-03-09 16:44:30 -0800 | [diff] [blame] | 2171 | mBackdropBack.setImageDrawable(null); |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2172 | mHandler.post(mHideBackdropFront); |
| 2173 | } |
| 2174 | }); |
| 2175 | if (mKeyguardFadingAway) { |
| 2176 | mBackdrop.animate() |
| 2177 | |
| 2178 | // Make it disappear faster, as the focus should be on the activity |
| 2179 | // behind. |
| 2180 | .setDuration(mKeyguardFadingAwayDuration / 2) |
| 2181 | .setStartDelay(mKeyguardFadingAwayDelay) |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 2182 | .setInterpolator(Interpolators.LINEAR) |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 2183 | .start(); |
| 2184 | } |
Jorim Jaggi | 4e0880e | 2014-07-25 14:51:50 +0200 | [diff] [blame] | 2185 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2186 | } |
| 2187 | } |
| 2188 | } |
| 2189 | |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 2190 | protected int adjustDisableFlags(int state) { |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 2191 | if (!mLaunchTransitionFadingAway && !mKeyguardFadingAway |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 2192 | && (mExpandedVisible || mBouncerShowing || mWaitingForKeyguardExit)) { |
Jorim Jaggi | b13d36d | 2014-06-06 18:03:52 +0200 | [diff] [blame] | 2193 | state |= StatusBarManager.DISABLE_NOTIFICATION_ICONS; |
| 2194 | state |= StatusBarManager.DISABLE_SYSTEM_INFO; |
| 2195 | } |
| 2196 | return state; |
| 2197 | } |
| 2198 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2199 | /** |
| 2200 | * State is one or more of the DISABLE constants from StatusBarManager. |
| 2201 | */ |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2202 | public void disable(int state1, int state2, boolean animate) { |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2203 | animate &= mStatusBarWindowState != WINDOW_STATE_HIDDEN; |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2204 | mDisabledUnmodified1 = state1; |
| 2205 | mDisabledUnmodified2 = state2; |
| 2206 | state1 = adjustDisableFlags(state1); |
| 2207 | final int old1 = mDisabled1; |
| 2208 | final int diff1 = state1 ^ old1; |
| 2209 | mDisabled1 = state1; |
| 2210 | |
| 2211 | final int old2 = mDisabled2; |
| 2212 | final int diff2 = state2 ^ old2; |
| 2213 | mDisabled2 = state2; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2214 | |
Daniel Sandler | e21f288 | 2011-08-18 10:14:59 -0400 | [diff] [blame] | 2215 | if (DEBUG) { |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2216 | Log.d(TAG, String.format("disable1: 0x%08x -> 0x%08x (diff1: 0x%08x)", |
| 2217 | old1, state1, diff1)); |
| 2218 | Log.d(TAG, String.format("disable2: 0x%08x -> 0x%08x (diff2: 0x%08x)", |
| 2219 | old2, state2, diff2)); |
Daniel Sandler | e21f288 | 2011-08-18 10:14:59 -0400 | [diff] [blame] | 2220 | } |
| 2221 | |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2222 | StringBuilder flagdbg = new StringBuilder(); |
| 2223 | flagdbg.append("disable: < "); |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2224 | flagdbg.append(((state1 & StatusBarManager.DISABLE_EXPAND) != 0) ? "EXPAND" : "expand"); |
| 2225 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_EXPAND) != 0) ? "* " : " "); |
| 2226 | flagdbg.append(((state1 & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) ? "ICONS" : "icons"); |
| 2227 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) ? "* " : " "); |
| 2228 | flagdbg.append(((state1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) ? "ALERTS" : "alerts"); |
| 2229 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) ? "* " : " "); |
| 2230 | flagdbg.append(((state1 & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) ? "SYSTEM_INFO" : "system_info"); |
| 2231 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) ? "* " : " "); |
| 2232 | flagdbg.append(((state1 & StatusBarManager.DISABLE_BACK) != 0) ? "BACK" : "back"); |
| 2233 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_BACK) != 0) ? "* " : " "); |
| 2234 | flagdbg.append(((state1 & StatusBarManager.DISABLE_HOME) != 0) ? "HOME" : "home"); |
| 2235 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_HOME) != 0) ? "* " : " "); |
| 2236 | flagdbg.append(((state1 & StatusBarManager.DISABLE_RECENT) != 0) ? "RECENT" : "recent"); |
| 2237 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_RECENT) != 0) ? "* " : " "); |
| 2238 | flagdbg.append(((state1 & StatusBarManager.DISABLE_CLOCK) != 0) ? "CLOCK" : "clock"); |
| 2239 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_CLOCK) != 0) ? "* " : " "); |
| 2240 | flagdbg.append(((state1 & StatusBarManager.DISABLE_SEARCH) != 0) ? "SEARCH" : "search"); |
| 2241 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_SEARCH) != 0) ? "* " : " "); |
Benjamin Franz | 27cf146 | 2015-04-23 19:36:42 +0100 | [diff] [blame] | 2242 | flagdbg.append(((state2 & StatusBarManager.DISABLE2_QUICK_SETTINGS) != 0) ? "QUICK_SETTINGS" |
| 2243 | : "quick_settings"); |
| 2244 | flagdbg.append(((diff2 & StatusBarManager.DISABLE2_QUICK_SETTINGS) != 0) ? "* " : " "); |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2245 | flagdbg.append(">"); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2246 | Log.d(TAG, flagdbg.toString()); |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 2247 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2248 | if ((diff1 & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) { |
| 2249 | if ((state1 & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) { |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 2250 | mIconController.hideSystemIconArea(animate); |
Daniel Sandler | 8e18dc7 | 2012-05-17 00:44:59 -0400 | [diff] [blame] | 2251 | } else { |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 2252 | mIconController.showSystemIconArea(animate); |
Daniel Sandler | 8e18dc7 | 2012-05-17 00:44:59 -0400 | [diff] [blame] | 2253 | } |
| 2254 | } |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2255 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2256 | if ((diff1 & StatusBarManager.DISABLE_CLOCK) != 0) { |
| 2257 | boolean visible = (state1 & StatusBarManager.DISABLE_CLOCK) == 0; |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 2258 | mIconController.setClockVisibility(visible); |
Jeff Sharkey | f52c70b | 2011-08-30 22:05:47 -0700 | [diff] [blame] | 2259 | } |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2260 | if ((diff1 & StatusBarManager.DISABLE_EXPAND) != 0) { |
| 2261 | if ((state1 & StatusBarManager.DISABLE_EXPAND) != 0) { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2262 | animateCollapsePanels(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2263 | } |
| 2264 | } |
Daniel Sandler | e21f288 | 2011-08-18 10:14:59 -0400 | [diff] [blame] | 2265 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2266 | if ((diff1 & (StatusBarManager.DISABLE_HOME |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 2267 | | StatusBarManager.DISABLE_RECENT |
Daniel Sandler | d5483c3 | 2012-10-19 16:44:15 -0400 | [diff] [blame] | 2268 | | StatusBarManager.DISABLE_BACK |
| 2269 | | StatusBarManager.DISABLE_SEARCH)) != 0) { |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame] | 2270 | // the nav bar will take care of these |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2271 | if (mNavigationBarView != null) mNavigationBarView.setDisabledFlags(state1); |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2272 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2273 | if ((state1 & StatusBarManager.DISABLE_RECENT) != 0) { |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2274 | // close recents if it's visible |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2275 | mHandler.removeMessages(MSG_HIDE_RECENT_APPS); |
| 2276 | mHandler.sendEmptyMessage(MSG_HIDE_RECENT_APPS); |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2277 | } |
Daniel Sandler | e21f288 | 2011-08-18 10:14:59 -0400 | [diff] [blame] | 2278 | } |
| 2279 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2280 | if ((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { |
| 2281 | if ((state1 & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 2282 | mIconController.hideNotificationIconArea(animate); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2283 | } else { |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 2284 | mIconController.showNotificationIconArea(animate); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2285 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2286 | } |
Jason Monk | f701954 | 2014-07-31 12:42:25 -0400 | [diff] [blame] | 2287 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2288 | if ((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) { |
Jason Monk | f701954 | 2014-07-31 12:42:25 -0400 | [diff] [blame] | 2289 | mDisableNotificationAlerts = |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2290 | (state1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0; |
Jason Monk | f701954 | 2014-07-31 12:42:25 -0400 | [diff] [blame] | 2291 | mHeadsUpObserver.onChange(true); |
| 2292 | } |
Benjamin Franz | 27cf146 | 2015-04-23 19:36:42 +0100 | [diff] [blame] | 2293 | |
| 2294 | if ((diff2 & StatusBarManager.DISABLE2_QUICK_SETTINGS) != 0) { |
| 2295 | updateQsExpansionEnabled(); |
| 2296 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2297 | } |
| 2298 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2299 | @Override |
Michael Jurka | ecc395a | 2012-03-30 05:31:46 -0700 | [diff] [blame] | 2300 | protected BaseStatusBar.H createHandler() { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2301 | return new PhoneStatusBar.H(); |
| 2302 | } |
| 2303 | |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 2304 | @Override |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 2305 | public void startActivity(Intent intent, boolean dismissShade) { |
| 2306 | startActivityDismissingKeyguard(intent, false, dismissShade); |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 2307 | } |
| 2308 | |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 2309 | @Override |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 2310 | public void startActivity(Intent intent, boolean dismissShade, Callback callback) { |
| 2311 | startActivityDismissingKeyguard(intent, false, dismissShade, callback); |
| 2312 | } |
| 2313 | |
| 2314 | @Override |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 2315 | public void preventNextAnimation() { |
| 2316 | overrideActivityPendingAppTransition(true /* keyguardShowing */); |
| 2317 | } |
| 2318 | |
Jorim Jaggi | b690f0d | 2014-07-03 23:25:44 +0200 | [diff] [blame] | 2319 | public void setQsExpanded(boolean expanded) { |
| 2320 | mStatusBarWindowManager.setQsExpanded(expanded); |
Adrian Roos | 4c7d960 | 2015-06-10 13:44:48 -0700 | [diff] [blame] | 2321 | mKeyguardStatusView.setImportantForAccessibility(expanded |
| 2322 | ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS |
| 2323 | : View.IMPORTANT_FOR_ACCESSIBILITY_AUTO); |
Jorim Jaggi | b690f0d | 2014-07-03 23:25:44 +0200 | [diff] [blame] | 2324 | } |
| 2325 | |
Jorim Jaggi | 84a3e7a | 2014-08-13 17:58:58 +0200 | [diff] [blame] | 2326 | public boolean isGoingToNotificationShade() { |
| 2327 | return mLeaveOpenOnKeyguardHide; |
| 2328 | } |
| 2329 | |
Jorim Jaggi | d692dd0 | 2014-08-14 20:57:42 +0200 | [diff] [blame] | 2330 | public boolean isQsExpanded() { |
| 2331 | return mNotificationPanel.isQsExpanded(); |
| 2332 | } |
| 2333 | |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 2334 | public boolean isWakeUpComingFromTouch() { |
| 2335 | return mWakeUpComingFromTouch; |
Selim Cinek | 29ed3c9 | 2014-09-23 20:44:35 +0200 | [diff] [blame] | 2336 | } |
| 2337 | |
Selim Cinek | 19c8c70 | 2014-08-25 22:09:19 +0200 | [diff] [blame] | 2338 | public boolean isFalsingThresholdNeeded() { |
Selim Cinek | 9db7105 | 2015-04-24 18:54:30 -0700 | [diff] [blame] | 2339 | return getBarState() == StatusBarState.KEYGUARD; |
Selim Cinek | 19c8c70 | 2014-08-25 22:09:19 +0200 | [diff] [blame] | 2340 | } |
| 2341 | |
John Spurlock | 0b99ea9 | 2014-10-01 15:32:22 -0400 | [diff] [blame] | 2342 | public boolean isDozing() { |
| 2343 | return mDozing; |
| 2344 | } |
| 2345 | |
Christoph Studer | 2e731b5 | 2014-08-22 16:01:51 +0200 | [diff] [blame] | 2346 | @Override // NotificationData.Environment |
| 2347 | public String getCurrentMediaNotificationKey() { |
| 2348 | return mMediaNotificationKey; |
| 2349 | } |
| 2350 | |
Jorim Jaggi | 0e66439 | 2014-09-27 01:30:22 +0200 | [diff] [blame] | 2351 | public boolean isScrimSrcModeEnabled() { |
| 2352 | return mScrimSrcModeEnabled; |
| 2353 | } |
| 2354 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2355 | /** |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 2356 | * To be called when there's a state change in StatusBarKeyguardViewManager. |
| 2357 | */ |
| 2358 | public void onKeyguardViewManagerStatesUpdated() { |
| 2359 | logStateToEventlog(); |
| 2360 | } |
| 2361 | |
| 2362 | @Override // UnlockMethodCache.OnUnlockMethodChangedListener |
| 2363 | public void onUnlockMethodStateChanged() { |
| 2364 | logStateToEventlog(); |
| 2365 | } |
| 2366 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2367 | @Override |
John Spurlock | b349af57 | 2015-04-29 12:24:19 -0400 | [diff] [blame] | 2368 | public void onHeadsUpPinnedModeChanged(boolean inPinnedMode) { |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2369 | if (inPinnedMode) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2370 | mStatusBarWindowManager.setHeadsUpShowing(true); |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2371 | mStatusBarWindowManager.setForceStatusBarVisible(true); |
Selim Cinek | 131c1e2 | 2015-05-11 19:04:49 -0700 | [diff] [blame] | 2372 | if (mNotificationPanel.isFullyCollapsed()) { |
| 2373 | // We need to ensure that the touchable region is updated before the window will be |
| 2374 | // resized, in order to not catch any touches. A layout will ensure that |
| 2375 | // onComputeInternalInsets will be called and after that we can resize the layout. Let's |
| 2376 | // make sure that the window stays small for one frame until the touchableRegion is set. |
| 2377 | mNotificationPanel.requestLayout(); |
| 2378 | mStatusBarWindowManager.setForceWindowCollapsed(true); |
| 2379 | mNotificationPanel.post(new Runnable() { |
| 2380 | @Override |
| 2381 | public void run() { |
| 2382 | mStatusBarWindowManager.setForceWindowCollapsed(false); |
| 2383 | } |
| 2384 | }); |
| 2385 | } |
Selim Cinek | 737bff3 | 2015-05-08 16:08:35 -0700 | [diff] [blame] | 2386 | } else { |
Selim Cinek | 131c1e2 | 2015-05-11 19:04:49 -0700 | [diff] [blame] | 2387 | if (!mNotificationPanel.isFullyCollapsed() || mNotificationPanel.isTracking()) { |
| 2388 | // We are currently tracking or is open and the shade doesn't need to be kept |
| 2389 | // open artificially. |
Selim Cinek | 737bff3 | 2015-05-08 16:08:35 -0700 | [diff] [blame] | 2390 | mStatusBarWindowManager.setHeadsUpShowing(false); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2391 | } else { |
Selim Cinek | 131c1e2 | 2015-05-11 19:04:49 -0700 | [diff] [blame] | 2392 | // we need to keep the panel open artificially, let's wait until the animation |
| 2393 | // is finished. |
Selim Cinek | 737bff3 | 2015-05-08 16:08:35 -0700 | [diff] [blame] | 2394 | mHeadsUpManager.setHeadsUpGoingAway(true); |
| 2395 | mStackScroller.runAfterAnimationFinished(new Runnable() { |
| 2396 | @Override |
| 2397 | public void run() { |
| 2398 | if (!mHeadsUpManager.hasPinnedHeadsUp()) { |
| 2399 | mStatusBarWindowManager.setHeadsUpShowing(false); |
| 2400 | mHeadsUpManager.setHeadsUpGoingAway(false); |
| 2401 | } |
| 2402 | } |
| 2403 | }); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2404 | } |
| 2405 | } |
| 2406 | } |
| 2407 | |
| 2408 | @Override |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2409 | public void onHeadsUpPinned(ExpandableNotificationRow headsUp) { |
John Spurlock | b349af57 | 2015-04-29 12:24:19 -0400 | [diff] [blame] | 2410 | dismissVolumeDialog(); |
Selim Cinek | 1f3f544 | 2015-04-10 17:54:46 -0700 | [diff] [blame] | 2411 | } |
| 2412 | |
| 2413 | @Override |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2414 | public void onHeadsUpUnPinned(ExpandableNotificationRow headsUp) { |
| 2415 | } |
| 2416 | |
| 2417 | @Override |
| 2418 | public void onHeadsUpStateChanged(Entry entry, boolean isHeadsUp) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2419 | if (!isHeadsUp && mHeadsUpEntriesToRemoveOnSwitch.contains(entry)) { |
| 2420 | removeNotification(entry.key, mLatestRankingMap); |
| 2421 | mHeadsUpEntriesToRemoveOnSwitch.remove(entry); |
| 2422 | if (mHeadsUpEntriesToRemoveOnSwitch.isEmpty()) { |
| 2423 | mLatestRankingMap = null; |
| 2424 | } |
Selim Cinek | fbe9a44 | 2015-04-13 16:09:49 -0700 | [diff] [blame] | 2425 | } else { |
| 2426 | updateNotificationRanking(null); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2427 | } |
Selim Cinek | fbe9a44 | 2015-04-13 16:09:49 -0700 | [diff] [blame] | 2428 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2429 | } |
| 2430 | |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 2431 | protected void updateHeadsUp(String key, Entry entry, boolean shouldPeek, |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 2432 | boolean alertAgain) { |
| 2433 | final boolean wasHeadsUp = isHeadsUp(key); |
| 2434 | if (wasHeadsUp) { |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 2435 | if (!shouldPeek) { |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 2436 | // We don't want this to be interrupting anymore, lets remove it |
Adrian Roos | c721fcc5 | 2016-04-29 11:28:37 -0700 | [diff] [blame] | 2437 | mHeadsUpManager.removeNotification(key, false /* ignoreEarliestRemovalTime */); |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2438 | } else { |
| 2439 | mHeadsUpManager.updateNotification(entry, alertAgain); |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 2440 | } |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 2441 | } else if (shouldPeek && alertAgain) { |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 2442 | // This notification was updated to be a heads-up, show it! |
| 2443 | mHeadsUpManager.showNotification(entry); |
| 2444 | } |
| 2445 | } |
| 2446 | |
| 2447 | protected void setHeadsUpUser(int newUserId) { |
| 2448 | if (mHeadsUpManager != null) { |
| 2449 | mHeadsUpManager.setUser(newUserId); |
| 2450 | } |
| 2451 | } |
| 2452 | |
| 2453 | public boolean isHeadsUp(String key) { |
| 2454 | return mHeadsUpManager.isHeadsUp(key); |
| 2455 | } |
| 2456 | |
| 2457 | protected boolean isSnoozedPackage(StatusBarNotification sbn) { |
| 2458 | return mHeadsUpManager.isSnoozed(sbn.getPackageName()); |
| 2459 | } |
| 2460 | |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 2461 | public boolean isKeyguardCurrentlySecure() { |
Selim Cinek | e8bae62 | 2015-07-15 13:24:06 -0700 | [diff] [blame] | 2462 | return !mUnlockMethodCache.canSkipBouncer(); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 2463 | } |
| 2464 | |
Selim Cinek | 4a21a7f | 2015-05-19 11:00:38 -0700 | [diff] [blame] | 2465 | public void setPanelExpanded(boolean isExpanded) { |
| 2466 | mStatusBarWindowManager.setPanelExpanded(isExpanded); |
| 2467 | } |
| 2468 | |
Adrian Roos | 401caae | 2016-03-04 13:35:21 -0800 | [diff] [blame] | 2469 | public void onScreenTurnedOff() { |
| 2470 | mFalsingManager.onScreenOff(); |
| 2471 | } |
| 2472 | |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 2473 | /** |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2474 | * All changes to the status bar and notifications funnel through here and are batched. |
| 2475 | */ |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2476 | private class H extends BaseStatusBar.H { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2477 | public void handleMessage(Message m) { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2478 | super.handleMessage(m); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2479 | switch (m.what) { |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2480 | case MSG_OPEN_NOTIFICATION_PANEL: |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2481 | animateExpandNotificationsPanel(); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2482 | break; |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2483 | case MSG_OPEN_SETTINGS_PANEL: |
Jason Monk | a992732 | 2015-12-13 16:22:37 -0500 | [diff] [blame] | 2484 | animateExpandSettingsPanel((String) m.obj); |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2485 | break; |
| 2486 | case MSG_CLOSE_PANELS: |
| 2487 | animateCollapsePanels(); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2488 | break; |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 2489 | case MSG_LAUNCH_TRANSITION_TIMEOUT: |
| 2490 | onLaunchTransitionTimeout(); |
| 2491 | break; |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2492 | } |
| 2493 | } |
| 2494 | } |
| 2495 | |
Chris Wren | 930ecca | 2014-11-12 17:43:41 -0500 | [diff] [blame] | 2496 | @Override |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2497 | public void maybeEscalateHeadsUp() { |
Selim Cinek | 3362c13 | 2016-02-11 15:43:03 -0800 | [diff] [blame] | 2498 | Collection<HeadsUpManager.HeadsUpEntry> entries = mHeadsUpManager.getAllEntries(); |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 2499 | for (HeadsUpManager.HeadsUpEntry entry : entries) { |
| 2500 | final StatusBarNotification sbn = entry.entry.notification; |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2501 | final Notification notification = sbn.getNotification(); |
| 2502 | if (notification.fullScreenIntent != null) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2503 | if (DEBUG) { |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2504 | Log.d(TAG, "converting a heads up to fullScreen"); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2505 | } |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2506 | try { |
Chris Wren | 223c66b6 | 2014-11-10 16:00:09 -0500 | [diff] [blame] | 2507 | EventLog.writeEvent(EventLogTags.SYSUI_HEADS_UP_ESCALATION, |
| 2508 | sbn.getKey()); |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2509 | notification.fullScreenIntent.send(); |
Selim Cinek | b18a20f | 2015-06-04 17:08:35 +0200 | [diff] [blame] | 2510 | entry.entry.notifyFullScreenIntentLaunched(); |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2511 | } catch (PendingIntent.CanceledException e) { |
| 2512 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2513 | } |
| 2514 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2515 | mHeadsUpManager.releaseAllImmediately(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2516 | } |
| 2517 | |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2518 | boolean panelsEnabled() { |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 2519 | return (mDisabled1 & StatusBarManager.DISABLE_EXPAND) == 0 && !ONLY_CORE_APPS; |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2520 | } |
| 2521 | |
Jorim Jaggi | fa505a7 | 2014-04-28 20:04:11 +0200 | [diff] [blame] | 2522 | void makeExpandedVisible(boolean force) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2523 | if (SPEW) Log.d(TAG, "Make expanded visible: expanded visible=" + mExpandedVisible); |
Jorim Jaggi | fa505a7 | 2014-04-28 20:04:11 +0200 | [diff] [blame] | 2524 | if (!force && (mExpandedVisible || !panelsEnabled())) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2525 | return; |
| 2526 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 2527 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2528 | mExpandedVisible = true; |
John Spurlock | d5ef546 | 2012-06-13 11:19:51 -0400 | [diff] [blame] | 2529 | if (mNavigationBarView != null) |
| 2530 | mNavigationBarView.setSlippery(true); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2531 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 2532 | // Expand the window to encompass the full screen in anticipation of the drag. |
| 2533 | // 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] | 2534 | mStatusBarWindowManager.setPanelVisible(true); |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 2535 | |
| 2536 | visibilityChanged(true); |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 2537 | mWaitingForKeyguardExit = false; |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2538 | disable(mDisabledUnmodified1, mDisabledUnmodified2, !force /* animate */); |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 2539 | setInteracting(StatusBarManager.WINDOW_STATUS_BAR, true); |
| 2540 | } |
| 2541 | |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2542 | public void animateCollapsePanels() { |
| 2543 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 2544 | } |
| 2545 | |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 2546 | private final Runnable mAnimateCollapsePanels = new Runnable() { |
| 2547 | @Override |
| 2548 | public void run() { |
| 2549 | animateCollapsePanels(); |
| 2550 | } |
| 2551 | }; |
| 2552 | |
| 2553 | public void postAnimateCollapsePanels() { |
| 2554 | mHandler.post(mAnimateCollapsePanels); |
| 2555 | } |
| 2556 | |
Jason Monk | ba2318e | 2015-12-08 09:04:23 -0500 | [diff] [blame] | 2557 | public void postAnimateOpenPanels() { |
| 2558 | mHandler.sendEmptyMessage(MSG_OPEN_SETTINGS_PANEL); |
| 2559 | } |
| 2560 | |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2561 | public void animateCollapsePanels(int flags) { |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 2562 | animateCollapsePanels(flags, false /* force */, false /* delayed */, |
| 2563 | 1.0f /* speedUpFactor */); |
Jorim Jaggi | 3425076 | 2014-07-03 23:51:19 +0200 | [diff] [blame] | 2564 | } |
| 2565 | |
| 2566 | public void animateCollapsePanels(int flags, boolean force) { |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 2567 | animateCollapsePanels(flags, force, false /* delayed */, 1.0f /* speedUpFactor */); |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 2568 | } |
| 2569 | |
| 2570 | public void animateCollapsePanels(int flags, boolean force, boolean delayed) { |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 2571 | animateCollapsePanels(flags, force, delayed, 1.0f /* speedUpFactor */); |
| 2572 | } |
| 2573 | |
| 2574 | public void animateCollapsePanels(int flags, boolean force, boolean delayed, |
| 2575 | float speedUpFactor) { |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 2576 | if (!force && mState != StatusBarState.SHADE) { |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2577 | runPostCollapseRunnables(); |
Jorim Jaggi | c1cf1ae | 2014-05-02 21:19:17 +0200 | [diff] [blame] | 2578 | return; |
| 2579 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2580 | if (SPEW) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2581 | Log.d(TAG, "animateCollapse():" |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2582 | + " mExpandedVisible=" + mExpandedVisible |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 2583 | + " flags=" + flags); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2584 | } |
| 2585 | |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 2586 | if ((flags & CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL) == 0) { |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame] | 2587 | if (!mHandler.hasMessages(MSG_HIDE_RECENT_APPS)) { |
| 2588 | mHandler.removeMessages(MSG_HIDE_RECENT_APPS); |
| 2589 | mHandler.sendEmptyMessage(MSG_HIDE_RECENT_APPS); |
| 2590 | } |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 2591 | } |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 2592 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 2593 | if (mStatusBarWindow != null) { |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 2594 | // release focus immediately to kick off focus change transition |
| 2595 | mStatusBarWindowManager.setStatusBarFocusable(false); |
| 2596 | |
John Spurlock | ab847cf | 2014-01-15 14:13:59 -0500 | [diff] [blame] | 2597 | mStatusBarWindow.cancelExpandHelper(); |
Xiaohui Chen | 9f96711 | 2016-01-07 14:14:06 -0800 | [diff] [blame] | 2598 | mStatusBarView.collapsePanel(true /* animate */, delayed, speedUpFactor); |
John Spurlock | ab847cf | 2014-01-15 14:13:59 -0500 | [diff] [blame] | 2599 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2600 | } |
| 2601 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2602 | private void runPostCollapseRunnables() { |
Selim Cinek | ae77f8e | 2015-07-07 18:43:59 -0700 | [diff] [blame] | 2603 | ArrayList<Runnable> clonedList = new ArrayList<>(mPostCollapseRunnables); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2604 | mPostCollapseRunnables.clear(); |
Selim Cinek | ae77f8e | 2015-07-07 18:43:59 -0700 | [diff] [blame] | 2605 | int size = clonedList.size(); |
| 2606 | for (int i = 0; i < size; i++) { |
| 2607 | clonedList.get(i).run(); |
| 2608 | } |
| 2609 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2610 | } |
| 2611 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 2612 | @Override |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2613 | public void animateExpandNotificationsPanel() { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2614 | if (SPEW) Log.d(TAG, "animateExpand: mExpandedVisible=" + mExpandedVisible); |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2615 | if (!panelsEnabled()) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2616 | return ; |
| 2617 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2618 | |
Oren Blasberg | 8d3fea1 | 2015-07-10 14:21:44 -0700 | [diff] [blame] | 2619 | mNotificationPanel.expand(true /* animate */); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2620 | |
| 2621 | if (false) postStartTracing(); |
| 2622 | } |
| 2623 | |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 2624 | @Override |
Jason Monk | a992732 | 2015-12-13 16:22:37 -0500 | [diff] [blame] | 2625 | public void animateExpandSettingsPanel(String subPanel) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2626 | if (SPEW) Log.d(TAG, "animateExpand: mExpandedVisible=" + mExpandedVisible); |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2627 | if (!panelsEnabled()) { |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 2628 | return; |
| 2629 | } |
| 2630 | |
Daniel Sandler | a8ef3b0 | 2012-11-29 15:52:39 -0500 | [diff] [blame] | 2631 | // Settings are not available in setup |
| 2632 | if (!mUserSetup) return; |
| 2633 | |
Jason Monk | a992732 | 2015-12-13 16:22:37 -0500 | [diff] [blame] | 2634 | |
| 2635 | if (subPanel != null) { |
| 2636 | mQSPanel.openDetails(subPanel); |
| 2637 | } |
Jason Monk | 3c68ca2 | 2015-01-30 11:30:29 -0500 | [diff] [blame] | 2638 | mNotificationPanel.expandWithQs(); |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 2639 | |
| 2640 | if (false) postStartTracing(); |
| 2641 | } |
| 2642 | |
| 2643 | public void animateCollapseQuickSettings() { |
Jorim Jaggi | 449981b | 2014-10-03 14:24:55 -0700 | [diff] [blame] | 2644 | if (mState == StatusBarState.SHADE) { |
Xiaohui Chen | 9f96711 | 2016-01-07 14:14:06 -0800 | [diff] [blame] | 2645 | mStatusBarView.collapsePanel(true, false /* delayed */, 1.0f /* speedUpFactor */); |
Jorim Jaggi | 449981b | 2014-10-03 14:24:55 -0700 | [diff] [blame] | 2646 | } |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 2647 | } |
| 2648 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 2649 | void makeExpandedInvisible() { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2650 | if (SPEW) Log.d(TAG, "makeExpandedInvisible: mExpandedVisible=" + mExpandedVisible |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2651 | + " mExpandedVisible=" + mExpandedVisible); |
| 2652 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 2653 | if (!mExpandedVisible || mStatusBarWindow == null) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2654 | return; |
| 2655 | } |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 2656 | |
Daniel Sandler | c38bbc3 | 2012-10-05 12:21:38 -0400 | [diff] [blame] | 2657 | // Ensure the panel is fully collapsed (just in case; bug 6765842, 7260868) |
Xiaohui Chen | 9f96711 | 2016-01-07 14:14:06 -0800 | [diff] [blame] | 2658 | mStatusBarView.collapsePanel(/*animate=*/ false, false /* delayed*/, |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 2659 | 1.0f /* speedUpFactor */); |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 2660 | |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 2661 | mNotificationPanel.closeQs(); |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 2662 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2663 | mExpandedVisible = false; |
John Spurlock | d5ef546 | 2012-06-13 11:19:51 -0400 | [diff] [blame] | 2664 | if (mNavigationBarView != null) |
| 2665 | mNavigationBarView.setSlippery(false); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2666 | visibilityChanged(false); |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 2667 | |
| 2668 | // Shrink the window to the size of the status bar only |
Selim Cinek | 4a21a7f | 2015-05-19 11:00:38 -0700 | [diff] [blame] | 2669 | mStatusBarWindowManager.setPanelVisible(false); |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2670 | mStatusBarWindowManager.setForceStatusBarVisible(false); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2671 | |
Daniel Sandler | 469e96e | 2012-05-04 15:56:19 -0400 | [diff] [blame] | 2672 | // Close any "App info" popups that might have snuck on-screen |
| 2673 | dismissPopups(); |
| 2674 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2675 | runPostCollapseRunnables(); |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 2676 | setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 2677 | showBouncer(); |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2678 | disable(mDisabledUnmodified1, mDisabledUnmodified2, true /* animate */); |
Jorim Jaggi | 786afcb | 2014-09-25 02:41:29 +0200 | [diff] [blame] | 2679 | |
| 2680 | // Trimming will happen later if Keyguard is showing - doing it here might cause a jank in |
| 2681 | // the bouncer appear animation. |
| 2682 | if (!mStatusBarKeyguardViewManager.isShowing()) { |
| 2683 | WindowManagerGlobal.getInstance().trimMemory(ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN); |
| 2684 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2685 | } |
| 2686 | |
Daniel Sandler | b17a726 | 2012-10-05 14:32:50 -0400 | [diff] [blame] | 2687 | public boolean interceptTouchEvent(MotionEvent event) { |
Chris Wren | 64161cc | 2012-12-17 16:49:30 -0500 | [diff] [blame] | 2688 | if (DEBUG_GESTURES) { |
| 2689 | if (event.getActionMasked() != MotionEvent.ACTION_MOVE) { |
| 2690 | EventLog.writeEvent(EventLogTags.SYSUI_STATUSBAR_TOUCH, |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2691 | event.getActionMasked(), (int) event.getX(), (int) event.getY(), |
| 2692 | mDisabled1, mDisabled2); |
Chris Wren | 64161cc | 2012-12-17 16:49:30 -0500 | [diff] [blame] | 2693 | } |
| 2694 | |
| 2695 | } |
| 2696 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2697 | if (SPEW) { |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2698 | Log.d(TAG, "Touch: rawY=" + event.getRawY() + " event=" + event + " mDisabled1=" |
| 2699 | + mDisabled1 + " mDisabled2=" + mDisabled2 + " mTracking=" + mTracking); |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 2700 | } else if (CHATTY) { |
Daniel Sandler | fe172cc | 2011-09-12 13:47:25 -0400 | [diff] [blame] | 2701 | if (event.getAction() != MotionEvent.ACTION_MOVE) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2702 | Log.d(TAG, String.format( |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2703 | "panel: %s at (%f, %f) mDisabled1=0x%08x mDisabled2=0x%08x", |
Daniel Sandler | fe172cc | 2011-09-12 13:47:25 -0400 | [diff] [blame] | 2704 | MotionEvent.actionToString(event.getAction()), |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2705 | event.getRawX(), event.getRawY(), mDisabled1, mDisabled2)); |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 2706 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2707 | } |
| 2708 | |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 2709 | if (DEBUG_GESTURES) { |
| 2710 | mGestureRec.add(event); |
| 2711 | } |
Daniel Sandler | 3380534 | 2012-07-23 15:45:12 -0400 | [diff] [blame] | 2712 | |
John Spurlock | 686820a | 2013-09-03 14:44:16 -0400 | [diff] [blame] | 2713 | if (mStatusBarWindowState == WINDOW_STATE_SHOWING) { |
John Spurlock | 5fee836 | 2013-09-12 10:34:33 -0400 | [diff] [blame] | 2714 | final boolean upOrCancel = |
| 2715 | event.getAction() == MotionEvent.ACTION_UP || |
| 2716 | event.getAction() == MotionEvent.ACTION_CANCEL; |
| 2717 | if (upOrCancel && !mExpandedVisible) { |
| 2718 | setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false); |
| 2719 | } else { |
| 2720 | setInteracting(StatusBarManager.WINDOW_STATUS_BAR, true); |
| 2721 | } |
John Spurlock | 686820a | 2013-09-03 14:44:16 -0400 | [diff] [blame] | 2722 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2723 | return false; |
| 2724 | } |
| 2725 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 2726 | public GestureRecorder getGestureRecorder() { |
| 2727 | return mGestureRec; |
Jeff Brown | 911fe30 | 2011-09-12 14:21:17 -0700 | [diff] [blame] | 2728 | } |
| 2729 | |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 2730 | private void setNavigationIconHints(int hints) { |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 2731 | if (hints == mNavigationIconHints) return; |
| 2732 | |
| 2733 | mNavigationIconHints = hints; |
| 2734 | |
| 2735 | if (mNavigationBarView != null) { |
| 2736 | mNavigationBarView.setNavigationIconHints(hints); |
| 2737 | } |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2738 | checkBarModes(); |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 2739 | } |
| 2740 | |
| 2741 | @Override // CommandQueue |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2742 | public void setWindowState(int window, int state) { |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2743 | boolean showing = state == WINDOW_STATE_SHOWING; |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2744 | if (mStatusBarWindow != null |
| 2745 | && window == StatusBarManager.WINDOW_STATUS_BAR |
| 2746 | && mStatusBarWindowState != state) { |
| 2747 | mStatusBarWindowState = state; |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 2748 | if (DEBUG_WINDOW_STATE) Log.d(TAG, "Status bar " + windowStateToString(state)); |
Jorim Jaggi | 449981b | 2014-10-03 14:24:55 -0700 | [diff] [blame] | 2749 | if (!showing && mState == StatusBarState.SHADE) { |
Xiaohui Chen | 9f96711 | 2016-01-07 14:14:06 -0800 | [diff] [blame] | 2750 | mStatusBarView.collapsePanel(false /* animate */, false /* delayed */, |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 2751 | 1.0f /* speedUpFactor */); |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2752 | } |
| 2753 | } |
| 2754 | if (mNavigationBarView != null |
| 2755 | && window == StatusBarManager.WINDOW_NAVIGATION_BAR |
| 2756 | && mNavigationBarWindowState != state) { |
| 2757 | mNavigationBarWindowState = state; |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 2758 | if (DEBUG_WINDOW_STATE) Log.d(TAG, "Navigation bar " + windowStateToString(state)); |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2759 | } |
| 2760 | } |
| 2761 | |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2762 | @Override // CommandQueue |
John Spurlock | cad5768 | 2014-07-26 17:09:56 -0400 | [diff] [blame] | 2763 | public void buzzBeepBlinked() { |
| 2764 | if (mDozeServiceHost != null) { |
| 2765 | mDozeServiceHost.fireBuzzBeepBlinked(); |
| 2766 | } |
| 2767 | } |
| 2768 | |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 2769 | @Override |
| 2770 | public void notificationLightOff() { |
| 2771 | if (mDozeServiceHost != null) { |
| 2772 | mDozeServiceHost.fireNotificationLight(false); |
| 2773 | } |
| 2774 | } |
| 2775 | |
| 2776 | @Override |
| 2777 | public void notificationLightPulse(int argb, int onMillis, int offMillis) { |
| 2778 | if (mDozeServiceHost != null) { |
| 2779 | mDozeServiceHost.fireNotificationLight(true); |
| 2780 | } |
| 2781 | } |
| 2782 | |
John Spurlock | cad5768 | 2014-07-26 17:09:56 -0400 | [diff] [blame] | 2783 | @Override // CommandQueue |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 2784 | public void setSystemUiVisibility(int vis, int fullscreenStackVis, int dockedStackVis, |
| 2785 | int mask, Rect fullscreenStackBounds, Rect dockedStackBounds) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2786 | final int oldVal = mSystemUiVisibility; |
| 2787 | final int newVal = (oldVal&~mask) | (vis&mask); |
| 2788 | final int diff = newVal ^ oldVal; |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2789 | if (DEBUG) Log.d(TAG, String.format( |
John Spurlock | dcf4f21 | 2013-05-21 17:19:53 -0400 | [diff] [blame] | 2790 | "setSystemUiVisibility vis=%s mask=%s oldVal=%s newVal=%s diff=%s", |
| 2791 | Integer.toHexString(vis), Integer.toHexString(mask), |
| 2792 | Integer.toHexString(oldVal), Integer.toHexString(newVal), |
| 2793 | Integer.toHexString(diff))); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 2794 | boolean sbModeChanged = false; |
Daniel Sandler | e137a1e | 2011-08-17 16:47:19 -0400 | [diff] [blame] | 2795 | if (diff != 0) { |
Winson Chung | 9214eff | 2014-06-12 13:59:25 -0700 | [diff] [blame] | 2796 | // we never set the recents bit via this method, so save the prior state to prevent |
| 2797 | // clobbering the bit below |
| 2798 | final boolean wasRecentsVisible = (mSystemUiVisibility & View.RECENT_APPS_VISIBLE) > 0; |
| 2799 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2800 | mSystemUiVisibility = newVal; |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 2801 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2802 | // update low profile |
| 2803 | if ((diff & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) { |
John Spurlock | 7edfbca | 2013-09-14 11:58:55 -0400 | [diff] [blame] | 2804 | setAreThereNotifications(); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 2805 | } |
| 2806 | |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2807 | // ready to unhide |
| 2808 | if ((vis & View.STATUS_BAR_UNHIDE) != 0) { |
| 2809 | mSystemUiVisibility &= ~View.STATUS_BAR_UNHIDE; |
| 2810 | mNoAnimationOnNextBarModeChange = true; |
| 2811 | } |
| 2812 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2813 | // update status bar mode |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2814 | final int sbMode = computeBarMode(oldVal, newVal, mStatusBarView.getBarTransitions(), |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 2815 | View.STATUS_BAR_TRANSIENT, View.STATUS_BAR_TRANSLUCENT, |
| 2816 | View.STATUS_BAR_TRANSPARENT); |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2817 | |
| 2818 | // update navigation bar mode |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2819 | final int nbMode = mNavigationBarView == null ? -1 : computeBarMode( |
John Spurlock | f6b6397 | 2013-08-27 16:08:28 -0400 | [diff] [blame] | 2820 | oldVal, newVal, mNavigationBarView.getBarTransitions(), |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 2821 | View.NAVIGATION_BAR_TRANSIENT, View.NAVIGATION_BAR_TRANSLUCENT, |
| 2822 | View.NAVIGATION_BAR_TRANSPARENT); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 2823 | sbModeChanged = sbMode != -1; |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2824 | final boolean nbModeChanged = nbMode != -1; |
| 2825 | boolean checkBarModes = false; |
| 2826 | if (sbModeChanged && sbMode != mStatusBarMode) { |
| 2827 | mStatusBarMode = sbMode; |
| 2828 | checkBarModes = true; |
| 2829 | } |
| 2830 | if (nbModeChanged && nbMode != mNavigationBarMode) { |
| 2831 | mNavigationBarMode = nbMode; |
| 2832 | checkBarModes = true; |
| 2833 | } |
| 2834 | if (checkBarModes) { |
| 2835 | checkBarModes(); |
| 2836 | } |
| 2837 | if (sbModeChanged || nbModeChanged) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2838 | // update transient bar autohide |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 2839 | if (mStatusBarMode == MODE_SEMI_TRANSPARENT || mNavigationBarMode == MODE_SEMI_TRANSPARENT) { |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 2840 | scheduleAutohide(); |
| 2841 | } else { |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 2842 | cancelAutohide(); |
| 2843 | } |
| 2844 | } |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2845 | |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 2846 | if ((vis & View.NAVIGATION_BAR_UNHIDE) != 0) { |
| 2847 | mSystemUiVisibility &= ~View.NAVIGATION_BAR_UNHIDE; |
| 2848 | } |
| 2849 | |
Winson Chung | 9214eff | 2014-06-12 13:59:25 -0700 | [diff] [blame] | 2850 | // restore the recents bit |
| 2851 | if (wasRecentsVisible) { |
| 2852 | mSystemUiVisibility |= View.RECENT_APPS_VISIBLE; |
| 2853 | } |
| 2854 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2855 | // send updated sysui visibility to window manager |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 2856 | notifyUiVisibilityChanged(mSystemUiVisibility); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 2857 | } |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 2858 | |
| 2859 | mLightStatusBarController.onSystemUiVisibilityChanged(fullscreenStackVis, dockedStackVis, |
| 2860 | mask, fullscreenStackBounds, dockedStackBounds, sbModeChanged, mStatusBarMode); |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 2861 | } |
| 2862 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2863 | private int computeBarMode(int oldVis, int newVis, BarTransitions transitions, |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 2864 | int transientFlag, int translucentFlag, int transparentFlag) { |
| 2865 | final int oldMode = barMode(oldVis, transientFlag, translucentFlag, transparentFlag); |
| 2866 | final int newMode = barMode(newVis, transientFlag, translucentFlag, transparentFlag); |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2867 | if (oldMode == newMode) { |
| 2868 | return -1; // no mode change |
| 2869 | } |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2870 | return newMode; |
| 2871 | } |
| 2872 | |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 2873 | private int barMode(int vis, int transientFlag, int translucentFlag, int transparentFlag) { |
| 2874 | int lightsOutTransparent = View.SYSTEM_UI_FLAG_LOW_PROFILE | transparentFlag; |
John Spurlock | 89835dd | 2013-08-16 15:06:51 -0400 | [diff] [blame] | 2875 | return (vis & transientFlag) != 0 ? MODE_SEMI_TRANSPARENT |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 2876 | : (vis & translucentFlag) != 0 ? MODE_TRANSLUCENT |
Adrian Roos | c0f0a74 | 2014-10-28 16:39:56 +0100 | [diff] [blame] | 2877 | : (vis & lightsOutTransparent) == lightsOutTransparent ? MODE_LIGHTS_OUT_TRANSPARENT |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 2878 | : (vis & transparentFlag) != 0 ? MODE_TRANSPARENT |
John Spurlock | 7edfbca | 2013-09-14 11:58:55 -0400 | [diff] [blame] | 2879 | : (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0 ? MODE_LIGHTS_OUT |
John Spurlock | 3b139a9 | 2013-08-17 17:18:08 -0400 | [diff] [blame] | 2880 | : MODE_OPAQUE; |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2881 | } |
| 2882 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2883 | private void checkBarModes() { |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 2884 | if (mDemoMode) return; |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2885 | checkBarMode(mStatusBarMode, mStatusBarWindowState, mStatusBarView.getBarTransitions(), |
| 2886 | mNoAnimationOnNextBarModeChange); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2887 | if (mNavigationBarView != null) { |
| 2888 | checkBarMode(mNavigationBarMode, |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2889 | mNavigationBarWindowState, mNavigationBarView.getBarTransitions(), |
| 2890 | mNoAnimationOnNextBarModeChange); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2891 | } |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2892 | mNoAnimationOnNextBarModeChange = false; |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2893 | } |
| 2894 | |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2895 | private void checkBarMode(int mode, int windowState, BarTransitions transitions, |
| 2896 | boolean noAnimation) { |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 2897 | final boolean powerSave = mBatteryController.isPowerSave(); |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 2898 | final boolean anim = !noAnimation && mDeviceInteractive |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2899 | && windowState != WINDOW_STATE_HIDDEN && !powerSave; |
John Spurlock | 1bb480a | 2014-08-02 17:12:43 -0400 | [diff] [blame] | 2900 | if (powerSave && getBarState() == StatusBarState.SHADE) { |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 2901 | mode = MODE_WARNING; |
| 2902 | } |
John Spurlock | c68d577 | 2013-10-08 11:47:58 -0400 | [diff] [blame] | 2903 | transitions.transitionTo(mode, anim); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2904 | } |
| 2905 | |
John Spurlock | 4219726 | 2013-10-21 09:32:25 -0400 | [diff] [blame] | 2906 | private void finishBarAnimations() { |
| 2907 | mStatusBarView.getBarTransitions().finishAnimations(); |
| 2908 | if (mNavigationBarView != null) { |
| 2909 | mNavigationBarView.getBarTransitions().finishAnimations(); |
| 2910 | } |
| 2911 | } |
| 2912 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2913 | private final Runnable mCheckBarModes = new Runnable() { |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 2914 | @Override |
| 2915 | public void run() { |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2916 | checkBarModes(); |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 2917 | } |
| 2918 | }; |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 2919 | |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2920 | @Override |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 2921 | public void setInteracting(int barWindow, boolean interacting) { |
John Spurlock | 7fbf573 | 2014-11-18 11:40:22 -0500 | [diff] [blame] | 2922 | final boolean changing = ((mInteractingWindows & barWindow) != 0) != interacting; |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 2923 | mInteractingWindows = interacting |
| 2924 | ? (mInteractingWindows | barWindow) |
| 2925 | : (mInteractingWindows & ~barWindow); |
| 2926 | if (mInteractingWindows != 0) { |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2927 | suspendAutohide(); |
| 2928 | } else { |
| 2929 | resumeSuspendedAutohide(); |
| 2930 | } |
John Spurlock | 7fbf573 | 2014-11-18 11:40:22 -0500 | [diff] [blame] | 2931 | // manually dismiss the volume panel when interacting with the nav bar |
| 2932 | if (changing && interacting && barWindow == StatusBarManager.WINDOW_NAVIGATION_BAR) { |
John Spurlock | b349af57 | 2015-04-29 12:24:19 -0400 | [diff] [blame] | 2933 | dismissVolumeDialog(); |
John Spurlock | 7fbf573 | 2014-11-18 11:40:22 -0500 | [diff] [blame] | 2934 | } |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2935 | checkBarModes(); |
| 2936 | } |
| 2937 | |
John Spurlock | b349af57 | 2015-04-29 12:24:19 -0400 | [diff] [blame] | 2938 | private void dismissVolumeDialog() { |
| 2939 | if (mVolumeComponent != null) { |
| 2940 | mVolumeComponent.dismissNow(); |
| 2941 | } |
| 2942 | } |
| 2943 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2944 | private void resumeSuspendedAutohide() { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2945 | if (mAutohideSuspended) { |
| 2946 | scheduleAutohide(); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2947 | mHandler.postDelayed(mCheckBarModes, 500); // longer than home -> launcher |
John Spurlock | 3b139a9 | 2013-08-17 17:18:08 -0400 | [diff] [blame] | 2948 | } |
| 2949 | } |
| 2950 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2951 | private void suspendAutohide() { |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 2952 | mHandler.removeCallbacks(mAutohide); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2953 | mHandler.removeCallbacks(mCheckBarModes); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 2954 | mAutohideSuspended = (mSystemUiVisibility & STATUS_OR_NAV_TRANSIENT) != 0; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 2955 | } |
| 2956 | |
| 2957 | private void cancelAutohide() { |
| 2958 | mAutohideSuspended = false; |
| 2959 | mHandler.removeCallbacks(mAutohide); |
| 2960 | } |
| 2961 | |
| 2962 | private void scheduleAutohide() { |
| 2963 | cancelAutohide(); |
| 2964 | mHandler.postDelayed(mAutohide, AUTOHIDE_TIMEOUT_MS); |
| 2965 | } |
| 2966 | |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 2967 | private void checkUserAutohide(View v, MotionEvent event) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2968 | if ((mSystemUiVisibility & STATUS_OR_NAV_TRANSIENT) != 0 // a transient bar is revealed |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 2969 | && event.getAction() == MotionEvent.ACTION_OUTSIDE // touch outside the source bar |
| 2970 | && event.getX() == 0 && event.getY() == 0 // a touch outside both bars |
| 2971 | ) { |
| 2972 | userAutohide(); |
| 2973 | } |
| 2974 | } |
| 2975 | |
| 2976 | private void userAutohide() { |
| 2977 | cancelAutohide(); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 2978 | mHandler.postDelayed(mAutohide, 350); // longer than app gesture -> flag clear |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 2979 | } |
| 2980 | |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 2981 | private boolean areLightsOn() { |
| 2982 | return 0 == (mSystemUiVisibility & View.SYSTEM_UI_FLAG_LOW_PROFILE); |
| 2983 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 2984 | |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 2985 | public void setLightsOn(boolean on) { |
| 2986 | Log.v(TAG, "setLightsOn(" + on + ")"); |
| 2987 | if (on) { |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 2988 | setSystemUiVisibility(0, 0, 0, View.SYSTEM_UI_FLAG_LOW_PROFILE, |
| 2989 | mLastFullscreenStackBounds, mLastDockedStackBounds); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 2990 | } else { |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 2991 | setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE, 0, 0, |
| 2992 | View.SYSTEM_UI_FLAG_LOW_PROFILE, mLastFullscreenStackBounds, |
| 2993 | mLastDockedStackBounds); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 2994 | } |
| 2995 | } |
| 2996 | |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 2997 | private void notifyUiVisibilityChanged(int vis) { |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 2998 | try { |
Adrian Roos | 389beec | 2015-05-12 13:33:25 -0700 | [diff] [blame] | 2999 | if (mLastDispatchedSystemUiVisibility != vis) { |
| 3000 | mWindowManagerService.statusBarVisibilityChanged(vis); |
| 3001 | mLastDispatchedSystemUiVisibility = vis; |
| 3002 | } |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 3003 | } catch (RemoteException ex) { |
| 3004 | } |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3005 | } |
| 3006 | |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 3007 | public void topAppWindowChanged(boolean showMenu) { |
Chris Wren | 8a1638f | 2016-05-02 16:19:14 -0400 | [diff] [blame] | 3008 | if (SPEW) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 3009 | Log.d(TAG, (showMenu?"showing":"hiding") + " the MENU button"); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 3010 | } |
| 3011 | if (mNavigationBarView != null) { |
Daniel Sandler | f1ebcee | 2011-09-15 16:02:56 -0400 | [diff] [blame] | 3012 | mNavigationBarView.setMenuVisibility(showMenu); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 3013 | } |
| 3014 | |
| 3015 | // See above re: lights-out policy for legacy apps. |
| 3016 | if (showMenu) setLightsOn(true); |
| 3017 | } |
| 3018 | |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 3019 | @Override |
Jason Monk | b605fec | 2014-05-02 17:04:10 -0400 | [diff] [blame] | 3020 | public void setImeWindowStatus(IBinder token, int vis, int backDisposition, |
| 3021 | boolean showImeSwitcher) { |
Jason Monk | f1ff209 | 2014-04-29 16:50:53 -0400 | [diff] [blame] | 3022 | boolean imeShown = (vis & InputMethodService.IME_VISIBLE) != 0; |
| 3023 | int flags = mNavigationIconHints; |
| 3024 | if ((backDisposition == InputMethodService.BACK_DISPOSITION_WILL_DISMISS) || imeShown) { |
| 3025 | flags |= NAVIGATION_HINT_BACK_ALT; |
| 3026 | } else { |
| 3027 | flags &= ~NAVIGATION_HINT_BACK_ALT; |
| 3028 | } |
Jason Monk | b605fec | 2014-05-02 17:04:10 -0400 | [diff] [blame] | 3029 | if (showImeSwitcher) { |
Jason Monk | f1ff209 | 2014-04-29 16:50:53 -0400 | [diff] [blame] | 3030 | flags |= NAVIGATION_HINT_IME_SHOWN; |
| 3031 | } else { |
| 3032 | flags &= ~NAVIGATION_HINT_IME_SHOWN; |
| 3033 | } |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 3034 | |
Jason Monk | f1ff209 | 2014-04-29 16:50:53 -0400 | [diff] [blame] | 3035 | setNavigationIconHints(flags); |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 3036 | } |
| 3037 | |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 3038 | public static String viewInfo(View v) { |
| 3039 | return "[(" + v.getLeft() + "," + v.getTop() + ")(" + v.getRight() + "," + v.getBottom() |
| 3040 | + ") " + v.getWidth() + "x" + v.getHeight() + "]"; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3041 | } |
| 3042 | |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 3043 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3044 | synchronized (mQueueLock) { |
| 3045 | pw.println("Current Status Bar state:"); |
Daniel Sandler | e7237fc | 2012-08-14 16:08:27 -0400 | [diff] [blame] | 3046 | pw.println(" mExpandedVisible=" + mExpandedVisible |
Daniel Sandler | fdbac77 | 2012-07-03 14:30:10 -0400 | [diff] [blame] | 3047 | + ", mTrackingPosition=" + mTrackingPosition); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3048 | pw.println(" mTracking=" + mTracking); |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 3049 | pw.println(" mDisplayMetrics=" + mDisplayMetrics); |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 3050 | pw.println(" mStackScroller: " + viewInfo(mStackScroller)); |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 3051 | pw.println(" mStackScroller: " + viewInfo(mStackScroller) |
| 3052 | + " scroll " + mStackScroller.getScrollX() |
| 3053 | + "," + mStackScroller.getScrollY()); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3054 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3055 | |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 3056 | pw.print(" mInteractingWindows="); pw.println(mInteractingWindows); |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 3057 | pw.print(" mStatusBarWindowState="); |
| 3058 | pw.println(windowStateToString(mStatusBarWindowState)); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3059 | pw.print(" mStatusBarMode="); |
| 3060 | pw.println(BarTransitions.modeToString(mStatusBarMode)); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 3061 | pw.print(" mDozing="); pw.println(mDozing); |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 3062 | pw.print(" mZenMode="); |
| 3063 | pw.println(Settings.Global.zenModeToString(mZenMode)); |
Chris Wren | 3b6745b | 2014-03-07 14:34:35 -0500 | [diff] [blame] | 3064 | pw.print(" mUseHeadsUp="); |
| 3065 | pw.println(mUseHeadsUp); |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 3066 | dumpBarTransitions(pw, "mStatusBarView", mStatusBarView.getBarTransitions()); |
| 3067 | if (mNavigationBarView != null) { |
| 3068 | pw.print(" mNavigationBarWindowState="); |
| 3069 | pw.println(windowStateToString(mNavigationBarWindowState)); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 3070 | pw.print(" mNavigationBarMode="); |
| 3071 | pw.println(BarTransitions.modeToString(mNavigationBarMode)); |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 3072 | dumpBarTransitions(pw, "mNavigationBarView", mNavigationBarView.getBarTransitions()); |
| 3073 | } |
| 3074 | |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 3075 | pw.print(" mNavigationBarView="); |
| 3076 | if (mNavigationBarView == null) { |
| 3077 | pw.println("null"); |
| 3078 | } else { |
| 3079 | mNavigationBarView.dump(fd, pw, args); |
| 3080 | } |
| 3081 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 3082 | pw.print(" mMediaSessionManager="); |
| 3083 | pw.println(mMediaSessionManager); |
| 3084 | pw.print(" mMediaNotificationKey="); |
| 3085 | pw.println(mMediaNotificationKey); |
| 3086 | pw.print(" mMediaController="); |
| 3087 | pw.print(mMediaController); |
| 3088 | if (mMediaController != null) { |
| 3089 | pw.print(" state=" + mMediaController.getPlaybackState()); |
| 3090 | } |
| 3091 | pw.println(); |
| 3092 | pw.print(" mMediaMetadata="); |
| 3093 | pw.print(mMediaMetadata); |
| 3094 | if (mMediaMetadata != null) { |
RoboErik | 75847b9 | 2014-07-29 13:10:17 -0700 | [diff] [blame] | 3095 | pw.print(" title=" + mMediaMetadata.getText(MediaMetadata.METADATA_KEY_TITLE)); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 3096 | } |
| 3097 | pw.println(); |
| 3098 | |
Daniel Sandler | 37a38aa | 2013-02-13 17:15:57 -0500 | [diff] [blame] | 3099 | pw.println(" Panels: "); |
| 3100 | if (mNotificationPanel != null) { |
| 3101 | pw.println(" mNotificationPanel=" + |
| 3102 | mNotificationPanel + " params=" + mNotificationPanel.getLayoutParams().debug("")); |
| 3103 | pw.print (" "); |
| 3104 | mNotificationPanel.dump(fd, pw, args); |
| 3105 | } |
Daniel Sandler | 37a38aa | 2013-02-13 17:15:57 -0500 | [diff] [blame] | 3106 | |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 3107 | DozeLog.dump(pw); |
| 3108 | |
Daniel Sandler | 7579bca | 2011-08-18 15:47:26 -0400 | [diff] [blame] | 3109 | if (DUMPTRUCK) { |
| 3110 | synchronized (mNotificationData) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 3111 | mNotificationData.dump(pw, " "); |
Daniel Sandler | 7579bca | 2011-08-18 15:47:26 -0400 | [diff] [blame] | 3112 | } |
| 3113 | |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 3114 | mIconController.dump(pw); |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 3115 | |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 3116 | if (false) { |
| 3117 | pw.println("see the logcat for a dump of the views we have created."); |
| 3118 | // must happen on ui thread |
| 3119 | mHandler.post(new Runnable() { |
| 3120 | public void run() { |
| 3121 | mStatusBarView.getLocationOnScreen(mAbsPos); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 3122 | Log.d(TAG, "mStatusBarView: ----- (" + mAbsPos[0] + "," + mAbsPos[1] |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 3123 | + ") " + mStatusBarView.getWidth() + "x" |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 3124 | + getStatusBarHeight()); |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 3125 | mStatusBarView.debug(); |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 3126 | } |
| 3127 | }); |
| 3128 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3129 | } |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 3130 | |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 3131 | if (DEBUG_GESTURES) { |
| 3132 | pw.print(" status bar gestures: "); |
| 3133 | mGestureRec.dump(fd, pw, args); |
| 3134 | } |
Selim Cinek | 7025f26 | 2015-07-13 16:22:48 -0700 | [diff] [blame] | 3135 | if (mStatusBarWindowManager != null) { |
| 3136 | mStatusBarWindowManager.dump(fd, pw, args); |
| 3137 | } |
John Spurlock | 486b78e | 2014-07-07 08:37:56 -0400 | [diff] [blame] | 3138 | if (mNetworkController != null) { |
| 3139 | mNetworkController.dump(fd, pw, args); |
| 3140 | } |
| 3141 | if (mBluetoothController != null) { |
| 3142 | mBluetoothController.dump(fd, pw, args); |
| 3143 | } |
Jason Monk | dd5bdc6 | 2015-07-20 12:18:38 -0400 | [diff] [blame] | 3144 | if (mHotspotController != null) { |
| 3145 | mHotspotController.dump(fd, pw, args); |
| 3146 | } |
John Spurlock | 1e6eb17 | 2014-07-13 11:59:50 -0400 | [diff] [blame] | 3147 | if (mCastController != null) { |
| 3148 | mCastController.dump(fd, pw, args); |
| 3149 | } |
Adrian Roos | 00a0b1f | 2014-07-16 16:44:49 +0200 | [diff] [blame] | 3150 | if (mUserSwitcherController != null) { |
| 3151 | mUserSwitcherController.dump(fd, pw, args); |
| 3152 | } |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 3153 | if (mBatteryController != null) { |
| 3154 | mBatteryController.dump(fd, pw, args); |
| 3155 | } |
Jorim Jaggi | c7dea6e | 2014-07-26 14:36:57 +0200 | [diff] [blame] | 3156 | if (mNextAlarmController != null) { |
| 3157 | mNextAlarmController.dump(fd, pw, args); |
| 3158 | } |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 3159 | if (mSecurityController != null) { |
| 3160 | mSecurityController.dump(fd, pw, args); |
| 3161 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 3162 | if (mHeadsUpManager != null) { |
| 3163 | mHeadsUpManager.dump(fd, pw, args); |
Chris Wren | 428c6b6 | 2014-12-05 16:07:06 -0500 | [diff] [blame] | 3164 | } else { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 3165 | pw.println(" mHeadsUpManager: null"); |
Chris Wren | 428c6b6 | 2014-12-05 16:07:06 -0500 | [diff] [blame] | 3166 | } |
Selim Cinek | 52941c5 | 2016-05-07 18:29:32 -0400 | [diff] [blame] | 3167 | if (mGroupManager != null) { |
| 3168 | mGroupManager.dump(fd, pw, args); |
| 3169 | } else { |
| 3170 | pw.println(" mGroupManager: null"); |
| 3171 | } |
Jason Monk | ab52527 | 2015-07-13 17:02:49 -0400 | [diff] [blame] | 3172 | if (KeyguardUpdateMonitor.getInstance(mContext) != null) { |
| 3173 | KeyguardUpdateMonitor.getInstance(mContext).dump(fd, pw, args); |
| 3174 | } |
Chris Wren | 428c6b6 | 2014-12-05 16:07:06 -0500 | [diff] [blame] | 3175 | |
Adrian Roos | 401caae | 2016-03-04 13:35:21 -0800 | [diff] [blame] | 3176 | FalsingManager.getInstance(mContext).dump(pw); |
| 3177 | FalsingLog.dump(pw); |
| 3178 | |
John Spurlock | 7bbb9f6 | 2014-10-21 12:15:28 -0400 | [diff] [blame] | 3179 | pw.println("SharedPreferences:"); |
Andrew Flynn | 8286257 | 2015-04-01 14:22:37 -0400 | [diff] [blame] | 3180 | for (Map.Entry<String, ?> entry : Prefs.getAll(mContext).entrySet()) { |
John Spurlock | 7bbb9f6 | 2014-10-21 12:15:28 -0400 | [diff] [blame] | 3181 | pw.print(" "); pw.print(entry.getKey()); pw.print("="); pw.println(entry.getValue()); |
| 3182 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3183 | } |
| 3184 | |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 3185 | private static void dumpBarTransitions(PrintWriter pw, String var, BarTransitions transitions) { |
| 3186 | pw.print(" "); pw.print(var); pw.print(".BarTransitions.mMode="); |
| 3187 | pw.println(BarTransitions.modeToString(transitions.getMode())); |
| 3188 | } |
| 3189 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 3190 | @Override |
| 3191 | public void createAndAddWindows() { |
| 3192 | addStatusBarWindow(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3193 | } |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 3194 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 3195 | private void addStatusBarWindow() { |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 3196 | makeStatusBarView(); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3197 | mStatusBarWindowManager = new StatusBarWindowManager(mContext); |
Adrian Roos | 1c0ca50 | 2015-10-07 12:20:42 -0700 | [diff] [blame] | 3198 | mRemoteInputController = new RemoteInputController(mStatusBarWindowManager, |
| 3199 | mHeadsUpManager); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3200 | mStatusBarWindowManager.add(mStatusBarWindow, getStatusBarHeight()); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3201 | } |
| 3202 | |
Daniel Sandler | 747a9e9 | 2012-08-10 16:39:19 -0400 | [diff] [blame] | 3203 | // called by makeStatusbar and also by PhoneStatusBarView |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 3204 | void updateDisplaySize() { |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 3205 | mDisplay.getMetrics(mDisplayMetrics); |
Daniel Sandler | 7e8ae50 | 2013-10-10 23:38:19 -0400 | [diff] [blame] | 3206 | mDisplay.getSize(mCurrentDisplaySize); |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 3207 | if (DEBUG_GESTURES) { |
John Spurlock | 209bede | 2013-07-17 12:23:27 -0400 | [diff] [blame] | 3208 | mGestureRec.tag("display", |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 3209 | String.format("%dx%d", mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels)); |
| 3210 | } |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 3211 | } |
| 3212 | |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 3213 | float getDisplayDensity() { |
| 3214 | return mDisplayMetrics.density; |
| 3215 | } |
| 3216 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 3217 | public void startActivityDismissingKeyguard(final Intent intent, boolean onlyProvisioned, |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3218 | boolean dismissShade) { |
| 3219 | startActivityDismissingKeyguard(intent, onlyProvisioned, dismissShade, null /* callback */); |
| 3220 | } |
| 3221 | |
| 3222 | public void startActivityDismissingKeyguard(final Intent intent, boolean onlyProvisioned, |
| 3223 | final boolean dismissShade, final Callback callback) { |
Daniel Sandler | 3679bf5 | 2012-10-16 21:30:28 -0400 | [diff] [blame] | 3224 | if (onlyProvisioned && !isDeviceProvisioned()) return; |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 3225 | |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 3226 | final boolean afterKeyguardGone = PreviewInflater.wouldLaunchResolverActivity( |
| 3227 | mContext, intent, mCurrentUserId); |
Jorim Jaggi | c7dea6e | 2014-07-26 14:36:57 +0200 | [diff] [blame] | 3228 | final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing(); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3229 | Runnable runnable = new Runnable() { |
| 3230 | public void run() { |
Jorim Jaggi | b835dd7 | 2015-06-08 12:28:42 -0700 | [diff] [blame] | 3231 | mAssistManager.hideAssist(); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3232 | intent.setFlags( |
| 3233 | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3234 | int result = ActivityManager.START_CANCELED; |
| 3235 | try { |
| 3236 | result = ActivityManagerNative.getDefault().startActivityAsUser( |
| 3237 | null, mContext.getBasePackageName(), |
| 3238 | intent, |
| 3239 | intent.resolveTypeIfNeeded(mContext.getContentResolver()), |
Jorim Jaggi | e6e108e | 2016-03-28 13:38:45 -0700 | [diff] [blame] | 3240 | null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, |
| 3241 | getActivityOptions(), UserHandle.CURRENT.getIdentifier()); |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3242 | } catch (RemoteException e) { |
| 3243 | Log.w(TAG, "Unable to start activity", e); |
| 3244 | } |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3245 | overrideActivityPendingAppTransition( |
| 3246 | keyguardShowing && !afterKeyguardGone); |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3247 | if (callback != null) { |
| 3248 | callback.onActivityStarted(result); |
| 3249 | } |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3250 | } |
| 3251 | }; |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3252 | Runnable cancelRunnable = new Runnable() { |
| 3253 | @Override |
| 3254 | public void run() { |
Jorim Jaggi | 5cc8659 | 2015-06-08 14:48:28 -0700 | [diff] [blame] | 3255 | if (callback != null) { |
| 3256 | callback.onActivityStarted(ActivityManager.START_CANCELED); |
| 3257 | } |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3258 | } |
| 3259 | }; |
Jorim Jaggi | b835dd7 | 2015-06-08 12:28:42 -0700 | [diff] [blame] | 3260 | executeRunnableDismissingKeyguard(runnable, cancelRunnable, dismissShade, |
Felipe Leme | ee5d630 | 2016-04-22 16:11:19 -0700 | [diff] [blame] | 3261 | afterKeyguardGone, true /* deferred */); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3262 | } |
| 3263 | |
| 3264 | public void executeRunnableDismissingKeyguard(final Runnable runnable, |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3265 | final Runnable cancelAction, |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3266 | final boolean dismissShade, |
Felipe Leme | ee5d630 | 2016-04-22 16:11:19 -0700 | [diff] [blame] | 3267 | final boolean afterKeyguardGone, |
| 3268 | final boolean deferred) { |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3269 | final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing(); |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 3270 | dismissKeyguardThenExecute(new OnDismissAction() { |
| 3271 | @Override |
| 3272 | public boolean onDismiss() { |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 3273 | AsyncTask.execute(new Runnable() { |
| 3274 | public void run() { |
| 3275 | try { |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 3276 | if (keyguardShowing && !afterKeyguardGone) { |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 3277 | ActivityManagerNative.getDefault() |
| 3278 | .keyguardWaitingForActivityDrawn(); |
| 3279 | } |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3280 | if (runnable != null) { |
| 3281 | runnable.run(); |
| 3282 | } |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 3283 | } catch (RemoteException e) { |
| 3284 | } |
| 3285 | } |
| 3286 | }); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 3287 | if (dismissShade) { |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 3288 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */, |
| 3289 | true /* delayed*/); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 3290 | } |
Felipe Leme | ee5d630 | 2016-04-22 16:11:19 -0700 | [diff] [blame] | 3291 | return deferred; |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 3292 | } |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3293 | }, cancelAction, afterKeyguardGone); |
Daniel Sandler | 3679bf5 | 2012-10-16 21:30:28 -0400 | [diff] [blame] | 3294 | } |
| 3295 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3296 | private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { |
| 3297 | public void onReceive(Context context, Intent intent) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 3298 | if (DEBUG) Log.v(TAG, "onReceive: " + intent); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3299 | String action = intent.getAction(); |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 3300 | if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) { |
Andrei Stingaceanu | f86bc97 | 2016-04-12 15:29:25 +0100 | [diff] [blame] | 3301 | KeyboardShortcuts.dismiss(); |
Kenny Guy | 44fc65f | 2014-11-28 22:18:14 +0000 | [diff] [blame] | 3302 | if (isCurrentProfile(getSendingUserId())) { |
| 3303 | int flags = CommandQueue.FLAG_EXCLUDE_NONE; |
| 3304 | String reason = intent.getStringExtra("reason"); |
| 3305 | if (reason != null && reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) { |
| 3306 | flags |= CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL; |
| 3307 | } |
| 3308 | animateCollapsePanels(flags); |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 3309 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3310 | } |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 3311 | else if (Intent.ACTION_SCREEN_OFF.equals(action)) { |
John Spurlock | 1bbd49d | 2012-10-19 11:09:32 -0400 | [diff] [blame] | 3312 | notifyNavigationBarScreenOn(false); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 3313 | notifyHeadsUpScreenOff(); |
John Spurlock | 4219726 | 2013-10-21 09:32:25 -0400 | [diff] [blame] | 3314 | finishBarAnimations(); |
Selim Cinek | ccd14fb | 2014-08-12 18:53:24 +0200 | [diff] [blame] | 3315 | resetUserExpandedStates(); |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 3316 | } |
Daniel Sandler | 7f3cf95 | 2012-08-31 14:57:09 -0400 | [diff] [blame] | 3317 | else if (Intent.ACTION_SCREEN_ON.equals(action)) { |
John Spurlock | 1bbd49d | 2012-10-19 11:09:32 -0400 | [diff] [blame] | 3318 | notifyNavigationBarScreenOn(true); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3319 | } |
Adrian Roos | 8e3e836 | 2015-07-16 19:42:22 -0700 | [diff] [blame] | 3320 | } |
| 3321 | }; |
| 3322 | |
| 3323 | private BroadcastReceiver mDemoReceiver = new BroadcastReceiver() { |
| 3324 | public void onReceive(Context context, Intent intent) { |
| 3325 | if (DEBUG) Log.v(TAG, "onReceive: " + intent); |
| 3326 | String action = intent.getAction(); |
| 3327 | if (ACTION_DEMO.equals(action)) { |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3328 | Bundle bundle = intent.getExtras(); |
| 3329 | if (bundle != null) { |
| 3330 | String command = bundle.getString("command", "").trim().toLowerCase(); |
| 3331 | if (command.length() > 0) { |
| 3332 | try { |
| 3333 | dispatchDemoCommand(command, bundle); |
| 3334 | } catch (Throwable t) { |
| 3335 | Log.w(TAG, "Error running demo command, intent=" + intent, t); |
| 3336 | } |
| 3337 | } |
| 3338 | } |
Adrian Roos | 8e3e836 | 2015-07-16 19:42:22 -0700 | [diff] [blame] | 3339 | } else if (ACTION_FAKE_ARTWORK.equals(action)) { |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 3340 | if (DEBUG_MEDIA_FAKE_ARTWORK) { |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 3341 | updateMediaMetaData(true, true); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 3342 | } |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3343 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3344 | } |
| 3345 | }; |
| 3346 | |
Selim Cinek | 78f4008 | 2016-03-10 18:06:27 -0800 | [diff] [blame] | 3347 | public void resetUserExpandedStates() { |
Selim Cinek | ccd14fb | 2014-08-12 18:53:24 +0200 | [diff] [blame] | 3348 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
| 3349 | final int notificationCount = activeNotifications.size(); |
| 3350 | for (int i = 0; i < notificationCount; i++) { |
| 3351 | NotificationData.Entry entry = activeNotifications.get(i); |
| 3352 | if (entry.row != null) { |
| 3353 | entry.row.resetUserExpansion(); |
| 3354 | } |
| 3355 | } |
| 3356 | } |
| 3357 | |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 3358 | @Override |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3359 | protected void dismissKeyguardThenExecute(OnDismissAction action, boolean afterKeyguardGone) { |
| 3360 | dismissKeyguardThenExecute(action, null /* cancelRunnable */, afterKeyguardGone); |
| 3361 | } |
| 3362 | |
Jason Monk | abe1974 | 2015-09-29 09:47:06 -0400 | [diff] [blame] | 3363 | public void dismissKeyguard() { |
| 3364 | mStatusBarKeyguardViewManager.dismiss(); |
| 3365 | } |
| 3366 | |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3367 | private void dismissKeyguardThenExecute(OnDismissAction action, Runnable cancelAction, |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 3368 | boolean afterKeyguardGone) { |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 3369 | if (mStatusBarKeyguardViewManager.isShowing()) { |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3370 | mStatusBarKeyguardViewManager.dismissWithAction(action, cancelAction, |
| 3371 | afterKeyguardGone); |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 3372 | } else { |
| 3373 | action.onDismiss(); |
| 3374 | } |
| 3375 | } |
| 3376 | |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 3377 | // SystemUIService notifies SystemBars of configuration changes, which then calls down here |
| 3378 | @Override |
| 3379 | protected void onConfigurationChanged(Configuration newConfig) { |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 3380 | updateResources(); |
| 3381 | updateDisplaySize(); // populates mDisplayMetrics |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 3382 | super.onConfigurationChanged(newConfig); // calls refreshLayout |
| 3383 | |
| 3384 | if (DEBUG) { |
| 3385 | Log.v(TAG, "configuration changed: " + mContext.getResources().getConfiguration()); |
| 3386 | } |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 3387 | |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 3388 | repositionNavigationBar(); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 3389 | updateRowStates(); |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 3390 | mIconController.defineSlots(); |
Jason Monk | 18f99d9 | 2014-09-11 13:36:42 -0400 | [diff] [blame] | 3391 | mScreenPinningRequest.onConfigurationChanged(); |
Jason Monk | 1c040db | 2015-07-20 09:45:54 -0400 | [diff] [blame] | 3392 | mNetworkController.onConfigurationChanged(); |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 3393 | } |
| 3394 | |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 3395 | @Override |
| 3396 | public void userSwitched(int newUserId) { |
Chris Wren | a6d4fb6 | 2014-11-20 14:46:23 -0500 | [diff] [blame] | 3397 | super.userSwitched(newUserId); |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 3398 | if (MULTIUSER_DEBUG) mNotificationPanelDebugText.setText("USER " + newUserId); |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 3399 | animateCollapsePanels(); |
Adrian Roos | 31b844b | 2014-11-21 13:55:09 +0100 | [diff] [blame] | 3400 | updatePublicMode(); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 3401 | updateNotifications(); |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 3402 | resetUserSetupObserver(); |
John Spurlock | 89f060a | 2014-07-16 21:03:15 -0400 | [diff] [blame] | 3403 | setControllerUsers(); |
Julia Reynolds | 86ef8e2 | 2015-09-09 16:42:38 -0400 | [diff] [blame] | 3404 | clearCurrentMediaNotification(); |
Vadim Tryshev | 12a30e8 | 2016-02-12 15:39:28 -0800 | [diff] [blame] | 3405 | mLockscreenWallpaper.setCurrentUser(newUserId); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 3406 | updateMediaMetaData(true, false); |
John Spurlock | 89f060a | 2014-07-16 21:03:15 -0400 | [diff] [blame] | 3407 | } |
| 3408 | |
| 3409 | private void setControllerUsers() { |
| 3410 | if (mZenModeController != null) { |
| 3411 | mZenModeController.setUserId(mCurrentUserId); |
| 3412 | } |
Robin Lee | 63204ee | 2015-06-04 01:53:01 +0100 | [diff] [blame] | 3413 | if (mSecurityController != null) { |
| 3414 | mSecurityController.onUserSwitched(mCurrentUserId); |
| 3415 | } |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 3416 | } |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 3417 | |
| 3418 | private void resetUserSetupObserver() { |
| 3419 | mContext.getContentResolver().unregisterContentObserver(mUserSetupObserver); |
| 3420 | mUserSetupObserver.onChange(false); |
| 3421 | mContext.getContentResolver().registerContentObserver( |
| 3422 | Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE), true, |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 3423 | mUserSetupObserver, mCurrentUserId); |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 3424 | } |
| 3425 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3426 | /** |
| 3427 | * Reload some of our resources when the configuration changes. |
| 3428 | * |
| 3429 | * We don't reload everything when the configuration changes -- we probably |
| 3430 | * should, but getting that smooth is tough. Someday we'll fix that. In the |
| 3431 | * meantime, just update the things that we know change. |
| 3432 | */ |
| 3433 | void updateResources() { |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 3434 | // Update the quick setting tiles |
John Spurlock | 7e6809a | 2014-08-06 16:03:14 -0400 | [diff] [blame] | 3435 | if (mQSPanel != null) { |
| 3436 | mQSPanel.updateResources(); |
| 3437 | } |
Winson Chung | d63c5978 | 2012-09-05 17:34:41 -0700 | [diff] [blame] | 3438 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 3439 | loadDimens(); |
John Spurlock | 7e6809a | 2014-08-06 16:03:14 -0400 | [diff] [blame] | 3440 | |
| 3441 | if (mNotificationPanel != null) { |
| 3442 | mNotificationPanel.updateResources(); |
| 3443 | } |
Adrian Roos | 5fd872e | 2014-08-12 17:28:58 +0200 | [diff] [blame] | 3444 | if (mBrightnessMirrorController != null) { |
| 3445 | mBrightnessMirrorController.updateResources(); |
| 3446 | } |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 3447 | } |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 3448 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 3449 | protected void loadDimens() { |
| 3450 | final Resources res = mContext.getResources(); |
| 3451 | |
Jorim Jaggi | 11c62e1 | 2016-04-05 20:41:21 -0700 | [diff] [blame] | 3452 | int oldBarHeight = mNaturalBarHeight; |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 3453 | mNaturalBarHeight = res.getDimensionPixelSize( |
| 3454 | com.android.internal.R.dimen.status_bar_height); |
Jorim Jaggi | 11c62e1 | 2016-04-05 20:41:21 -0700 | [diff] [blame] | 3455 | if (mStatusBarWindowManager != null && mNaturalBarHeight != oldBarHeight) { |
| 3456 | mStatusBarWindowManager.setBarHeight(mNaturalBarHeight); |
| 3457 | } |
| 3458 | mMaxAllowedKeyguardNotifications = res.getInteger( |
| 3459 | R.integer.keyguard_max_notification_count); |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 3460 | |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame] | 3461 | if (DEBUG) Log.v(TAG, "defineSlots"); |
John Spurlock | 804df70 | 2012-06-01 15:34:27 -0400 | [diff] [blame] | 3462 | } |
| 3463 | |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3464 | // Visibility reporting |
| 3465 | |
| 3466 | @Override |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 3467 | protected void handleVisibleToUserChanged(boolean visibleToUser) { |
| 3468 | if (visibleToUser) { |
| 3469 | super.handleVisibleToUserChanged(visibleToUser); |
| 3470 | startNotificationLogging(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3471 | } else { |
Christoph Studer | 037e34c | 2014-04-30 20:06:04 +0200 | [diff] [blame] | 3472 | stopNotificationLogging(); |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 3473 | super.handleVisibleToUserChanged(visibleToUser); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3474 | } |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3475 | } |
| 3476 | |
Christoph Studer | 037e34c | 2014-04-30 20:06:04 +0200 | [diff] [blame] | 3477 | private void stopNotificationLogging() { |
| 3478 | // Report all notifications as invisible and turn down the |
| 3479 | // reporter. |
| 3480 | if (!mCurrentlyVisibleNotifications.isEmpty()) { |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 3481 | logNotificationVisibilityChanges(Collections.<NotificationVisibility>emptyList(), |
| 3482 | mCurrentlyVisibleNotifications); |
| 3483 | recycleAllVisibilityObjects(mCurrentlyVisibleNotifications); |
Christoph Studer | 037e34c | 2014-04-30 20:06:04 +0200 | [diff] [blame] | 3484 | } |
| 3485 | mHandler.removeCallbacks(mVisibilityReporter); |
| 3486 | mStackScroller.setChildLocationsChangedListener(null); |
| 3487 | } |
| 3488 | |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 3489 | private void startNotificationLogging() { |
| 3490 | mStackScroller.setChildLocationsChangedListener(mNotificationLocationsChangedListener); |
| 3491 | // Some transitions like mVisibleToUser=false -> mVisibleToUser=true don't |
| 3492 | // cause the scroller to emit child location events. Hence generate |
| 3493 | // one ourselves to guarantee that we're reporting visible |
| 3494 | // notifications. |
| 3495 | // (Note that in cases where the scroller does emit events, this |
| 3496 | // additional event doesn't break anything.) |
| 3497 | mNotificationLocationsChangedListener.onChildLocationsChanged(mStackScroller); |
Christoph Studer | 037e34c | 2014-04-30 20:06:04 +0200 | [diff] [blame] | 3498 | } |
| 3499 | |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3500 | private void logNotificationVisibilityChanges( |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 3501 | Collection<NotificationVisibility> newlyVisible, |
| 3502 | Collection<NotificationVisibility> noLongerVisible) { |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3503 | if (newlyVisible.isEmpty() && noLongerVisible.isEmpty()) { |
| 3504 | return; |
| 3505 | } |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 3506 | NotificationVisibility[] newlyVisibleAr = |
| 3507 | newlyVisible.toArray(new NotificationVisibility[newlyVisible.size()]); |
| 3508 | NotificationVisibility[] noLongerVisibleAr = |
| 3509 | noLongerVisible.toArray(new NotificationVisibility[noLongerVisible.size()]); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3510 | try { |
| 3511 | mBarService.onNotificationVisibilityChanged(newlyVisibleAr, noLongerVisibleAr); |
| 3512 | } catch (RemoteException e) { |
| 3513 | // Ignore. |
| 3514 | } |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 3515 | |
| 3516 | final int N = newlyVisible.size(); |
Amith Yamasani | 7649567 | 2015-07-07 15:22:54 -0700 | [diff] [blame] | 3517 | if (N > 0) { |
| 3518 | String[] newlyVisibleKeyAr = new String[N]; |
| 3519 | for (int i = 0; i < N; i++) { |
| 3520 | newlyVisibleKeyAr[i] = newlyVisibleAr[i].key; |
| 3521 | } |
| 3522 | |
| 3523 | setNotificationsShown(newlyVisibleKeyAr); |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 3524 | } |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3525 | } |
| 3526 | |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 3527 | // State logging |
| 3528 | |
| 3529 | private void logStateToEventlog() { |
| 3530 | boolean isShowing = mStatusBarKeyguardViewManager.isShowing(); |
| 3531 | boolean isOccluded = mStatusBarKeyguardViewManager.isOccluded(); |
| 3532 | boolean isBouncerShowing = mStatusBarKeyguardViewManager.isBouncerShowing(); |
| 3533 | boolean isSecure = mUnlockMethodCache.isMethodSecure(); |
Selim Cinek | e8bae62 | 2015-07-15 13:24:06 -0700 | [diff] [blame] | 3534 | boolean canSkipBouncer = mUnlockMethodCache.canSkipBouncer(); |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 3535 | int stateFingerprint = getLoggingFingerprint(mState, |
| 3536 | isShowing, |
| 3537 | isOccluded, |
| 3538 | isBouncerShowing, |
| 3539 | isSecure, |
Selim Cinek | e8bae62 | 2015-07-15 13:24:06 -0700 | [diff] [blame] | 3540 | canSkipBouncer); |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 3541 | if (stateFingerprint != mLastLoggedStateFingerprint) { |
| 3542 | EventLogTags.writeSysuiStatusBarState(mState, |
| 3543 | isShowing ? 1 : 0, |
| 3544 | isOccluded ? 1 : 0, |
| 3545 | isBouncerShowing ? 1 : 0, |
| 3546 | isSecure ? 1 : 0, |
Selim Cinek | e8bae62 | 2015-07-15 13:24:06 -0700 | [diff] [blame] | 3547 | canSkipBouncer ? 1 : 0); |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 3548 | mLastLoggedStateFingerprint = stateFingerprint; |
| 3549 | } |
| 3550 | } |
| 3551 | |
| 3552 | /** |
| 3553 | * Returns a fingerprint of fields logged to eventlog |
| 3554 | */ |
| 3555 | private static int getLoggingFingerprint(int statusBarState, boolean keyguardShowing, |
| 3556 | boolean keyguardOccluded, boolean bouncerShowing, boolean secure, |
| 3557 | boolean currentlyInsecure) { |
| 3558 | // Reserve 8 bits for statusBarState. We'll never go higher than |
| 3559 | // that, right? Riiiight. |
| 3560 | return (statusBarState & 0xFF) |
| 3561 | | ((keyguardShowing ? 1 : 0) << 8) |
| 3562 | | ((keyguardOccluded ? 1 : 0) << 9) |
| 3563 | | ((bouncerShowing ? 1 : 0) << 10) |
| 3564 | | ((secure ? 1 : 0) << 11) |
| 3565 | | ((currentlyInsecure ? 1 : 0) << 12); |
| 3566 | } |
| 3567 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3568 | // |
| 3569 | // tracing |
| 3570 | // |
| 3571 | |
| 3572 | void postStartTracing() { |
| 3573 | mHandler.postDelayed(mStartTracing, 3000); |
| 3574 | } |
| 3575 | |
| 3576 | void vibrate() { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 3577 | android.os.Vibrator vib = (android.os.Vibrator)mContext.getSystemService( |
| 3578 | Context.VIBRATOR_SERVICE); |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 3579 | vib.vibrate(250, VIBRATION_ATTRIBUTES); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3580 | } |
| 3581 | |
| 3582 | Runnable mStartTracing = new Runnable() { |
| 3583 | public void run() { |
| 3584 | vibrate(); |
| 3585 | SystemClock.sleep(250); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 3586 | Log.d(TAG, "startTracing"); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3587 | android.os.Debug.startMethodTracing("/data/statusbar-traces/trace"); |
| 3588 | mHandler.postDelayed(mStopTracing, 10000); |
| 3589 | } |
| 3590 | }; |
| 3591 | |
| 3592 | Runnable mStopTracing = new Runnable() { |
| 3593 | public void run() { |
| 3594 | android.os.Debug.stopMethodTracing(); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 3595 | Log.d(TAG, "stopTracing"); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3596 | vibrate(); |
| 3597 | } |
| 3598 | }; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 3599 | |
| 3600 | @Override |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 3601 | public boolean shouldDisableNavbarGestures() { |
Jorim Jaggi | 18976a5 | 2015-07-24 13:18:19 -0700 | [diff] [blame] | 3602 | return !isDeviceProvisioned() || (mDisabled1 & StatusBarManager.DISABLE_SEARCH) != 0; |
Jim Miller | 670d9dd | 2012-05-12 13:28:26 -0700 | [diff] [blame] | 3603 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3604 | |
Jason Monk | ba2318e | 2015-12-08 09:04:23 -0500 | [diff] [blame] | 3605 | public void postQSRunnableDismissingKeyguard(final Runnable runnable) { |
| 3606 | mHandler.post(new Runnable() { |
| 3607 | @Override |
| 3608 | public void run() { |
| 3609 | mLeaveOpenOnKeyguardHide = true; |
Felipe Leme | ee5d630 | 2016-04-22 16:11:19 -0700 | [diff] [blame] | 3610 | executeRunnableDismissingKeyguard(runnable, null, false, false, false); |
Jason Monk | ba2318e | 2015-12-08 09:04:23 -0500 | [diff] [blame] | 3611 | } |
| 3612 | }); |
| 3613 | } |
| 3614 | |
Adrian Roos | 62692b2 | 2015-09-11 17:46:23 -0700 | [diff] [blame] | 3615 | public void postStartActivityDismissingKeyguard(final PendingIntent intent) { |
| 3616 | mHandler.post(new Runnable() { |
| 3617 | @Override |
| 3618 | public void run() { |
| 3619 | startPendingIntentDismissingKeyguard(intent); |
| 3620 | } |
| 3621 | }); |
| 3622 | } |
| 3623 | |
Jason Monk | ee43cdf | 2015-06-19 14:20:46 -0400 | [diff] [blame] | 3624 | public void postStartActivityDismissingKeyguard(final Intent intent, int delay) { |
John Spurlock | d47a3f3 | 2014-05-18 19:14:14 -0400 | [diff] [blame] | 3625 | mHandler.postDelayed(new Runnable() { |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 3626 | @Override |
| 3627 | public void run() { |
Jason Monk | ee43cdf | 2015-06-19 14:20:46 -0400 | [diff] [blame] | 3628 | handleStartActivityDismissingKeyguard(intent, true /*onlyProvisioned*/); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 3629 | } |
John Spurlock | d47a3f3 | 2014-05-18 19:14:14 -0400 | [diff] [blame] | 3630 | }, delay); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 3631 | } |
| 3632 | |
Jason Monk | ee43cdf | 2015-06-19 14:20:46 -0400 | [diff] [blame] | 3633 | private void handleStartActivityDismissingKeyguard(Intent intent, boolean onlyProvisioned) { |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 3634 | startActivityDismissingKeyguard(intent, onlyProvisioned, true /* dismissShade */); |
John Spurlock | de54700 | 2014-02-28 17:50:39 -0500 | [diff] [blame] | 3635 | } |
| 3636 | |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 3637 | private static class FastColorDrawable extends Drawable { |
| 3638 | private final int mColor; |
| 3639 | |
| 3640 | public FastColorDrawable(int color) { |
| 3641 | mColor = 0xff000000 | color; |
| 3642 | } |
| 3643 | |
| 3644 | @Override |
| 3645 | public void draw(Canvas canvas) { |
| 3646 | canvas.drawColor(mColor, PorterDuff.Mode.SRC); |
| 3647 | } |
| 3648 | |
| 3649 | @Override |
| 3650 | public void setAlpha(int alpha) { |
| 3651 | } |
| 3652 | |
| 3653 | @Override |
Chris Craik | bd3bfc5 | 2015-03-02 10:43:29 -0800 | [diff] [blame] | 3654 | public void setColorFilter(ColorFilter colorFilter) { |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 3655 | } |
| 3656 | |
| 3657 | @Override |
| 3658 | public int getOpacity() { |
| 3659 | return PixelFormat.OPAQUE; |
| 3660 | } |
| 3661 | |
| 3662 | @Override |
| 3663 | public void setBounds(int left, int top, int right, int bottom) { |
| 3664 | } |
| 3665 | |
| 3666 | @Override |
| 3667 | public void setBounds(Rect bounds) { |
| 3668 | } |
| 3669 | } |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 3670 | |
| 3671 | @Override |
| 3672 | public void destroy() { |
| 3673 | super.destroy(); |
| 3674 | if (mStatusBarWindow != null) { |
| 3675 | mWindowManager.removeViewImmediate(mStatusBarWindow); |
John Spurlock | ab847cf | 2014-01-15 14:13:59 -0500 | [diff] [blame] | 3676 | mStatusBarWindow = null; |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 3677 | } |
| 3678 | if (mNavigationBarView != null) { |
| 3679 | mWindowManager.removeViewImmediate(mNavigationBarView); |
John Spurlock | ab847cf | 2014-01-15 14:13:59 -0500 | [diff] [blame] | 3680 | mNavigationBarView = null; |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 3681 | } |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 3682 | if (mHandlerThread != null) { |
| 3683 | mHandlerThread.quitSafely(); |
| 3684 | mHandlerThread = null; |
| 3685 | } |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 3686 | mContext.unregisterReceiver(mBroadcastReceiver); |
Adrian Roos | 8e3e836 | 2015-07-16 19:42:22 -0700 | [diff] [blame] | 3687 | mContext.unregisterReceiver(mDemoReceiver); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3688 | mAssistManager.destroy(); |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 3689 | |
| 3690 | final SignalClusterView signalCluster = |
| 3691 | (SignalClusterView) mStatusBarView.findViewById(R.id.signal_cluster); |
| 3692 | final SignalClusterView signalClusterKeyguard = |
| 3693 | (SignalClusterView) mKeyguardStatusBar.findViewById(R.id.signal_cluster); |
| 3694 | final SignalClusterView signalClusterQs = |
| 3695 | (SignalClusterView) mHeader.findViewById(R.id.signal_cluster); |
Jason Monk | 5e74517 | 2015-06-02 19:14:44 -0400 | [diff] [blame] | 3696 | mNetworkController.removeSignalCallback(signalCluster); |
| 3697 | mNetworkController.removeSignalCallback(signalClusterKeyguard); |
| 3698 | mNetworkController.removeSignalCallback(signalClusterQs); |
| 3699 | if (mQSPanel != null && mQSPanel.getHost() != null) { |
| 3700 | mQSPanel.getHost().destroy(); |
| 3701 | } |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 3702 | } |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3703 | |
| 3704 | private boolean mDemoModeAllowed; |
| 3705 | private boolean mDemoMode; |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3706 | |
| 3707 | @Override |
| 3708 | public void dispatchDemoCommand(String command, Bundle args) { |
| 3709 | if (!mDemoModeAllowed) { |
| 3710 | mDemoModeAllowed = Settings.Global.getInt(mContext.getContentResolver(), |
Jason Monk | 431ad73 | 2015-07-16 08:58:15 -0400 | [diff] [blame] | 3711 | DEMO_MODE_ALLOWED, 0) != 0; |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3712 | } |
| 3713 | if (!mDemoModeAllowed) return; |
| 3714 | if (command.equals(COMMAND_ENTER)) { |
| 3715 | mDemoMode = true; |
| 3716 | } else if (command.equals(COMMAND_EXIT)) { |
| 3717 | mDemoMode = false; |
| 3718 | checkBarModes(); |
| 3719 | } else if (!mDemoMode) { |
| 3720 | // automatically enter demo mode on first demo command |
| 3721 | dispatchDemoCommand(COMMAND_ENTER, new Bundle()); |
| 3722 | } |
| 3723 | boolean modeChange = command.equals(COMMAND_ENTER) || command.equals(COMMAND_EXIT); |
John Spurlock | bb4a702 | 2014-11-08 12:40:19 -0500 | [diff] [blame] | 3724 | if ((modeChange || command.equals(COMMAND_VOLUME)) && mVolumeComponent != null) { |
| 3725 | mVolumeComponent.dispatchDemoCommand(command, args); |
| 3726 | } |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3727 | if (modeChange || command.equals(COMMAND_CLOCK)) { |
| 3728 | dispatchDemoCommandToView(command, args, R.id.clock); |
| 3729 | } |
| 3730 | if (modeChange || command.equals(COMMAND_BATTERY)) { |
Jason Monk | 98d7c7a | 2016-04-12 13:08:31 -0400 | [diff] [blame] | 3731 | mBatteryController.dispatchDemoCommand(command, args); |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3732 | } |
| 3733 | if (modeChange || command.equals(COMMAND_STATUS)) { |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 3734 | mIconController.dispatchDemoCommand(command, args); |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3735 | } |
| 3736 | if (mNetworkController != null && (modeChange || command.equals(COMMAND_NETWORK))) { |
| 3737 | mNetworkController.dispatchDemoCommand(command, args); |
| 3738 | } |
John Spurlock | 7f42fc5 | 2014-01-14 16:20:39 -0500 | [diff] [blame] | 3739 | if (modeChange || command.equals(COMMAND_NOTIFICATIONS)) { |
| 3740 | View notifications = mStatusBarView == null ? null |
| 3741 | : mStatusBarView.findViewById(R.id.notification_icon_area); |
| 3742 | if (notifications != null) { |
| 3743 | String visible = args.getString("visible"); |
| 3744 | int vis = mDemoMode && "false".equals(visible) ? View.INVISIBLE : View.VISIBLE; |
| 3745 | notifications.setVisibility(vis); |
| 3746 | } |
| 3747 | } |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3748 | if (command.equals(COMMAND_BARS)) { |
| 3749 | String mode = args.getString("mode"); |
| 3750 | int barMode = "opaque".equals(mode) ? MODE_OPAQUE : |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3751 | "translucent".equals(mode) ? MODE_TRANSLUCENT : |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3752 | "semi-transparent".equals(mode) ? MODE_SEMI_TRANSPARENT : |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 3753 | "transparent".equals(mode) ? MODE_TRANSPARENT : |
| 3754 | "warning".equals(mode) ? MODE_WARNING : |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3755 | -1; |
| 3756 | if (barMode != -1) { |
| 3757 | boolean animate = true; |
| 3758 | if (mStatusBarView != null) { |
| 3759 | mStatusBarView.getBarTransitions().transitionTo(barMode, animate); |
| 3760 | } |
| 3761 | if (mNavigationBarView != null) { |
| 3762 | mNavigationBarView.getBarTransitions().transitionTo(barMode, animate); |
| 3763 | } |
| 3764 | } |
| 3765 | } |
| 3766 | } |
| 3767 | |
| 3768 | private void dispatchDemoCommandToView(String command, Bundle args, int id) { |
| 3769 | if (mStatusBarView == null) return; |
| 3770 | View v = mStatusBarView.findViewById(id); |
| 3771 | if (v instanceof DemoMode) { |
| 3772 | ((DemoMode)v).dispatchDemoCommand(command, args); |
| 3773 | } |
| 3774 | } |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 3775 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 3776 | /** |
| 3777 | * @return The {@link StatusBarState} the status bar is in. |
| 3778 | */ |
| 3779 | public int getBarState() { |
| 3780 | return mState; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 3781 | } |
| 3782 | |
Chris Wren | 1689594 | 2015-06-23 11:22:20 -0400 | [diff] [blame] | 3783 | @Override |
Yorke Lee | e4ea6ab | 2016-03-03 14:51:49 -0800 | [diff] [blame] | 3784 | public boolean isPanelFullyCollapsed() { |
Chris Wren | 1689594 | 2015-06-23 11:22:20 -0400 | [diff] [blame] | 3785 | return mNotificationPanel.isFullyCollapsed(); |
| 3786 | } |
| 3787 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 3788 | public void showKeyguard() { |
Jorim Jaggi | 5e08e69 | 2014-10-03 15:17:20 -0700 | [diff] [blame] | 3789 | if (mLaunchTransitionFadingAway) { |
| 3790 | mNotificationPanel.animate().cancel(); |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 3791 | onLaunchTransitionFadingEnded(); |
Jorim Jaggi | 5e08e69 | 2014-10-03 15:17:20 -0700 | [diff] [blame] | 3792 | } |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 3793 | mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 3794 | if (mUserSwitcherController != null && mUserSwitcherController.useFullscreenUserSwitcher()) { |
| 3795 | setBarState(StatusBarState.FULLSCREEN_USER_SWITCHER); |
| 3796 | } else { |
| 3797 | setBarState(StatusBarState.KEYGUARD); |
| 3798 | } |
Jorim Jaggi | 98f8530 | 2014-08-07 17:45:04 +0200 | [diff] [blame] | 3799 | updateKeyguardState(false /* goingToFullShade */, false /* fromShadeLocked */); |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 3800 | if (!mDeviceInteractive) { |
Jorim Jaggi | d41083a | 2014-09-12 02:54:40 +0200 | [diff] [blame] | 3801 | |
| 3802 | // If the screen is off already, we need to disable touch events because these might |
| 3803 | // collapse the panel after we expanded it, and thus we would end up with a blank |
| 3804 | // Keyguard. |
| 3805 | mNotificationPanel.setTouchDisabled(true); |
| 3806 | } |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 3807 | if (mState == StatusBarState.KEYGUARD) { |
| 3808 | instantExpandNotificationsPanel(); |
| 3809 | } else if (mState == StatusBarState.FULLSCREEN_USER_SWITCHER) { |
| 3810 | instantCollapseNotificationPanel(); |
| 3811 | } |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 3812 | mLeaveOpenOnKeyguardHide = false; |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 3813 | if (mDraggedDownRow != null) { |
| 3814 | mDraggedDownRow.setUserLocked(false); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 3815 | mDraggedDownRow.notifyHeightChanged(false /* needsAnimation */); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 3816 | mDraggedDownRow = null; |
| 3817 | } |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 3818 | mPendingRemoteInputView = null; |
Jorim Jaggi | 19695d9 | 2015-07-20 15:51:40 -0700 | [diff] [blame] | 3819 | mAssistManager.onLockscreenShown(); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 3820 | } |
| 3821 | |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 3822 | private void onLaunchTransitionFadingEnded() { |
| 3823 | mNotificationPanel.setAlpha(1.0f); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 3824 | mNotificationPanel.onAffordanceLaunchEnded(); |
| 3825 | releaseGestureWakeLock(); |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 3826 | runLaunchTransitionEndRunnable(); |
| 3827 | mLaunchTransitionFadingAway = false; |
| 3828 | mScrimController.forceHideScrims(false /* hide */); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 3829 | updateMediaMetaData(true /* metaDataChanged */, true); |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 3830 | } |
| 3831 | |
Selim Cinek | 36b0223 | 2016-05-11 23:07:05 -0400 | [diff] [blame] | 3832 | @Override |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 3833 | public boolean isCollapsing() { |
| 3834 | return mNotificationPanel.isCollapsing(); |
| 3835 | } |
| 3836 | |
Selim Cinek | 36b0223 | 2016-05-11 23:07:05 -0400 | [diff] [blame] | 3837 | @Override |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 3838 | public void addPostCollapseAction(Runnable r) { |
| 3839 | mPostCollapseRunnables.add(r); |
| 3840 | } |
| 3841 | |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 3842 | public boolean isInLaunchTransition() { |
| 3843 | return mNotificationPanel.isLaunchTransitionRunning() |
| 3844 | || mNotificationPanel.isLaunchTransitionFinished(); |
| 3845 | } |
| 3846 | |
| 3847 | /** |
| 3848 | * Fades the content of the keyguard away after the launch transition is done. |
| 3849 | * |
| 3850 | * @param beforeFading the runnable to be run when the circle is fully expanded and the fading |
| 3851 | * starts |
| 3852 | * @param endRunnable the runnable to be run when the transition is done |
| 3853 | */ |
| 3854 | public void fadeKeyguardAfterLaunchTransition(final Runnable beforeFading, |
Jorim Jaggi | 5e08e69 | 2014-10-03 15:17:20 -0700 | [diff] [blame] | 3855 | Runnable endRunnable) { |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 3856 | mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); |
Jorim Jaggi | 5e08e69 | 2014-10-03 15:17:20 -0700 | [diff] [blame] | 3857 | mLaunchTransitionEndRunnable = endRunnable; |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 3858 | Runnable hideRunnable = new Runnable() { |
| 3859 | @Override |
| 3860 | public void run() { |
| 3861 | mLaunchTransitionFadingAway = true; |
| 3862 | if (beforeFading != null) { |
| 3863 | beforeFading.run(); |
| 3864 | } |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 3865 | mScrimController.forceHideScrims(true /* hide */); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 3866 | updateMediaMetaData(false, true); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 3867 | mNotificationPanel.setAlpha(1); |
| 3868 | mNotificationPanel.animate() |
| 3869 | .alpha(0) |
| 3870 | .setStartDelay(FADE_KEYGUARD_START_DELAY) |
| 3871 | .setDuration(FADE_KEYGUARD_DURATION) |
| 3872 | .withLayer() |
| 3873 | .withEndAction(new Runnable() { |
| 3874 | @Override |
| 3875 | public void run() { |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 3876 | onLaunchTransitionFadingEnded(); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 3877 | } |
| 3878 | }); |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 3879 | mIconController.appTransitionStarting(SystemClock.uptimeMillis(), |
| 3880 | StatusBarIconController.DEFAULT_TINT_ANIMATION_DURATION); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 3881 | } |
| 3882 | }; |
| 3883 | if (mNotificationPanel.isLaunchTransitionRunning()) { |
| 3884 | mNotificationPanel.setLaunchTransitionEndRunnable(hideRunnable); |
| 3885 | } else { |
| 3886 | hideRunnable.run(); |
| 3887 | } |
| 3888 | } |
| 3889 | |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 3890 | /** |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 3891 | * Fades the content of the Keyguard while we are dozing and makes it invisible when finished |
| 3892 | * fading. |
| 3893 | */ |
| 3894 | public void fadeKeyguardWhilePulsing() { |
| 3895 | mNotificationPanel.animate() |
| 3896 | .alpha(0f) |
| 3897 | .setStartDelay(0) |
| 3898 | .setDuration(FADE_KEYGUARD_DURATION_PULSING) |
Jorim Jaggi | ab45a21 | 2015-08-20 16:59:44 -0700 | [diff] [blame] | 3899 | .setInterpolator(ScrimController.KEYGUARD_FADE_OUT_INTERPOLATOR) |
| 3900 | .start(); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 3901 | } |
| 3902 | |
| 3903 | /** |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 3904 | * Starts the timeout when we try to start the affordances on Keyguard. We usually rely that |
| 3905 | * Keyguard goes away via fadeKeyguardAfterLaunchTransition, however, that might not happen |
| 3906 | * because the launched app crashed or something else went wrong. |
| 3907 | */ |
| 3908 | public void startLaunchTransitionTimeout() { |
| 3909 | mHandler.sendEmptyMessageDelayed(MSG_LAUNCH_TRANSITION_TIMEOUT, |
| 3910 | LAUNCH_TRANSITION_TIMEOUT_MS); |
| 3911 | } |
| 3912 | |
| 3913 | private void onLaunchTransitionTimeout() { |
| 3914 | Log.w(TAG, "Launch transition: Timeout!"); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 3915 | mNotificationPanel.onAffordanceLaunchEnded(); |
| 3916 | releaseGestureWakeLock(); |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 3917 | mNotificationPanel.resetViews(); |
| 3918 | } |
| 3919 | |
| 3920 | private void runLaunchTransitionEndRunnable() { |
| 3921 | if (mLaunchTransitionEndRunnable != null) { |
| 3922 | Runnable r = mLaunchTransitionEndRunnable; |
| 3923 | |
| 3924 | // mLaunchTransitionEndRunnable might call showKeyguard, which would execute it again, |
| 3925 | // which would lead to infinite recursion. Protect against it. |
| 3926 | mLaunchTransitionEndRunnable = null; |
| 3927 | r.run(); |
| 3928 | } |
| 3929 | } |
| 3930 | |
| 3931 | /** |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 3932 | * @return true if we would like to stay in the shade, false if it should go away entirely |
| 3933 | */ |
| 3934 | public boolean hideKeyguard() { |
| 3935 | boolean staying = mLeaveOpenOnKeyguardHide; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 3936 | setBarState(StatusBarState.SHADE); |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 3937 | View viewToClick = null; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 3938 | if (mLeaveOpenOnKeyguardHide) { |
| 3939 | mLeaveOpenOnKeyguardHide = false; |
Jorim Jaggi | 37c1180 | 2015-08-18 20:27:54 -0700 | [diff] [blame] | 3940 | long delay = calculateGoingToFullShadeDelay(); |
| 3941 | mNotificationPanel.animateToFullShade(delay); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 3942 | if (mDraggedDownRow != null) { |
| 3943 | mDraggedDownRow.setUserLocked(false); |
| 3944 | mDraggedDownRow = null; |
| 3945 | } |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 3946 | viewToClick = mPendingRemoteInputView; |
| 3947 | mPendingRemoteInputView = null; |
Jorim Jaggi | 37c1180 | 2015-08-18 20:27:54 -0700 | [diff] [blame] | 3948 | |
| 3949 | // Disable layout transitions in navbar for this transition because the load is just |
| 3950 | // too heavy for the CPU and GPU on any device. |
| 3951 | if (mNavigationBarView != null) { |
| 3952 | mNavigationBarView.setLayoutTransitionsEnabled(false); |
| 3953 | mNavigationBarView.postDelayed(new Runnable() { |
| 3954 | @Override |
| 3955 | public void run() { |
| 3956 | mNavigationBarView.setLayoutTransitionsEnabled(true); |
| 3957 | } |
| 3958 | }, delay + StackStateAnimator.ANIMATION_DURATION_GO_TO_FULL_SHADE); |
| 3959 | } |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 3960 | } else { |
| 3961 | instantCollapseNotificationPanel(); |
| 3962 | } |
Jorim Jaggi | 98f8530 | 2014-08-07 17:45:04 +0200 | [diff] [blame] | 3963 | updateKeyguardState(staying, false /* fromShadeLocked */); |
Jorim Jaggi | 1ecd7cd | 2014-11-03 16:18:03 +0100 | [diff] [blame] | 3964 | |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 3965 | if (viewToClick != null) { |
| 3966 | viewToClick.callOnClick(); |
| 3967 | } |
| 3968 | |
Jorim Jaggi | 1ecd7cd | 2014-11-03 16:18:03 +0100 | [diff] [blame] | 3969 | // Keyguard state has changed, but QS is not listening anymore. Make sure to update the tile |
| 3970 | // visibilities so next time we open the panel we know the correct height already. |
| 3971 | if (mQSPanel != null) { |
| 3972 | mQSPanel.refreshAllTiles(); |
| 3973 | } |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 3974 | mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 3975 | releaseGestureWakeLock(); |
| 3976 | mNotificationPanel.onAffordanceLaunchEnded(); |
Jorim Jaggi | 52429b4 | 2015-09-03 19:58:19 -0700 | [diff] [blame] | 3977 | mNotificationPanel.animate().cancel(); |
Jorim Jaggi | 9097885 | 2015-08-18 19:55:53 -0700 | [diff] [blame] | 3978 | mNotificationPanel.setAlpha(1f); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 3979 | return staying; |
| 3980 | } |
| 3981 | |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 3982 | private void releaseGestureWakeLock() { |
| 3983 | if (mGestureWakeLock.isHeld()) { |
| 3984 | mGestureWakeLock.release(); |
| 3985 | } |
| 3986 | } |
| 3987 | |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 3988 | public long calculateGoingToFullShadeDelay() { |
| 3989 | return mKeyguardFadingAwayDelay + mKeyguardFadingAwayDuration; |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 3990 | } |
| 3991 | |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 3992 | /** |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 3993 | * Notifies the status bar that Keyguard is going away very soon. |
| 3994 | */ |
| 3995 | public void keyguardGoingAway() { |
| 3996 | |
| 3997 | // Treat Keyguard exit animation as an app transition to achieve nice transition for status |
| 3998 | // bar. |
Adrian Roos | 46df1ca | 2015-09-11 12:38:43 -0700 | [diff] [blame] | 3999 | mKeyguardGoingAway = true; |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4000 | mIconController.appTransitionPending(); |
| 4001 | } |
| 4002 | |
| 4003 | /** |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4004 | * Notifies the status bar the Keyguard is fading away with the specified timings. |
| 4005 | * |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4006 | * @param startTime the start time of the animations in uptime millis |
| 4007 | * @param delay the precalculated animation delay in miliseconds |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4008 | * @param fadeoutDuration the duration of the exit animation, in milliseconds |
| 4009 | */ |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4010 | public void setKeyguardFadingAway(long startTime, long delay, long fadeoutDuration) { |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4011 | mKeyguardFadingAway = true; |
| 4012 | mKeyguardFadingAwayDelay = delay; |
| 4013 | mKeyguardFadingAwayDuration = fadeoutDuration; |
| 4014 | mWaitingForKeyguardExit = false; |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4015 | mIconController.appTransitionStarting( |
| 4016 | startTime + fadeoutDuration |
| 4017 | - StatusBarIconController.DEFAULT_TINT_ANIMATION_DURATION, |
| 4018 | StatusBarIconController.DEFAULT_TINT_ANIMATION_DURATION); |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 4019 | disable(mDisabledUnmodified1, mDisabledUnmodified2, fadeoutDuration > 0 /* animate */); |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4020 | } |
| 4021 | |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 4022 | public boolean isKeyguardFadingAway() { |
| 4023 | return mKeyguardFadingAway; |
| 4024 | } |
| 4025 | |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4026 | /** |
| 4027 | * Notifies that the Keyguard fading away animation is done. |
| 4028 | */ |
| 4029 | public void finishKeyguardFadingAway() { |
| 4030 | mKeyguardFadingAway = false; |
Adrian Roos | 46df1ca | 2015-09-11 12:38:43 -0700 | [diff] [blame] | 4031 | mKeyguardGoingAway = false; |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4032 | } |
| 4033 | |
Adrian Roos | d322f1a | 2015-04-23 15:19:45 -0700 | [diff] [blame] | 4034 | public void stopWaitingForKeyguardExit() { |
| 4035 | mWaitingForKeyguardExit = false; |
| 4036 | } |
| 4037 | |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 4038 | private void updatePublicMode() { |
Tony Mak | 92c989d | 2016-04-19 14:02:44 +0100 | [diff] [blame] | 4039 | boolean isPublic = false; |
| 4040 | if (mStatusBarKeyguardViewManager.isShowing()) { |
| 4041 | for (int i = mCurrentProfiles.size() - 1; i >= 0; i--) { |
| 4042 | UserInfo userInfo = mCurrentProfiles.valueAt(i); |
| 4043 | if (mStatusBarKeyguardViewManager.isSecure(userInfo.id)) { |
| 4044 | isPublic = true; |
| 4045 | break; |
| 4046 | } |
| 4047 | } |
| 4048 | } |
| 4049 | setLockscreenPublicMode(isPublic); |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 4050 | } |
| 4051 | |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 4052 | protected void updateKeyguardState(boolean goingToFullShade, boolean fromShadeLocked) { |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4053 | if (mState == StatusBarState.KEYGUARD) { |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4054 | mKeyguardIndicationController.setVisible(true); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 4055 | mNotificationPanel.resetViews(); |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 4056 | if (mKeyguardUserSwitcher != null) { |
| 4057 | mKeyguardUserSwitcher.setKeyguard(true, fromShadeLocked); |
| 4058 | } |
Selim Cinek | 80c2abe | 2015-06-17 15:37:30 -0700 | [diff] [blame] | 4059 | mStatusBarView.removePendingHideExpandedRunnables(); |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 4060 | } else { |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4061 | mKeyguardIndicationController.setVisible(false); |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 4062 | if (mKeyguardUserSwitcher != null) { |
| 4063 | mKeyguardUserSwitcher.setKeyguard(false, |
| 4064 | goingToFullShade || |
| 4065 | mState == StatusBarState.SHADE_LOCKED || |
| 4066 | fromShadeLocked); |
| 4067 | } |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 4068 | } |
Jorim Jaggi | 2042ef2 | 2014-05-13 21:55:18 +0200 | [diff] [blame] | 4069 | if (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) { |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 4070 | mScrimController.setKeyguardShowing(true); |
Jorim Jaggi | 2042ef2 | 2014-05-13 21:55:18 +0200 | [diff] [blame] | 4071 | } else { |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 4072 | mScrimController.setKeyguardShowing(false); |
Jorim Jaggi | 2042ef2 | 2014-05-13 21:55:18 +0200 | [diff] [blame] | 4073 | } |
Nicolas Prevot | 1dbbe7d | 2016-05-17 12:52:54 +0100 | [diff] [blame] | 4074 | mIconPolicy.notifyKeyguardShowingChanged(); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4075 | mNotificationPanel.setBarState(mState, mKeyguardFadingAway, goingToFullShade); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4076 | updateDozingState(); |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 4077 | updatePublicMode(); |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 4078 | updateStackScrollerState(goingToFullShade, fromShadeLocked); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 4079 | updateNotifications(); |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 4080 | checkBarModes(); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 4081 | updateMediaMetaData(false, mState != StatusBarState.KEYGUARD); |
John Spurlock | 657c62c | 2014-07-22 12:18:09 -0400 | [diff] [blame] | 4082 | mKeyguardMonitor.notifyKeyguardState(mStatusBarKeyguardViewManager.isShowing(), |
| 4083 | mStatusBarKeyguardViewManager.isSecure()); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4084 | } |
| 4085 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4086 | private void updateDozingState() { |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 4087 | boolean animate = !mDozing && mDozeScrimController.isPulsing(); |
| 4088 | mNotificationPanel.setDozing(mDozing, animate); |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4089 | mStackScroller.setDark(mDozing, animate, mWakeUpTouchLocation); |
Jorim Jaggi | 048af1f | 2014-11-11 22:51:10 +0100 | [diff] [blame] | 4090 | mScrimController.setDozing(mDozing); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 4091 | |
| 4092 | // Immediately abort the dozing from the doze scrim controller in case of wake-and-unlock |
| 4093 | // for pulsing so the Keyguard fade-out animation scrim can take over. |
| 4094 | mDozeScrimController.setDozing(mDozing && |
| 4095 | mFingerprintUnlockController.getMode() |
| 4096 | != FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING, animate); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4097 | } |
| 4098 | |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 4099 | public void updateStackScrollerState(boolean goingToFullShade, boolean fromShadeLocked) { |
John Spurlock | 4b3bda2 | 2014-05-22 14:32:20 -0400 | [diff] [blame] | 4100 | if (mStackScroller == null) return; |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 4101 | boolean onKeyguard = mState == StatusBarState.KEYGUARD; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 4102 | mStackScroller.setHideSensitive(isLockscreenPublicMode(), goingToFullShade); |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 4103 | mStackScroller.setDimmed(onKeyguard, fromShadeLocked /* animate */); |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 4104 | mStackScroller.setExpandingEnabled(!onKeyguard); |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 4105 | ActivatableNotificationView activatedChild = mStackScroller.getActivatedChild(); |
| 4106 | mStackScroller.setActivatedChild(null); |
| 4107 | if (activatedChild != null) { |
| 4108 | activatedChild.makeInactive(false /* animate */); |
| 4109 | } |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4110 | } |
| 4111 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4112 | public void userActivity() { |
Jorim Jaggi | b690f0d | 2014-07-03 23:25:44 +0200 | [diff] [blame] | 4113 | if (mState == StatusBarState.KEYGUARD) { |
| 4114 | mKeyguardViewMediatorCallback.userActivity(); |
| 4115 | } |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4116 | } |
| 4117 | |
Jorim Jaggi | df99351 | 2014-05-13 23:06:35 +0200 | [diff] [blame] | 4118 | public boolean interceptMediaKey(KeyEvent event) { |
| 4119 | return mState == StatusBarState.KEYGUARD |
| 4120 | && mStatusBarKeyguardViewManager.interceptMediaKey(event); |
| 4121 | } |
| 4122 | |
Jorim Jaggi | 8c8bcc1 | 2014-04-16 21:36:51 +0200 | [diff] [blame] | 4123 | public boolean onMenuPressed() { |
Selim Cinek | 2854019 | 2016-02-19 17:25:08 -0800 | [diff] [blame] | 4124 | if (mDeviceInteractive && mState != StatusBarState.SHADE |
| 4125 | && mStatusBarKeyguardViewManager.shouldDismissOnMenuPressed()) { |
| 4126 | animateCollapsePanels( |
| 4127 | CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL /* flags */, true /* force */); |
| 4128 | return true; |
| 4129 | } |
| 4130 | return false; |
Jorim Jaggi | 8c8bcc1 | 2014-04-16 21:36:51 +0200 | [diff] [blame] | 4131 | } |
| 4132 | |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4133 | public void endAffordanceLaunch() { |
| 4134 | releaseGestureWakeLock(); |
| 4135 | mNotificationPanel.onAffordanceLaunchEnded(); |
| 4136 | } |
| 4137 | |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 4138 | public boolean onBackPressed() { |
Adrian Roos | 0002a45 | 2014-07-03 13:46:07 +0200 | [diff] [blame] | 4139 | if (mStatusBarKeyguardViewManager.onBackPressed()) { |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 4140 | return true; |
| 4141 | } |
Adrian Roos | 0002a45 | 2014-07-03 13:46:07 +0200 | [diff] [blame] | 4142 | if (mNotificationPanel.isQsExpanded()) { |
John Spurlock | f7ae442 | 2014-08-01 12:45:18 -0400 | [diff] [blame] | 4143 | if (mNotificationPanel.isQsDetailShowing()) { |
| 4144 | mNotificationPanel.closeQsDetail(); |
| 4145 | } else { |
| 4146 | mNotificationPanel.animateCloseQs(); |
| 4147 | } |
Adrian Roos | 0002a45 | 2014-07-03 13:46:07 +0200 | [diff] [blame] | 4148 | return true; |
| 4149 | } |
| 4150 | if (mState != StatusBarState.KEYGUARD && mState != StatusBarState.SHADE_LOCKED) { |
| 4151 | animateCollapsePanels(); |
| 4152 | return true; |
| 4153 | } |
| 4154 | return false; |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 4155 | } |
| 4156 | |
Jorim Jaggi | 3425076 | 2014-07-03 23:51:19 +0200 | [diff] [blame] | 4157 | public boolean onSpacePressed() { |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 4158 | if (mDeviceInteractive && mState != StatusBarState.SHADE) { |
Jorim Jaggi | 4eedc1d | 2014-10-27 13:45:56 +0100 | [diff] [blame] | 4159 | animateCollapsePanels( |
| 4160 | CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL /* flags */, true /* force */); |
Jorim Jaggi | 3425076 | 2014-07-03 23:51:19 +0200 | [diff] [blame] | 4161 | return true; |
| 4162 | } |
| 4163 | return false; |
| 4164 | } |
| 4165 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4166 | private void showBouncer() { |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4167 | if (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) { |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 4168 | mWaitingForKeyguardExit = mStatusBarKeyguardViewManager.isShowing(); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4169 | mStatusBarKeyguardViewManager.dismiss(); |
| 4170 | } |
| 4171 | } |
| 4172 | |
| 4173 | private void instantExpandNotificationsPanel() { |
Jorim Jaggi | c357ca2 | 2014-04-25 14:56:15 +0200 | [diff] [blame] | 4174 | |
Jorim Jaggi | 0a27be8 | 2014-06-11 03:22:39 +0200 | [diff] [blame] | 4175 | // Make our window larger and the panel expanded. |
Jorim Jaggi | fa505a7 | 2014-04-28 20:04:11 +0200 | [diff] [blame] | 4176 | makeExpandedVisible(true); |
Oren Blasberg | 8d3fea1 | 2015-07-10 14:21:44 -0700 | [diff] [blame] | 4177 | mNotificationPanel.expand(false /* animate */); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 4178 | } |
Adrian Roos | 5a46cd3 | 2014-04-03 16:51:58 +0200 | [diff] [blame] | 4179 | |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 4180 | private void instantCollapseNotificationPanel() { |
Selim Cinek | 6bb4a9b | 2014-10-09 17:48:05 -0700 | [diff] [blame] | 4181 | mNotificationPanel.instantCollapse(); |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 4182 | } |
| 4183 | |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 4184 | @Override |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 4185 | public void onActivated(ActivatableNotificationView view) { |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 4186 | EventLogTags.writeSysuiLockscreenGesture( |
| 4187 | EventLogConstants.SYSUI_LOCKSCREEN_GESTURE_TAP_NOTIFICATION_ACTIVATE, |
| 4188 | 0 /* lengthDp - N/A */, 0 /* velocityDp - N/A */); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4189 | mKeyguardIndicationController.showTransientIndication(R.string.notification_tap_again); |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 4190 | ActivatableNotificationView previousView = mStackScroller.getActivatedChild(); |
| 4191 | if (previousView != null) { |
| 4192 | previousView.makeInactive(true /* animate */); |
| 4193 | } |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4194 | mStackScroller.setActivatedChild(view); |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 4195 | } |
| 4196 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4197 | /** |
| 4198 | * @param state The {@link StatusBarState} to set. |
| 4199 | */ |
| 4200 | public void setBarState(int state) { |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 4201 | // If we're visible and switched to SHADE_LOCKED (the user dragged |
| 4202 | // down on the lockscreen), clear notification LED, vibration, |
| 4203 | // ringing. |
| 4204 | // Other transitions are covered in handleVisibleToUserChanged(). |
Selim Cinek | 6577cae | 2015-08-31 16:15:49 -0700 | [diff] [blame] | 4205 | if (state != mState && mVisible && (state == StatusBarState.SHADE_LOCKED |
| 4206 | || (state == StatusBarState.SHADE && isGoingToNotificationShade()))) { |
| 4207 | clearNotificationEffects(); |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 4208 | } |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4209 | mState = state; |
Selim Cinek | 9c4c414 | 2015-12-04 16:44:56 -0800 | [diff] [blame] | 4210 | mGroupManager.setStatusBarState(state); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4211 | mFalsingManager.setStatusBarState(state); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4212 | mStatusBarWindowManager.setStatusBarState(state); |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 4213 | updateDozing(); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4214 | } |
| 4215 | |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 4216 | @Override |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 4217 | public void onActivationReset(ActivatableNotificationView view) { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4218 | if (view == mStackScroller.getActivatedChild()) { |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4219 | mKeyguardIndicationController.hideTransientIndication(); |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4220 | mStackScroller.setActivatedChild(null); |
| 4221 | } |
Jorim Jaggi | e70d31f | 2014-04-24 22:08:30 +0200 | [diff] [blame] | 4222 | } |
| 4223 | |
| 4224 | public void onTrackingStarted() { |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 4225 | runPostCollapseRunnables(); |
Jorim Jaggi | 9012958 | 2014-06-02 14:44:49 +0200 | [diff] [blame] | 4226 | } |
| 4227 | |
Selim Cinek | dbbcfbe | 2014-10-24 17:52:35 +0200 | [diff] [blame] | 4228 | public void onClosingFinished() { |
| 4229 | runPostCollapseRunnables(); |
| 4230 | } |
| 4231 | |
Jorim Jaggi | 9012958 | 2014-06-02 14:44:49 +0200 | [diff] [blame] | 4232 | public void onUnlockHintStarted() { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4233 | mFalsingManager.onUnlockHintStarted(); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4234 | mKeyguardIndicationController.showTransientIndication(R.string.keyguard_unlock); |
Jorim Jaggi | 9012958 | 2014-06-02 14:44:49 +0200 | [diff] [blame] | 4235 | } |
| 4236 | |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 4237 | public void onHintFinished() { |
Jorim Jaggi | 93a2bb2 | 2014-06-02 19:57:28 +0200 | [diff] [blame] | 4238 | // Delay the reset a bit so the user can read the text. |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4239 | mKeyguardIndicationController.hideTransientIndicationDelayed(HINT_RESET_DELAY_MS); |
Jorim Jaggi | e70d31f | 2014-04-24 22:08:30 +0200 | [diff] [blame] | 4240 | } |
| 4241 | |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 4242 | public void onCameraHintStarted() { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4243 | mFalsingManager.onCameraHintStarted(); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4244 | mKeyguardIndicationController.showTransientIndication(R.string.camera_hint); |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 4245 | } |
| 4246 | |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 4247 | public void onVoiceAssistHintStarted() { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4248 | mFalsingManager.onLeftAffordanceHintStarted(); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 4249 | mKeyguardIndicationController.showTransientIndication(R.string.voice_hint); |
| 4250 | } |
| 4251 | |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 4252 | public void onPhoneHintStarted() { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4253 | mFalsingManager.onLeftAffordanceHintStarted(); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4254 | mKeyguardIndicationController.showTransientIndication(R.string.phone_hint); |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 4255 | } |
| 4256 | |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 4257 | public void onTrackingStopped(boolean expand) { |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 4258 | if (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) { |
Selim Cinek | e8bae62 | 2015-07-15 13:24:06 -0700 | [diff] [blame] | 4259 | if (!expand && !mUnlockMethodCache.canSkipBouncer()) { |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 4260 | showBouncer(); |
| 4261 | } |
| 4262 | } |
Jorim Jaggi | e70d31f | 2014-04-24 22:08:30 +0200 | [diff] [blame] | 4263 | } |
| 4264 | |
| 4265 | @Override |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 4266 | protected int getMaxKeyguardNotifications(boolean recompute) { |
| 4267 | if (recompute) { |
| 4268 | mMaxKeyguardNotifications = Math.max(1, |
| 4269 | mNotificationPanel.computeMaxKeyguardNotifications( |
| 4270 | mMaxAllowedKeyguardNotifications)); |
| 4271 | return mMaxKeyguardNotifications; |
| 4272 | } |
| 4273 | return mMaxKeyguardNotifications; |
| 4274 | } |
| 4275 | |
| 4276 | public int getMaxKeyguardNotifications() { |
| 4277 | return getMaxKeyguardNotifications(false /* recompute */); |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 4278 | } |
| 4279 | |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 4280 | public NavigationBarView getNavigationBarView() { |
| 4281 | return mNavigationBarView; |
| 4282 | } |
| 4283 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4284 | // ---------------------- DragDownHelper.OnDragDownListener ------------------------------------ |
| 4285 | |
| 4286 | @Override |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 4287 | public boolean onDraggedDown(View startingChild, int dragLengthY) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 4288 | if (hasActiveNotifications()) { |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 4289 | EventLogTags.writeSysuiLockscreenGesture( |
| 4290 | EventLogConstants.SYSUI_LOCKSCREEN_GESTURE_SWIPE_DOWN_FULL_SHADE, |
| 4291 | (int) (dragLengthY / mDisplayMetrics.density), |
| 4292 | 0 /* velocityDp - N/A */); |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 4293 | |
| 4294 | // We have notifications, go to locked shade. |
| 4295 | goToLockedShade(startingChild); |
| 4296 | return true; |
| 4297 | } else { |
| 4298 | |
| 4299 | // No notifications - abort gesture. |
| 4300 | return false; |
| 4301 | } |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4302 | } |
| 4303 | |
| 4304 | @Override |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4305 | public void onDragDownReset() { |
| 4306 | mStackScroller.setDimmed(true /* dimmed */, true /* animated */); |
Selim Cinek | 177fd43 | 2015-11-18 11:53:47 -0800 | [diff] [blame] | 4307 | mStackScroller.resetScrollPosition(); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4308 | } |
| 4309 | |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 4310 | @Override |
Selim Cinek | 177fd43 | 2015-11-18 11:53:47 -0800 | [diff] [blame] | 4311 | public void onCrossedThreshold(boolean above) { |
| 4312 | mStackScroller.setDimmed(!above /* dimmed */, true /* animate */); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4313 | } |
| 4314 | |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 4315 | @Override |
| 4316 | public void onTouchSlopExceeded() { |
| 4317 | mStackScroller.removeLongPressCallback(); |
| 4318 | } |
| 4319 | |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 4320 | @Override |
| 4321 | public void setEmptyDragAmount(float amount) { |
| 4322 | mNotificationPanel.setEmptyDragAmount(amount); |
| 4323 | } |
| 4324 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4325 | /** |
| 4326 | * If secure with redaction: Show bouncer, go to unlocked shade. |
| 4327 | * |
Jorim Jaggi | 2042ef2 | 2014-05-13 21:55:18 +0200 | [diff] [blame] | 4328 | * <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] | 4329 | * |
| 4330 | * @param expandView The view to expand after going to the shade. |
| 4331 | */ |
| 4332 | public void goToLockedShade(View expandView) { |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4333 | ExpandableNotificationRow row = null; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4334 | if (expandView instanceof ExpandableNotificationRow) { |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4335 | row = (ExpandableNotificationRow) expandView; |
Selim Cinek | cb24ab8 | 2016-02-25 12:49:08 -0800 | [diff] [blame] | 4336 | row.setUserExpanded(true /* userExpanded */, true /* allowChildExpansion */); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4337 | } |
Adrian Roos | aee7046 | 2014-09-03 16:27:39 +0200 | [diff] [blame] | 4338 | boolean fullShadeNeedsBouncer = !userAllowsPrivateNotificationsInPublic(mCurrentUserId) |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4339 | || !mShowLockscreenNotifications || mFalsingManager.shouldEnforceBouncer(); |
Adrian Roos | aee7046 | 2014-09-03 16:27:39 +0200 | [diff] [blame] | 4340 | if (isLockscreenPublicMode() && fullShadeNeedsBouncer) { |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4341 | mLeaveOpenOnKeyguardHide = true; |
| 4342 | showBouncer(); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4343 | mDraggedDownRow = row; |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 4344 | mPendingRemoteInputView = null; |
Jorim Jaggi | 2042ef2 | 2014-05-13 21:55:18 +0200 | [diff] [blame] | 4345 | } else { |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4346 | mNotificationPanel.animateToFullShade(0 /* delay */); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4347 | setBarState(StatusBarState.SHADE_LOCKED); |
Jorim Jaggi | 98f8530 | 2014-08-07 17:45:04 +0200 | [diff] [blame] | 4348 | updateKeyguardState(false /* goingToFullShade */, false /* fromShadeLocked */); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4349 | } |
| 4350 | } |
| 4351 | |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 4352 | @Override |
Mady Mellor | 8e8a69e | 2016-03-14 12:30:10 -0700 | [diff] [blame] | 4353 | public void onLockedNotificationImportanceChange(OnDismissAction dismissAction) { |
| 4354 | mLeaveOpenOnKeyguardHide = true; |
| 4355 | dismissKeyguardThenExecute(dismissAction, true /* afterKeyguardGone */); |
| 4356 | } |
| 4357 | |
| 4358 | @Override |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 4359 | protected void onLockedRemoteInput(ExpandableNotificationRow row, View clicked) { |
| 4360 | mLeaveOpenOnKeyguardHide = true; |
| 4361 | showBouncer(); |
| 4362 | mPendingRemoteInputView = clicked; |
| 4363 | } |
| 4364 | |
| 4365 | @Override |
Ricky Wai | cd35def | 2016-05-03 11:07:07 +0100 | [diff] [blame] | 4366 | protected boolean startWorkChallengeIfNecessary(int userId, IntentSender intendSender, |
| 4367 | String notificationKey) { |
| 4368 | // Clear pending remote view, as we do not want to trigger pending remote input view when |
| 4369 | // it's called by other code |
| 4370 | mPendingWorkRemoteInputView = null; |
| 4371 | return super.startWorkChallengeIfNecessary(userId, intendSender, notificationKey); |
| 4372 | } |
| 4373 | |
| 4374 | @Override |
| 4375 | protected void onLockedWorkRemoteInput(int userId, ExpandableNotificationRow row, |
| 4376 | View clicked) { |
| 4377 | // Collapse notification and show work challenge |
| 4378 | animateCollapsePanels(); |
| 4379 | startWorkChallengeIfNecessary(userId, null, null); |
| 4380 | // Add pending remote input view after starting work challenge, as starting work challenge |
| 4381 | // will clear all previous pending review view |
| 4382 | mPendingWorkRemoteInputView = clicked; |
| 4383 | } |
| 4384 | |
| 4385 | @Override |
| 4386 | protected void onWorkChallengeUnlocked() { |
| 4387 | if (mPendingWorkRemoteInputView != null) { |
| 4388 | final View pendingWorkRemoteInputView = mPendingWorkRemoteInputView; |
| 4389 | // Expand notification panel and the notification row, then click on remote input view |
| 4390 | final Runnable clickPendingViewRunnable = new Runnable() { |
| 4391 | @Override |
| 4392 | public void run() { |
| 4393 | if (mPendingWorkRemoteInputView != null) { |
| 4394 | final View pendingWorkRemoteInputView = mPendingWorkRemoteInputView; |
| 4395 | ViewParent p = pendingWorkRemoteInputView.getParent(); |
| 4396 | while (p != null) { |
| 4397 | if (p instanceof ExpandableNotificationRow) { |
| 4398 | final ExpandableNotificationRow row = (ExpandableNotificationRow) p; |
| 4399 | ViewParent viewParent = row.getParent(); |
| 4400 | if (viewParent instanceof NotificationStackScrollLayout) { |
| 4401 | final NotificationStackScrollLayout scrollLayout = |
| 4402 | (NotificationStackScrollLayout) viewParent; |
| 4403 | row.makeActionsVisibile(); |
| 4404 | row.post(new Runnable() { |
| 4405 | @Override |
| 4406 | public void run() { |
| 4407 | final Runnable finishScrollingCallback = new Runnable() |
| 4408 | { |
| 4409 | @Override |
| 4410 | public void run() { |
| 4411 | mPendingWorkRemoteInputView.callOnClick(); |
| 4412 | mPendingWorkRemoteInputView = null; |
| 4413 | scrollLayout.setFinishScrollingCallback(null); |
| 4414 | } |
| 4415 | }; |
| 4416 | if (scrollLayout.scrollTo(row)) { |
| 4417 | // It scrolls! So call it when it's finished. |
| 4418 | scrollLayout.setFinishScrollingCallback( |
| 4419 | finishScrollingCallback); |
| 4420 | } else { |
| 4421 | // It does not scroll, so call it now! |
| 4422 | finishScrollingCallback.run(); |
| 4423 | } |
| 4424 | } |
| 4425 | }); |
| 4426 | } |
| 4427 | break; |
| 4428 | } |
| 4429 | p = p.getParent(); |
| 4430 | } |
| 4431 | } |
| 4432 | } |
| 4433 | }; |
| 4434 | mNotificationPanel.getViewTreeObserver().addOnGlobalLayoutListener( |
| 4435 | new ViewTreeObserver.OnGlobalLayoutListener() { |
| 4436 | @Override |
| 4437 | public void onGlobalLayout() { |
| 4438 | if (mNotificationPanel.mStatusBar.getStatusBarWindow() |
| 4439 | .getHeight() != mNotificationPanel.mStatusBar |
| 4440 | .getStatusBarHeight()) { |
| 4441 | mNotificationPanel.getViewTreeObserver() |
| 4442 | .removeOnGlobalLayoutListener(this); |
| 4443 | mNotificationPanel.post(clickPendingViewRunnable); |
| 4444 | } |
| 4445 | } |
| 4446 | }); |
| 4447 | instantExpandNotificationsPanel(); |
| 4448 | } |
| 4449 | } |
| 4450 | |
| 4451 | @Override |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 4452 | public void onExpandClicked(Entry clickedEntry, boolean nowExpanded) { |
| 4453 | mHeadsUpManager.setExpanded(clickedEntry, nowExpanded); |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 4454 | if (mState == StatusBarState.KEYGUARD && nowExpanded) { |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 4455 | goToLockedShade(clickedEntry.row); |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 4456 | } |
| 4457 | } |
| 4458 | |
Adrian Roos | 5a46cd3 | 2014-04-03 16:51:58 +0200 | [diff] [blame] | 4459 | /** |
Jorim Jaggi | 6539a83 | 2014-06-03 23:33:09 +0200 | [diff] [blame] | 4460 | * Goes back to the keyguard after hanging around in {@link StatusBarState#SHADE_LOCKED}. |
| 4461 | */ |
| 4462 | public void goToKeyguard() { |
| 4463 | if (mState == StatusBarState.SHADE_LOCKED) { |
Selim Cinek | d9acca5 | 2014-09-01 22:33:25 +0200 | [diff] [blame] | 4464 | mStackScroller.onGoToKeyguard(); |
Jorim Jaggi | 6539a83 | 2014-06-03 23:33:09 +0200 | [diff] [blame] | 4465 | setBarState(StatusBarState.KEYGUARD); |
Jorim Jaggi | 98f8530 | 2014-08-07 17:45:04 +0200 | [diff] [blame] | 4466 | updateKeyguardState(false /* goingToFullShade */, true /* fromShadeLocked*/); |
Jorim Jaggi | 6539a83 | 2014-06-03 23:33:09 +0200 | [diff] [blame] | 4467 | } |
| 4468 | } |
| 4469 | |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4470 | public long getKeyguardFadingAwayDelay() { |
| 4471 | return mKeyguardFadingAwayDelay; |
| 4472 | } |
| 4473 | |
| 4474 | public long getKeyguardFadingAwayDuration() { |
| 4475 | return mKeyguardFadingAwayDuration; |
| 4476 | } |
| 4477 | |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4478 | @Override |
| 4479 | public void setBouncerShowing(boolean bouncerShowing) { |
| 4480 | super.setBouncerShowing(bouncerShowing); |
Adrian Roos | d0b2f7d | 2015-04-29 13:36:12 -0700 | [diff] [blame] | 4481 | mStatusBarView.setBouncerShowing(bouncerShowing); |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 4482 | disable(mDisabledUnmodified1, mDisabledUnmodified2, true /* animate */); |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4483 | } |
| 4484 | |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4485 | public void onStartedGoingToSleep() { |
| 4486 | mStartedGoingToSleep = true; |
| 4487 | } |
| 4488 | |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4489 | public void onFinishedGoingToSleep() { |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4490 | mNotificationPanel.onAffordanceLaunchEnded(); |
| 4491 | releaseGestureWakeLock(); |
| 4492 | mLaunchCameraOnScreenTurningOn = false; |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4493 | mStartedGoingToSleep = false; |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4494 | mDeviceInteractive = false; |
| 4495 | mWakeUpComingFromTouch = false; |
| 4496 | mWakeUpTouchLocation = null; |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 4497 | mStackScroller.setAnimationsEnabled(false); |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 4498 | updateVisibleToUser(); |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4499 | if (mLaunchCameraOnFinishedGoingToSleep) { |
| 4500 | mLaunchCameraOnFinishedGoingToSleep = false; |
| 4501 | |
| 4502 | // This gets executed before we will show Keyguard, so post it in order that the state |
| 4503 | // is correct. |
| 4504 | mHandler.post(new Runnable() { |
| 4505 | @Override |
| 4506 | public void run() { |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 4507 | onCameraLaunchGestureDetected(mLastCameraLaunchSource); |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4508 | } |
| 4509 | }); |
| 4510 | } |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 4511 | } |
| 4512 | |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4513 | public void onStartedWakingUp() { |
| 4514 | mDeviceInteractive = true; |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 4515 | mStackScroller.setAnimationsEnabled(true); |
Jorim Jaggi | d41083a | 2014-09-12 02:54:40 +0200 | [diff] [blame] | 4516 | mNotificationPanel.setTouchDisabled(false); |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 4517 | updateVisibleToUser(); |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 4518 | } |
John Spurlock | d08f91f | 2014-05-23 11:00:34 -0400 | [diff] [blame] | 4519 | |
Jorim Jaggi | 9373911 | 2015-08-13 15:53:14 -0700 | [diff] [blame] | 4520 | public void onScreenTurningOn() { |
Selim Cinek | 1b6f819 | 2015-09-03 16:01:53 -0700 | [diff] [blame] | 4521 | mScreenTurningOn = true; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4522 | mFalsingManager.onScreenTurningOn(); |
Jorim Jaggi | 9373911 | 2015-08-13 15:53:14 -0700 | [diff] [blame] | 4523 | mNotificationPanel.onScreenTurningOn(); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4524 | if (mLaunchCameraOnScreenTurningOn) { |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 4525 | mNotificationPanel.launchCamera(false, mLastCameraLaunchSource); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4526 | mLaunchCameraOnScreenTurningOn = false; |
| 4527 | } |
Jorim Jaggi | 9373911 | 2015-08-13 15:53:14 -0700 | [diff] [blame] | 4528 | } |
| 4529 | |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 4530 | private void vibrateForCameraGesture() { |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4531 | // Make sure to pass -1 for repeat so VibratorService doesn't stop us when going to sleep. |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 4532 | mVibrator.vibrate(new long[]{0, 750L}, -1 /* repeat */); |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 4533 | } |
| 4534 | |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4535 | public void onScreenTurnedOn() { |
Selim Cinek | 1b6f819 | 2015-09-03 16:01:53 -0700 | [diff] [blame] | 4536 | mScreenTurningOn = false; |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4537 | mDozeScrimController.onScreenTurnedOn(); |
| 4538 | } |
| 4539 | |
Jason Monk | 815e057 | 2014-08-12 17:26:36 -0400 | [diff] [blame] | 4540 | /** |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 4541 | * Handles long press for back button. This exits screen pinning. |
Jason Monk | 815e057 | 2014-08-12 17:26:36 -0400 | [diff] [blame] | 4542 | */ |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 4543 | private boolean handleLongPressBack() { |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 4544 | try { |
| 4545 | IActivityManager activityManager = ActivityManagerNative.getDefault(); |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 4546 | if (activityManager.isInLockTaskMode()) { |
Andrii Kulian | 0f051f5 | 2016-04-14 00:41:51 -0700 | [diff] [blame] | 4547 | activityManager.stopSystemLockTaskMode(); |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 4548 | |
| 4549 | // When exiting refresh disabled flags. |
| 4550 | mNavigationBarView.setDisabledFlags(mDisabled1, true); |
| 4551 | return true; |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 4552 | } |
| 4553 | } catch (RemoteException e) { |
Jason Monk | 815e057 | 2014-08-12 17:26:36 -0400 | [diff] [blame] | 4554 | Log.d(TAG, "Unable to reach activity manager", e); |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 4555 | } |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 4556 | return false; |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 4557 | } |
| 4558 | |
Winson | 3e7e3aa | 2015-09-22 14:22:58 -0700 | [diff] [blame] | 4559 | public void updateRecentsVisibility(boolean visible) { |
Winson Chung | 9214eff | 2014-06-12 13:59:25 -0700 | [diff] [blame] | 4560 | // Update the recents visibility flag |
| 4561 | if (visible) { |
| 4562 | mSystemUiVisibility |= View.RECENT_APPS_VISIBLE; |
| 4563 | } else { |
| 4564 | mSystemUiVisibility &= ~View.RECENT_APPS_VISIBLE; |
| 4565 | } |
| 4566 | notifyUiVisibilityChanged(mSystemUiVisibility); |
| 4567 | } |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4568 | |
Jason Monk | 5565cb4 | 2014-09-12 10:59:21 -0400 | [diff] [blame] | 4569 | @Override |
Andrii Kulian | 0f051f5 | 2016-04-14 00:41:51 -0700 | [diff] [blame] | 4570 | public void showScreenPinningRequest(int taskId) { |
Jason Monk | 18f99d9 | 2014-09-11 13:36:42 -0400 | [diff] [blame] | 4571 | if (mKeyguardMonitor.isShowing()) { |
| 4572 | // Don't allow apps to trigger this from keyguard. |
| 4573 | return; |
| 4574 | } |
| 4575 | // 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] | 4576 | showScreenPinningRequest(taskId, true); |
Jason Monk | 18f99d9 | 2014-09-11 13:36:42 -0400 | [diff] [blame] | 4577 | } |
| 4578 | |
Andrii Kulian | 0f051f5 | 2016-04-14 00:41:51 -0700 | [diff] [blame] | 4579 | public void showScreenPinningRequest(int taskId, boolean allowCancel) { |
| 4580 | mScreenPinningRequest.showPrompt(taskId, allowCancel); |
Jason Monk | 5565cb4 | 2014-09-12 10:59:21 -0400 | [diff] [blame] | 4581 | } |
| 4582 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 4583 | public boolean hasActiveNotifications() { |
| 4584 | return !mNotificationData.getActiveNotifications().isEmpty(); |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 4585 | } |
| 4586 | |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 4587 | public void wakeUpIfDozing(long time, MotionEvent event) { |
Jorim Jaggi | 048af1f | 2014-11-11 22:51:10 +0100 | [diff] [blame] | 4588 | if (mDozing && mDozeScrimController.isPulsing()) { |
John Spurlock | 8b12f22 | 2014-09-09 11:54:11 -0400 | [diff] [blame] | 4589 | PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); |
Dianne Hackborn | 280a64e | 2015-07-13 14:48:08 -0700 | [diff] [blame] | 4590 | pm.wakeUp(time, "com.android.systemui:NODOZE"); |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4591 | mWakeUpComingFromTouch = true; |
| 4592 | mWakeUpTouchLocation = new PointF(event.getX(), event.getY()); |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 4593 | mNotificationPanel.setTouchDisabled(false); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 4594 | mStatusBarKeyguardViewManager.notifyDeviceWakeUpRequested(); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4595 | mFalsingManager.onScreenOnFromTouch(); |
John Spurlock | 8b12f22 | 2014-09-09 11:54:11 -0400 | [diff] [blame] | 4596 | } |
| 4597 | } |
| 4598 | |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 4599 | @Override |
| 4600 | public void appTransitionPending() { |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4601 | |
| 4602 | // Use own timings when Keyguard is going away, see keyguardGoingAway and |
| 4603 | // setKeyguardFadingAway |
| 4604 | if (!mKeyguardFadingAway) { |
| 4605 | mIconController.appTransitionPending(); |
| 4606 | } |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 4607 | } |
| 4608 | |
| 4609 | @Override |
| 4610 | public void appTransitionCancelled() { |
| 4611 | mIconController.appTransitionCancelled(); |
Jorim Jaggi | 2adba07 | 2016-03-03 13:43:39 +0100 | [diff] [blame] | 4612 | EventBus.getDefault().send(new AppTransitionFinishedEvent()); |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 4613 | } |
| 4614 | |
| 4615 | @Override |
| 4616 | public void appTransitionStarting(long startTime, long duration) { |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4617 | |
| 4618 | // Use own timings when Keyguard is going away, see keyguardGoingAway and |
Adrian Roos | 46df1ca | 2015-09-11 12:38:43 -0700 | [diff] [blame] | 4619 | // setKeyguardFadingAway. |
| 4620 | if (!mKeyguardGoingAway) { |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4621 | mIconController.appTransitionStarting(startTime, duration); |
| 4622 | } |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 4623 | if (mIconPolicy != null) { |
| 4624 | mIconPolicy.appTransitionStarting(startTime, duration); |
| 4625 | } |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 4626 | } |
| 4627 | |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4628 | @Override |
Jorim Jaggi | 2adba07 | 2016-03-03 13:43:39 +0100 | [diff] [blame] | 4629 | public void appTransitionFinished() { |
| 4630 | EventBus.getDefault().send(new AppTransitionFinishedEvent()); |
| 4631 | } |
| 4632 | |
| 4633 | @Override |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 4634 | public void onCameraLaunchGestureDetected(int source) { |
| 4635 | mLastCameraLaunchSource = source; |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4636 | if (mStartedGoingToSleep) { |
| 4637 | mLaunchCameraOnFinishedGoingToSleep = true; |
| 4638 | return; |
| 4639 | } |
Zhentao Sun | 04f9740 | 2015-08-26 17:37:30 -0700 | [diff] [blame] | 4640 | if (!mNotificationPanel.canCameraGestureBeLaunched( |
| 4641 | mStatusBarKeyguardViewManager.isShowing() && mExpandedVisible)) { |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4642 | return; |
| 4643 | } |
| 4644 | if (!mDeviceInteractive) { |
| 4645 | PowerManager pm = mContext.getSystemService(PowerManager.class); |
| 4646 | pm.wakeUp(SystemClock.uptimeMillis(), "com.android.systemui:CAMERA_GESTURE"); |
| 4647 | mStatusBarKeyguardViewManager.notifyDeviceWakeUpRequested(); |
| 4648 | } |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 4649 | vibrateForCameraGesture(); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4650 | if (!mStatusBarKeyguardViewManager.isShowing()) { |
| 4651 | startActivity(KeyguardBottomAreaView.INSECURE_CAMERA_INTENT, |
| 4652 | true /* dismissShade */); |
| 4653 | } else { |
| 4654 | if (!mDeviceInteractive) { |
| 4655 | // Avoid flickering of the scrim when we instant launch the camera and the bouncer |
| 4656 | // comes on. |
| 4657 | mScrimController.dontAnimateBouncerChangesUntilNextFrame(); |
| 4658 | mGestureWakeLock.acquire(LAUNCH_TRANSITION_TIMEOUT_MS + 1000L); |
| 4659 | } |
Selim Cinek | 1b6f819 | 2015-09-03 16:01:53 -0700 | [diff] [blame] | 4660 | if (mScreenTurningOn || mStatusBarKeyguardViewManager.isScreenTurnedOn()) { |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 4661 | mNotificationPanel.launchCamera(mDeviceInteractive /* animate */, source); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4662 | } else { |
| 4663 | // We need to defer the camera launch until the screen comes on, since otherwise |
| 4664 | // we will dismiss us too early since we are waiting on an activity to be drawn and |
| 4665 | // incorrectly get notified because of the screen on event (which resumes and pauses |
| 4666 | // some activities) |
| 4667 | mLaunchCameraOnScreenTurningOn = true; |
| 4668 | } |
| 4669 | } |
| 4670 | } |
| 4671 | |
Jaewan Kim | c552b04 | 2016-01-18 16:08:45 +0900 | [diff] [blame] | 4672 | @Override |
Jaewan Kim | f0fd218 | 2016-04-20 21:17:58 +0900 | [diff] [blame] | 4673 | public void showTvPictureInPictureMenu() { |
Jaewan Kim | c552b04 | 2016-01-18 16:08:45 +0900 | [diff] [blame] | 4674 | // no-op. |
| 4675 | } |
| 4676 | |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 4677 | public void notifyFpAuthModeChanged() { |
| 4678 | updateDozing(); |
| 4679 | } |
| 4680 | |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 4681 | private void updateDozing() { |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 4682 | // When in wake-and-unlock while pulsing, keep dozing state until fully unlocked. |
| 4683 | mDozing = mDozingRequested && mState == StatusBarState.KEYGUARD |
| 4684 | || mFingerprintUnlockController.getMode() |
| 4685 | == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING; |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 4686 | updateDozingState(); |
| 4687 | } |
| 4688 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4689 | private final class ShadeUpdates { |
| 4690 | private final ArraySet<String> mVisibleNotifications = new ArraySet<String>(); |
| 4691 | private final ArraySet<String> mNewVisibleNotifications = new ArraySet<String>(); |
| 4692 | |
| 4693 | public void check() { |
| 4694 | mNewVisibleNotifications.clear(); |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 4695 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
| 4696 | for (int i = 0; i < activeNotifications.size(); i++) { |
| 4697 | final Entry entry = activeNotifications.get(i); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4698 | final boolean visible = entry.row != null |
| 4699 | && entry.row.getVisibility() == View.VISIBLE; |
| 4700 | if (visible) { |
| 4701 | mNewVisibleNotifications.add(entry.key + entry.notification.getPostTime()); |
| 4702 | } |
| 4703 | } |
| 4704 | final boolean updates = !mVisibleNotifications.containsAll(mNewVisibleNotifications); |
| 4705 | mVisibleNotifications.clear(); |
Dianne Hackborn | 497175b | 2014-07-01 12:56:08 -0700 | [diff] [blame] | 4706 | mVisibleNotifications.addAll(mNewVisibleNotifications); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4707 | |
| 4708 | // We have new notifications |
| 4709 | if (updates && mDozeServiceHost != null) { |
| 4710 | mDozeServiceHost.fireNewNotifications(); |
| 4711 | } |
| 4712 | } |
| 4713 | } |
| 4714 | |
Jorim Jaggi | 007f0e8 | 2015-08-14 13:56:01 -0700 | [diff] [blame] | 4715 | private final class DozeServiceHost extends KeyguardUpdateMonitorCallback implements DozeHost { |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4716 | // Amount of time to allow to update the time shown on the screen before releasing |
| 4717 | // the wakelock. This timeout is design to compensate for the fact that we don't |
| 4718 | // currently have a way to know when time display contents have actually been |
| 4719 | // refreshed once we've finished rendering a new frame. |
| 4720 | private static final long PROCESSING_TIME = 500; |
| 4721 | |
| 4722 | private final ArrayList<Callback> mCallbacks = new ArrayList<Callback>(); |
| 4723 | private final H mHandler = new H(); |
| 4724 | |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 4725 | // Keeps the last reported state by fireNotificationLight. |
| 4726 | private boolean mNotificationLightOn; |
| 4727 | |
John Spurlock | c6eed84 | 2014-08-25 12:19:41 -0400 | [diff] [blame] | 4728 | @Override |
| 4729 | public String toString() { |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 4730 | return "PSB.DozeServiceHost[mCallbacks=" + mCallbacks.size() + "]"; |
John Spurlock | 8b12f22 | 2014-09-09 11:54:11 -0400 | [diff] [blame] | 4731 | } |
| 4732 | |
John Spurlock | d96179e | 2014-08-21 16:43:45 -0400 | [diff] [blame] | 4733 | public void firePowerSaveChanged(boolean active) { |
| 4734 | for (Callback callback : mCallbacks) { |
| 4735 | callback.onPowerSaveChanged(active); |
| 4736 | } |
| 4737 | } |
| 4738 | |
John Spurlock | cad5768 | 2014-07-26 17:09:56 -0400 | [diff] [blame] | 4739 | public void fireBuzzBeepBlinked() { |
| 4740 | for (Callback callback : mCallbacks) { |
| 4741 | callback.onBuzzBeepBlinked(); |
| 4742 | } |
| 4743 | } |
| 4744 | |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 4745 | public void fireNotificationLight(boolean on) { |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 4746 | mNotificationLightOn = on; |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 4747 | for (Callback callback : mCallbacks) { |
| 4748 | callback.onNotificationLight(on); |
| 4749 | } |
| 4750 | } |
| 4751 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4752 | public void fireNewNotifications() { |
| 4753 | for (Callback callback : mCallbacks) { |
| 4754 | callback.onNewNotifications(); |
| 4755 | } |
| 4756 | } |
| 4757 | |
| 4758 | @Override |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 4759 | public void addCallback(@NonNull Callback callback) { |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4760 | mCallbacks.add(callback); |
| 4761 | } |
| 4762 | |
| 4763 | @Override |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 4764 | public void removeCallback(@NonNull Callback callback) { |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4765 | mCallbacks.remove(callback); |
| 4766 | } |
| 4767 | |
| 4768 | @Override |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 4769 | public void startDozing(@NonNull Runnable ready) { |
| 4770 | mHandler.obtainMessage(H.MSG_START_DOZING, ready).sendToTarget(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4771 | } |
| 4772 | |
| 4773 | @Override |
John Spurlock | eab28e6 | 2014-11-29 11:33:49 -0500 | [diff] [blame] | 4774 | public void pulseWhileDozing(@NonNull PulseCallback callback, int reason) { |
| 4775 | mHandler.obtainMessage(H.MSG_PULSE_WHILE_DOZING, reason, 0, callback).sendToTarget(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4776 | } |
| 4777 | |
| 4778 | @Override |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 4779 | public void stopDozing() { |
| 4780 | mHandler.obtainMessage(H.MSG_STOP_DOZING).sendToTarget(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4781 | } |
| 4782 | |
John Spurlock | d96179e | 2014-08-21 16:43:45 -0400 | [diff] [blame] | 4783 | @Override |
| 4784 | public boolean isPowerSaveActive() { |
| 4785 | return mBatteryController != null && mBatteryController.isPowerSave(); |
| 4786 | } |
| 4787 | |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 4788 | @Override |
Jorim Jaggi | 007f0e8 | 2015-08-14 13:56:01 -0700 | [diff] [blame] | 4789 | public boolean isPulsingBlocked() { |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 4790 | return mFingerprintUnlockController.getMode() |
| 4791 | == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK; |
Jorim Jaggi | 007f0e8 | 2015-08-14 13:56:01 -0700 | [diff] [blame] | 4792 | } |
| 4793 | |
| 4794 | @Override |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 4795 | public boolean isNotificationLightOn() { |
| 4796 | return mNotificationLightOn; |
| 4797 | } |
| 4798 | |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 4799 | private void handleStartDozing(@NonNull Runnable ready) { |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 4800 | if (!mDozingRequested) { |
| 4801 | mDozingRequested = true; |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 4802 | DozeLog.traceDozing(mContext, mDozing); |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 4803 | updateDozing(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4804 | } |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 4805 | ready.run(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4806 | } |
| 4807 | |
John Spurlock | eab28e6 | 2014-11-29 11:33:49 -0500 | [diff] [blame] | 4808 | private void handlePulseWhileDozing(@NonNull PulseCallback callback, int reason) { |
Selim Cinek | cd5b22f | 2016-03-08 16:15:41 -0800 | [diff] [blame] | 4809 | mDozeScrimController.pulse(new PulseCallback() { |
| 4810 | |
| 4811 | @Override |
| 4812 | public void onPulseStarted() { |
| 4813 | callback.onPulseStarted(); |
| 4814 | mStackScroller.setPulsing(true); |
| 4815 | } |
| 4816 | |
| 4817 | @Override |
| 4818 | public void onPulseFinished() { |
| 4819 | callback.onPulseFinished(); |
| 4820 | mStackScroller.setPulsing(false); |
| 4821 | } |
| 4822 | }, reason); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4823 | } |
| 4824 | |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 4825 | private void handleStopDozing() { |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 4826 | if (mDozingRequested) { |
| 4827 | mDozingRequested = false; |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 4828 | DozeLog.traceDozing(mContext, mDozing); |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 4829 | updateDozing(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4830 | } |
| 4831 | } |
| 4832 | |
| 4833 | private final class H extends Handler { |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 4834 | private static final int MSG_START_DOZING = 1; |
| 4835 | private static final int MSG_PULSE_WHILE_DOZING = 2; |
| 4836 | private static final int MSG_STOP_DOZING = 3; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4837 | |
| 4838 | @Override |
| 4839 | public void handleMessage(Message msg) { |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 4840 | switch (msg.what) { |
| 4841 | case MSG_START_DOZING: |
| 4842 | handleStartDozing((Runnable) msg.obj); |
| 4843 | break; |
| 4844 | case MSG_PULSE_WHILE_DOZING: |
John Spurlock | eab28e6 | 2014-11-29 11:33:49 -0500 | [diff] [blame] | 4845 | handlePulseWhileDozing((PulseCallback) msg.obj, msg.arg1); |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 4846 | break; |
| 4847 | case MSG_STOP_DOZING: |
| 4848 | handleStopDozing(); |
| 4849 | break; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4850 | } |
| 4851 | } |
| 4852 | } |
| 4853 | } |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 4854 | } |