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; |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 35 | import android.content.pm.IPackageManager; |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 36 | import android.content.pm.PackageManager; |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 37 | import android.content.res.Configuration; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 38 | import android.content.res.Resources; |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 39 | import android.database.ContentObserver; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 40 | import android.graphics.Bitmap; |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 41 | import android.graphics.Canvas; |
| 42 | import android.graphics.ColorFilter; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 43 | import android.graphics.PixelFormat; |
Daniel Sandler | e680f54 | 2012-09-28 12:22:27 -0400 | [diff] [blame] | 44 | import android.graphics.Point; |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 45 | import android.graphics.PointF; |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 46 | import android.graphics.PorterDuff; |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 47 | import android.graphics.PorterDuffXfermode; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 48 | import android.graphics.Rect; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 49 | import android.graphics.drawable.ColorDrawable; |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 50 | import android.graphics.drawable.Drawable; |
Jorim Jaggi | 11cc01d | 2016-01-22 19:39:23 -0800 | [diff] [blame] | 51 | import android.hardware.display.DisplayManager; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 52 | import android.inputmethodservice.InputMethodService; |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 53 | import android.media.AudioAttributes; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 54 | import android.media.MediaMetadata; |
| 55 | import android.media.session.MediaController; |
| 56 | import android.media.session.MediaSession; |
| 57 | import android.media.session.MediaSessionManager; |
| 58 | import android.media.session.PlaybackState; |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 59 | import android.os.AsyncTask; |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 60 | import android.os.Bundle; |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 61 | import android.os.Handler; |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 62 | import android.os.HandlerThread; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 63 | import android.os.IBinder; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 64 | import android.os.Message; |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 65 | import android.os.PowerManager; |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 66 | import android.os.Process; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 67 | import android.os.RemoteException; |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 68 | import android.os.ServiceManager; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 69 | import android.os.SystemClock; |
Dianne Hackborn | f02b60a | 2012-08-16 10:48:27 -0700 | [diff] [blame] | 70 | import android.os.UserHandle; |
Adrian Roos | 2b154a9 | 2014-11-17 15:18:39 +0100 | [diff] [blame] | 71 | import android.os.UserManager; |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 72 | import android.os.Vibrator; |
Daniel Sandler | d309056 | 2011-08-09 00:28:44 -0400 | [diff] [blame] | 73 | import android.provider.Settings; |
Chris Wren | 3ad4e3a | 2014-09-02 17:23:51 -0400 | [diff] [blame] | 74 | import android.service.notification.NotificationListenerService; |
Christoph Studer | d0694b6 | 2014-06-04 16:36:01 +0200 | [diff] [blame] | 75 | import android.service.notification.NotificationListenerService.RankingMap; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 76 | import android.service.notification.StatusBarNotification; |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 77 | import android.util.ArraySet; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 78 | import android.util.DisplayMetrics; |
Chris Wren | 64161cc | 2012-12-17 16:49:30 -0500 | [diff] [blame] | 79 | import android.util.EventLog; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 80 | import android.util.Log; |
| 81 | import android.view.Display; |
Jorim Jaggi | df99351 | 2014-05-13 23:06:35 +0200 | [diff] [blame] | 82 | import android.view.KeyEvent; |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 83 | import android.view.LayoutInflater; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 84 | import android.view.MotionEvent; |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 85 | import android.view.ThreadedRenderer; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 86 | import android.view.View; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 87 | import android.view.ViewGroup; |
Jim Miller | f2a16b2 | 2011-07-06 17:32:48 -0700 | [diff] [blame] | 88 | import android.view.ViewGroup.LayoutParams; |
Dan Sandler | 44c0dfd | 2014-06-09 11:26:16 -0400 | [diff] [blame] | 89 | import android.view.ViewStub; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 90 | import android.view.WindowManager; |
Jorim Jaggi | 786afcb | 2014-09-25 02:41:29 +0200 | [diff] [blame] | 91 | import android.view.WindowManagerGlobal; |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 92 | import android.view.animation.AccelerateInterpolator; |
Jorim Jaggi | b13d36d | 2014-06-06 18:03:52 +0200 | [diff] [blame] | 93 | import android.view.animation.Interpolator; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 94 | import android.widget.ImageView; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 95 | import android.widget.TextView; |
Chris Wren | 9763d42 | 2015-04-30 15:24:05 -0400 | [diff] [blame] | 96 | import com.android.internal.logging.MetricsLogger; |
Chris Wren | f6e9228b | 2016-01-26 18:04:35 -0500 | [diff] [blame] | 97 | import com.android.internal.logging.MetricsProto.MetricsEvent; |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 98 | import com.android.internal.statusbar.NotificationVisibility; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 99 | import com.android.internal.statusbar.StatusBarIcon; |
Jorim Jaggi | 6b88cdf | 2014-12-22 20:56:50 +0100 | [diff] [blame] | 100 | import com.android.keyguard.KeyguardHostView.OnDismissAction; |
Jason Monk | ab52527 | 2015-07-13 17:02:49 -0400 | [diff] [blame] | 101 | import com.android.keyguard.KeyguardUpdateMonitor; |
Jorim Jaggi | 007f0e8 | 2015-08-14 13:56:01 -0700 | [diff] [blame] | 102 | import com.android.keyguard.KeyguardUpdateMonitorCallback; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 103 | import com.android.keyguard.ViewMediatorCallback; |
Jorim Jaggi | 708f772 | 2014-08-20 17:30:38 +0200 | [diff] [blame] | 104 | import com.android.systemui.BatteryMeterView; |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 105 | import com.android.systemui.DemoMode; |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 106 | import com.android.systemui.DensityContainer; |
| 107 | import com.android.systemui.DensityContainer.InflateListener; |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 108 | import com.android.systemui.EventLogConstants; |
Chris Wren | 64161cc | 2012-12-17 16:49:30 -0500 | [diff] [blame] | 109 | import com.android.systemui.EventLogTags; |
Winson | c0d7058 | 2016-01-29 10:24:39 -0800 | [diff] [blame] | 110 | import com.android.systemui.Interpolators; |
Andrew Flynn | 8286257 | 2015-04-01 14:22:37 -0400 | [diff] [blame] | 111 | import com.android.systemui.Prefs; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 112 | import com.android.systemui.R; |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 113 | import com.android.systemui.SystemUIFactory; |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 114 | import com.android.systemui.assist.AssistManager; |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 115 | import com.android.systemui.classifier.FalsingManager; |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 116 | import com.android.systemui.doze.DozeHost; |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 117 | import com.android.systemui.doze.DozeLog; |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 118 | import com.android.systemui.keyguard.KeyguardViewMediator; |
Jason Monk | 162011e | 2016-02-19 08:11:55 -0500 | [diff] [blame] | 119 | import com.android.systemui.qs.QSContainer; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 120 | import com.android.systemui.qs.QSPanel; |
Jorim Jaggi | d61f227 | 2014-12-19 20:35:35 +0100 | [diff] [blame] | 121 | import com.android.systemui.recents.ScreenPinningRequest; |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 122 | import com.android.systemui.recents.events.EventBus; |
| 123 | import com.android.systemui.recents.events.activity.UndockingTaskEvent; |
Jorim Jaggi | dd98d41 | 2015-11-18 15:57:38 -0800 | [diff] [blame] | 124 | import com.android.systemui.stackdivider.Divider; |
Jorim Jaggi | ea4a19f | 2016-02-03 21:31:27 -0800 | [diff] [blame] | 125 | import com.android.systemui.stackdivider.WindowManagerProxy; |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 126 | import com.android.systemui.statusbar.ActivatableNotificationView; |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 127 | import com.android.systemui.statusbar.BackDropView; |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 128 | import com.android.systemui.statusbar.BaseStatusBar; |
Michael Jurka | a600fd9 | 2012-06-25 15:57:05 -0700 | [diff] [blame] | 129 | import com.android.systemui.statusbar.CommandQueue; |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 130 | import com.android.systemui.statusbar.DismissView; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 131 | import com.android.systemui.statusbar.DragDownHelper; |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 132 | import com.android.systemui.statusbar.EmptyShadeView; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 133 | import com.android.systemui.statusbar.ExpandableNotificationRow; |
Daniel Sandler | 3380534 | 2012-07-23 15:45:12 -0400 | [diff] [blame] | 134 | import com.android.systemui.statusbar.GestureRecorder; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 135 | import com.android.systemui.statusbar.KeyguardIndicationController; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 136 | import com.android.systemui.statusbar.NotificationData; |
Daniel Sandler | 58b173b | 2012-05-03 11:25:29 -0400 | [diff] [blame] | 137 | import com.android.systemui.statusbar.NotificationData.Entry; |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 138 | import com.android.systemui.statusbar.NotificationOverflowContainer; |
Adrian Roos | 1c0ca50 | 2015-10-07 12:20:42 -0700 | [diff] [blame] | 139 | import com.android.systemui.statusbar.RemoteInputController; |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 140 | import com.android.systemui.statusbar.ScrimView; |
Christian Robertson | 2e34742 | 2011-08-11 14:01:04 -0700 | [diff] [blame] | 141 | import com.android.systemui.statusbar.SignalClusterView; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 142 | import com.android.systemui.statusbar.StatusBarState; |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 143 | import com.android.systemui.statusbar.phone.UnlockMethodCache.OnUnlockMethodChangedListener; |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 144 | import com.android.systemui.statusbar.policy.AccessibilityController; |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 145 | import com.android.systemui.statusbar.policy.BatteryController; |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 146 | import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 147 | import com.android.systemui.statusbar.policy.BluetoothControllerImpl; |
Adrian Roos | 5fd872e | 2014-08-12 17:28:58 +0200 | [diff] [blame] | 148 | import com.android.systemui.statusbar.policy.BrightnessMirrorController; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 149 | import com.android.systemui.statusbar.policy.CastControllerImpl; |
Adrian Roos | b83777b | 2014-06-30 15:11:53 +0200 | [diff] [blame] | 150 | import com.android.systemui.statusbar.policy.FlashlightController; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 151 | import com.android.systemui.statusbar.policy.HeadsUpManager; |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 152 | import com.android.systemui.statusbar.policy.HotspotControllerImpl; |
John Spurlock | 657c62c | 2014-07-22 12:18:09 -0400 | [diff] [blame] | 153 | import com.android.systemui.statusbar.policy.KeyguardMonitor; |
Adrian Roos | 8ddb2da | 2014-06-16 18:56:22 -0700 | [diff] [blame] | 154 | import com.android.systemui.statusbar.policy.KeyguardUserSwitcher; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 155 | import com.android.systemui.statusbar.policy.LocationControllerImpl; |
| 156 | import com.android.systemui.statusbar.policy.NetworkControllerImpl; |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 157 | import com.android.systemui.statusbar.policy.NextAlarmController; |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 158 | import com.android.systemui.statusbar.policy.PreviewInflater; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 159 | import com.android.systemui.statusbar.policy.RotationLockControllerImpl; |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 160 | import com.android.systemui.statusbar.policy.SecurityControllerImpl; |
| 161 | import com.android.systemui.statusbar.policy.UserInfoController; |
Adrian Roos | 00a0b1f | 2014-07-16 16:44:49 +0200 | [diff] [blame] | 162 | import com.android.systemui.statusbar.policy.UserSwitcherController; |
John Spurlock | 8600534 | 2014-05-23 11:58:00 -0400 | [diff] [blame] | 163 | import com.android.systemui.statusbar.policy.ZenModeController; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 164 | import com.android.systemui.statusbar.stack.NotificationStackScrollLayout; |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 165 | import com.android.systemui.statusbar.stack.NotificationStackScrollLayout.OnChildLocationsChangedListener; |
Jorim Jaggi | 37c1180 | 2015-08-18 20:27:54 -0700 | [diff] [blame] | 166 | import com.android.systemui.statusbar.stack.StackStateAnimator; |
Selim Cinek | b036ca4 | 2015-02-20 15:56:28 +0100 | [diff] [blame] | 167 | import com.android.systemui.statusbar.stack.StackViewState; |
John Spurlock | 8600534 | 2014-05-23 11:58:00 -0400 | [diff] [blame] | 168 | import com.android.systemui.volume.VolumeComponent; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 169 | |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 170 | import java.io.FileDescriptor; |
| 171 | import java.io.PrintWriter; |
| 172 | import java.util.ArrayList; |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 173 | import java.util.Collection; |
| 174 | import java.util.Collections; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 175 | import java.util.HashMap; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 176 | import java.util.List; |
John Spurlock | 7bbb9f6 | 2014-10-21 12:15:28 -0400 | [diff] [blame] | 177 | import java.util.Map; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 178 | |
| 179 | import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_ALT; |
| 180 | import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SHOWN; |
| 181 | import static android.app.StatusBarManager.WINDOW_STATE_HIDDEN; |
| 182 | import static android.app.StatusBarManager.WINDOW_STATE_SHOWING; |
| 183 | import static android.app.StatusBarManager.windowStateToString; |
| 184 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT; |
| 185 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT_TRANSPARENT; |
| 186 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_OPAQUE; |
| 187 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_SEMI_TRANSPARENT; |
| 188 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSLUCENT; |
| 189 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARENT; |
| 190 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_WARNING; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 191 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 192 | public class PhoneStatusBar extends BaseStatusBar implements DemoMode, |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 193 | DragDownHelper.DragDownCallback, ActivityStarter, OnUnlockMethodChangedListener, |
| 194 | HeadsUpManager.OnHeadsUpChangedListener { |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 195 | static final String TAG = "PhoneStatusBar"; |
Daniel Sandler | 198a030 | 2012-08-17 16:04:31 -0400 | [diff] [blame] | 196 | public static final boolean DEBUG = BaseStatusBar.DEBUG; |
Chris Wren | 6d15a36 | 2013-08-20 18:46:29 -0400 | [diff] [blame] | 197 | public static final boolean SPEW = false; |
Daniel Sandler | 7579bca | 2011-08-18 15:47:26 -0400 | [diff] [blame] | 198 | public static final boolean DUMPTRUCK = true; // extra dumpsys info |
Daniel Sandler | fa027f5 | 2013-04-11 22:01:47 -0400 | [diff] [blame] | 199 | public static final boolean DEBUG_GESTURES = false; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 200 | public static final boolean DEBUG_MEDIA = false; |
| 201 | public static final boolean DEBUG_MEDIA_FAKE_ARTWORK = false; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 202 | |
John Spurlock | 342cad7 | 2013-10-08 09:36:50 -0400 | [diff] [blame] | 203 | public static final boolean DEBUG_WINDOW_STATE = false; |
Daniel Sandler | b17a726 | 2012-10-05 14:32:50 -0400 | [diff] [blame] | 204 | |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 205 | // additional instrumentation for testing purposes; intended to be left on during development |
Daniel Sandler | 7c35174 | 2011-10-17 10:48:06 -0400 | [diff] [blame] | 206 | public static final boolean CHATTY = DEBUG; |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 207 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 208 | public static final boolean SHOW_LOCKSCREEN_MEDIA_ARTWORK = true; |
| 209 | |
Adrian Roos | 8e3e836 | 2015-07-16 19:42:22 -0700 | [diff] [blame] | 210 | public static final String ACTION_FAKE_ARTWORK = "fake_artwork"; |
| 211 | |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 212 | private static final int MSG_OPEN_NOTIFICATION_PANEL = 1000; |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 213 | private static final int MSG_CLOSE_PANELS = 1001; |
| 214 | private static final int MSG_OPEN_SETTINGS_PANEL = 1002; |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 215 | private static final int MSG_LAUNCH_TRANSITION_TIMEOUT = 1003; |
Winson Chung | b1f7499 | 2014-08-08 12:53:09 -0700 | [diff] [blame] | 216 | // 1020-1040 reserved for BaseStatusBar |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 217 | |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 218 | // Time after we abort the launch transition. |
| 219 | private static final long LAUNCH_TRANSITION_TIMEOUT_MS = 5000; |
| 220 | |
Daniel Sandler | 8cc36e5 | 2011-10-17 14:18:46 -0400 | [diff] [blame] | 221 | private static final boolean CLOSE_PANEL_WHEN_EMPTIED = true; |
| 222 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 223 | private static final int STATUS_OR_NAV_TRANSIENT = |
| 224 | View.STATUS_BAR_TRANSIENT | View.NAVIGATION_BAR_TRANSIENT; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 225 | private static final long AUTOHIDE_TIMEOUT_MS = 3000; |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 226 | |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 227 | /** The minimum delay in ms between reports of notification visibility. */ |
| 228 | private static final int VISIBILITY_REPORT_MIN_DELAY_MS = 500; |
| 229 | |
Jorim Jaggi | 93a2bb2 | 2014-06-02 19:57:28 +0200 | [diff] [blame] | 230 | /** |
| 231 | * The delay to reset the hint text when the hint animation is finished running. |
| 232 | */ |
| 233 | private static final int HINT_RESET_DELAY_MS = 1200; |
| 234 | |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 235 | private static final AudioAttributes VIBRATION_ATTRIBUTES = new AudioAttributes.Builder() |
| 236 | .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) |
| 237 | .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) |
| 238 | .build(); |
| 239 | |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 240 | public static final int FADE_KEYGUARD_START_DELAY = 100; |
| 241 | public static final int FADE_KEYGUARD_DURATION = 300; |
Jorim Jaggi | 9097885 | 2015-08-18 19:55:53 -0700 | [diff] [blame] | 242 | public static final int FADE_KEYGUARD_DURATION_PULSING = 96; |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 243 | |
Jason Monk | 815e057 | 2014-08-12 17:26:36 -0400 | [diff] [blame] | 244 | /** Allow some time inbetween the long press for back and recents. */ |
| 245 | private static final int LOCK_TO_APP_GESTURE_TOLERENCE = 200; |
| 246 | |
Adrian Roos | 2f2bd9a | 2015-06-04 18:11:14 -0700 | [diff] [blame] | 247 | /** If true, the system is in the half-boot-to-decryption-screen state. |
| 248 | * Prudently disable QS and notifications. */ |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 249 | private static final boolean ONLY_CORE_APPS; |
| 250 | |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 251 | /** If true, the lockscreen will show a distinct wallpaper */ |
Adrian Roos | e381c16 | 2016-02-11 15:26:42 -0800 | [diff] [blame] | 252 | private static final boolean ENABLE_LOCKSCREEN_WALLPAPER = true; |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 253 | |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 254 | /* If true, the device supports freeform window management. |
| 255 | * This affects the status bar UI. */ |
| 256 | private static final boolean FREEFORM_WINDOW_MANAGEMENT; |
| 257 | |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 258 | static { |
| 259 | boolean onlyCoreApps; |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 260 | boolean freeformWindowManagement; |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 261 | try { |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 262 | IPackageManager packageManager = |
| 263 | IPackageManager.Stub.asInterface(ServiceManager.getService("package")); |
| 264 | onlyCoreApps = packageManager.isOnlyCoreApps(); |
| 265 | freeformWindowManagement = packageManager.hasSystemFeature( |
Jeff Sharkey | 115d2c1 | 2016-02-15 17:25:57 -0700 | [diff] [blame] | 266 | PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT, 0); |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 267 | } catch (RemoteException e) { |
| 268 | onlyCoreApps = false; |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 269 | freeformWindowManagement = false; |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 270 | } |
| 271 | ONLY_CORE_APPS = onlyCoreApps; |
Vladislav Kaznacheev | 38f426c | 2015-10-28 15:48:12 -0700 | [diff] [blame] | 272 | FREEFORM_WINDOW_MANAGEMENT = freeformWindowManagement; |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 273 | } |
| 274 | |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 275 | PhoneStatusBarPolicy mIconPolicy; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 276 | |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 277 | // 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] | 278 | BluetoothControllerImpl mBluetoothController; |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 279 | SecurityControllerImpl mSecurityController; |
Xiaohui Chen | 8bdcd1f | 2016-01-19 13:52:07 -0800 | [diff] [blame] | 280 | protected BatteryController mBatteryController; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 281 | LocationControllerImpl mLocationController; |
| 282 | NetworkControllerImpl mNetworkController; |
Jason Monk | 51e4dc0 | 2014-07-22 12:00:47 -0400 | [diff] [blame] | 283 | HotspotControllerImpl mHotspotController; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 284 | RotationLockControllerImpl mRotationLockController; |
Jorim Jaggi | 3d878be | 2014-05-10 03:22:32 +0200 | [diff] [blame] | 285 | UserInfoController mUserInfoController; |
John Spurlock | 8600534 | 2014-05-23 11:58:00 -0400 | [diff] [blame] | 286 | ZenModeController mZenModeController; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 287 | CastControllerImpl mCastController; |
John Spurlock | 8600534 | 2014-05-23 11:58:00 -0400 | [diff] [blame] | 288 | VolumeComponent mVolumeComponent; |
Adrian Roos | 8ddb2da | 2014-06-16 18:56:22 -0700 | [diff] [blame] | 289 | KeyguardUserSwitcher mKeyguardUserSwitcher; |
Adrian Roos | b83777b | 2014-06-30 15:11:53 +0200 | [diff] [blame] | 290 | FlashlightController mFlashlightController; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 291 | protected UserSwitcherController mUserSwitcherController; |
Jorim Jaggi | c7dea6e | 2014-07-26 14:36:57 +0200 | [diff] [blame] | 292 | NextAlarmController mNextAlarmController; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 293 | protected KeyguardMonitor mKeyguardMonitor; |
Adrian Roos | 5fd872e | 2014-08-12 17:28:58 +0200 | [diff] [blame] | 294 | BrightnessMirrorController mBrightnessMirrorController; |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 295 | AccessibilityController mAccessibilityController; |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 296 | FingerprintUnlockController mFingerprintUnlockController; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 297 | LightStatusBarController mLightStatusBarController; |
Vadim Tryshev | 12a30e8 | 2016-02-12 15:39:28 -0800 | [diff] [blame] | 298 | protected LockscreenWallpaper mLockscreenWallpaper; |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 299 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 300 | int mNaturalBarHeight = -1; |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 301 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 302 | Display mDisplay; |
Daniel Sandler | e680f54 | 2012-09-28 12:22:27 -0400 | [diff] [blame] | 303 | Point mCurrentDisplaySize = new Point(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 304 | |
Xiaohui Chen | d839d1a | 2016-01-21 13:05:02 -0800 | [diff] [blame] | 305 | protected StatusBarWindowView mStatusBarWindow; |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 306 | PhoneStatusBarView mStatusBarView; |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 307 | private int mStatusBarWindowState = WINDOW_STATE_SHOWING; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 308 | protected StatusBarWindowManager mStatusBarWindowManager; |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 309 | private UnlockMethodCache mUnlockMethodCache; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 310 | private DozeServiceHost mDozeServiceHost; |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 311 | private boolean mWakeUpComingFromTouch; |
| 312 | private PointF mWakeUpTouchLocation; |
Selim Cinek | 1b6f819 | 2015-09-03 16:01:53 -0700 | [diff] [blame] | 313 | private boolean mScreenTurningOn; |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 314 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 315 | int mPixelFormat; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 316 | Object mQueueLock = new Object(); |
| 317 | |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 318 | StatusBarIconController mIconController; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 319 | |
| 320 | // expanded notifications |
Xiaohui Chen | ea4b6ba | 2016-02-18 10:53:17 -0800 | [diff] [blame] | 321 | protected NotificationPanelView mNotificationPanel; // the sliding/resizing panel within the notification window |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 322 | View mExpandedContents; |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 323 | TextView mNotificationPanelDebugText; |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 324 | |
Daniel Sandler | 8e72c9e | 2012-08-15 00:09:26 -0400 | [diff] [blame] | 325 | // settings |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 326 | private QSPanel mQSPanel; |
Daniel Sandler | 8e72c9e | 2012-08-15 00:09:26 -0400 | [diff] [blame] | 327 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 328 | // top bar |
Jason Monk | 0e1101d | 2015-10-07 13:06:09 -0400 | [diff] [blame] | 329 | BaseStatusBarHeader mHeader; |
Jorim Jaggi | 4538027d | 2014-07-30 15:43:13 +0200 | [diff] [blame] | 330 | KeyguardStatusBarView mKeyguardStatusBar; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 331 | View mKeyguardStatusView; |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 332 | KeyguardBottomAreaView mKeyguardBottomArea; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 333 | boolean mLeaveOpenOnKeyguardHide; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 334 | KeyguardIndicationController mKeyguardIndicationController; |
Jorim Jaggi | e70d31f | 2014-04-24 22:08:30 +0200 | [diff] [blame] | 335 | |
Adrian Roos | 46df1ca | 2015-09-11 12:38:43 -0700 | [diff] [blame] | 336 | // Keyguard is going away soon. |
| 337 | private boolean mKeyguardGoingAway; |
| 338 | // Keyguard is actually fading away now. |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 339 | private boolean mKeyguardFadingAway; |
| 340 | private long mKeyguardFadingAwayDelay; |
| 341 | private long mKeyguardFadingAwayDuration; |
| 342 | |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 343 | // RemoteInputView to be activated after unlock |
| 344 | private View mPendingRemoteInputView; |
| 345 | |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 346 | int mMaxAllowedKeyguardNotifications; |
Daniel Sandler | d309056 | 2011-08-09 00:28:44 -0400 | [diff] [blame] | 347 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 348 | boolean mExpandedVisible; |
| 349 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 350 | private int mNavigationBarWindowState = WINDOW_STATE_SHOWING; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 351 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 352 | // the tracker view |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 353 | int mTrackingPosition; // the position of the top of the tracking view. |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 354 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 355 | // Tracking finger for opening/closing. |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 356 | boolean mTracking; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 357 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 358 | int[] mAbsPos = new int[2]; |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 359 | ArrayList<Runnable> mPostCollapseRunnables = new ArrayList<>(); |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 360 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 361 | // for disabling the status bar |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 362 | int mDisabled1 = 0; |
| 363 | int mDisabled2 = 0; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 364 | |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 365 | // tracking calls to View.setSystemUiVisibility() |
| 366 | int mSystemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 367 | private final Rect mLastFullscreenStackBounds = new Rect(); |
| 368 | private final Rect mLastDockedStackBounds = new Rect(); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 369 | |
Adrian Roos | 389beec | 2015-05-12 13:33:25 -0700 | [diff] [blame] | 370 | // last value sent to window manager |
| 371 | private int mLastDispatchedSystemUiVisibility = ~View.SYSTEM_UI_FLAG_VISIBLE; |
| 372 | |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 373 | DisplayMetrics mDisplayMetrics = new DisplayMetrics(); |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 374 | |
Daniel Sandler | 3380534 | 2012-07-23 15:45:12 -0400 | [diff] [blame] | 375 | // XXX: gesture research |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 376 | private final GestureRecorder mGestureRec = DEBUG_GESTURES |
John Spurlock | 209bede | 2013-07-17 12:23:27 -0400 | [diff] [blame] | 377 | ? new GestureRecorder("/sdcard/statusbar_gestures.dat") |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 378 | : null; |
Daniel Sandler | 3380534 | 2012-07-23 15:45:12 -0400 | [diff] [blame] | 379 | |
Jason Monk | 18f99d9 | 2014-09-11 13:36:42 -0400 | [diff] [blame] | 380 | private ScreenPinningRequest mScreenPinningRequest; |
| 381 | |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 382 | private int mNavigationIconHints = 0; |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 383 | private HandlerThread mHandlerThread; |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 384 | |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 385 | // ensure quick settings is disabled until the current user makes it through the setup wizard |
| 386 | private boolean mUserSetup = false; |
| 387 | private ContentObserver mUserSetupObserver = new ContentObserver(new Handler()) { |
| 388 | @Override |
| 389 | public void onChange(boolean selfChange) { |
| 390 | final boolean userSetup = 0 != Settings.Secure.getIntForUser( |
| 391 | mContext.getContentResolver(), |
| 392 | Settings.Secure.USER_SETUP_COMPLETE, |
| 393 | 0 /*default */, |
| 394 | mCurrentUserId); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 395 | if (MULTIUSER_DEBUG) Log.d(TAG, String.format("User setup changed: " + |
John Spurlock | e4e8c56 | 2012-10-04 09:55:01 -0400 | [diff] [blame] | 396 | "selfChange=%s userSetup=%s mUserSetup=%s", |
| 397 | selfChange, userSetup, mUserSetup)); |
John Spurlock | 73203eb | 2014-04-15 16:14:46 -0400 | [diff] [blame] | 398 | |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 399 | if (userSetup != mUserSetup) { |
| 400 | mUserSetup = userSetup; |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 401 | if (!mUserSetup && mStatusBarView != null) |
| 402 | animateCollapseQuickSettings(); |
Adrian Roos | a4eba9f | 2015-07-22 18:13:04 -0700 | [diff] [blame] | 403 | if (mKeyguardBottomArea != null) { |
| 404 | mKeyguardBottomArea.setUserSetupComplete(mUserSetup); |
| 405 | } |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 406 | } |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 407 | if (mIconPolicy != null) { |
| 408 | mIconPolicy.setCurrentUserSetup(mUserSetup); |
| 409 | } |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 410 | } |
| 411 | }; |
| 412 | |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 413 | final private ContentObserver mHeadsUpObserver = new ContentObserver(mHandler) { |
| 414 | @Override |
| 415 | public void onChange(boolean selfChange) { |
| 416 | boolean wasUsing = mUseHeadsUp; |
Jason Monk | f701954 | 2014-07-31 12:42:25 -0400 | [diff] [blame] | 417 | mUseHeadsUp = ENABLE_HEADS_UP && !mDisableNotificationAlerts |
| 418 | && Settings.Global.HEADS_UP_OFF != Settings.Global.getInt( |
Chris Wren | 10d82df | 2014-03-01 10:34:51 -0500 | [diff] [blame] | 419 | mContext.getContentResolver(), Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED, |
Chris Wren | 7bd24123 | 2014-02-28 16:25:05 -0500 | [diff] [blame] | 420 | Settings.Global.HEADS_UP_OFF); |
Chris Wren | 22ae46e | 2014-02-26 18:08:09 -0500 | [diff] [blame] | 421 | mHeadsUpTicker = mUseHeadsUp && 0 != Settings.Global.getInt( |
| 422 | mContext.getContentResolver(), SETTING_HEADS_UP_TICKER, 0); |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 423 | Log.d(TAG, "heads up is " + (mUseHeadsUp ? "enabled" : "disabled")); |
| 424 | if (wasUsing != mUseHeadsUp) { |
| 425 | if (!mUseHeadsUp) { |
| 426 | Log.d(TAG, "dismissing any existing heads up notification on disable event"); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 427 | mHeadsUpManager.releaseAllImmediately(); |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 428 | } |
| 429 | } |
| 430 | } |
| 431 | }; |
| 432 | |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 433 | private int mInteractingWindows; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 434 | private boolean mAutohideSuspended; |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 435 | private int mStatusBarMode; |
| 436 | private int mNavigationBarMode; |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 437 | private int mMaxKeyguardNotifications; |
Jorim Jaggi | d41083a | 2014-09-12 02:54:40 +0200 | [diff] [blame] | 438 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 439 | private ViewMediatorCallback mKeyguardViewMediatorCallback; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 440 | protected ScrimController mScrimController; |
| 441 | protected DozeScrimController mDozeScrimController; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 442 | |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 443 | private final Runnable mAutohide = new Runnable() { |
| 444 | @Override |
| 445 | public void run() { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 446 | int requested = mSystemUiVisibility & ~STATUS_OR_NAV_TRANSIENT; |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 447 | if (mSystemUiVisibility != requested) { |
| 448 | notifyUiVisibilityChanged(requested); |
| 449 | } |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 450 | }}; |
| 451 | |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 452 | private boolean mWaitingForKeyguardExit; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 453 | private boolean mDozing; |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 454 | private boolean mDozingRequested; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 455 | protected boolean mScrimSrcModeEnabled; |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 456 | |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 457 | public static final Interpolator ALPHA_IN = Interpolators.ALPHA_IN; |
| 458 | public static final Interpolator ALPHA_OUT = Interpolators.ALPHA_OUT; |
Jorim Jaggi | b13d36d | 2014-06-06 18:03:52 +0200 | [diff] [blame] | 459 | |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 460 | private BackDropView mBackdrop; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 461 | private ImageView mBackdropFront, mBackdropBack; |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 462 | private PorterDuffXfermode mSrcXferMode = new PorterDuffXfermode(PorterDuff.Mode.SRC); |
| 463 | private PorterDuffXfermode mSrcOverXferMode = new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 464 | |
| 465 | private MediaSessionManager mMediaSessionManager; |
| 466 | private MediaController mMediaController; |
| 467 | private String mMediaNotificationKey; |
| 468 | private MediaMetadata mMediaMetadata; |
| 469 | private MediaController.Callback mMediaListener |
| 470 | = new MediaController.Callback() { |
| 471 | @Override |
| 472 | public void onPlaybackStateChanged(PlaybackState state) { |
| 473 | super.onPlaybackStateChanged(state); |
| 474 | if (DEBUG_MEDIA) Log.v(TAG, "DEBUG_MEDIA: onPlaybackStateChanged: " + state); |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 475 | if (state != null) { |
| 476 | if (!isPlaybackActive(state.getState())) { |
| 477 | clearCurrentMediaNotification(); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 478 | updateMediaMetaData(true, true); |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 479 | } |
| 480 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 481 | } |
| 482 | |
| 483 | @Override |
| 484 | public void onMetadataChanged(MediaMetadata metadata) { |
| 485 | super.onMetadataChanged(metadata); |
| 486 | if (DEBUG_MEDIA) Log.v(TAG, "DEBUG_MEDIA: onMetadataChanged: " + metadata); |
| 487 | mMediaMetadata = metadata; |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 488 | updateMediaMetaData(true, true); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 489 | } |
| 490 | }; |
| 491 | |
| 492 | private final OnChildLocationsChangedListener mOnChildLocationsChangedListener = |
| 493 | new OnChildLocationsChangedListener() { |
| 494 | @Override |
| 495 | public void onChildLocationsChanged(NotificationStackScrollLayout stackScrollLayout) { |
| 496 | userActivity(); |
| 497 | } |
| 498 | }; |
| 499 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 500 | private int mDisabledUnmodified1; |
| 501 | private int mDisabledUnmodified2; |
Jorim Jaggi | b13d36d | 2014-06-06 18:03:52 +0200 | [diff] [blame] | 502 | |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 503 | /** Keys of notifications currently visible to the user. */ |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 504 | private final ArraySet<NotificationVisibility> mCurrentlyVisibleNotifications = |
| 505 | new ArraySet<>(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 506 | private long mLastVisibilityReportUptimeMs; |
| 507 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 508 | private final ShadeUpdates mShadeUpdates = new ShadeUpdates(); |
| 509 | |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 510 | private Runnable mLaunchTransitionEndRunnable; |
| 511 | private boolean mLaunchTransitionFadingAway; |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 512 | private ExpandableNotificationRow mDraggedDownRow; |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 513 | private boolean mLaunchCameraOnScreenTurningOn; |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 514 | private boolean mLaunchCameraOnFinishedGoingToSleep; |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 515 | private int mLastCameraLaunchSource; |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 516 | private PowerManager.WakeLock mGestureWakeLock; |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 517 | private Vibrator mVibrator; |
Jorim Jaggi | 362dd6d | 2014-07-09 19:04:07 +0200 | [diff] [blame] | 518 | |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 519 | // Fingerprint (as computed by getLoggingFingerprint() of the last logged state. |
| 520 | private int mLastLoggedStateFingerprint; |
| 521 | |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 522 | /** |
| 523 | * If set, the device has started going to sleep but isn't fully non-interactive yet. |
| 524 | */ |
| 525 | protected boolean mStartedGoingToSleep; |
| 526 | |
Selim Cinek | 3776fe0 | 2016-02-04 13:32:43 -0800 | [diff] [blame] | 527 | private static final int VISIBLE_LOCATIONS = StackViewState.LOCATION_FIRST_HUN |
Chris Wren | 35a7c92 | 2015-06-22 16:31:01 -0400 | [diff] [blame] | 528 | | StackViewState.LOCATION_MAIN_AREA; |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 529 | |
| 530 | private final OnChildLocationsChangedListener mNotificationLocationsChangedListener = |
| 531 | new OnChildLocationsChangedListener() { |
| 532 | @Override |
| 533 | public void onChildLocationsChanged( |
| 534 | NotificationStackScrollLayout stackScrollLayout) { |
| 535 | if (mHandler.hasCallbacks(mVisibilityReporter)) { |
| 536 | // Visibilities will be reported when the existing |
| 537 | // callback is executed. |
| 538 | return; |
| 539 | } |
| 540 | // Calculate when we're allowed to run the visibility |
| 541 | // reporter. Note that this timestamp might already have |
| 542 | // passed. That's OK, the callback will just be executed |
| 543 | // ASAP. |
| 544 | long nextReportUptimeMs = |
| 545 | mLastVisibilityReportUptimeMs + VISIBILITY_REPORT_MIN_DELAY_MS; |
| 546 | mHandler.postAtTime(mVisibilityReporter, nextReportUptimeMs); |
| 547 | } |
| 548 | }; |
| 549 | |
| 550 | // Tracks notifications currently visible in mNotificationStackScroller and |
| 551 | // emits visibility events via NoMan on changes. |
| 552 | private final Runnable mVisibilityReporter = new Runnable() { |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 553 | private final ArraySet<NotificationVisibility> mTmpNewlyVisibleNotifications = |
| 554 | new ArraySet<>(); |
| 555 | private final ArraySet<NotificationVisibility> mTmpCurrentlyVisibleNotifications = |
| 556 | new ArraySet<>(); |
| 557 | private final ArraySet<NotificationVisibility> mTmpNoLongerVisibleNotifications = |
| 558 | new ArraySet<>(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 559 | |
| 560 | @Override |
| 561 | public void run() { |
| 562 | mLastVisibilityReportUptimeMs = SystemClock.uptimeMillis(); |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 563 | final String mediaKey = getCurrentMediaNotificationKey(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 564 | |
| 565 | // 1. Loop over mNotificationData entries: |
| 566 | // A. Keep list of visible notifications. |
| 567 | // B. Keep list of previously hidden, now visible notifications. |
| 568 | // 2. Compute no-longer visible notifications by removing currently |
| 569 | // visible notifications from the set of previously visible |
| 570 | // notifications. |
| 571 | // 3. Report newly visible and no-longer visible notifications. |
| 572 | // 4. Keep currently visible notifications for next report. |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 573 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
| 574 | int N = activeNotifications.size(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 575 | for (int i = 0; i < N; i++) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 576 | Entry entry = activeNotifications.get(i); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 577 | String key = entry.notification.getKey(); |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 578 | boolean isVisible = |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 579 | (mStackScroller.getChildLocation(entry.row) & VISIBLE_LOCATIONS) != 0; |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 580 | NotificationVisibility visObj = NotificationVisibility.obtain(key, i, isVisible); |
| 581 | boolean previouslyVisible = mCurrentlyVisibleNotifications.contains(visObj); |
| 582 | if (isVisible) { |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 583 | // Build new set of visible notifications. |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 584 | mTmpCurrentlyVisibleNotifications.add(visObj); |
| 585 | if (!previouslyVisible) { |
| 586 | mTmpNewlyVisibleNotifications.add(visObj); |
| 587 | } |
| 588 | } else { |
| 589 | // release object |
| 590 | visObj.recycle(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 591 | } |
| 592 | } |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 593 | mTmpNoLongerVisibleNotifications.addAll(mCurrentlyVisibleNotifications); |
| 594 | mTmpNoLongerVisibleNotifications.removeAll(mTmpCurrentlyVisibleNotifications); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 595 | |
| 596 | logNotificationVisibilityChanges( |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 597 | mTmpNewlyVisibleNotifications, mTmpNoLongerVisibleNotifications); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 598 | |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 599 | recycleAllVisibilityObjects(mCurrentlyVisibleNotifications); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 600 | mCurrentlyVisibleNotifications.addAll(mTmpCurrentlyVisibleNotifications); |
| 601 | |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 602 | recycleAllVisibilityObjects(mTmpNoLongerVisibleNotifications); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 603 | mTmpCurrentlyVisibleNotifications.clear(); |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 604 | mTmpNewlyVisibleNotifications.clear(); |
| 605 | mTmpNoLongerVisibleNotifications.clear(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 606 | } |
| 607 | }; |
| 608 | |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 609 | private void recycleAllVisibilityObjects(ArraySet<NotificationVisibility> array) { |
| 610 | final int N = array.size(); |
| 611 | for (int i = 0 ; i < N; i++) { |
| 612 | array.valueAt(i).recycle(); |
| 613 | } |
| 614 | array.clear(); |
| 615 | } |
| 616 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 617 | private final View.OnClickListener mOverflowClickListener = new View.OnClickListener() { |
| 618 | @Override |
| 619 | public void onClick(View v) { |
| 620 | goToLockedShade(null); |
| 621 | } |
| 622 | }; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 623 | private HashMap<ExpandableNotificationRow, List<ExpandableNotificationRow>> mTmpChildOrderMap |
| 624 | = new HashMap<>(); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 625 | private RankingMap mLatestRankingMap; |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 626 | private boolean mNoAnimationOnNextBarModeChange; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 627 | private FalsingManager mFalsingManager; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 628 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 629 | @Override |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 630 | public void start() { |
| 631 | mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)) |
| 632 | .getDefaultDisplay(); |
Daniel Sandler | 7e8ae50 | 2013-10-10 23:38:19 -0400 | [diff] [blame] | 633 | updateDisplaySize(); |
Jorim Jaggi | 0e66439 | 2014-09-27 01:30:22 +0200 | [diff] [blame] | 634 | mScrimSrcModeEnabled = mContext.getResources().getBoolean( |
| 635 | R.bool.config_status_bar_scrim_behind_use_src); |
Adrian Roos | 75fa385 | 2015-01-27 20:21:44 +0100 | [diff] [blame] | 636 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 637 | super.start(); // calls createAndAddWindows() |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 638 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 639 | mMediaSessionManager |
| 640 | = (MediaSessionManager) mContext.getSystemService(Context.MEDIA_SESSION_SERVICE); |
| 641 | // TODO: use MediaSessionManager.SessionListener to hook us up to future updates |
| 642 | // in session state |
| 643 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 644 | addNavigationBar(); |
| 645 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 646 | // Lastly, call to the icon policy to install/update all the icons. |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 647 | mIconPolicy = new PhoneStatusBarPolicy(mContext, mIconController, mCastController, |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 648 | mHotspotController, mUserInfoController, mBluetoothController, |
Jason Monk | f23aa99 | 2016-01-22 16:45:21 -0500 | [diff] [blame] | 649 | mRotationLockController, mNetworkController.getDataSaverController()); |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 650 | mIconPolicy.setCurrentUserSetup(mUserSetup); |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 651 | mSettingsObserver.onChange(false); // set up |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 652 | |
| 653 | mHeadsUpObserver.onChange(true); // set up |
| 654 | if (ENABLE_HEADS_UP) { |
| 655 | mContext.getContentResolver().registerContentObserver( |
Chris Wren | 10d82df | 2014-03-01 10:34:51 -0500 | [diff] [blame] | 656 | Settings.Global.getUriFor(Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED), true, |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 657 | mHeadsUpObserver); |
Chris Wren | 22ae46e | 2014-02-26 18:08:09 -0500 | [diff] [blame] | 658 | mContext.getContentResolver().registerContentObserver( |
| 659 | Settings.Global.getUriFor(SETTING_HEADS_UP_TICKER), true, |
| 660 | mHeadsUpObserver); |
Chris Wren | f6e83f4 | 2013-09-11 14:02:59 -0400 | [diff] [blame] | 661 | } |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 662 | mUnlockMethodCache = UnlockMethodCache.getInstance(mContext); |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 663 | mUnlockMethodCache.addListener(this); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 664 | startKeyguard(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 665 | |
| 666 | mDozeServiceHost = new DozeServiceHost(); |
Jorim Jaggi | 007f0e8 | 2015-08-14 13:56:01 -0700 | [diff] [blame] | 667 | KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mDozeServiceHost); |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 668 | putComponent(DozeHost.class, mDozeServiceHost); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 669 | putComponent(PhoneStatusBar.class, this); |
John Spurlock | 89f060a | 2014-07-16 21:03:15 -0400 | [diff] [blame] | 670 | |
| 671 | setControllerUsers(); |
Chris Wren | cd8f4f7 | 2014-08-27 18:48:13 -0400 | [diff] [blame] | 672 | |
| 673 | notifyUserAboutHiddenNotifications(); |
Jason Monk | 18f99d9 | 2014-09-11 13:36:42 -0400 | [diff] [blame] | 674 | |
| 675 | mScreenPinningRequest = new ScreenPinningRequest(mContext); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 676 | mFalsingManager = FalsingManager.getInstance(mContext); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 677 | } |
| 678 | |
| 679 | // ================================================================================ |
| 680 | // Constructing the view |
| 681 | // ================================================================================ |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 682 | protected PhoneStatusBarView makeStatusBarView() { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 683 | final Context context = mContext; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 684 | |
Daniel Sandler | 6e8db88 | 2011-10-26 15:40:51 -0400 | [diff] [blame] | 685 | updateDisplaySize(); // populates mDisplayMetrics |
Jorim Jaggi | 2e115c5 | 2014-07-01 21:27:58 +0200 | [diff] [blame] | 686 | updateResources(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 687 | |
Xiaohui Chen | d839d1a | 2016-01-21 13:05:02 -0800 | [diff] [blame] | 688 | inflateStatusBarWindow(context); |
Selim Cinek | 4e6b2d3 | 2015-06-25 20:15:33 -0400 | [diff] [blame] | 689 | mStatusBarWindow.setService(this); |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 690 | mStatusBarWindow.setOnTouchListener(new View.OnTouchListener() { |
| 691 | @Override |
| 692 | public boolean onTouch(View v, MotionEvent event) { |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 693 | checkUserAutohide(v, event); |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 694 | if (event.getAction() == MotionEvent.ACTION_DOWN) { |
Daniel Sandler | 37a38aa | 2013-02-13 17:15:57 -0500 | [diff] [blame] | 695 | if (mExpandedVisible) { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 696 | animateCollapsePanels(); |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 697 | } |
| 698 | } |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame] | 699 | return mStatusBarWindow.onTouchEvent(event); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 700 | } |
| 701 | }); |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 702 | |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 703 | mNotificationPanel = (NotificationPanelView) mStatusBarWindow.findViewById( |
| 704 | R.id.notification_panel); |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 705 | mNotificationPanel.setStatusBar(this); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 706 | |
Xiaohui Chen | 9f96711 | 2016-01-07 14:14:06 -0800 | [diff] [blame] | 707 | mStatusBarView = (PhoneStatusBarView) mStatusBarWindow.findViewById(R.id.status_bar); |
| 708 | mStatusBarView.setBar(this); |
| 709 | mStatusBarView.setPanel(mNotificationPanel); |
| 710 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 711 | if (!ActivityManager.isHighEndGfx()) { |
Romain Guy | 328b358 | 2012-05-08 15:30:57 -0700 | [diff] [blame] | 712 | mStatusBarWindow.setBackground(null); |
Alan Viverette | 4a357cd | 2015-03-18 18:37:18 -0700 | [diff] [blame] | 713 | mNotificationPanel.setBackground(new FastColorDrawable(context.getColor( |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 714 | R.color.notification_panel_solid_background))); |
Romain Guy | 328b358 | 2012-05-08 15:30:57 -0700 | [diff] [blame] | 715 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 716 | |
Selim Cinek | 83bc783 | 2015-10-22 13:26:54 -0700 | [diff] [blame] | 717 | mHeadsUpManager = new HeadsUpManager(context, mStatusBarWindow, mGroupManager); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 718 | mHeadsUpManager.setBar(this); |
| 719 | mHeadsUpManager.addListener(this); |
| 720 | mHeadsUpManager.addListener(mNotificationPanel); |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 721 | mHeadsUpManager.addListener(mGroupManager); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 722 | mNotificationPanel.setHeadsUpManager(mHeadsUpManager); |
Selim Cinek | fbe9a44 | 2015-04-13 16:09:49 -0700 | [diff] [blame] | 723 | mNotificationData.setHeadsUpManager(mHeadsUpManager); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 724 | |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 725 | if (MULTIUSER_DEBUG) { |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 726 | mNotificationPanelDebugText = (TextView) mNotificationPanel.findViewById( |
| 727 | R.id.header_debug_info); |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 728 | mNotificationPanelDebugText.setVisibility(View.VISIBLE); |
| 729 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 730 | |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 731 | try { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 732 | boolean showNav = mWindowManagerService.hasNavigationBar(); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 733 | if (DEBUG) Log.v(TAG, "hasNavigationBar=" + showNav); |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 734 | if (showNav) { |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 735 | createNavigationBarView(context); |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 736 | } |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 737 | } catch (RemoteException ex) { |
| 738 | // no window manager? good luck with that |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 739 | } |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 740 | |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 741 | mAssistManager = new AssistManager(this, context); |
| 742 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 743 | // figure out which pixel-format to use for the status bar. |
Daniel Sandler | f733c2a | 2011-09-25 15:03:40 -0400 | [diff] [blame] | 744 | mPixelFormat = PixelFormat.OPAQUE; |
Daniel Sandler | 173bae2 | 2012-09-25 14:37:42 -0400 | [diff] [blame] | 745 | |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 746 | mStackScroller = (NotificationStackScrollLayout) mStatusBarWindow.findViewById( |
| 747 | R.id.notification_stack_scroller); |
| 748 | mStackScroller.setLongPressListener(getNotificationLongClicker()); |
Mady Mellor | 4b80b10 | 2016-01-22 08:03:58 -0800 | [diff] [blame] | 749 | mStackScroller.setGearDisplayedListener(getGearDisplayedListener()); |
Selim Cinek | 19c8c70 | 2014-08-25 22:09:19 +0200 | [diff] [blame] | 750 | mStackScroller.setPhoneStatusBar(this); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 751 | mStackScroller.setGroupManager(mGroupManager); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 752 | mStackScroller.setHeadsUpManager(mHeadsUpManager); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 753 | mGroupManager.setOnGroupChangeListener(mStackScroller); |
Selim Cinek | 80a14e5 | 2014-03-27 16:58:04 +0100 | [diff] [blame] | 754 | |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 755 | mKeyguardIconOverflowContainer = |
| 756 | (NotificationOverflowContainer) LayoutInflater.from(mContext).inflate( |
| 757 | R.layout.status_bar_notification_keyguard_overflow, mStackScroller, false); |
| 758 | mKeyguardIconOverflowContainer.setOnActivatedListener(this); |
Jorim Jaggi | e96fcd1 | 2014-05-07 21:10:35 +0200 | [diff] [blame] | 759 | mKeyguardIconOverflowContainer.setOnClickListener(mOverflowClickListener); |
Selim Cinek | 2cd45df | 2015-06-09 18:00:07 -0700 | [diff] [blame] | 760 | mStackScroller.setOverflowContainer(mKeyguardIconOverflowContainer); |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 761 | |
Selim Cinek | 4fd5dfc | 2016-01-19 15:16:15 -0800 | [diff] [blame] | 762 | |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 763 | inflateEmptyShadeView(); |
| 764 | inflateDismissView(); |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 765 | mExpandedContents = mStackScroller; |
Selim Cinek | 67b2260 | 2014-03-10 15:40:16 +0100 | [diff] [blame] | 766 | |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 767 | mBackdrop = (BackDropView) mStatusBarWindow.findViewById(R.id.backdrop); |
| 768 | mBackdropFront = (ImageView) mBackdrop.findViewById(R.id.backdrop_front); |
| 769 | mBackdropBack = (ImageView) mBackdrop.findViewById(R.id.backdrop_back); |
| 770 | |
| 771 | ScrimView scrimBehind = (ScrimView) mStatusBarWindow.findViewById(R.id.scrim_behind); |
| 772 | ScrimView scrimInFront = (ScrimView) mStatusBarWindow.findViewById(R.id.scrim_in_front); |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 773 | View headsUpScrim = mStatusBarWindow.findViewById(R.id.heads_up_scrim); |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 774 | mScrimController = SystemUIFactory.getInstance().createScrimController( |
| 775 | scrimBehind, scrimInFront, headsUpScrim, mScrimSrcModeEnabled); |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 776 | mHeadsUpManager.addListener(mScrimController); |
| 777 | mStackScroller.setScrimController(mScrimController); |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 778 | mScrimController.setBackDropView(mBackdrop); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 779 | mStatusBarView.setScrimController(mScrimController); |
Jorim Jaggi | 048af1f | 2014-11-11 22:51:10 +0100 | [diff] [blame] | 780 | mDozeScrimController = new DozeScrimController(mScrimController, context); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 781 | |
Jorim Jaggi | 4538027d | 2014-07-30 15:43:13 +0200 | [diff] [blame] | 782 | mKeyguardStatusBar = (KeyguardStatusBarView) mStatusBarWindow.findViewById(R.id.keyguard_header); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 783 | mKeyguardStatusView = mStatusBarWindow.findViewById(R.id.keyguard_status_view); |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 784 | mKeyguardBottomArea = |
| 785 | (KeyguardBottomAreaView) mStatusBarWindow.findViewById(R.id.keyguard_bottom_area); |
| 786 | mKeyguardBottomArea.setActivityStarter(this); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 787 | mKeyguardBottomArea.setAssistManager(mAssistManager); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 788 | mKeyguardIndicationController = new KeyguardIndicationController(mContext, |
| 789 | (KeyguardIndicationTextView) mStatusBarWindow.findViewById( |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 790 | R.id.keyguard_indication_text), |
| 791 | mKeyguardBottomArea.getLockIcon()); |
Adrian Roos | 4ebcdfd | 2014-08-12 23:33:49 +0200 | [diff] [blame] | 792 | mKeyguardBottomArea.setKeyguardIndicationController(mKeyguardIndicationController); |
Daniel Sandler | e111ad3 | 2012-10-13 15:17:45 -0400 | [diff] [blame] | 793 | |
Adrian Roos | e381c16 | 2016-02-11 15:26:42 -0800 | [diff] [blame] | 794 | if (ENABLE_LOCKSCREEN_WALLPAPER) { |
| 795 | mLockscreenWallpaper = new LockscreenWallpaper(mContext, this, mHandler); |
| 796 | } |
| 797 | |
Xiaohui Chen | f43491f | 2016-02-01 12:19:35 -0800 | [diff] [blame] | 798 | // set the initial view visibility |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 799 | setAreThereNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 800 | |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 801 | mIconController = new StatusBarIconController( |
| 802 | mContext, mStatusBarView, mKeyguardStatusBar, this); |
| 803 | |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 804 | // Background thread for any controllers that need it. |
| 805 | mHandlerThread = new HandlerThread(TAG, Process.THREAD_PRIORITY_BACKGROUND); |
| 806 | mHandlerThread.start(); |
| 807 | |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 808 | // Other icons |
Jason Monk | 05b86bc | 2015-05-19 14:21:28 -0400 | [diff] [blame] | 809 | mLocationController = new LocationControllerImpl(mContext, |
| 810 | mHandlerThread.getLooper()); // will post a notification |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 811 | mBatteryController = new BatteryController(mContext); |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 812 | mBatteryController.addStateChangedCallback(new BatteryStateChangeCallback() { |
| 813 | @Override |
Jason Monk | c06fbb1 | 2016-01-08 14:12:18 -0500 | [diff] [blame] | 814 | public void onPowerSaveChanged(boolean isPowerSave) { |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 815 | mHandler.post(mCheckBarModes); |
John Spurlock | d96179e | 2014-08-21 16:43:45 -0400 | [diff] [blame] | 816 | if (mDozeServiceHost != null) { |
Jason Monk | c06fbb1 | 2016-01-08 14:12:18 -0500 | [diff] [blame] | 817 | mDozeServiceHost.firePowerSaveChanged(isPowerSave); |
John Spurlock | d96179e | 2014-08-21 16:43:45 -0400 | [diff] [blame] | 818 | } |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 819 | } |
| 820 | @Override |
| 821 | public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) { |
| 822 | // noop |
| 823 | } |
| 824 | }); |
Jason Monk | 30d8004 | 2015-05-08 16:54:18 -0400 | [diff] [blame] | 825 | mNetworkController = new NetworkControllerImpl(mContext, mHandlerThread.getLooper()); |
Jason Monk | 51e4dc0 | 2014-07-22 12:00:47 -0400 | [diff] [blame] | 826 | mHotspotController = new HotspotControllerImpl(mContext); |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 827 | mBluetoothController = new BluetoothControllerImpl(mContext, mHandlerThread.getLooper()); |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 828 | mSecurityController = new SecurityControllerImpl(mContext); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 829 | if (mContext.getResources().getBoolean(R.bool.config_showRotationLock)) { |
| 830 | mRotationLockController = new RotationLockControllerImpl(mContext); |
John Spurlock | 8ab172e | 2013-12-19 16:39:23 -0500 | [diff] [blame] | 831 | } |
Jorim Jaggi | 3d878be | 2014-05-10 03:22:32 +0200 | [diff] [blame] | 832 | mUserInfoController = new UserInfoController(mContext); |
John Spurlock | 8600534 | 2014-05-23 11:58:00 -0400 | [diff] [blame] | 833 | mVolumeComponent = getComponent(VolumeComponent.class); |
John Spurlock | f2565a8 | 2014-10-23 20:16:22 -0400 | [diff] [blame] | 834 | if (mVolumeComponent != null) { |
| 835 | mZenModeController = mVolumeComponent.getZenController(); |
| 836 | } |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 837 | mCastController = new CastControllerImpl(mContext); |
Xiaohui Chen | 1094230 | 2015-12-16 16:38:13 -0800 | [diff] [blame] | 838 | |
| 839 | initSignalCluster(mStatusBarView); |
| 840 | initSignalCluster(mKeyguardStatusBar); |
Daniel Sandler | dd4ef49 | 2012-07-27 11:19:52 -0400 | [diff] [blame] | 841 | |
Adrian Roos | b83777b | 2014-06-30 15:11:53 +0200 | [diff] [blame] | 842 | mFlashlightController = new FlashlightController(mContext); |
Adrian Roos | 1e1d6ac | 2014-07-22 17:18:55 +0200 | [diff] [blame] | 843 | mKeyguardBottomArea.setFlashlightController(mFlashlightController); |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 844 | mKeyguardBottomArea.setPhoneStatusBar(this); |
Adrian Roos | a4eba9f | 2015-07-22 18:13:04 -0700 | [diff] [blame] | 845 | mKeyguardBottomArea.setUserSetupComplete(mUserSetup); |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 846 | mAccessibilityController = new AccessibilityController(mContext); |
| 847 | mKeyguardBottomArea.setAccessibilityController(mAccessibilityController); |
Jorim Jaggi | c7dea6e | 2014-07-26 14:36:57 +0200 | [diff] [blame] | 848 | mNextAlarmController = new NextAlarmController(mContext); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 849 | mLightStatusBarController = new LightStatusBarController(mIconController, |
| 850 | mBatteryController); |
Jason Monk | 8a3a964 | 2015-06-05 11:01:30 -0400 | [diff] [blame] | 851 | mKeyguardMonitor = new KeyguardMonitor(mContext); |
Fyodor Kupolov | cd86ebf | 2015-09-29 17:06:50 -0700 | [diff] [blame] | 852 | if (UserManager.get(mContext).isUserSwitcherEnabled()) { |
Adrian Roos | 88b1193 | 2015-07-22 14:59:48 -0700 | [diff] [blame] | 853 | mUserSwitcherController = new UserSwitcherController(mContext, mKeyguardMonitor, |
Sudheer Shanka | 1c7cda8 | 2015-12-31 14:46:02 +0000 | [diff] [blame] | 854 | mHandler, this); |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 855 | createUserSwitcher(); |
Adrian Roos | 2b154a9 | 2014-11-17 15:18:39 +0100 | [diff] [blame] | 856 | } |
Adrian Roos | 723632e | 2014-07-23 21:13:21 +0200 | [diff] [blame] | 857 | |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 858 | // Set up the quick settings tile panel |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 859 | DensityContainer container = (DensityContainer) mStatusBarWindow.findViewById( |
| 860 | R.id.qs_density_container); |
| 861 | if (container != null) { |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 862 | final QSTileHost qsh = new QSTileHost(mContext, this, |
| 863 | mBluetoothController, mLocationController, mRotationLockController, |
Jason Monk | 51e4dc0 | 2014-07-22 12:00:47 -0400 | [diff] [blame] | 864 | mNetworkController, mZenModeController, mHotspotController, |
John Spurlock | 657c62c | 2014-07-22 12:18:09 -0400 | [diff] [blame] | 865 | mCastController, mFlashlightController, |
Jason Monk | abe1974 | 2015-09-29 09:47:06 -0400 | [diff] [blame] | 866 | mUserSwitcherController, mUserInfoController, mKeyguardMonitor, |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 867 | mSecurityController, mBatteryController, mIconController, |
| 868 | mNextAlarmController); |
Adrian Roos | 5fd872e | 2014-08-12 17:28:58 +0200 | [diff] [blame] | 869 | mBrightnessMirrorController = new BrightnessMirrorController(mStatusBarWindow); |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 870 | container.addInflateListener(new InflateListener() { |
John Spurlock | bceed06 | 2014-08-10 18:04:16 -0400 | [diff] [blame] | 871 | @Override |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 872 | public void onInflated(View v) { |
| 873 | QSContainer qsContainer = (QSContainer) v.findViewById( |
| 874 | R.id.quick_settings_container); |
| 875 | qsContainer.setHost(qsh); |
| 876 | mQSPanel = qsContainer.getQsPanel(); |
| 877 | mQSPanel.setBrightnessMirror(mBrightnessMirrorController); |
| 878 | mHeader = qsContainer.getHeader(); |
| 879 | initSignalCluster(mHeader); |
| 880 | mHeader.setActivityStarter(PhoneStatusBar.this); |
John Spurlock | bceed06 | 2014-08-10 18:04:16 -0400 | [diff] [blame] | 881 | } |
| 882 | }); |
Siva Velusamy | 537421b | 2012-09-14 14:45:02 -0700 | [diff] [blame] | 883 | } |
| 884 | |
Jorim Jaggi | 3d878be | 2014-05-10 03:22:32 +0200 | [diff] [blame] | 885 | // User info. Trigger first load. |
Jorim Jaggi | 4538027d | 2014-07-30 15:43:13 +0200 | [diff] [blame] | 886 | mKeyguardStatusBar.setUserInfoController(mUserInfoController); |
Adrian Roos | ffc9097 | 2015-06-09 18:09:49 -0700 | [diff] [blame] | 887 | mKeyguardStatusBar.setUserSwitcherController(mUserSwitcherController); |
Jorim Jaggi | 3d878be | 2014-05-10 03:22:32 +0200 | [diff] [blame] | 888 | mUserInfoController.reloadUserInfo(); |
| 889 | |
Jorim Jaggi | 708f772 | 2014-08-20 17:30:38 +0200 | [diff] [blame] | 890 | ((BatteryMeterView) mStatusBarView.findViewById(R.id.battery)).setBatteryController( |
| 891 | mBatteryController); |
Jorim Jaggi | 4538027d | 2014-07-30 15:43:13 +0200 | [diff] [blame] | 892 | mKeyguardStatusBar.setBatteryController(mBatteryController); |
Jorim Jaggi | 853b070 | 2014-07-05 04:31:14 +0200 | [diff] [blame] | 893 | |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 894 | PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); |
| 895 | mBroadcastReceiver.onReceive(mContext, |
| 896 | new Intent(pm.isScreenOn() ? Intent.ACTION_SCREEN_ON : Intent.ACTION_SCREEN_OFF)); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 897 | mGestureWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, |
| 898 | "GestureWakeLock"); |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 899 | mVibrator = mContext.getSystemService(Vibrator.class); |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 900 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 901 | // receive broadcasts |
| 902 | IntentFilter filter = new IntentFilter(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 903 | filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); |
| 904 | filter.addAction(Intent.ACTION_SCREEN_OFF); |
Daniel Sandler | 7f3cf95 | 2012-08-31 14:57:09 -0400 | [diff] [blame] | 905 | filter.addAction(Intent.ACTION_SCREEN_ON); |
Kenny Guy | 44fc65f | 2014-11-28 22:18:14 +0000 | [diff] [blame] | 906 | context.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 907 | |
Adrian Roos | 8e3e836 | 2015-07-16 19:42:22 -0700 | [diff] [blame] | 908 | IntentFilter demoFilter = new IntentFilter(); |
| 909 | if (DEBUG_MEDIA_FAKE_ARTWORK) { |
| 910 | demoFilter.addAction(ACTION_FAKE_ARTWORK); |
| 911 | } |
| 912 | demoFilter.addAction(ACTION_DEMO); |
| 913 | context.registerReceiverAsUser(mDemoReceiver, UserHandle.ALL, demoFilter, |
| 914 | android.Manifest.permission.DUMP, null); |
| 915 | |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 916 | // listen for USER_SETUP_COMPLETE setting (per-user) |
| 917 | resetUserSetupObserver(); |
| 918 | |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 919 | // disable profiling bars, since they overlap and clutter the output on app windows |
| 920 | ThreadedRenderer.overrideProperty("disableProfileBars", "true"); |
| 921 | |
| 922 | // Private API call to make the shadows look better for Recents |
| 923 | ThreadedRenderer.overrideProperty("ambientRatio", String.valueOf(1.5f)); |
| 924 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 925 | return mStatusBarView; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 926 | } |
| 927 | |
Selim Cinek | 01af334 | 2016-02-09 19:25:31 -0800 | [diff] [blame] | 928 | @Override |
| 929 | protected void reInflateViews() { |
| 930 | super.reInflateViews(); |
| 931 | inflateDismissView(); |
| 932 | updateClearAll(); |
| 933 | inflateEmptyShadeView(); |
| 934 | updateEmptyShadeView(); |
| 935 | } |
| 936 | |
| 937 | private void inflateEmptyShadeView() { |
| 938 | mEmptyShadeView = (EmptyShadeView) LayoutInflater.from(mContext).inflate( |
| 939 | R.layout.status_bar_no_notifications, mStackScroller, false); |
| 940 | mStackScroller.setEmptyShadeView(mEmptyShadeView); |
| 941 | } |
| 942 | |
| 943 | private void inflateDismissView() { |
| 944 | mDismissView = (DismissView) LayoutInflater.from(mContext).inflate( |
| 945 | R.layout.status_bar_notification_dismiss_all, mStackScroller, false); |
| 946 | mDismissView.setOnButtonClickListener(new View.OnClickListener() { |
| 947 | @Override |
| 948 | public void onClick(View v) { |
| 949 | MetricsLogger.action(mContext, MetricsEvent.ACTION_DISMISS_ALL_NOTES); |
| 950 | clearAllNotifications(); |
| 951 | } |
| 952 | }); |
| 953 | mStackScroller.setDismissView(mDismissView); |
| 954 | } |
| 955 | |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 956 | protected void createUserSwitcher() { |
| 957 | mKeyguardUserSwitcher = new KeyguardUserSwitcher(mContext, |
| 958 | (ViewStub) mStatusBarWindow.findViewById(R.id.keyguard_user_switcher), |
| 959 | mKeyguardStatusBar, mNotificationPanel, mUserSwitcherController); |
| 960 | } |
| 961 | |
Xiaohui Chen | d839d1a | 2016-01-21 13:05:02 -0800 | [diff] [blame] | 962 | protected void inflateStatusBarWindow(Context context) { |
| 963 | mStatusBarWindow = (StatusBarWindowView) View.inflate(context, |
| 964 | R.layout.super_status_bar, null); |
| 965 | } |
| 966 | |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 967 | protected void createNavigationBarView(Context context) { |
Xiaohui Chen | 8bdcd1f | 2016-01-19 13:52:07 -0800 | [diff] [blame] | 968 | inflateNavigationBarView(context); |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 969 | mNavigationBarView.setDisabledFlags(mDisabled1); |
| 970 | mNavigationBarView.setComponents(mRecents, getComponent(Divider.class)); |
| 971 | mNavigationBarView.setOnVerticalChangedListener( |
| 972 | new NavigationBarView.OnVerticalChangedListener() { |
| 973 | @Override |
| 974 | public void onVerticalChanged(boolean isVertical) { |
| 975 | if (mAssistManager != null) { |
| 976 | mAssistManager.onConfigurationChanged(); |
| 977 | } |
| 978 | mNotificationPanel.setQsScrimEnabled(!isVertical); |
| 979 | } |
| 980 | }); |
| 981 | mNavigationBarView.setOnTouchListener(new View.OnTouchListener() { |
| 982 | @Override |
| 983 | public boolean onTouch(View v, MotionEvent event) { |
| 984 | checkUserAutohide(v, event); |
| 985 | return false; |
| 986 | }}); |
| 987 | } |
| 988 | |
Xiaohui Chen | 8bdcd1f | 2016-01-19 13:52:07 -0800 | [diff] [blame] | 989 | protected void inflateNavigationBarView(Context context) { |
Jason Monk | 4f878ef | 2016-01-23 14:37:38 -0500 | [diff] [blame] | 990 | mNavigationBarView = (NavigationBarView) View.inflate( |
| 991 | context, R.layout.navigation_bar, null); |
Xiaohui Chen | 8bdcd1f | 2016-01-19 13:52:07 -0800 | [diff] [blame] | 992 | } |
| 993 | |
| 994 | protected void initSignalCluster(View containerView) { |
Xiaohui Chen | 1094230 | 2015-12-16 16:38:13 -0800 | [diff] [blame] | 995 | SignalClusterView signalCluster = |
| 996 | (SignalClusterView) containerView.findViewById(R.id.signal_cluster); |
| 997 | if (signalCluster != null) { |
| 998 | mNetworkController.addSignalCallback(signalCluster); |
| 999 | signalCluster.setSecurityController(mSecurityController); |
| 1000 | signalCluster.setNetworkController(mNetworkController); |
| 1001 | } |
| 1002 | } |
| 1003 | |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1004 | private void clearAllNotifications() { |
| 1005 | |
| 1006 | // animate-swipe all dismissable notifications, then animate the shade closed |
| 1007 | int numChildren = mStackScroller.getChildCount(); |
| 1008 | |
| 1009 | final ArrayList<View> viewsToHide = new ArrayList<View>(numChildren); |
| 1010 | for (int i = 0; i < numChildren; i++) { |
| 1011 | final View child = mStackScroller.getChildAt(i); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1012 | if (child instanceof ExpandableNotificationRow) { |
| 1013 | if (mStackScroller.canChildBeDismissed(child)) { |
| 1014 | if (child.getVisibility() == View.VISIBLE) { |
| 1015 | viewsToHide.add(child); |
| 1016 | } |
| 1017 | } |
| 1018 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
| 1019 | List<ExpandableNotificationRow> children = row.getNotificationChildren(); |
| 1020 | if (row.areChildrenExpanded() && children != null) { |
| 1021 | for (ExpandableNotificationRow childRow : children) { |
| 1022 | if (childRow.getVisibility() == View.VISIBLE) { |
| 1023 | viewsToHide.add(childRow); |
| 1024 | } |
| 1025 | } |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1026 | } |
| 1027 | } |
| 1028 | } |
| 1029 | if (viewsToHide.isEmpty()) { |
| 1030 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
| 1031 | return; |
| 1032 | } |
| 1033 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1034 | addPostCollapseAction(new Runnable() { |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1035 | @Override |
| 1036 | public void run() { |
Selim Cinek | 9c17b77 | 2015-07-07 20:37:09 -0700 | [diff] [blame] | 1037 | mStackScroller.setDismissAllInProgress(false); |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1038 | try { |
| 1039 | mBarService.onClearAllNotifications(mCurrentUserId); |
| 1040 | } catch (Exception ex) { } |
| 1041 | } |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1042 | }); |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1043 | |
| 1044 | performDismissAllAnimations(viewsToHide); |
| 1045 | |
| 1046 | } |
| 1047 | |
| 1048 | private void performDismissAllAnimations(ArrayList<View> hideAnimatedList) { |
| 1049 | Runnable animationFinishAction = new Runnable() { |
| 1050 | @Override |
| 1051 | public void run() { |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1052 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
| 1053 | } |
| 1054 | }; |
| 1055 | |
| 1056 | // let's disable our normal animations |
| 1057 | mStackScroller.setDismissAllInProgress(true); |
| 1058 | |
| 1059 | // Decrease the delay for every row we animate to give the sense of |
| 1060 | // accelerating the swipes |
| 1061 | int rowDelayDecrement = 10; |
| 1062 | int currentDelay = 140; |
Selim Cinek | 7d5f374 | 2014-11-07 18:07:49 +0100 | [diff] [blame] | 1063 | int totalDelay = 180; |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1064 | int numItems = hideAnimatedList.size(); |
Selim Cinek | 7d5f374 | 2014-11-07 18:07:49 +0100 | [diff] [blame] | 1065 | for (int i = numItems - 1; i >= 0; i--) { |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1066 | View view = hideAnimatedList.get(i); |
| 1067 | Runnable endRunnable = null; |
Selim Cinek | 7d5f374 | 2014-11-07 18:07:49 +0100 | [diff] [blame] | 1068 | if (i == 0) { |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1069 | endRunnable = animationFinishAction; |
| 1070 | } |
| 1071 | mStackScroller.dismissViewAnimated(view, endRunnable, totalDelay, 260); |
| 1072 | currentDelay = Math.max(50, currentDelay - rowDelayDecrement); |
| 1073 | totalDelay += currentDelay; |
| 1074 | } |
| 1075 | } |
| 1076 | |
John Spurlock | ae641c9 | 2014-06-30 18:11:40 -0400 | [diff] [blame] | 1077 | @Override |
| 1078 | protected void setZenMode(int mode) { |
| 1079 | super.setZenMode(mode); |
| 1080 | if (mIconPolicy != null) { |
| 1081 | mIconPolicy.setZenMode(mode); |
| 1082 | } |
| 1083 | } |
| 1084 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 1085 | protected void startKeyguard() { |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 1086 | KeyguardViewMediator keyguardViewMediator = getComponent(KeyguardViewMediator.class); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 1087 | mFingerprintUnlockController = new FingerprintUnlockController(mContext, |
| 1088 | mStatusBarWindowManager, mDozeScrimController, keyguardViewMediator, |
| 1089 | mScrimController, this); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 1090 | mStatusBarKeyguardViewManager = keyguardViewMediator.registerStatusBar(this, |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 1091 | getBouncerContainer(), mStatusBarWindowManager, mScrimController, |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 1092 | mFingerprintUnlockController); |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 1093 | mKeyguardIndicationController.setStatusBarKeyguardViewManager( |
| 1094 | mStatusBarKeyguardViewManager); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 1095 | mFingerprintUnlockController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager); |
Adrian Roos | d28ccd7 | 2016-01-06 15:23:14 +0100 | [diff] [blame] | 1096 | mRemoteInputController.addCallback(mStatusBarKeyguardViewManager); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 1097 | mKeyguardViewMediatorCallback = keyguardViewMediator.getViewMediatorCallback(); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 1098 | mLightStatusBarController.setFingerprintUnlockController(mFingerprintUnlockController); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1099 | } |
| 1100 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1101 | @Override |
Michael Jurka | cb2522c | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 1102 | protected View getStatusBarView() { |
| 1103 | return mStatusBarView; |
| 1104 | } |
| 1105 | |
Jorim Jaggi | 0a27be8 | 2014-06-11 03:22:39 +0200 | [diff] [blame] | 1106 | public StatusBarWindowView getStatusBarWindow() { |
| 1107 | return mStatusBarWindow; |
| 1108 | } |
| 1109 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 1110 | protected ViewGroup getBouncerContainer() { |
| 1111 | return mStatusBarWindow; |
| 1112 | } |
| 1113 | |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 1114 | public int getStatusBarHeight() { |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1115 | if (mNaturalBarHeight < 0) { |
| 1116 | final Resources res = mContext.getResources(); |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 1117 | mNaturalBarHeight = |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1118 | res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); |
| 1119 | } |
| 1120 | return mNaturalBarHeight; |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 1121 | } |
| 1122 | |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1123 | private View.OnClickListener mRecentsClickListener = new View.OnClickListener() { |
| 1124 | public void onClick(View v) { |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 1125 | awakenDreams(); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1126 | toggleRecentApps(); |
| 1127 | } |
| 1128 | }; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1129 | |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 1130 | private View.OnLongClickListener mLongPressBackListener = new View.OnLongClickListener() { |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 1131 | @Override |
| 1132 | public boolean onLongClick(View v) { |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 1133 | return handleLongPressBack(); |
| 1134 | } |
| 1135 | }; |
| 1136 | |
| 1137 | private View.OnLongClickListener mRecentsLongClickListener = new View.OnLongClickListener() { |
| 1138 | |
| 1139 | @Override |
| 1140 | public boolean onLongClick(View v) { |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1141 | if (mRecents == null) { |
| 1142 | return false; |
| 1143 | } |
| 1144 | boolean initiallyDocked = WindowManagerProxy.getInstance().getDockSide() |
| 1145 | == WindowManager.DOCKED_INVALID; |
| 1146 | boolean dockedAtEnd = toggleSplitScreenMode(); |
| 1147 | if (dockedAtEnd != initiallyDocked) { |
| 1148 | int logAction = dockedAtEnd ? MetricsEvent.ACTION_WINDOW_DOCK_LONGPRESS |
| 1149 | : MetricsEvent.ACTION_WINDOW_UNDOCK_LONGPRESS; |
| 1150 | MetricsLogger.action(mContext, logAction); |
| 1151 | return true; |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 1152 | } |
| 1153 | return false; |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 1154 | } |
| 1155 | }; |
| 1156 | |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 1157 | @Override |
| 1158 | protected boolean toggleSplitScreenMode() { |
| 1159 | if (mRecents == null) { |
| 1160 | return false; |
| 1161 | } |
| 1162 | int dockSide = WindowManagerProxy.getInstance().getDockSide(); |
| 1163 | if (dockSide == WindowManager.DOCKED_INVALID) { |
| 1164 | Point realSize = new Point(); |
| 1165 | mContext.getSystemService(DisplayManager.class).getDisplay(Display.DEFAULT_DISPLAY) |
| 1166 | .getRealSize(realSize); |
| 1167 | Rect initialBounds= new Rect(0, 0, realSize.x, realSize.y); |
| 1168 | return mRecents.dockTopTask(NavigationBarGestureHelper.DRAG_MODE_NONE, |
| 1169 | ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT, |
| 1170 | initialBounds); |
| 1171 | } else { |
| 1172 | EventBus.getDefault().send(new UndockingTaskEvent()); |
| 1173 | return false; |
| 1174 | } |
| 1175 | } |
| 1176 | |
Jorim Jaggi | 7e6571f | 2015-06-25 11:52:48 -0700 | [diff] [blame] | 1177 | private final View.OnLongClickListener mLongPressHomeListener |
| 1178 | = new View.OnLongClickListener() { |
| 1179 | @Override |
| 1180 | public boolean onLongClick(View v) { |
| 1181 | if (shouldDisableNavbarGestures()) { |
| 1182 | return false; |
| 1183 | } |
Chris Wren | f6e9228b | 2016-01-26 18:04:35 -0500 | [diff] [blame] | 1184 | MetricsLogger.action(mContext, MetricsEvent.ACTION_ASSIST_LONG_PRESS); |
Jorim Jaggi | 165ce06 | 2015-07-06 16:18:11 -0700 | [diff] [blame] | 1185 | mAssistManager.startAssist(new Bundle() /* args */); |
Daniel Sandler | a2fbe53 | 2012-08-10 01:19:03 -0400 | [diff] [blame] | 1186 | awakenDreams(); |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 1187 | if (mNavigationBarView != null) { |
Xiyuan Xia | ee7dd05 | 2015-05-15 09:46:27 -0700 | [diff] [blame] | 1188 | mNavigationBarView.abortCurrentGesture(); |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 1189 | } |
Jorim Jaggi | 7e6571f | 2015-06-25 11:52:48 -0700 | [diff] [blame] | 1190 | return true; |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 1191 | } |
| 1192 | }; |
| 1193 | |
Jorim Jaggi | 7e6571f | 2015-06-25 11:52:48 -0700 | [diff] [blame] | 1194 | private final View.OnTouchListener mHomeActionListener = new View.OnTouchListener() { |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 1195 | public boolean onTouch(View v, MotionEvent event) { |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 1196 | switch (event.getAction()) { |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 1197 | case MotionEvent.ACTION_UP: |
| 1198 | case MotionEvent.ACTION_CANCEL: |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 1199 | awakenDreams(); |
| 1200 | break; |
| 1201 | } |
| 1202 | return false; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 1203 | } |
| 1204 | }; |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1205 | |
Daniel Sandler | a2fbe53 | 2012-08-10 01:19:03 -0400 | [diff] [blame] | 1206 | private void awakenDreams() { |
| 1207 | if (mDreamManager != null) { |
| 1208 | try { |
| 1209 | mDreamManager.awaken(); |
| 1210 | } catch (RemoteException e) { |
| 1211 | // fine, stay asleep then |
| 1212 | } |
| 1213 | } |
| 1214 | } |
| 1215 | |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 1216 | private void prepareNavigationBarView() { |
| 1217 | mNavigationBarView.reorient(); |
| 1218 | |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 1219 | ButtonDispatcher recentsButton = mNavigationBarView.getRecentsButton(); |
| 1220 | recentsButton.setOnClickListener(mRecentsClickListener); |
| 1221 | recentsButton.setOnTouchListener(mRecentsPreloadOnTouchListener); |
| 1222 | recentsButton.setLongClickable(true); |
| 1223 | recentsButton.setOnLongClickListener(mRecentsLongClickListener); |
Anthony Chen | ada1304 | 2016-01-19 16:57:20 -0800 | [diff] [blame] | 1224 | |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 1225 | ButtonDispatcher backButton = mNavigationBarView.getBackButton(); |
| 1226 | backButton.setLongClickable(true); |
| 1227 | backButton.setOnLongClickListener(mLongPressBackListener); |
Anthony Chen | ada1304 | 2016-01-19 16:57:20 -0800 | [diff] [blame] | 1228 | |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 1229 | ButtonDispatcher homeButton = mNavigationBarView.getHomeButton(); |
| 1230 | homeButton.setOnTouchListener(mHomeActionListener); |
| 1231 | homeButton.setOnLongClickListener(mLongPressHomeListener); |
Anthony Chen | ada1304 | 2016-01-19 16:57:20 -0800 | [diff] [blame] | 1232 | |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 1233 | mAssistManager.onConfigurationChanged(); |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 1234 | } |
| 1235 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1236 | // For small-screen devices (read: phones) that lack hardware navigation buttons |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 1237 | protected void addNavigationBar() { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 1238 | if (DEBUG) Log.v(TAG, "addNavigationBar: about to add " + mNavigationBarView); |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 1239 | if (mNavigationBarView == null) return; |
Jim Miller | 17dfec7 | 2011-07-08 19:09:55 -0700 | [diff] [blame] | 1240 | |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 1241 | prepareNavigationBarView(); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1242 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1243 | mWindowManager.addView(mNavigationBarView, getNavigationBarLayoutParams()); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1244 | } |
| 1245 | |
Victor Chan | ecdb8b0 | 2016-01-07 18:32:43 -0800 | [diff] [blame] | 1246 | protected void repositionNavigationBar() { |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 1247 | if (mNavigationBarView == null || !mNavigationBarView.isAttachedToWindow()) return; |
Jim Miller | 17dfec7 | 2011-07-08 19:09:55 -0700 | [diff] [blame] | 1248 | |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 1249 | prepareNavigationBarView(); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1250 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1251 | mWindowManager.updateViewLayout(mNavigationBarView, getNavigationBarLayoutParams()); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1252 | } |
| 1253 | |
John Spurlock | 1bbd49d | 2012-10-19 11:09:32 -0400 | [diff] [blame] | 1254 | private void notifyNavigationBarScreenOn(boolean screenOn) { |
| 1255 | if (mNavigationBarView == null) return; |
| 1256 | mNavigationBarView.notifyScreenOn(screenOn); |
| 1257 | } |
| 1258 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1259 | private WindowManager.LayoutParams getNavigationBarLayoutParams() { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1260 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1261 | LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1262 | WindowManager.LayoutParams.TYPE_NAVIGATION_BAR, |
| 1263 | 0 |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1264 | | WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING |
| 1265 | | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 1266 | | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
Daniel Sandler | c26185b | 2012-08-29 15:49:53 -0400 | [diff] [blame] | 1267 | | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
Jim Miller | d99e7fd | 2012-05-08 16:30:42 -0700 | [diff] [blame] | 1268 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1269 | PixelFormat.TRANSLUCENT); |
Daniel Sandler | c638c1e | 2011-08-24 16:19:23 -0700 | [diff] [blame] | 1270 | // 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] | 1271 | if (ActivityManager.isHighEndGfx()) { |
Daniel Sandler | c638c1e | 2011-08-24 16:19:23 -0700 | [diff] [blame] | 1272 | lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
| 1273 | } |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1274 | |
| 1275 | lp.setTitle("NavigationBar"); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1276 | lp.windowAnimations = 0; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1277 | return lp; |
| 1278 | } |
| 1279 | |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 1280 | @Override |
| 1281 | public void setIcon(String slot, StatusBarIcon icon) { |
| 1282 | mIconController.setIcon(slot, icon); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1283 | } |
| 1284 | |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 1285 | @Override |
| 1286 | public void removeIcon(String slot) { |
| 1287 | mIconController.removeIcon(slot); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1288 | } |
| 1289 | |
John Spurlock | bf20eab | 2014-04-09 16:40:39 -0400 | [diff] [blame] | 1290 | public UserHandle getCurrentUserHandle() { |
| 1291 | return new UserHandle(mCurrentUserId); |
| 1292 | } |
| 1293 | |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 1294 | @Override |
Selim Cinek | 379ff8f | 2015-02-20 17:03:16 +0100 | [diff] [blame] | 1295 | public void addNotification(StatusBarNotification notification, RankingMap ranking, |
| 1296 | Entry oldEntry) { |
Chris Wren | aaa58d1 | 2014-06-03 14:29:12 -0400 | [diff] [blame] | 1297 | if (DEBUG) Log.d(TAG, "addNotification key=" + notification.getKey()); |
Chris Wren | d4db6cb | 2013-08-07 16:05:23 -0400 | [diff] [blame] | 1298 | |
Julia Reynolds | f612869ae | 2015-11-05 16:48:55 -0500 | [diff] [blame] | 1299 | mNotificationData.updateRanking(ranking); |
Selim Cinek | 8d490d4 | 2015-04-10 00:05:50 -0700 | [diff] [blame] | 1300 | Entry shadeEntry = createNotificationViews(notification); |
Chris Wren | a4ef620 | 2014-06-09 18:07:30 -0400 | [diff] [blame] | 1301 | if (shadeEntry == null) { |
| 1302 | return; |
| 1303 | } |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 1304 | boolean isHeadsUped = mUseHeadsUp && shouldPeek(shadeEntry); |
Selim Cinek | 31d9ef7 | 2015-04-15 19:29:49 -0700 | [diff] [blame] | 1305 | if (isHeadsUped) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1306 | mHeadsUpManager.showNotification(shadeEntry); |
Amith Yamasani | f47e51e | 2015-04-17 10:02:15 -0700 | [diff] [blame] | 1307 | // Mark as seen immediately |
| 1308 | setNotificationShown(notification); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1309 | } |
Chris Wren | a4ef620 | 2014-06-09 18:07:30 -0400 | [diff] [blame] | 1310 | |
Selim Cinek | 31d9ef7 | 2015-04-15 19:29:49 -0700 | [diff] [blame] | 1311 | if (!isHeadsUped && notification.getNotification().fullScreenIntent != null) { |
Julia Reynolds | d560729 | 2016-02-05 15:25:58 -0500 | [diff] [blame] | 1312 | if (shouldSuppressFullScreenIntent(notification.getKey())) { |
Julia Reynolds | 6172158 | 2016-01-05 08:35:25 -0500 | [diff] [blame] | 1313 | if (DEBUG) { |
| 1314 | Log.d(TAG, "No Fullscreen intent: suppressed by DND: " + notification.getKey()); |
| 1315 | } |
Julia Reynolds | f0f629f | 2016-02-25 09:34:04 -0500 | [diff] [blame] | 1316 | } else if (mNotificationData.getImportance(notification.getKey()) |
| 1317 | < NotificationListenerService.Ranking.IMPORTANCE_MAX) { |
| 1318 | if (DEBUG) { |
| 1319 | Log.d(TAG, "No Fullscreen intent: not important enough: " |
| 1320 | + notification.getKey()); |
| 1321 | } |
Julia Reynolds | 6172158 | 2016-01-05 08:35:25 -0500 | [diff] [blame] | 1322 | } else { |
| 1323 | // Stop screensaver if the notification has a full-screen intent. |
| 1324 | // (like an incoming phone call) |
| 1325 | awakenDreams(); |
Daniel Sandler | c9ce0ab | 2012-09-04 13:27:09 -0400 | [diff] [blame] | 1326 | |
Julia Reynolds | 6172158 | 2016-01-05 08:35:25 -0500 | [diff] [blame] | 1327 | // not immersive & a full-screen alert should be shown |
| 1328 | if (DEBUG) |
| 1329 | Log.d(TAG, "Notification has fullScreenIntent; sending fullScreenIntent"); |
| 1330 | try { |
| 1331 | EventLog.writeEvent(EventLogTags.SYSUI_FULLSCREEN_NOTIFICATION, |
| 1332 | notification.getKey()); |
| 1333 | notification.getNotification().fullScreenIntent.send(); |
| 1334 | shadeEntry.notifyFullScreenIntentLaunched(); |
| 1335 | MetricsLogger.count(mContext, "note_fullscreen", 1); |
| 1336 | } catch (PendingIntent.CanceledException e) { |
| 1337 | } |
John Spurlock | bf20eab | 2014-04-09 16:40:39 -0400 | [diff] [blame] | 1338 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1339 | } |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1340 | addNotificationViews(shadeEntry, ranking); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1341 | // Recalculate the position of the sliding windows and the titles. |
| 1342 | setAreThereNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1343 | } |
| 1344 | |
Julia Reynolds | d560729 | 2016-02-05 15:25:58 -0500 | [diff] [blame] | 1345 | private boolean shouldSuppressFullScreenIntent(String key) { |
Julia Reynolds | 0971cb0 | 2016-01-26 17:00:22 -0500 | [diff] [blame] | 1346 | if (mPowerManager.isInteractive()) { |
Julia Reynolds | 0971cb0 | 2016-01-26 17:00:22 -0500 | [diff] [blame] | 1347 | return mNotificationData.shouldSuppressScreenOn(key); |
Julia Reynolds | d560729 | 2016-02-05 15:25:58 -0500 | [diff] [blame] | 1348 | } else { |
| 1349 | return mNotificationData.shouldSuppressScreenOff(key); |
Julia Reynolds | 0971cb0 | 2016-01-26 17:00:22 -0500 | [diff] [blame] | 1350 | } |
| 1351 | } |
| 1352 | |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 1353 | @Override |
Christoph Studer | e71fefc | 2014-06-24 16:16:49 +0200 | [diff] [blame] | 1354 | protected void updateNotificationRanking(RankingMap ranking) { |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 1355 | mNotificationData.updateRanking(ranking); |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 1356 | updateNotifications(); |
| 1357 | } |
| 1358 | |
| 1359 | @Override |
Christoph Studer | e71fefc | 2014-06-24 16:16:49 +0200 | [diff] [blame] | 1360 | public void removeNotification(String key, RankingMap ranking) { |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1361 | boolean deferRemoval = false; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1362 | if (mHeadsUpManager.isHeadsUp(key)) { |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1363 | deferRemoval = !mHeadsUpManager.removeNotification(key); |
Chris Wren | a4ef620 | 2014-06-09 18:07:30 -0400 | [diff] [blame] | 1364 | } |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1365 | if (key.equals(mMediaNotificationKey)) { |
| 1366 | clearCurrentMediaNotification(); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 1367 | updateMediaMetaData(true, true); |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1368 | } |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 1369 | if (deferRemoval) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 1370 | mLatestRankingMap = ranking; |
| 1371 | mHeadsUpEntriesToRemoveOnSwitch.add(mHeadsUpManager.getEntry(key)); |
| 1372 | return; |
| 1373 | } |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1374 | StatusBarNotification old = removeNotificationViews(key, ranking); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 1375 | if (SPEW) Log.d(TAG, "removeNotification key=" + key + " old=" + old); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1376 | |
| 1377 | if (old != null) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1378 | if (CLOSE_PANEL_WHEN_EMPTIED && !hasActiveNotifications() |
Jorim Jaggi | ba94f88 | 2014-08-20 19:23:55 +0200 | [diff] [blame] | 1379 | && !mNotificationPanel.isTracking() && !mNotificationPanel.isQsExpanded()) { |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 1380 | if (mState == StatusBarState.SHADE) { |
| 1381 | animateCollapsePanels(); |
| 1382 | } else if (mState == StatusBarState.SHADE_LOCKED) { |
| 1383 | goToKeyguard(); |
| 1384 | } |
Daniel Sandler | 8cc36e5 | 2011-10-17 14:18:46 -0400 | [diff] [blame] | 1385 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1386 | } |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 1387 | setAreThereNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1388 | } |
| 1389 | |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 1390 | @Override |
| 1391 | protected void refreshLayout(int layoutDirection) { |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 1392 | if (mNavigationBarView != null) { |
| 1393 | mNavigationBarView.setLayoutDirection(layoutDirection); |
| 1394 | } |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 1395 | } |
| 1396 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1397 | private void updateNotificationShade() { |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 1398 | if (mStackScroller == null) return; |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 1399 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1400 | // Do not modify the notifications during collapse. |
| 1401 | if (isCollapsing()) { |
| 1402 | addPostCollapseAction(new Runnable() { |
| 1403 | @Override |
| 1404 | public void run() { |
| 1405 | updateNotificationShade(); |
| 1406 | } |
| 1407 | }); |
| 1408 | return; |
| 1409 | } |
| 1410 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1411 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1412 | ArrayList<ExpandableNotificationRow> toShow = new ArrayList<>(activeNotifications.size()); |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1413 | final int N = activeNotifications.size(); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1414 | for (int i=0; i<N; i++) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1415 | Entry ent = activeNotifications.get(i); |
| 1416 | int vis = ent.notification.getNotification().visibility; |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 1417 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1418 | // Display public version of the notification if we need to redact. |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1419 | final boolean hideSensitive = |
| 1420 | !userAllowsPrivateNotificationsInPublic(ent.notification.getUserId()); |
Chris Wren | 3ad4e3a | 2014-09-02 17:23:51 -0400 | [diff] [blame] | 1421 | boolean sensitiveNote = vis == Notification.VISIBILITY_PRIVATE; |
| 1422 | boolean sensitivePackage = packageHasVisibilityOverride(ent.notification.getKey()); |
| 1423 | boolean sensitive = (sensitiveNote && hideSensitive) || sensitivePackage; |
| 1424 | boolean showingPublic = sensitive && isLockscreenPublicMode(); |
Sudheer Shanka | f5b850e | 2016-01-25 19:58:59 +0000 | [diff] [blame] | 1425 | if (showingPublic) { |
| 1426 | updatePublicContentView(ent, ent.notification); |
| 1427 | } |
Selim Cinek | 3c76d50 | 2016-02-19 15:16:33 -0800 | [diff] [blame] | 1428 | ent.row.setSensitive(sensitive, hideSensitive); |
Dan Sandler | 1b71878 | 2014-07-18 12:43:45 -0400 | [diff] [blame] | 1429 | if (ent.autoRedacted && ent.legacy) { |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 1430 | // TODO: Also fade this? Or, maybe easier (and better), provide a dark redacted form |
| 1431 | // for legacy auto redacted notifications. |
Dan Sandler | 1b71878 | 2014-07-18 12:43:45 -0400 | [diff] [blame] | 1432 | if (showingPublic) { |
| 1433 | ent.row.setShowingLegacyBackground(false); |
| 1434 | } else { |
| 1435 | ent.row.setShowingLegacyBackground(true); |
| 1436 | } |
| 1437 | } |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1438 | if (mGroupManager.isChildInGroupWithSummary(ent.row.getStatusBarNotification())) { |
| 1439 | ExpandableNotificationRow summary = mGroupManager.getGroupSummary( |
| 1440 | ent.row.getStatusBarNotification()); |
| 1441 | List<ExpandableNotificationRow> orderedChildren = |
| 1442 | mTmpChildOrderMap.get(summary); |
| 1443 | if (orderedChildren == null) { |
| 1444 | orderedChildren = new ArrayList<>(); |
| 1445 | mTmpChildOrderMap.put(summary, orderedChildren); |
| 1446 | } |
| 1447 | orderedChildren.add(ent.row); |
| 1448 | } else { |
| 1449 | toShow.add(ent.row); |
| 1450 | } |
| 1451 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1452 | } |
| 1453 | |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1454 | ArrayList<ExpandableNotificationRow> toRemove = new ArrayList<>(); |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 1455 | for (int i=0; i< mStackScroller.getChildCount(); i++) { |
| 1456 | View child = mStackScroller.getChildAt(i); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1457 | if (!toShow.contains(child) && child instanceof ExpandableNotificationRow) { |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1458 | toRemove.add((ExpandableNotificationRow) child); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1459 | } |
| 1460 | } |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1461 | |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1462 | for (ExpandableNotificationRow remove : toRemove) { |
| 1463 | if (mGroupManager.isChildInGroupWithSummary(remove.getStatusBarNotification())) { |
| 1464 | // we are only transfering this notification to its parent, don't generate an animation |
| 1465 | mStackScroller.setChildTransferInProgress(true); |
| 1466 | } |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 1467 | mStackScroller.removeView(remove); |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1468 | mStackScroller.setChildTransferInProgress(false); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1469 | } |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1470 | for (int i=0; i<toShow.size(); i++) { |
| 1471 | View v = toShow.get(i); |
| 1472 | if (v.getParent() == null) { |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1473 | mStackScroller.addView(v); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1474 | } |
| 1475 | } |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 1476 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1477 | // So after all this work notifications still aren't sorted correctly. |
| 1478 | // Let's do that now by advancing through toShow and mStackScroller in |
| 1479 | // lock-step, making sure mStackScroller matches what we see in toShow. |
| 1480 | int j = 0; |
| 1481 | for (int i = 0; i < mStackScroller.getChildCount(); i++) { |
| 1482 | View child = mStackScroller.getChildAt(i); |
| 1483 | if (!(child instanceof ExpandableNotificationRow)) { |
| 1484 | // We don't care about non-notification views. |
| 1485 | continue; |
| 1486 | } |
| 1487 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1488 | ExpandableNotificationRow targetChild = toShow.get(j); |
| 1489 | if (child != targetChild) { |
| 1490 | // Oops, wrong notification at this position. Put the right one |
| 1491 | // here and advance both lists. |
| 1492 | mStackScroller.changeViewPosition(targetChild, i); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1493 | } |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1494 | j++; |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1495 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1496 | } |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1497 | |
| 1498 | // lets handle the child notifications now |
| 1499 | updateNotificationShadeForChildren(); |
| 1500 | |
| 1501 | // clear the map again for the next usage |
| 1502 | mTmpChildOrderMap.clear(); |
| 1503 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1504 | updateRowStates(); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1505 | updateSpeedbump(); |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1506 | updateClearAll(); |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 1507 | updateEmptyShadeView(); |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1508 | |
Benjamin Franz | 27cf146 | 2015-04-23 19:36:42 +0100 | [diff] [blame] | 1509 | updateQsExpansionEnabled(); |
| 1510 | mShadeUpdates.check(); |
| 1511 | } |
| 1512 | |
| 1513 | /** |
| 1514 | * Disable QS if device not provisioned. |
| 1515 | * If the user switcher is simple then disable QS during setup because |
| 1516 | * the user intends to use the lock screen user switcher, QS in not needed. |
| 1517 | */ |
| 1518 | private void updateQsExpansionEnabled() { |
Jason Monk | 3ad242d | 2014-09-15 11:13:35 -0400 | [diff] [blame] | 1519 | mNotificationPanel.setQsExpansionEnabled(isDeviceProvisioned() |
Adrian Roos | 2b154a9 | 2014-11-17 15:18:39 +0100 | [diff] [blame] | 1520 | && (mUserSetup || mUserSwitcherController == null |
Benjamin Franz | 27cf146 | 2015-04-23 19:36:42 +0100 | [diff] [blame] | 1521 | || !mUserSwitcherController.isSimpleUserSwitcher()) |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 1522 | && ((mDisabled2 & StatusBarManager.DISABLE2_QUICK_SETTINGS) == 0) |
| 1523 | && !ONLY_CORE_APPS); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1524 | } |
| 1525 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1526 | private void updateNotificationShadeForChildren() { |
Selim Cinek | 322ec7e | 2016-02-11 14:47:06 -0800 | [diff] [blame] | 1527 | // First let's remove all children which don't belong in the parents |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1528 | ArrayList<ExpandableNotificationRow> toRemove = new ArrayList<>(); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1529 | for (int i = 0; i < mStackScroller.getChildCount(); i++) { |
| 1530 | View view = mStackScroller.getChildAt(i); |
| 1531 | if (!(view instanceof ExpandableNotificationRow)) { |
| 1532 | // We don't care about non-notification views. |
| 1533 | continue; |
| 1534 | } |
| 1535 | |
| 1536 | ExpandableNotificationRow parent = (ExpandableNotificationRow) view; |
| 1537 | List<ExpandableNotificationRow> children = parent.getNotificationChildren(); |
| 1538 | List<ExpandableNotificationRow> orderedChildren = mTmpChildOrderMap.get(parent); |
| 1539 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1540 | if (children != null) { |
| 1541 | toRemove.clear(); |
| 1542 | for (ExpandableNotificationRow childRow : children) { |
| 1543 | if (orderedChildren == null || !orderedChildren.contains(childRow)) { |
| 1544 | toRemove.add(childRow); |
| 1545 | } |
| 1546 | } |
| 1547 | for (ExpandableNotificationRow remove : toRemove) { |
| 1548 | parent.removeChildNotification(remove); |
| 1549 | mStackScroller.notifyGroupChildRemoved(remove); |
| 1550 | } |
| 1551 | } |
Selim Cinek | 322ec7e | 2016-02-11 14:47:06 -0800 | [diff] [blame] | 1552 | } |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1553 | |
Selim Cinek | 322ec7e | 2016-02-11 14:47:06 -0800 | [diff] [blame] | 1554 | // Let's now add all notification children which are missing |
| 1555 | boolean orderChanged = false; |
| 1556 | for (int i = 0; i < mStackScroller.getChildCount(); i++) { |
| 1557 | View view = mStackScroller.getChildAt(i); |
| 1558 | if (!(view instanceof ExpandableNotificationRow)) { |
| 1559 | // We don't care about non-notification views. |
| 1560 | continue; |
| 1561 | } |
| 1562 | |
| 1563 | ExpandableNotificationRow parent = (ExpandableNotificationRow) view; |
| 1564 | List<ExpandableNotificationRow> children = parent.getNotificationChildren(); |
| 1565 | List<ExpandableNotificationRow> orderedChildren = mTmpChildOrderMap.get(parent); |
| 1566 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1567 | for (int childIndex = 0; orderedChildren != null && childIndex < orderedChildren.size(); |
| 1568 | childIndex++) { |
| 1569 | ExpandableNotificationRow childView = orderedChildren.get(childIndex); |
| 1570 | if (children == null || !children.contains(childView)) { |
| 1571 | parent.addChildNotification(childView, childIndex); |
| 1572 | mStackScroller.notifyGroupChildAdded(childView); |
| 1573 | } |
| 1574 | } |
| 1575 | |
| 1576 | // Finally after removing and adding has been beformed we can apply the order. |
| 1577 | orderChanged |= parent.applyChildOrder(orderedChildren); |
| 1578 | } |
| 1579 | if (orderChanged) { |
| 1580 | mStackScroller.generateChildOrderChangedEvent(); |
| 1581 | } |
| 1582 | } |
| 1583 | |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 1584 | @Override |
| 1585 | public void addQsTile(ComponentName tile) { |
| 1586 | mQSPanel.getHost().addTile(tile); |
| 1587 | } |
| 1588 | |
| 1589 | @Override |
| 1590 | public void remQsTile(ComponentName tile) { |
| 1591 | mQSPanel.getHost().removeTile(tile); |
| 1592 | } |
| 1593 | |
| 1594 | @Override |
| 1595 | public void clickTile(ComponentName tile) { |
| 1596 | mQSPanel.clickTile(tile); |
| 1597 | } |
| 1598 | |
Chris Wren | 3ad4e3a | 2014-09-02 17:23:51 -0400 | [diff] [blame] | 1599 | private boolean packageHasVisibilityOverride(String key) { |
| 1600 | return mNotificationData.getVisibilityOverride(key) |
| 1601 | != NotificationListenerService.Ranking.VISIBILITY_NO_OVERRIDE; |
| 1602 | } |
| 1603 | |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1604 | private void updateClearAll() { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1605 | boolean showDismissView = |
| 1606 | mState != StatusBarState.KEYGUARD && |
| 1607 | mNotificationData.hasActiveClearableNotifications(); |
Dan Sandler | eceda3d | 2014-07-21 15:35:01 -0400 | [diff] [blame] | 1608 | mStackScroller.updateDismissView(showDismissView); |
| 1609 | } |
| 1610 | |
Jorim Jaggi | a2052ea | 2014-08-05 16:22:30 +0200 | [diff] [blame] | 1611 | private void updateEmptyShadeView() { |
| 1612 | boolean showEmptyShade = |
| 1613 | mState != StatusBarState.KEYGUARD && |
| 1614 | mNotificationData.getActiveNotifications().size() == 0; |
| 1615 | mNotificationPanel.setShadeEmpty(showEmptyShade); |
| 1616 | } |
| 1617 | |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1618 | private void updateSpeedbump() { |
| 1619 | int speedbumpIndex = -1; |
| 1620 | int currentIndex = 0; |
| 1621 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
| 1622 | final int N = activeNotifications.size(); |
| 1623 | for (int i = 0; i < N; i++) { |
| 1624 | Entry entry = activeNotifications.get(i); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1625 | boolean isChild = !isTopLevelChild(entry); |
| 1626 | if (isChild) { |
| 1627 | continue; |
| 1628 | } |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 1629 | if (entry.row.getVisibility() != View.GONE && |
| 1630 | mNotificationData.isAmbient(entry.key)) { |
| 1631 | speedbumpIndex = currentIndex; |
| 1632 | break; |
| 1633 | } |
| 1634 | currentIndex++; |
| 1635 | } |
| 1636 | mStackScroller.updateSpeedBumpIndex(speedbumpIndex); |
| 1637 | } |
| 1638 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 1639 | public static boolean isTopLevelChild(Entry entry) { |
| 1640 | return entry.row.getParent() instanceof NotificationStackScrollLayout; |
| 1641 | } |
| 1642 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1643 | @Override |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1644 | protected void updateNotifications() { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1645 | mNotificationData.filterAndSort(); |
| 1646 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 1647 | updateNotificationShade(); |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 1648 | mIconController.updateNotificationIcons(mNotificationData); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1649 | } |
| 1650 | |
Selim Cinek | ef5127e | 2015-12-21 16:55:58 -0800 | [diff] [blame] | 1651 | public void requestNotificationUpdate() { |
| 1652 | updateNotifications(); |
| 1653 | } |
| 1654 | |
Jorim Jaggi | 5404542 | 2014-07-03 18:30:40 +0200 | [diff] [blame] | 1655 | @Override |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1656 | protected void setAreThereNotifications() { |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 1657 | |
Chris Wren | 6d15a36 | 2013-08-20 18:46:29 -0400 | [diff] [blame] | 1658 | if (SPEW) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1659 | final boolean clearable = hasActiveNotifications() && |
| 1660 | mNotificationData.hasActiveClearableNotifications(); |
| 1661 | Log.d(TAG, "setAreThereNotifications: N=" + |
| 1662 | mNotificationData.getActiveNotifications().size() + " any=" + |
| 1663 | hasActiveNotifications() + " clearable=" + clearable); |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 1664 | } |
| 1665 | |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 1666 | final View nlo = mStatusBarView.findViewById(R.id.notification_lights_out); |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1667 | final boolean showDot = hasActiveNotifications() && !areLightsOn(); |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 1668 | if (showDot != (nlo.getAlpha() == 1.0f)) { |
| 1669 | if (showDot) { |
| 1670 | nlo.setAlpha(0f); |
| 1671 | nlo.setVisibility(View.VISIBLE); |
| 1672 | } |
| 1673 | nlo.animate() |
| 1674 | .alpha(showDot?1:0) |
| 1675 | .setDuration(showDot?750:250) |
| 1676 | .setInterpolator(new AccelerateInterpolator(2.0f)) |
| 1677 | .setListener(showDot ? null : new AnimatorListenerAdapter() { |
| 1678 | @Override |
| 1679 | public void onAnimationEnd(Animator _a) { |
| 1680 | nlo.setVisibility(View.GONE); |
| 1681 | } |
| 1682 | }) |
| 1683 | .start(); |
| 1684 | } |
Daniel Sandler | 3d32a24 | 2012-06-05 13:44:14 -0400 | [diff] [blame] | 1685 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1686 | findAndUpdateMediaNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1687 | } |
| 1688 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1689 | public void findAndUpdateMediaNotifications() { |
| 1690 | boolean metaDataChanged = false; |
| 1691 | |
| 1692 | synchronized (mNotificationData) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1693 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
| 1694 | final int N = activeNotifications.size(); |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1695 | |
| 1696 | // Promote the media notification with a controller in 'playing' state, if any. |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1697 | Entry mediaNotification = null; |
| 1698 | MediaController controller = null; |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 1699 | for (int i = 0; i < N; i++) { |
| 1700 | final Entry entry = activeNotifications.get(i); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1701 | if (isMediaNotification(entry)) { |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1702 | final MediaSession.Token token = |
| 1703 | entry.notification.getNotification().extras |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1704 | .getParcelable(Notification.EXTRA_MEDIA_SESSION); |
| 1705 | if (token != null) { |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1706 | MediaController aController = new MediaController(mContext, token); |
| 1707 | if (PlaybackState.STATE_PLAYING == |
| 1708 | getMediaControllerPlaybackState(aController)) { |
| 1709 | if (DEBUG_MEDIA) { |
| 1710 | Log.v(TAG, "DEBUG_MEDIA: found mediastyle controller matching " |
| 1711 | + entry.notification.getKey()); |
| 1712 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1713 | mediaNotification = entry; |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1714 | controller = aController; |
| 1715 | break; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1716 | } |
| 1717 | } |
| 1718 | } |
| 1719 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1720 | if (mediaNotification == null) { |
| 1721 | // Still nothing? OK, let's just look for live media sessions and see if they match |
| 1722 | // one of our notifications. This will catch apps that aren't (yet!) using media |
| 1723 | // notifications. |
| 1724 | |
| 1725 | if (mMediaSessionManager != null) { |
| 1726 | final List<MediaController> sessions |
| 1727 | = mMediaSessionManager.getActiveSessionsForUser( |
| 1728 | null, |
| 1729 | UserHandle.USER_ALL); |
| 1730 | |
| 1731 | for (MediaController aController : sessions) { |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1732 | if (PlaybackState.STATE_PLAYING == |
| 1733 | getMediaControllerPlaybackState(aController)) { |
| 1734 | // now to see if we have one like this |
| 1735 | final String pkg = aController.getPackageName(); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1736 | |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1737 | for (int i = 0; i < N; i++) { |
| 1738 | final Entry entry = activeNotifications.get(i); |
| 1739 | if (entry.notification.getPackageName().equals(pkg)) { |
| 1740 | if (DEBUG_MEDIA) { |
| 1741 | Log.v(TAG, "DEBUG_MEDIA: found controller matching " |
| 1742 | + entry.notification.getKey()); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1743 | } |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1744 | controller = aController; |
| 1745 | mediaNotification = entry; |
| 1746 | break; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1747 | } |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1748 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1749 | } |
| 1750 | } |
| 1751 | } |
| 1752 | } |
| 1753 | |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1754 | if (controller != null && !sameSessions(mMediaController, controller)) { |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1755 | // We have a new media session |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1756 | clearCurrentMediaNotification(); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1757 | mMediaController = controller; |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1758 | mMediaController.registerCallback(mMediaListener); |
| 1759 | mMediaMetadata = mMediaController.getMetadata(); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1760 | if (DEBUG_MEDIA) { |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1761 | Log.v(TAG, "DEBUG_MEDIA: insert listener, receive metadata: " |
| 1762 | + mMediaMetadata); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1763 | } |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1764 | |
| 1765 | if (mediaNotification != null) { |
| 1766 | mMediaNotificationKey = mediaNotification.notification.getKey(); |
| 1767 | if (DEBUG_MEDIA) { |
| 1768 | Log.v(TAG, "DEBUG_MEDIA: Found new media notification: key=" |
| 1769 | + mMediaNotificationKey + " controller=" + mMediaController); |
| 1770 | } |
| 1771 | } |
| 1772 | metaDataChanged = true; |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1773 | } |
| 1774 | } |
| 1775 | |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1776 | if (metaDataChanged) { |
| 1777 | updateNotifications(); |
| 1778 | } |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 1779 | updateMediaMetaData(metaDataChanged, true); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1780 | } |
| 1781 | |
Julia Reynolds | d30e42d | 2015-07-20 17:02:14 -0400 | [diff] [blame] | 1782 | private int getMediaControllerPlaybackState(MediaController controller) { |
| 1783 | if (controller != null) { |
| 1784 | final PlaybackState playbackState = controller.getPlaybackState(); |
| 1785 | if (playbackState != null) { |
| 1786 | return playbackState.getState(); |
| 1787 | } |
| 1788 | } |
| 1789 | return PlaybackState.STATE_NONE; |
| 1790 | } |
| 1791 | |
| 1792 | private boolean isPlaybackActive(int state) { |
| 1793 | if (state != PlaybackState.STATE_STOPPED |
| 1794 | && state != PlaybackState.STATE_ERROR |
| 1795 | && state != PlaybackState.STATE_NONE) { |
| 1796 | return true; |
| 1797 | } |
| 1798 | return false; |
| 1799 | } |
| 1800 | |
| 1801 | private void clearCurrentMediaNotification() { |
| 1802 | mMediaNotificationKey = null; |
| 1803 | mMediaMetadata = null; |
| 1804 | if (mMediaController != null) { |
| 1805 | if (DEBUG_MEDIA) { |
| 1806 | Log.v(TAG, "DEBUG_MEDIA: Disconnecting from old controller: " |
| 1807 | + mMediaController.getPackageName()); |
| 1808 | } |
| 1809 | mMediaController.unregisterCallback(mMediaListener); |
| 1810 | } |
| 1811 | mMediaController = null; |
| 1812 | } |
| 1813 | |
Christoph Studer | b5245d8 | 2014-09-19 16:54:36 +0200 | [diff] [blame] | 1814 | private boolean sameSessions(MediaController a, MediaController b) { |
| 1815 | if (a == b) return true; |
| 1816 | if (a == null) return false; |
| 1817 | return a.controlsSameSession(b); |
| 1818 | } |
| 1819 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1820 | /** |
Dan Sandler | 7dea0ee | 2014-07-21 21:07:15 -0400 | [diff] [blame] | 1821 | * Hide the album artwork that is fading out and release its bitmap. |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1822 | */ |
| 1823 | private Runnable mHideBackdropFront = new Runnable() { |
| 1824 | @Override |
| 1825 | public void run() { |
| 1826 | if (DEBUG_MEDIA) { |
| 1827 | Log.v(TAG, "DEBUG_MEDIA: removing fade layer"); |
| 1828 | } |
| 1829 | mBackdropFront.setVisibility(View.INVISIBLE); |
Dan Sandler | 7dea0ee | 2014-07-21 21:07:15 -0400 | [diff] [blame] | 1830 | mBackdropFront.animate().cancel(); |
| 1831 | mBackdropFront.setImageDrawable(null); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1832 | } |
| 1833 | }; |
| 1834 | |
| 1835 | /** |
Adrian Roos | e381c16 | 2016-02-11 15:26:42 -0800 | [diff] [blame] | 1836 | * Refresh or remove lockscreen artwork from media metadata or the lockscreen wallpaper. |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1837 | */ |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 1838 | public void updateMediaMetaData(boolean metaDataChanged, boolean allowEnterAnimation) { |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1839 | if (!SHOW_LOCKSCREEN_MEDIA_ARTWORK) return; |
| 1840 | |
| 1841 | if (mBackdrop == null) return; // called too early |
| 1842 | |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 1843 | if (mLaunchTransitionFadingAway) { |
| 1844 | mBackdrop.setVisibility(View.INVISIBLE); |
| 1845 | return; |
| 1846 | } |
| 1847 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1848 | if (DEBUG_MEDIA) { |
| 1849 | Log.v(TAG, "DEBUG_MEDIA: updating album art for notification " + mMediaNotificationKey |
Selim Cinek | 131c1e2 | 2015-05-11 19:04:49 -0700 | [diff] [blame] | 1850 | + " metadata=" + mMediaMetadata |
| 1851 | + " metaDataChanged=" + metaDataChanged |
| 1852 | + " state=" + mState); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1853 | } |
| 1854 | |
| 1855 | Bitmap artworkBitmap = null; |
| 1856 | if (mMediaMetadata != null) { |
| 1857 | artworkBitmap = mMediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ART); |
| 1858 | if (artworkBitmap == null) { |
| 1859 | artworkBitmap = mMediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART); |
| 1860 | // might still be null |
| 1861 | } |
| 1862 | } |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 1863 | if (ENABLE_LOCKSCREEN_WALLPAPER && artworkBitmap == null) { |
Adrian Roos | e381c16 | 2016-02-11 15:26:42 -0800 | [diff] [blame] | 1864 | artworkBitmap = mLockscreenWallpaper.getBitmap(); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 1865 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1866 | |
| 1867 | final boolean hasArtwork = artworkBitmap != null; |
| 1868 | |
Jorim Jaggi | 95d16bf | 2015-08-24 17:42:02 -0700 | [diff] [blame] | 1869 | if ((hasArtwork || DEBUG_MEDIA_FAKE_ARTWORK) && mState != StatusBarState.SHADE |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 1870 | && mFingerprintUnlockController.getMode() |
| 1871 | != FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING) { |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1872 | // time to show some art! |
| 1873 | if (mBackdrop.getVisibility() != View.VISIBLE) { |
| 1874 | mBackdrop.setVisibility(View.VISIBLE); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 1875 | if (allowEnterAnimation) { |
| 1876 | mBackdrop.animate().alpha(1f); |
| 1877 | } else { |
| 1878 | mBackdrop.animate().cancel(); |
| 1879 | mBackdrop.setAlpha(1f); |
| 1880 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1881 | metaDataChanged = true; |
| 1882 | if (DEBUG_MEDIA) { |
| 1883 | Log.v(TAG, "DEBUG_MEDIA: Fading in album artwork"); |
| 1884 | } |
| 1885 | } |
| 1886 | if (metaDataChanged) { |
| 1887 | if (mBackdropBack.getDrawable() != null) { |
Julia Reynolds | 4b9658a | 2015-07-22 17:07:42 -0400 | [diff] [blame] | 1888 | Drawable drawable = |
| 1889 | mBackdropBack.getDrawable().getConstantState().newDrawable().mutate(); |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 1890 | mBackdropFront.setImageDrawable(drawable); |
Jorim Jaggi | 0e66439 | 2014-09-27 01:30:22 +0200 | [diff] [blame] | 1891 | if (mScrimSrcModeEnabled) { |
| 1892 | mBackdropFront.getDrawable().mutate().setXfermode(mSrcOverXferMode); |
| 1893 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1894 | mBackdropFront.setAlpha(1f); |
| 1895 | mBackdropFront.setVisibility(View.VISIBLE); |
| 1896 | } else { |
| 1897 | mBackdropFront.setVisibility(View.INVISIBLE); |
| 1898 | } |
| 1899 | |
| 1900 | if (DEBUG_MEDIA_FAKE_ARTWORK) { |
| 1901 | final int c = 0xFF000000 | (int)(Math.random() * 0xFFFFFF); |
| 1902 | Log.v(TAG, String.format("DEBUG_MEDIA: setting new color: 0x%08x", c)); |
| 1903 | mBackdropBack.setBackgroundColor(0xFFFFFFFF); |
| 1904 | mBackdropBack.setImageDrawable(new ColorDrawable(c)); |
| 1905 | } else { |
| 1906 | mBackdropBack.setImageBitmap(artworkBitmap); |
| 1907 | } |
Jorim Jaggi | 0e66439 | 2014-09-27 01:30:22 +0200 | [diff] [blame] | 1908 | if (mScrimSrcModeEnabled) { |
| 1909 | mBackdropBack.getDrawable().mutate().setXfermode(mSrcXferMode); |
| 1910 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1911 | |
| 1912 | if (mBackdropFront.getVisibility() == View.VISIBLE) { |
| 1913 | if (DEBUG_MEDIA) { |
| 1914 | Log.v(TAG, "DEBUG_MEDIA: Crossfading album artwork from " |
| 1915 | + mBackdropFront.getDrawable() |
| 1916 | + " to " |
| 1917 | + mBackdropBack.getDrawable()); |
| 1918 | } |
Jorim Jaggi | 4e0880e | 2014-07-25 14:51:50 +0200 | [diff] [blame] | 1919 | mBackdropFront.animate() |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1920 | .setDuration(250) |
| 1921 | .alpha(0f).withEndAction(mHideBackdropFront); |
| 1922 | } |
| 1923 | } |
| 1924 | } else { |
| 1925 | // need to hide the album art, either because we are unlocked or because |
| 1926 | // the metadata isn't there to support it |
| 1927 | if (mBackdrop.getVisibility() != View.GONE) { |
| 1928 | if (DEBUG_MEDIA) { |
| 1929 | Log.v(TAG, "DEBUG_MEDIA: Fading out album artwork"); |
| 1930 | } |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 1931 | if (mFingerprintUnlockController.getMode() |
| 1932 | == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING) { |
Jorim Jaggi | 4e0880e | 2014-07-25 14:51:50 +0200 | [diff] [blame] | 1933 | |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 1934 | // We are unlocking directly - no animation! |
| 1935 | mBackdrop.setVisibility(View.GONE); |
| 1936 | } else { |
| 1937 | mBackdrop.animate() |
| 1938 | // Never let the alpha become zero - otherwise the RenderNode |
| 1939 | // won't draw anything and uninitialized memory will show through |
| 1940 | // if mScrimSrcModeEnabled. Note that 0.001 is rounded down to 0 in |
| 1941 | // libhwui. |
| 1942 | .alpha(0.002f) |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 1943 | .setInterpolator(Interpolators.ACCELERATE_DECELERATE) |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 1944 | .setDuration(300) |
| 1945 | .setStartDelay(0) |
| 1946 | .withEndAction(new Runnable() { |
| 1947 | @Override |
| 1948 | public void run() { |
| 1949 | mBackdrop.setVisibility(View.GONE); |
| 1950 | mBackdropFront.animate().cancel(); |
| 1951 | mBackdropBack.animate().cancel(); |
| 1952 | mHandler.post(mHideBackdropFront); |
| 1953 | } |
| 1954 | }); |
| 1955 | if (mKeyguardFadingAway) { |
| 1956 | mBackdrop.animate() |
| 1957 | |
| 1958 | // Make it disappear faster, as the focus should be on the activity |
| 1959 | // behind. |
| 1960 | .setDuration(mKeyguardFadingAwayDuration / 2) |
| 1961 | .setStartDelay(mKeyguardFadingAwayDelay) |
Selim Cinek | c18010f | 2016-01-20 13:41:30 -0800 | [diff] [blame] | 1962 | .setInterpolator(Interpolators.LINEAR) |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 1963 | .start(); |
| 1964 | } |
Jorim Jaggi | 4e0880e | 2014-07-25 14:51:50 +0200 | [diff] [blame] | 1965 | } |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 1966 | } |
| 1967 | } |
| 1968 | } |
| 1969 | |
Jorim Jaggi | b13d36d | 2014-06-06 18:03:52 +0200 | [diff] [blame] | 1970 | private int adjustDisableFlags(int state) { |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 1971 | if (!mLaunchTransitionFadingAway && !mKeyguardFadingAway |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 1972 | && (mExpandedVisible || mBouncerShowing || mWaitingForKeyguardExit)) { |
Jorim Jaggi | b13d36d | 2014-06-06 18:03:52 +0200 | [diff] [blame] | 1973 | state |= StatusBarManager.DISABLE_NOTIFICATION_ICONS; |
| 1974 | state |= StatusBarManager.DISABLE_SYSTEM_INFO; |
| 1975 | } |
| 1976 | return state; |
| 1977 | } |
| 1978 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1979 | /** |
| 1980 | * State is one or more of the DISABLE constants from StatusBarManager. |
| 1981 | */ |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 1982 | public void disable(int state1, int state2, boolean animate) { |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 1983 | animate &= mStatusBarWindowState != WINDOW_STATE_HIDDEN; |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 1984 | mDisabledUnmodified1 = state1; |
| 1985 | mDisabledUnmodified2 = state2; |
| 1986 | state1 = adjustDisableFlags(state1); |
| 1987 | final int old1 = mDisabled1; |
| 1988 | final int diff1 = state1 ^ old1; |
| 1989 | mDisabled1 = state1; |
| 1990 | |
| 1991 | final int old2 = mDisabled2; |
| 1992 | final int diff2 = state2 ^ old2; |
| 1993 | mDisabled2 = state2; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1994 | |
Daniel Sandler | e21f288 | 2011-08-18 10:14:59 -0400 | [diff] [blame] | 1995 | if (DEBUG) { |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 1996 | Log.d(TAG, String.format("disable1: 0x%08x -> 0x%08x (diff1: 0x%08x)", |
| 1997 | old1, state1, diff1)); |
| 1998 | Log.d(TAG, String.format("disable2: 0x%08x -> 0x%08x (diff2: 0x%08x)", |
| 1999 | old2, state2, diff2)); |
Daniel Sandler | e21f288 | 2011-08-18 10:14:59 -0400 | [diff] [blame] | 2000 | } |
| 2001 | |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2002 | StringBuilder flagdbg = new StringBuilder(); |
| 2003 | flagdbg.append("disable: < "); |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2004 | flagdbg.append(((state1 & StatusBarManager.DISABLE_EXPAND) != 0) ? "EXPAND" : "expand"); |
| 2005 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_EXPAND) != 0) ? "* " : " "); |
| 2006 | flagdbg.append(((state1 & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) ? "ICONS" : "icons"); |
| 2007 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) ? "* " : " "); |
| 2008 | flagdbg.append(((state1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) ? "ALERTS" : "alerts"); |
| 2009 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) ? "* " : " "); |
| 2010 | flagdbg.append(((state1 & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) ? "SYSTEM_INFO" : "system_info"); |
| 2011 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) ? "* " : " "); |
| 2012 | flagdbg.append(((state1 & StatusBarManager.DISABLE_BACK) != 0) ? "BACK" : "back"); |
| 2013 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_BACK) != 0) ? "* " : " "); |
| 2014 | flagdbg.append(((state1 & StatusBarManager.DISABLE_HOME) != 0) ? "HOME" : "home"); |
| 2015 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_HOME) != 0) ? "* " : " "); |
| 2016 | flagdbg.append(((state1 & StatusBarManager.DISABLE_RECENT) != 0) ? "RECENT" : "recent"); |
| 2017 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_RECENT) != 0) ? "* " : " "); |
| 2018 | flagdbg.append(((state1 & StatusBarManager.DISABLE_CLOCK) != 0) ? "CLOCK" : "clock"); |
| 2019 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_CLOCK) != 0) ? "* " : " "); |
| 2020 | flagdbg.append(((state1 & StatusBarManager.DISABLE_SEARCH) != 0) ? "SEARCH" : "search"); |
| 2021 | flagdbg.append(((diff1 & StatusBarManager.DISABLE_SEARCH) != 0) ? "* " : " "); |
Benjamin Franz | 27cf146 | 2015-04-23 19:36:42 +0100 | [diff] [blame] | 2022 | flagdbg.append(((state2 & StatusBarManager.DISABLE2_QUICK_SETTINGS) != 0) ? "QUICK_SETTINGS" |
| 2023 | : "quick_settings"); |
| 2024 | flagdbg.append(((diff2 & StatusBarManager.DISABLE2_QUICK_SETTINGS) != 0) ? "* " : " "); |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2025 | flagdbg.append(">"); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2026 | Log.d(TAG, flagdbg.toString()); |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 2027 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2028 | if ((diff1 & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) { |
| 2029 | if ((state1 & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) { |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 2030 | mIconController.hideSystemIconArea(animate); |
Daniel Sandler | 8e18dc7 | 2012-05-17 00:44:59 -0400 | [diff] [blame] | 2031 | } else { |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 2032 | mIconController.showSystemIconArea(animate); |
Daniel Sandler | 8e18dc7 | 2012-05-17 00:44:59 -0400 | [diff] [blame] | 2033 | } |
| 2034 | } |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2035 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2036 | if ((diff1 & StatusBarManager.DISABLE_CLOCK) != 0) { |
| 2037 | boolean visible = (state1 & StatusBarManager.DISABLE_CLOCK) == 0; |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 2038 | mIconController.setClockVisibility(visible); |
Jeff Sharkey | f52c70b | 2011-08-30 22:05:47 -0700 | [diff] [blame] | 2039 | } |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2040 | if ((diff1 & StatusBarManager.DISABLE_EXPAND) != 0) { |
| 2041 | if ((state1 & StatusBarManager.DISABLE_EXPAND) != 0) { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2042 | animateCollapsePanels(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2043 | } |
| 2044 | } |
Daniel Sandler | e21f288 | 2011-08-18 10:14:59 -0400 | [diff] [blame] | 2045 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2046 | if ((diff1 & (StatusBarManager.DISABLE_HOME |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 2047 | | StatusBarManager.DISABLE_RECENT |
Daniel Sandler | d5483c3 | 2012-10-19 16:44:15 -0400 | [diff] [blame] | 2048 | | StatusBarManager.DISABLE_BACK |
| 2049 | | StatusBarManager.DISABLE_SEARCH)) != 0) { |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame] | 2050 | // the nav bar will take care of these |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2051 | if (mNavigationBarView != null) mNavigationBarView.setDisabledFlags(state1); |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2052 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2053 | if ((state1 & StatusBarManager.DISABLE_RECENT) != 0) { |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2054 | // close recents if it's visible |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2055 | mHandler.removeMessages(MSG_HIDE_RECENT_APPS); |
| 2056 | mHandler.sendEmptyMessage(MSG_HIDE_RECENT_APPS); |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 2057 | } |
Daniel Sandler | e21f288 | 2011-08-18 10:14:59 -0400 | [diff] [blame] | 2058 | } |
| 2059 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2060 | if ((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { |
| 2061 | if ((state1 & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 2062 | mIconController.hideNotificationIconArea(animate); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2063 | } else { |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 2064 | mIconController.showNotificationIconArea(animate); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2065 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2066 | } |
Jason Monk | f701954 | 2014-07-31 12:42:25 -0400 | [diff] [blame] | 2067 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2068 | if ((diff1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) { |
Jason Monk | f701954 | 2014-07-31 12:42:25 -0400 | [diff] [blame] | 2069 | mDisableNotificationAlerts = |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2070 | (state1 & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0; |
Jason Monk | f701954 | 2014-07-31 12:42:25 -0400 | [diff] [blame] | 2071 | mHeadsUpObserver.onChange(true); |
| 2072 | } |
Benjamin Franz | 27cf146 | 2015-04-23 19:36:42 +0100 | [diff] [blame] | 2073 | |
| 2074 | if ((diff2 & StatusBarManager.DISABLE2_QUICK_SETTINGS) != 0) { |
| 2075 | updateQsExpansionEnabled(); |
| 2076 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2077 | } |
| 2078 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2079 | @Override |
Michael Jurka | ecc395a | 2012-03-30 05:31:46 -0700 | [diff] [blame] | 2080 | protected BaseStatusBar.H createHandler() { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2081 | return new PhoneStatusBar.H(); |
| 2082 | } |
| 2083 | |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 2084 | @Override |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 2085 | public void startActivity(Intent intent, boolean dismissShade) { |
| 2086 | startActivityDismissingKeyguard(intent, false, dismissShade); |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 2087 | } |
| 2088 | |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 2089 | @Override |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 2090 | public void startActivity(Intent intent, boolean dismissShade, Callback callback) { |
| 2091 | startActivityDismissingKeyguard(intent, false, dismissShade, callback); |
| 2092 | } |
| 2093 | |
| 2094 | @Override |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 2095 | public void preventNextAnimation() { |
| 2096 | overrideActivityPendingAppTransition(true /* keyguardShowing */); |
| 2097 | } |
| 2098 | |
Jorim Jaggi | b690f0d | 2014-07-03 23:25:44 +0200 | [diff] [blame] | 2099 | public void setQsExpanded(boolean expanded) { |
| 2100 | mStatusBarWindowManager.setQsExpanded(expanded); |
Adrian Roos | 4c7d960 | 2015-06-10 13:44:48 -0700 | [diff] [blame] | 2101 | mKeyguardStatusView.setImportantForAccessibility(expanded |
| 2102 | ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS |
| 2103 | : View.IMPORTANT_FOR_ACCESSIBILITY_AUTO); |
Jorim Jaggi | b690f0d | 2014-07-03 23:25:44 +0200 | [diff] [blame] | 2104 | } |
| 2105 | |
Jorim Jaggi | 84a3e7a | 2014-08-13 17:58:58 +0200 | [diff] [blame] | 2106 | public boolean isGoingToNotificationShade() { |
| 2107 | return mLeaveOpenOnKeyguardHide; |
| 2108 | } |
| 2109 | |
Jorim Jaggi | d692dd0 | 2014-08-14 20:57:42 +0200 | [diff] [blame] | 2110 | public boolean isQsExpanded() { |
| 2111 | return mNotificationPanel.isQsExpanded(); |
| 2112 | } |
| 2113 | |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 2114 | public boolean isWakeUpComingFromTouch() { |
| 2115 | return mWakeUpComingFromTouch; |
Selim Cinek | 29ed3c9 | 2014-09-23 20:44:35 +0200 | [diff] [blame] | 2116 | } |
| 2117 | |
Selim Cinek | 19c8c70 | 2014-08-25 22:09:19 +0200 | [diff] [blame] | 2118 | public boolean isFalsingThresholdNeeded() { |
Selim Cinek | 9db7105 | 2015-04-24 18:54:30 -0700 | [diff] [blame] | 2119 | return getBarState() == StatusBarState.KEYGUARD; |
Selim Cinek | 19c8c70 | 2014-08-25 22:09:19 +0200 | [diff] [blame] | 2120 | } |
| 2121 | |
John Spurlock | 0b99ea9 | 2014-10-01 15:32:22 -0400 | [diff] [blame] | 2122 | public boolean isDozing() { |
| 2123 | return mDozing; |
| 2124 | } |
| 2125 | |
Christoph Studer | 2e731b5 | 2014-08-22 16:01:51 +0200 | [diff] [blame] | 2126 | @Override // NotificationData.Environment |
| 2127 | public String getCurrentMediaNotificationKey() { |
| 2128 | return mMediaNotificationKey; |
| 2129 | } |
| 2130 | |
Jorim Jaggi | 0e66439 | 2014-09-27 01:30:22 +0200 | [diff] [blame] | 2131 | public boolean isScrimSrcModeEnabled() { |
| 2132 | return mScrimSrcModeEnabled; |
| 2133 | } |
| 2134 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2135 | /** |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 2136 | * To be called when there's a state change in StatusBarKeyguardViewManager. |
| 2137 | */ |
| 2138 | public void onKeyguardViewManagerStatesUpdated() { |
| 2139 | logStateToEventlog(); |
| 2140 | } |
| 2141 | |
| 2142 | @Override // UnlockMethodCache.OnUnlockMethodChangedListener |
| 2143 | public void onUnlockMethodStateChanged() { |
| 2144 | logStateToEventlog(); |
| 2145 | } |
| 2146 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2147 | @Override |
John Spurlock | b349af57 | 2015-04-29 12:24:19 -0400 | [diff] [blame] | 2148 | public void onHeadsUpPinnedModeChanged(boolean inPinnedMode) { |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2149 | if (inPinnedMode) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2150 | mStatusBarWindowManager.setHeadsUpShowing(true); |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2151 | mStatusBarWindowManager.setForceStatusBarVisible(true); |
Selim Cinek | 131c1e2 | 2015-05-11 19:04:49 -0700 | [diff] [blame] | 2152 | if (mNotificationPanel.isFullyCollapsed()) { |
| 2153 | // We need to ensure that the touchable region is updated before the window will be |
| 2154 | // resized, in order to not catch any touches. A layout will ensure that |
| 2155 | // onComputeInternalInsets will be called and after that we can resize the layout. Let's |
| 2156 | // make sure that the window stays small for one frame until the touchableRegion is set. |
| 2157 | mNotificationPanel.requestLayout(); |
| 2158 | mStatusBarWindowManager.setForceWindowCollapsed(true); |
| 2159 | mNotificationPanel.post(new Runnable() { |
| 2160 | @Override |
| 2161 | public void run() { |
| 2162 | mStatusBarWindowManager.setForceWindowCollapsed(false); |
| 2163 | } |
| 2164 | }); |
| 2165 | } |
Selim Cinek | 737bff3 | 2015-05-08 16:08:35 -0700 | [diff] [blame] | 2166 | } else { |
Selim Cinek | 131c1e2 | 2015-05-11 19:04:49 -0700 | [diff] [blame] | 2167 | if (!mNotificationPanel.isFullyCollapsed() || mNotificationPanel.isTracking()) { |
| 2168 | // We are currently tracking or is open and the shade doesn't need to be kept |
| 2169 | // open artificially. |
Selim Cinek | 737bff3 | 2015-05-08 16:08:35 -0700 | [diff] [blame] | 2170 | mStatusBarWindowManager.setHeadsUpShowing(false); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2171 | } else { |
Selim Cinek | 131c1e2 | 2015-05-11 19:04:49 -0700 | [diff] [blame] | 2172 | // we need to keep the panel open artificially, let's wait until the animation |
| 2173 | // is finished. |
Selim Cinek | 737bff3 | 2015-05-08 16:08:35 -0700 | [diff] [blame] | 2174 | mHeadsUpManager.setHeadsUpGoingAway(true); |
| 2175 | mStackScroller.runAfterAnimationFinished(new Runnable() { |
| 2176 | @Override |
| 2177 | public void run() { |
| 2178 | if (!mHeadsUpManager.hasPinnedHeadsUp()) { |
| 2179 | mStatusBarWindowManager.setHeadsUpShowing(false); |
| 2180 | mHeadsUpManager.setHeadsUpGoingAway(false); |
| 2181 | } |
| 2182 | } |
| 2183 | }); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2184 | } |
| 2185 | } |
| 2186 | } |
| 2187 | |
| 2188 | @Override |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2189 | public void onHeadsUpPinned(ExpandableNotificationRow headsUp) { |
John Spurlock | b349af57 | 2015-04-29 12:24:19 -0400 | [diff] [blame] | 2190 | dismissVolumeDialog(); |
Selim Cinek | 1f3f544 | 2015-04-10 17:54:46 -0700 | [diff] [blame] | 2191 | } |
| 2192 | |
| 2193 | @Override |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2194 | public void onHeadsUpUnPinned(ExpandableNotificationRow headsUp) { |
| 2195 | } |
| 2196 | |
| 2197 | @Override |
| 2198 | public void onHeadsUpStateChanged(Entry entry, boolean isHeadsUp) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2199 | if (!isHeadsUp && mHeadsUpEntriesToRemoveOnSwitch.contains(entry)) { |
| 2200 | removeNotification(entry.key, mLatestRankingMap); |
| 2201 | mHeadsUpEntriesToRemoveOnSwitch.remove(entry); |
| 2202 | if (mHeadsUpEntriesToRemoveOnSwitch.isEmpty()) { |
| 2203 | mLatestRankingMap = null; |
| 2204 | } |
Selim Cinek | fbe9a44 | 2015-04-13 16:09:49 -0700 | [diff] [blame] | 2205 | } else { |
| 2206 | updateNotificationRanking(null); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2207 | } |
Selim Cinek | fbe9a44 | 2015-04-13 16:09:49 -0700 | [diff] [blame] | 2208 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2209 | } |
| 2210 | |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 2211 | protected void updateHeadsUp(String key, Entry entry, boolean shouldPeek, |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 2212 | boolean alertAgain) { |
| 2213 | final boolean wasHeadsUp = isHeadsUp(key); |
| 2214 | if (wasHeadsUp) { |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 2215 | if (!shouldPeek) { |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 2216 | // We don't want this to be interrupting anymore, lets remove it |
| 2217 | mHeadsUpManager.removeNotification(key); |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2218 | } else { |
| 2219 | mHeadsUpManager.updateNotification(entry, alertAgain); |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 2220 | } |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 2221 | } else if (shouldPeek && alertAgain) { |
Selim Cinek | 29fa89b | 2015-04-17 10:39:11 -0700 | [diff] [blame] | 2222 | // This notification was updated to be a heads-up, show it! |
| 2223 | mHeadsUpManager.showNotification(entry); |
| 2224 | } |
| 2225 | } |
| 2226 | |
| 2227 | protected void setHeadsUpUser(int newUserId) { |
| 2228 | if (mHeadsUpManager != null) { |
| 2229 | mHeadsUpManager.setUser(newUserId); |
| 2230 | } |
| 2231 | } |
| 2232 | |
| 2233 | public boolean isHeadsUp(String key) { |
| 2234 | return mHeadsUpManager.isHeadsUp(key); |
| 2235 | } |
| 2236 | |
| 2237 | protected boolean isSnoozedPackage(StatusBarNotification sbn) { |
| 2238 | return mHeadsUpManager.isSnoozed(sbn.getPackageName()); |
| 2239 | } |
| 2240 | |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 2241 | public boolean isKeyguardCurrentlySecure() { |
Selim Cinek | e8bae62 | 2015-07-15 13:24:06 -0700 | [diff] [blame] | 2242 | return !mUnlockMethodCache.canSkipBouncer(); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 2243 | } |
| 2244 | |
Selim Cinek | 4a21a7f | 2015-05-19 11:00:38 -0700 | [diff] [blame] | 2245 | public void setPanelExpanded(boolean isExpanded) { |
| 2246 | mStatusBarWindowManager.setPanelExpanded(isExpanded); |
| 2247 | } |
| 2248 | |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 2249 | /** |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2250 | * All changes to the status bar and notifications funnel through here and are batched. |
| 2251 | */ |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2252 | private class H extends BaseStatusBar.H { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2253 | public void handleMessage(Message m) { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2254 | super.handleMessage(m); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2255 | switch (m.what) { |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2256 | case MSG_OPEN_NOTIFICATION_PANEL: |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2257 | animateExpandNotificationsPanel(); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2258 | break; |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2259 | case MSG_OPEN_SETTINGS_PANEL: |
Jason Monk | a992732 | 2015-12-13 16:22:37 -0500 | [diff] [blame] | 2260 | animateExpandSettingsPanel((String) m.obj); |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2261 | break; |
| 2262 | case MSG_CLOSE_PANELS: |
| 2263 | animateCollapsePanels(); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2264 | break; |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 2265 | case MSG_LAUNCH_TRANSITION_TIMEOUT: |
| 2266 | onLaunchTransitionTimeout(); |
| 2267 | break; |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2268 | } |
| 2269 | } |
| 2270 | } |
| 2271 | |
Chris Wren | 930ecca | 2014-11-12 17:43:41 -0500 | [diff] [blame] | 2272 | @Override |
Selim Cinek | 684a442 | 2015-04-15 16:18:39 -0700 | [diff] [blame] | 2273 | public void maybeEscalateHeadsUp() { |
Selim Cinek | 3362c13 | 2016-02-11 15:43:03 -0800 | [diff] [blame] | 2274 | Collection<HeadsUpManager.HeadsUpEntry> entries = mHeadsUpManager.getAllEntries(); |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 2275 | for (HeadsUpManager.HeadsUpEntry entry : entries) { |
| 2276 | final StatusBarNotification sbn = entry.entry.notification; |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2277 | final Notification notification = sbn.getNotification(); |
| 2278 | if (notification.fullScreenIntent != null) { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2279 | if (DEBUG) { |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2280 | Log.d(TAG, "converting a heads up to fullScreen"); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2281 | } |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2282 | try { |
Chris Wren | 223c66b6 | 2014-11-10 16:00:09 -0500 | [diff] [blame] | 2283 | EventLog.writeEvent(EventLogTags.SYSUI_HEADS_UP_ESCALATION, |
| 2284 | sbn.getKey()); |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2285 | notification.fullScreenIntent.send(); |
Selim Cinek | b18a20f | 2015-06-04 17:08:35 +0200 | [diff] [blame] | 2286 | entry.entry.notifyFullScreenIntentLaunched(); |
Chris Wren | e97f90b | 2013-08-07 17:39:35 -0400 | [diff] [blame] | 2287 | } catch (PendingIntent.CanceledException e) { |
| 2288 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2289 | } |
| 2290 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2291 | mHeadsUpManager.releaseAllImmediately(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2292 | } |
| 2293 | |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2294 | boolean panelsEnabled() { |
Adrian Roos | 21d2a25 | 2015-06-01 13:59:59 -0700 | [diff] [blame] | 2295 | return (mDisabled1 & StatusBarManager.DISABLE_EXPAND) == 0 && !ONLY_CORE_APPS; |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2296 | } |
| 2297 | |
Jorim Jaggi | fa505a7 | 2014-04-28 20:04:11 +0200 | [diff] [blame] | 2298 | void makeExpandedVisible(boolean force) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2299 | if (SPEW) Log.d(TAG, "Make expanded visible: expanded visible=" + mExpandedVisible); |
Jorim Jaggi | fa505a7 | 2014-04-28 20:04:11 +0200 | [diff] [blame] | 2300 | if (!force && (mExpandedVisible || !panelsEnabled())) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2301 | return; |
| 2302 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 2303 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2304 | mExpandedVisible = true; |
John Spurlock | d5ef546 | 2012-06-13 11:19:51 -0400 | [diff] [blame] | 2305 | if (mNavigationBarView != null) |
| 2306 | mNavigationBarView.setSlippery(true); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2307 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 2308 | // Expand the window to encompass the full screen in anticipation of the drag. |
| 2309 | // 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] | 2310 | mStatusBarWindowManager.setPanelVisible(true); |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 2311 | |
| 2312 | visibilityChanged(true); |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 2313 | mWaitingForKeyguardExit = false; |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2314 | disable(mDisabledUnmodified1, mDisabledUnmodified2, !force /* animate */); |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 2315 | setInteracting(StatusBarManager.WINDOW_STATUS_BAR, true); |
| 2316 | } |
| 2317 | |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2318 | public void animateCollapsePanels() { |
| 2319 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 2320 | } |
| 2321 | |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 2322 | private final Runnable mAnimateCollapsePanels = new Runnable() { |
| 2323 | @Override |
| 2324 | public void run() { |
| 2325 | animateCollapsePanels(); |
| 2326 | } |
| 2327 | }; |
| 2328 | |
| 2329 | public void postAnimateCollapsePanels() { |
| 2330 | mHandler.post(mAnimateCollapsePanels); |
| 2331 | } |
| 2332 | |
Jason Monk | ba2318e | 2015-12-08 09:04:23 -0500 | [diff] [blame] | 2333 | public void postAnimateOpenPanels() { |
| 2334 | mHandler.sendEmptyMessage(MSG_OPEN_SETTINGS_PANEL); |
| 2335 | } |
| 2336 | |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2337 | public void animateCollapsePanels(int flags) { |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 2338 | animateCollapsePanels(flags, false /* force */, false /* delayed */, |
| 2339 | 1.0f /* speedUpFactor */); |
Jorim Jaggi | 3425076 | 2014-07-03 23:51:19 +0200 | [diff] [blame] | 2340 | } |
| 2341 | |
| 2342 | public void animateCollapsePanels(int flags, boolean force) { |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 2343 | animateCollapsePanels(flags, force, false /* delayed */, 1.0f /* speedUpFactor */); |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 2344 | } |
| 2345 | |
| 2346 | public void animateCollapsePanels(int flags, boolean force, boolean delayed) { |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 2347 | animateCollapsePanels(flags, force, delayed, 1.0f /* speedUpFactor */); |
| 2348 | } |
| 2349 | |
| 2350 | public void animateCollapsePanels(int flags, boolean force, boolean delayed, |
| 2351 | float speedUpFactor) { |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 2352 | if (!force && mState != StatusBarState.SHADE) { |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2353 | runPostCollapseRunnables(); |
Jorim Jaggi | c1cf1ae | 2014-05-02 21:19:17 +0200 | [diff] [blame] | 2354 | return; |
| 2355 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2356 | if (SPEW) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2357 | Log.d(TAG, "animateCollapse():" |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2358 | + " mExpandedVisible=" + mExpandedVisible |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 2359 | + " flags=" + flags); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2360 | } |
| 2361 | |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 2362 | if ((flags & CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL) == 0) { |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame] | 2363 | if (!mHandler.hasMessages(MSG_HIDE_RECENT_APPS)) { |
| 2364 | mHandler.removeMessages(MSG_HIDE_RECENT_APPS); |
| 2365 | mHandler.sendEmptyMessage(MSG_HIDE_RECENT_APPS); |
| 2366 | } |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 2367 | } |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 2368 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 2369 | if (mStatusBarWindow != null) { |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 2370 | // release focus immediately to kick off focus change transition |
| 2371 | mStatusBarWindowManager.setStatusBarFocusable(false); |
| 2372 | |
John Spurlock | ab847cf | 2014-01-15 14:13:59 -0500 | [diff] [blame] | 2373 | mStatusBarWindow.cancelExpandHelper(); |
Xiaohui Chen | 9f96711 | 2016-01-07 14:14:06 -0800 | [diff] [blame] | 2374 | mStatusBarView.collapsePanel(true /* animate */, delayed, speedUpFactor); |
John Spurlock | ab847cf | 2014-01-15 14:13:59 -0500 | [diff] [blame] | 2375 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2376 | } |
| 2377 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2378 | private void runPostCollapseRunnables() { |
Selim Cinek | ae77f8e | 2015-07-07 18:43:59 -0700 | [diff] [blame] | 2379 | ArrayList<Runnable> clonedList = new ArrayList<>(mPostCollapseRunnables); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2380 | mPostCollapseRunnables.clear(); |
Selim Cinek | ae77f8e | 2015-07-07 18:43:59 -0700 | [diff] [blame] | 2381 | int size = clonedList.size(); |
| 2382 | for (int i = 0; i < size; i++) { |
| 2383 | clonedList.get(i).run(); |
| 2384 | } |
| 2385 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2386 | } |
| 2387 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 2388 | @Override |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2389 | public void animateExpandNotificationsPanel() { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2390 | if (SPEW) Log.d(TAG, "animateExpand: mExpandedVisible=" + mExpandedVisible); |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2391 | if (!panelsEnabled()) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2392 | return ; |
| 2393 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2394 | |
Oren Blasberg | 8d3fea1 | 2015-07-10 14:21:44 -0700 | [diff] [blame] | 2395 | mNotificationPanel.expand(true /* animate */); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2396 | |
| 2397 | if (false) postStartTracing(); |
| 2398 | } |
| 2399 | |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 2400 | @Override |
Jason Monk | a992732 | 2015-12-13 16:22:37 -0500 | [diff] [blame] | 2401 | public void animateExpandSettingsPanel(String subPanel) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2402 | if (SPEW) Log.d(TAG, "animateExpand: mExpandedVisible=" + mExpandedVisible); |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2403 | if (!panelsEnabled()) { |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 2404 | return; |
| 2405 | } |
| 2406 | |
Daniel Sandler | a8ef3b0 | 2012-11-29 15:52:39 -0500 | [diff] [blame] | 2407 | // Settings are not available in setup |
| 2408 | if (!mUserSetup) return; |
| 2409 | |
Jason Monk | a992732 | 2015-12-13 16:22:37 -0500 | [diff] [blame] | 2410 | |
| 2411 | if (subPanel != null) { |
| 2412 | mQSPanel.openDetails(subPanel); |
| 2413 | } |
Jason Monk | 3c68ca2 | 2015-01-30 11:30:29 -0500 | [diff] [blame] | 2414 | mNotificationPanel.expandWithQs(); |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 2415 | |
| 2416 | if (false) postStartTracing(); |
| 2417 | } |
| 2418 | |
| 2419 | public void animateCollapseQuickSettings() { |
Jorim Jaggi | 449981b | 2014-10-03 14:24:55 -0700 | [diff] [blame] | 2420 | if (mState == StatusBarState.SHADE) { |
Xiaohui Chen | 9f96711 | 2016-01-07 14:14:06 -0800 | [diff] [blame] | 2421 | mStatusBarView.collapsePanel(true, false /* delayed */, 1.0f /* speedUpFactor */); |
Jorim Jaggi | 449981b | 2014-10-03 14:24:55 -0700 | [diff] [blame] | 2422 | } |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 2423 | } |
| 2424 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 2425 | void makeExpandedInvisible() { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2426 | if (SPEW) Log.d(TAG, "makeExpandedInvisible: mExpandedVisible=" + mExpandedVisible |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2427 | + " mExpandedVisible=" + mExpandedVisible); |
| 2428 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 2429 | if (!mExpandedVisible || mStatusBarWindow == null) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2430 | return; |
| 2431 | } |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 2432 | |
Daniel Sandler | c38bbc3 | 2012-10-05 12:21:38 -0400 | [diff] [blame] | 2433 | // Ensure the panel is fully collapsed (just in case; bug 6765842, 7260868) |
Xiaohui Chen | 9f96711 | 2016-01-07 14:14:06 -0800 | [diff] [blame] | 2434 | mStatusBarView.collapsePanel(/*animate=*/ false, false /* delayed*/, |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 2435 | 1.0f /* speedUpFactor */); |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 2436 | |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 2437 | mNotificationPanel.closeQs(); |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 2438 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2439 | mExpandedVisible = false; |
John Spurlock | d5ef546 | 2012-06-13 11:19:51 -0400 | [diff] [blame] | 2440 | if (mNavigationBarView != null) |
| 2441 | mNavigationBarView.setSlippery(false); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2442 | visibilityChanged(false); |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 2443 | |
| 2444 | // Shrink the window to the size of the status bar only |
Selim Cinek | 4a21a7f | 2015-05-19 11:00:38 -0700 | [diff] [blame] | 2445 | mStatusBarWindowManager.setPanelVisible(false); |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2446 | mStatusBarWindowManager.setForceStatusBarVisible(false); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2447 | |
Daniel Sandler | 469e96e | 2012-05-04 15:56:19 -0400 | [diff] [blame] | 2448 | // Close any "App info" popups that might have snuck on-screen |
| 2449 | dismissPopups(); |
| 2450 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2451 | runPostCollapseRunnables(); |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 2452 | setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 2453 | showBouncer(); |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2454 | disable(mDisabledUnmodified1, mDisabledUnmodified2, true /* animate */); |
Jorim Jaggi | 786afcb | 2014-09-25 02:41:29 +0200 | [diff] [blame] | 2455 | |
| 2456 | // Trimming will happen later if Keyguard is showing - doing it here might cause a jank in |
| 2457 | // the bouncer appear animation. |
| 2458 | if (!mStatusBarKeyguardViewManager.isShowing()) { |
| 2459 | WindowManagerGlobal.getInstance().trimMemory(ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN); |
| 2460 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2461 | } |
| 2462 | |
Daniel Sandler | b17a726 | 2012-10-05 14:32:50 -0400 | [diff] [blame] | 2463 | public boolean interceptTouchEvent(MotionEvent event) { |
Chris Wren | 64161cc | 2012-12-17 16:49:30 -0500 | [diff] [blame] | 2464 | if (DEBUG_GESTURES) { |
| 2465 | if (event.getActionMasked() != MotionEvent.ACTION_MOVE) { |
| 2466 | EventLog.writeEvent(EventLogTags.SYSUI_STATUSBAR_TOUCH, |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2467 | event.getActionMasked(), (int) event.getX(), (int) event.getY(), |
| 2468 | mDisabled1, mDisabled2); |
Chris Wren | 64161cc | 2012-12-17 16:49:30 -0500 | [diff] [blame] | 2469 | } |
| 2470 | |
| 2471 | } |
| 2472 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2473 | if (SPEW) { |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2474 | Log.d(TAG, "Touch: rawY=" + event.getRawY() + " event=" + event + " mDisabled1=" |
| 2475 | + mDisabled1 + " mDisabled2=" + mDisabled2 + " mTracking=" + mTracking); |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 2476 | } else if (CHATTY) { |
Daniel Sandler | fe172cc | 2011-09-12 13:47:25 -0400 | [diff] [blame] | 2477 | if (event.getAction() != MotionEvent.ACTION_MOVE) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2478 | Log.d(TAG, String.format( |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2479 | "panel: %s at (%f, %f) mDisabled1=0x%08x mDisabled2=0x%08x", |
Daniel Sandler | fe172cc | 2011-09-12 13:47:25 -0400 | [diff] [blame] | 2480 | MotionEvent.actionToString(event.getAction()), |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 2481 | event.getRawX(), event.getRawY(), mDisabled1, mDisabled2)); |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 2482 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2483 | } |
| 2484 | |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 2485 | if (DEBUG_GESTURES) { |
| 2486 | mGestureRec.add(event); |
| 2487 | } |
Daniel Sandler | 3380534 | 2012-07-23 15:45:12 -0400 | [diff] [blame] | 2488 | |
John Spurlock | 686820a | 2013-09-03 14:44:16 -0400 | [diff] [blame] | 2489 | if (mStatusBarWindowState == WINDOW_STATE_SHOWING) { |
John Spurlock | 5fee836 | 2013-09-12 10:34:33 -0400 | [diff] [blame] | 2490 | final boolean upOrCancel = |
| 2491 | event.getAction() == MotionEvent.ACTION_UP || |
| 2492 | event.getAction() == MotionEvent.ACTION_CANCEL; |
| 2493 | if (upOrCancel && !mExpandedVisible) { |
| 2494 | setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false); |
| 2495 | } else { |
| 2496 | setInteracting(StatusBarManager.WINDOW_STATUS_BAR, true); |
| 2497 | } |
John Spurlock | 686820a | 2013-09-03 14:44:16 -0400 | [diff] [blame] | 2498 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2499 | return false; |
| 2500 | } |
| 2501 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 2502 | public GestureRecorder getGestureRecorder() { |
| 2503 | return mGestureRec; |
Jeff Brown | 911fe30 | 2011-09-12 14:21:17 -0700 | [diff] [blame] | 2504 | } |
| 2505 | |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 2506 | private void setNavigationIconHints(int hints) { |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 2507 | if (hints == mNavigationIconHints) return; |
| 2508 | |
| 2509 | mNavigationIconHints = hints; |
| 2510 | |
| 2511 | if (mNavigationBarView != null) { |
| 2512 | mNavigationBarView.setNavigationIconHints(hints); |
| 2513 | } |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2514 | checkBarModes(); |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 2515 | } |
| 2516 | |
| 2517 | @Override // CommandQueue |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2518 | public void setWindowState(int window, int state) { |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2519 | boolean showing = state == WINDOW_STATE_SHOWING; |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2520 | if (mStatusBarWindow != null |
| 2521 | && window == StatusBarManager.WINDOW_STATUS_BAR |
| 2522 | && mStatusBarWindowState != state) { |
| 2523 | mStatusBarWindowState = state; |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 2524 | if (DEBUG_WINDOW_STATE) Log.d(TAG, "Status bar " + windowStateToString(state)); |
Jorim Jaggi | 449981b | 2014-10-03 14:24:55 -0700 | [diff] [blame] | 2525 | if (!showing && mState == StatusBarState.SHADE) { |
Xiaohui Chen | 9f96711 | 2016-01-07 14:14:06 -0800 | [diff] [blame] | 2526 | mStatusBarView.collapsePanel(false /* animate */, false /* delayed */, |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 2527 | 1.0f /* speedUpFactor */); |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2528 | } |
| 2529 | } |
| 2530 | if (mNavigationBarView != null |
| 2531 | && window == StatusBarManager.WINDOW_NAVIGATION_BAR |
| 2532 | && mNavigationBarWindowState != state) { |
| 2533 | mNavigationBarWindowState = state; |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 2534 | if (DEBUG_WINDOW_STATE) Log.d(TAG, "Navigation bar " + windowStateToString(state)); |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2535 | } |
| 2536 | } |
| 2537 | |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 2538 | @Override // CommandQueue |
John Spurlock | cad5768 | 2014-07-26 17:09:56 -0400 | [diff] [blame] | 2539 | public void buzzBeepBlinked() { |
| 2540 | if (mDozeServiceHost != null) { |
| 2541 | mDozeServiceHost.fireBuzzBeepBlinked(); |
| 2542 | } |
| 2543 | } |
| 2544 | |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 2545 | @Override |
| 2546 | public void notificationLightOff() { |
| 2547 | if (mDozeServiceHost != null) { |
| 2548 | mDozeServiceHost.fireNotificationLight(false); |
| 2549 | } |
| 2550 | } |
| 2551 | |
| 2552 | @Override |
| 2553 | public void notificationLightPulse(int argb, int onMillis, int offMillis) { |
| 2554 | if (mDozeServiceHost != null) { |
| 2555 | mDozeServiceHost.fireNotificationLight(true); |
| 2556 | } |
| 2557 | } |
| 2558 | |
John Spurlock | cad5768 | 2014-07-26 17:09:56 -0400 | [diff] [blame] | 2559 | @Override // CommandQueue |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 2560 | public void setSystemUiVisibility(int vis, int fullscreenStackVis, int dockedStackVis, |
| 2561 | int mask, Rect fullscreenStackBounds, Rect dockedStackBounds) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2562 | final int oldVal = mSystemUiVisibility; |
| 2563 | final int newVal = (oldVal&~mask) | (vis&mask); |
| 2564 | final int diff = newVal ^ oldVal; |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2565 | if (DEBUG) Log.d(TAG, String.format( |
John Spurlock | dcf4f21 | 2013-05-21 17:19:53 -0400 | [diff] [blame] | 2566 | "setSystemUiVisibility vis=%s mask=%s oldVal=%s newVal=%s diff=%s", |
| 2567 | Integer.toHexString(vis), Integer.toHexString(mask), |
| 2568 | Integer.toHexString(oldVal), Integer.toHexString(newVal), |
| 2569 | Integer.toHexString(diff))); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 2570 | boolean sbModeChanged = false; |
Daniel Sandler | e137a1e | 2011-08-17 16:47:19 -0400 | [diff] [blame] | 2571 | if (diff != 0) { |
Winson Chung | 9214eff | 2014-06-12 13:59:25 -0700 | [diff] [blame] | 2572 | // we never set the recents bit via this method, so save the prior state to prevent |
| 2573 | // clobbering the bit below |
| 2574 | final boolean wasRecentsVisible = (mSystemUiVisibility & View.RECENT_APPS_VISIBLE) > 0; |
| 2575 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2576 | mSystemUiVisibility = newVal; |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 2577 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2578 | // update low profile |
| 2579 | if ((diff & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) { |
| 2580 | final boolean lightsOut = (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0; |
Daniel Sandler | e137a1e | 2011-08-17 16:47:19 -0400 | [diff] [blame] | 2581 | if (lightsOut) { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2582 | animateCollapsePanels(); |
Daniel Sandler | e137a1e | 2011-08-17 16:47:19 -0400 | [diff] [blame] | 2583 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 2584 | |
John Spurlock | 7edfbca | 2013-09-14 11:58:55 -0400 | [diff] [blame] | 2585 | setAreThereNotifications(); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 2586 | } |
| 2587 | |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2588 | // ready to unhide |
| 2589 | if ((vis & View.STATUS_BAR_UNHIDE) != 0) { |
| 2590 | mSystemUiVisibility &= ~View.STATUS_BAR_UNHIDE; |
| 2591 | mNoAnimationOnNextBarModeChange = true; |
| 2592 | } |
| 2593 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2594 | // update status bar mode |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2595 | final int sbMode = computeBarMode(oldVal, newVal, mStatusBarView.getBarTransitions(), |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 2596 | View.STATUS_BAR_TRANSIENT, View.STATUS_BAR_TRANSLUCENT, |
| 2597 | View.STATUS_BAR_TRANSPARENT); |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2598 | |
| 2599 | // update navigation bar mode |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2600 | final int nbMode = mNavigationBarView == null ? -1 : computeBarMode( |
John Spurlock | f6b6397 | 2013-08-27 16:08:28 -0400 | [diff] [blame] | 2601 | oldVal, newVal, mNavigationBarView.getBarTransitions(), |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 2602 | View.NAVIGATION_BAR_TRANSIENT, View.NAVIGATION_BAR_TRANSLUCENT, |
| 2603 | View.NAVIGATION_BAR_TRANSPARENT); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 2604 | sbModeChanged = sbMode != -1; |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2605 | final boolean nbModeChanged = nbMode != -1; |
| 2606 | boolean checkBarModes = false; |
| 2607 | if (sbModeChanged && sbMode != mStatusBarMode) { |
| 2608 | mStatusBarMode = sbMode; |
| 2609 | checkBarModes = true; |
| 2610 | } |
| 2611 | if (nbModeChanged && nbMode != mNavigationBarMode) { |
| 2612 | mNavigationBarMode = nbMode; |
| 2613 | checkBarModes = true; |
| 2614 | } |
| 2615 | if (checkBarModes) { |
| 2616 | checkBarModes(); |
| 2617 | } |
| 2618 | if (sbModeChanged || nbModeChanged) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2619 | // update transient bar autohide |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 2620 | if (mStatusBarMode == MODE_SEMI_TRANSPARENT || mNavigationBarMode == MODE_SEMI_TRANSPARENT) { |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 2621 | scheduleAutohide(); |
| 2622 | } else { |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 2623 | cancelAutohide(); |
| 2624 | } |
| 2625 | } |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2626 | |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 2627 | if ((vis & View.NAVIGATION_BAR_UNHIDE) != 0) { |
| 2628 | mSystemUiVisibility &= ~View.NAVIGATION_BAR_UNHIDE; |
| 2629 | } |
| 2630 | |
Winson Chung | 9214eff | 2014-06-12 13:59:25 -0700 | [diff] [blame] | 2631 | // restore the recents bit |
| 2632 | if (wasRecentsVisible) { |
| 2633 | mSystemUiVisibility |= View.RECENT_APPS_VISIBLE; |
| 2634 | } |
| 2635 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2636 | // send updated sysui visibility to window manager |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 2637 | notifyUiVisibilityChanged(mSystemUiVisibility); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 2638 | } |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 2639 | |
| 2640 | mLightStatusBarController.onSystemUiVisibilityChanged(fullscreenStackVis, dockedStackVis, |
| 2641 | mask, fullscreenStackBounds, dockedStackBounds, sbModeChanged, mStatusBarMode); |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 2642 | } |
| 2643 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2644 | private int computeBarMode(int oldVis, int newVis, BarTransitions transitions, |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 2645 | int transientFlag, int translucentFlag, int transparentFlag) { |
| 2646 | final int oldMode = barMode(oldVis, transientFlag, translucentFlag, transparentFlag); |
| 2647 | final int newMode = barMode(newVis, transientFlag, translucentFlag, transparentFlag); |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2648 | if (oldMode == newMode) { |
| 2649 | return -1; // no mode change |
| 2650 | } |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2651 | return newMode; |
| 2652 | } |
| 2653 | |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 2654 | private int barMode(int vis, int transientFlag, int translucentFlag, int transparentFlag) { |
| 2655 | int lightsOutTransparent = View.SYSTEM_UI_FLAG_LOW_PROFILE | transparentFlag; |
John Spurlock | 89835dd | 2013-08-16 15:06:51 -0400 | [diff] [blame] | 2656 | return (vis & transientFlag) != 0 ? MODE_SEMI_TRANSPARENT |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 2657 | : (vis & translucentFlag) != 0 ? MODE_TRANSLUCENT |
Adrian Roos | c0f0a74 | 2014-10-28 16:39:56 +0100 | [diff] [blame] | 2658 | : (vis & lightsOutTransparent) == lightsOutTransparent ? MODE_LIGHTS_OUT_TRANSPARENT |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 2659 | : (vis & transparentFlag) != 0 ? MODE_TRANSPARENT |
John Spurlock | 7edfbca | 2013-09-14 11:58:55 -0400 | [diff] [blame] | 2660 | : (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0 ? MODE_LIGHTS_OUT |
John Spurlock | 3b139a9 | 2013-08-17 17:18:08 -0400 | [diff] [blame] | 2661 | : MODE_OPAQUE; |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2662 | } |
| 2663 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2664 | private void checkBarModes() { |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 2665 | if (mDemoMode) return; |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2666 | checkBarMode(mStatusBarMode, mStatusBarWindowState, mStatusBarView.getBarTransitions(), |
| 2667 | mNoAnimationOnNextBarModeChange); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2668 | if (mNavigationBarView != null) { |
| 2669 | checkBarMode(mNavigationBarMode, |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2670 | mNavigationBarWindowState, mNavigationBarView.getBarTransitions(), |
| 2671 | mNoAnimationOnNextBarModeChange); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2672 | } |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2673 | mNoAnimationOnNextBarModeChange = false; |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2674 | } |
| 2675 | |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2676 | private void checkBarMode(int mode, int windowState, BarTransitions transitions, |
| 2677 | boolean noAnimation) { |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 2678 | final boolean powerSave = mBatteryController.isPowerSave(); |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 2679 | final boolean anim = !noAnimation && mDeviceInteractive |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 2680 | && windowState != WINDOW_STATE_HIDDEN && !powerSave; |
John Spurlock | 1bb480a | 2014-08-02 17:12:43 -0400 | [diff] [blame] | 2681 | if (powerSave && getBarState() == StatusBarState.SHADE) { |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 2682 | mode = MODE_WARNING; |
| 2683 | } |
John Spurlock | c68d577 | 2013-10-08 11:47:58 -0400 | [diff] [blame] | 2684 | transitions.transitionTo(mode, anim); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2685 | } |
| 2686 | |
John Spurlock | 4219726 | 2013-10-21 09:32:25 -0400 | [diff] [blame] | 2687 | private void finishBarAnimations() { |
| 2688 | mStatusBarView.getBarTransitions().finishAnimations(); |
| 2689 | if (mNavigationBarView != null) { |
| 2690 | mNavigationBarView.getBarTransitions().finishAnimations(); |
| 2691 | } |
| 2692 | } |
| 2693 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2694 | private final Runnable mCheckBarModes = new Runnable() { |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 2695 | @Override |
| 2696 | public void run() { |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2697 | checkBarModes(); |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 2698 | } |
| 2699 | }; |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 2700 | |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2701 | @Override |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 2702 | public void setInteracting(int barWindow, boolean interacting) { |
John Spurlock | 7fbf573 | 2014-11-18 11:40:22 -0500 | [diff] [blame] | 2703 | final boolean changing = ((mInteractingWindows & barWindow) != 0) != interacting; |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 2704 | mInteractingWindows = interacting |
| 2705 | ? (mInteractingWindows | barWindow) |
| 2706 | : (mInteractingWindows & ~barWindow); |
| 2707 | if (mInteractingWindows != 0) { |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2708 | suspendAutohide(); |
| 2709 | } else { |
| 2710 | resumeSuspendedAutohide(); |
| 2711 | } |
John Spurlock | 7fbf573 | 2014-11-18 11:40:22 -0500 | [diff] [blame] | 2712 | // manually dismiss the volume panel when interacting with the nav bar |
| 2713 | if (changing && interacting && barWindow == StatusBarManager.WINDOW_NAVIGATION_BAR) { |
John Spurlock | b349af57 | 2015-04-29 12:24:19 -0400 | [diff] [blame] | 2714 | dismissVolumeDialog(); |
John Spurlock | 7fbf573 | 2014-11-18 11:40:22 -0500 | [diff] [blame] | 2715 | } |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2716 | checkBarModes(); |
| 2717 | } |
| 2718 | |
John Spurlock | b349af57 | 2015-04-29 12:24:19 -0400 | [diff] [blame] | 2719 | private void dismissVolumeDialog() { |
| 2720 | if (mVolumeComponent != null) { |
| 2721 | mVolumeComponent.dismissNow(); |
| 2722 | } |
| 2723 | } |
| 2724 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2725 | private void resumeSuspendedAutohide() { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2726 | if (mAutohideSuspended) { |
| 2727 | scheduleAutohide(); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2728 | mHandler.postDelayed(mCheckBarModes, 500); // longer than home -> launcher |
John Spurlock | 3b139a9 | 2013-08-17 17:18:08 -0400 | [diff] [blame] | 2729 | } |
| 2730 | } |
| 2731 | |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2732 | private void suspendAutohide() { |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 2733 | mHandler.removeCallbacks(mAutohide); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2734 | mHandler.removeCallbacks(mCheckBarModes); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 2735 | mAutohideSuspended = (mSystemUiVisibility & STATUS_OR_NAV_TRANSIENT) != 0; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 2736 | } |
| 2737 | |
| 2738 | private void cancelAutohide() { |
| 2739 | mAutohideSuspended = false; |
| 2740 | mHandler.removeCallbacks(mAutohide); |
| 2741 | } |
| 2742 | |
| 2743 | private void scheduleAutohide() { |
| 2744 | cancelAutohide(); |
| 2745 | mHandler.postDelayed(mAutohide, AUTOHIDE_TIMEOUT_MS); |
| 2746 | } |
| 2747 | |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 2748 | private void checkUserAutohide(View v, MotionEvent event) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2749 | if ((mSystemUiVisibility & STATUS_OR_NAV_TRANSIENT) != 0 // a transient bar is revealed |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 2750 | && event.getAction() == MotionEvent.ACTION_OUTSIDE // touch outside the source bar |
| 2751 | && event.getX() == 0 && event.getY() == 0 // a touch outside both bars |
| 2752 | ) { |
| 2753 | userAutohide(); |
| 2754 | } |
| 2755 | } |
| 2756 | |
| 2757 | private void userAutohide() { |
| 2758 | cancelAutohide(); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 2759 | mHandler.postDelayed(mAutohide, 350); // longer than app gesture -> flag clear |
John Spurlock | 9deaa28 | 2013-07-25 13:03:47 -0400 | [diff] [blame] | 2760 | } |
| 2761 | |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 2762 | private boolean areLightsOn() { |
| 2763 | return 0 == (mSystemUiVisibility & View.SYSTEM_UI_FLAG_LOW_PROFILE); |
| 2764 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 2765 | |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 2766 | public void setLightsOn(boolean on) { |
| 2767 | Log.v(TAG, "setLightsOn(" + on + ")"); |
| 2768 | if (on) { |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 2769 | setSystemUiVisibility(0, 0, 0, View.SYSTEM_UI_FLAG_LOW_PROFILE, |
| 2770 | mLastFullscreenStackBounds, mLastDockedStackBounds); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 2771 | } else { |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 2772 | setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE, 0, 0, |
| 2773 | View.SYSTEM_UI_FLAG_LOW_PROFILE, mLastFullscreenStackBounds, |
| 2774 | mLastDockedStackBounds); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 2775 | } |
| 2776 | } |
| 2777 | |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 2778 | private void notifyUiVisibilityChanged(int vis) { |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 2779 | try { |
Adrian Roos | 389beec | 2015-05-12 13:33:25 -0700 | [diff] [blame] | 2780 | if (mLastDispatchedSystemUiVisibility != vis) { |
| 2781 | mWindowManagerService.statusBarVisibilityChanged(vis); |
| 2782 | mLastDispatchedSystemUiVisibility = vis; |
| 2783 | } |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 2784 | } catch (RemoteException ex) { |
| 2785 | } |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 2786 | } |
| 2787 | |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 2788 | public void topAppWindowChanged(boolean showMenu) { |
| 2789 | if (DEBUG) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2790 | Log.d(TAG, (showMenu?"showing":"hiding") + " the MENU button"); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 2791 | } |
| 2792 | if (mNavigationBarView != null) { |
Daniel Sandler | f1ebcee | 2011-09-15 16:02:56 -0400 | [diff] [blame] | 2793 | mNavigationBarView.setMenuVisibility(showMenu); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 2794 | } |
| 2795 | |
| 2796 | // See above re: lights-out policy for legacy apps. |
| 2797 | if (showMenu) setLightsOn(true); |
| 2798 | } |
| 2799 | |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 2800 | @Override |
Jason Monk | b605fec | 2014-05-02 17:04:10 -0400 | [diff] [blame] | 2801 | public void setImeWindowStatus(IBinder token, int vis, int backDisposition, |
| 2802 | boolean showImeSwitcher) { |
Jason Monk | f1ff209 | 2014-04-29 16:50:53 -0400 | [diff] [blame] | 2803 | boolean imeShown = (vis & InputMethodService.IME_VISIBLE) != 0; |
| 2804 | int flags = mNavigationIconHints; |
| 2805 | if ((backDisposition == InputMethodService.BACK_DISPOSITION_WILL_DISMISS) || imeShown) { |
| 2806 | flags |= NAVIGATION_HINT_BACK_ALT; |
| 2807 | } else { |
| 2808 | flags &= ~NAVIGATION_HINT_BACK_ALT; |
| 2809 | } |
Jason Monk | b605fec | 2014-05-02 17:04:10 -0400 | [diff] [blame] | 2810 | if (showImeSwitcher) { |
Jason Monk | f1ff209 | 2014-04-29 16:50:53 -0400 | [diff] [blame] | 2811 | flags |= NAVIGATION_HINT_IME_SHOWN; |
| 2812 | } else { |
| 2813 | flags &= ~NAVIGATION_HINT_IME_SHOWN; |
| 2814 | } |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 2815 | |
Jason Monk | f1ff209 | 2014-04-29 16:50:53 -0400 | [diff] [blame] | 2816 | setNavigationIconHints(flags); |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 2817 | } |
| 2818 | |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 2819 | public static String viewInfo(View v) { |
| 2820 | return "[(" + v.getLeft() + "," + v.getTop() + ")(" + v.getRight() + "," + v.getBottom() |
| 2821 | + ") " + v.getWidth() + "x" + v.getHeight() + "]"; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2822 | } |
| 2823 | |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 2824 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2825 | synchronized (mQueueLock) { |
| 2826 | pw.println("Current Status Bar state:"); |
Daniel Sandler | e7237fc | 2012-08-14 16:08:27 -0400 | [diff] [blame] | 2827 | pw.println(" mExpandedVisible=" + mExpandedVisible |
Daniel Sandler | fdbac77 | 2012-07-03 14:30:10 -0400 | [diff] [blame] | 2828 | + ", mTrackingPosition=" + mTrackingPosition); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2829 | pw.println(" mTracking=" + mTracking); |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 2830 | pw.println(" mDisplayMetrics=" + mDisplayMetrics); |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 2831 | pw.println(" mStackScroller: " + viewInfo(mStackScroller)); |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 2832 | pw.println(" mStackScroller: " + viewInfo(mStackScroller) |
| 2833 | + " scroll " + mStackScroller.getScrollX() |
| 2834 | + "," + mStackScroller.getScrollY()); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2835 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2836 | |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 2837 | pw.print(" mInteractingWindows="); pw.println(mInteractingWindows); |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 2838 | pw.print(" mStatusBarWindowState="); |
| 2839 | pw.println(windowStateToString(mStatusBarWindowState)); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2840 | pw.print(" mStatusBarMode="); |
| 2841 | pw.println(BarTransitions.modeToString(mStatusBarMode)); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 2842 | pw.print(" mDozing="); pw.println(mDozing); |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 2843 | pw.print(" mZenMode="); |
| 2844 | pw.println(Settings.Global.zenModeToString(mZenMode)); |
Chris Wren | 3b6745b | 2014-03-07 14:34:35 -0500 | [diff] [blame] | 2845 | pw.print(" mUseHeadsUp="); |
| 2846 | pw.println(mUseHeadsUp); |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 2847 | dumpBarTransitions(pw, "mStatusBarView", mStatusBarView.getBarTransitions()); |
| 2848 | if (mNavigationBarView != null) { |
| 2849 | pw.print(" mNavigationBarWindowState="); |
| 2850 | pw.println(windowStateToString(mNavigationBarWindowState)); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 2851 | pw.print(" mNavigationBarMode="); |
| 2852 | pw.println(BarTransitions.modeToString(mNavigationBarMode)); |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 2853 | dumpBarTransitions(pw, "mNavigationBarView", mNavigationBarView.getBarTransitions()); |
| 2854 | } |
| 2855 | |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 2856 | pw.print(" mNavigationBarView="); |
| 2857 | if (mNavigationBarView == null) { |
| 2858 | pw.println("null"); |
| 2859 | } else { |
| 2860 | mNavigationBarView.dump(fd, pw, args); |
| 2861 | } |
| 2862 | |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2863 | pw.print(" mMediaSessionManager="); |
| 2864 | pw.println(mMediaSessionManager); |
| 2865 | pw.print(" mMediaNotificationKey="); |
| 2866 | pw.println(mMediaNotificationKey); |
| 2867 | pw.print(" mMediaController="); |
| 2868 | pw.print(mMediaController); |
| 2869 | if (mMediaController != null) { |
| 2870 | pw.print(" state=" + mMediaController.getPlaybackState()); |
| 2871 | } |
| 2872 | pw.println(); |
| 2873 | pw.print(" mMediaMetadata="); |
| 2874 | pw.print(mMediaMetadata); |
| 2875 | if (mMediaMetadata != null) { |
RoboErik | 75847b9 | 2014-07-29 13:10:17 -0700 | [diff] [blame] | 2876 | pw.print(" title=" + mMediaMetadata.getText(MediaMetadata.METADATA_KEY_TITLE)); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 2877 | } |
| 2878 | pw.println(); |
| 2879 | |
Daniel Sandler | 37a38aa | 2013-02-13 17:15:57 -0500 | [diff] [blame] | 2880 | pw.println(" Panels: "); |
| 2881 | if (mNotificationPanel != null) { |
| 2882 | pw.println(" mNotificationPanel=" + |
| 2883 | mNotificationPanel + " params=" + mNotificationPanel.getLayoutParams().debug("")); |
| 2884 | pw.print (" "); |
| 2885 | mNotificationPanel.dump(fd, pw, args); |
| 2886 | } |
Daniel Sandler | 37a38aa | 2013-02-13 17:15:57 -0500 | [diff] [blame] | 2887 | |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 2888 | DozeLog.dump(pw); |
| 2889 | |
Daniel Sandler | 7579bca | 2011-08-18 15:47:26 -0400 | [diff] [blame] | 2890 | if (DUMPTRUCK) { |
| 2891 | synchronized (mNotificationData) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 2892 | mNotificationData.dump(pw, " "); |
Daniel Sandler | 7579bca | 2011-08-18 15:47:26 -0400 | [diff] [blame] | 2893 | } |
| 2894 | |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 2895 | mIconController.dump(pw); |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 2896 | |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 2897 | if (false) { |
| 2898 | pw.println("see the logcat for a dump of the views we have created."); |
| 2899 | // must happen on ui thread |
| 2900 | mHandler.post(new Runnable() { |
| 2901 | public void run() { |
| 2902 | mStatusBarView.getLocationOnScreen(mAbsPos); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 2903 | Log.d(TAG, "mStatusBarView: ----- (" + mAbsPos[0] + "," + mAbsPos[1] |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 2904 | + ") " + mStatusBarView.getWidth() + "x" |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 2905 | + getStatusBarHeight()); |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 2906 | mStatusBarView.debug(); |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 2907 | } |
| 2908 | }); |
| 2909 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2910 | } |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 2911 | |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 2912 | if (DEBUG_GESTURES) { |
| 2913 | pw.print(" status bar gestures: "); |
| 2914 | mGestureRec.dump(fd, pw, args); |
| 2915 | } |
Selim Cinek | 7025f26 | 2015-07-13 16:22:48 -0700 | [diff] [blame] | 2916 | if (mStatusBarWindowManager != null) { |
| 2917 | mStatusBarWindowManager.dump(fd, pw, args); |
| 2918 | } |
John Spurlock | 486b78e | 2014-07-07 08:37:56 -0400 | [diff] [blame] | 2919 | if (mNetworkController != null) { |
| 2920 | mNetworkController.dump(fd, pw, args); |
| 2921 | } |
| 2922 | if (mBluetoothController != null) { |
| 2923 | mBluetoothController.dump(fd, pw, args); |
| 2924 | } |
Jason Monk | dd5bdc6 | 2015-07-20 12:18:38 -0400 | [diff] [blame] | 2925 | if (mHotspotController != null) { |
| 2926 | mHotspotController.dump(fd, pw, args); |
| 2927 | } |
John Spurlock | 1e6eb17 | 2014-07-13 11:59:50 -0400 | [diff] [blame] | 2928 | if (mCastController != null) { |
| 2929 | mCastController.dump(fd, pw, args); |
| 2930 | } |
Adrian Roos | 00a0b1f | 2014-07-16 16:44:49 +0200 | [diff] [blame] | 2931 | if (mUserSwitcherController != null) { |
| 2932 | mUserSwitcherController.dump(fd, pw, args); |
| 2933 | } |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 2934 | if (mBatteryController != null) { |
| 2935 | mBatteryController.dump(fd, pw, args); |
| 2936 | } |
Jorim Jaggi | c7dea6e | 2014-07-26 14:36:57 +0200 | [diff] [blame] | 2937 | if (mNextAlarmController != null) { |
| 2938 | mNextAlarmController.dump(fd, pw, args); |
| 2939 | } |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 2940 | if (mSecurityController != null) { |
| 2941 | mSecurityController.dump(fd, pw, args); |
| 2942 | } |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2943 | if (mHeadsUpManager != null) { |
| 2944 | mHeadsUpManager.dump(fd, pw, args); |
Chris Wren | 428c6b6 | 2014-12-05 16:07:06 -0500 | [diff] [blame] | 2945 | } else { |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 2946 | pw.println(" mHeadsUpManager: null"); |
Chris Wren | 428c6b6 | 2014-12-05 16:07:06 -0500 | [diff] [blame] | 2947 | } |
Jason Monk | ab52527 | 2015-07-13 17:02:49 -0400 | [diff] [blame] | 2948 | if (KeyguardUpdateMonitor.getInstance(mContext) != null) { |
| 2949 | KeyguardUpdateMonitor.getInstance(mContext).dump(fd, pw, args); |
| 2950 | } |
Chris Wren | 428c6b6 | 2014-12-05 16:07:06 -0500 | [diff] [blame] | 2951 | |
John Spurlock | 7bbb9f6 | 2014-10-21 12:15:28 -0400 | [diff] [blame] | 2952 | pw.println("SharedPreferences:"); |
Andrew Flynn | 8286257 | 2015-04-01 14:22:37 -0400 | [diff] [blame] | 2953 | for (Map.Entry<String, ?> entry : Prefs.getAll(mContext).entrySet()) { |
John Spurlock | 7bbb9f6 | 2014-10-21 12:15:28 -0400 | [diff] [blame] | 2954 | pw.print(" "); pw.print(entry.getKey()); pw.print("="); pw.println(entry.getValue()); |
| 2955 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2956 | } |
| 2957 | |
Chris Wren | 3b6745b | 2014-03-07 14:34:35 -0500 | [diff] [blame] | 2958 | private String hunStateToString(Entry entry) { |
| 2959 | if (entry == null) return "null"; |
| 2960 | if (entry.notification == null) return "corrupt"; |
| 2961 | return entry.notification.getPackageName(); |
| 2962 | } |
| 2963 | |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 2964 | private static void dumpBarTransitions(PrintWriter pw, String var, BarTransitions transitions) { |
| 2965 | pw.print(" "); pw.print(var); pw.print(".BarTransitions.mMode="); |
| 2966 | pw.println(BarTransitions.modeToString(transitions.getMode())); |
| 2967 | } |
| 2968 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 2969 | @Override |
| 2970 | public void createAndAddWindows() { |
| 2971 | addStatusBarWindow(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2972 | } |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 2973 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 2974 | private void addStatusBarWindow() { |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 2975 | makeStatusBarView(); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 2976 | mStatusBarWindowManager = new StatusBarWindowManager(mContext); |
Adrian Roos | 1c0ca50 | 2015-10-07 12:20:42 -0700 | [diff] [blame] | 2977 | mRemoteInputController = new RemoteInputController(mStatusBarWindowManager, |
| 2978 | mHeadsUpManager); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 2979 | mStatusBarWindowManager.add(mStatusBarWindow, getStatusBarHeight()); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2980 | } |
| 2981 | |
Daniel Sandler | 747a9e9 | 2012-08-10 16:39:19 -0400 | [diff] [blame] | 2982 | // called by makeStatusbar and also by PhoneStatusBarView |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 2983 | void updateDisplaySize() { |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 2984 | mDisplay.getMetrics(mDisplayMetrics); |
Daniel Sandler | 7e8ae50 | 2013-10-10 23:38:19 -0400 | [diff] [blame] | 2985 | mDisplay.getSize(mCurrentDisplaySize); |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 2986 | if (DEBUG_GESTURES) { |
John Spurlock | 209bede | 2013-07-17 12:23:27 -0400 | [diff] [blame] | 2987 | mGestureRec.tag("display", |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 2988 | String.format("%dx%d", mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels)); |
| 2989 | } |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 2990 | } |
| 2991 | |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 2992 | float getDisplayDensity() { |
| 2993 | return mDisplayMetrics.density; |
| 2994 | } |
| 2995 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 2996 | public void startActivityDismissingKeyguard(final Intent intent, boolean onlyProvisioned, |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 2997 | boolean dismissShade) { |
| 2998 | startActivityDismissingKeyguard(intent, onlyProvisioned, dismissShade, null /* callback */); |
| 2999 | } |
| 3000 | |
| 3001 | public void startActivityDismissingKeyguard(final Intent intent, boolean onlyProvisioned, |
| 3002 | final boolean dismissShade, final Callback callback) { |
Daniel Sandler | 3679bf5 | 2012-10-16 21:30:28 -0400 | [diff] [blame] | 3003 | if (onlyProvisioned && !isDeviceProvisioned()) return; |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 3004 | |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 3005 | final boolean afterKeyguardGone = PreviewInflater.wouldLaunchResolverActivity( |
| 3006 | mContext, intent, mCurrentUserId); |
Jorim Jaggi | c7dea6e | 2014-07-26 14:36:57 +0200 | [diff] [blame] | 3007 | final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing(); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3008 | Runnable runnable = new Runnable() { |
| 3009 | public void run() { |
Jorim Jaggi | b835dd7 | 2015-06-08 12:28:42 -0700 | [diff] [blame] | 3010 | mAssistManager.hideAssist(); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3011 | intent.setFlags( |
| 3012 | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3013 | int result = ActivityManager.START_CANCELED; |
| 3014 | try { |
| 3015 | result = ActivityManagerNative.getDefault().startActivityAsUser( |
| 3016 | null, mContext.getBasePackageName(), |
| 3017 | intent, |
| 3018 | intent.resolveTypeIfNeeded(mContext.getContentResolver()), |
| 3019 | null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, null, |
| 3020 | UserHandle.CURRENT.getIdentifier()); |
| 3021 | } catch (RemoteException e) { |
| 3022 | Log.w(TAG, "Unable to start activity", e); |
| 3023 | } |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3024 | overrideActivityPendingAppTransition( |
| 3025 | keyguardShowing && !afterKeyguardGone); |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3026 | if (callback != null) { |
| 3027 | callback.onActivityStarted(result); |
| 3028 | } |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3029 | } |
| 3030 | }; |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3031 | Runnable cancelRunnable = new Runnable() { |
| 3032 | @Override |
| 3033 | public void run() { |
Jorim Jaggi | 5cc8659 | 2015-06-08 14:48:28 -0700 | [diff] [blame] | 3034 | if (callback != null) { |
| 3035 | callback.onActivityStarted(ActivityManager.START_CANCELED); |
| 3036 | } |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3037 | } |
| 3038 | }; |
Jorim Jaggi | b835dd7 | 2015-06-08 12:28:42 -0700 | [diff] [blame] | 3039 | executeRunnableDismissingKeyguard(runnable, cancelRunnable, dismissShade, |
| 3040 | afterKeyguardGone); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3041 | } |
| 3042 | |
| 3043 | public void executeRunnableDismissingKeyguard(final Runnable runnable, |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3044 | final Runnable cancelAction, |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3045 | final boolean dismissShade, |
| 3046 | final boolean afterKeyguardGone) { |
| 3047 | final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing(); |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 3048 | dismissKeyguardThenExecute(new OnDismissAction() { |
| 3049 | @Override |
| 3050 | public boolean onDismiss() { |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 3051 | AsyncTask.execute(new Runnable() { |
| 3052 | public void run() { |
| 3053 | try { |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 3054 | if (keyguardShowing && !afterKeyguardGone) { |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 3055 | ActivityManagerNative.getDefault() |
| 3056 | .keyguardWaitingForActivityDrawn(); |
| 3057 | } |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3058 | if (runnable != null) { |
| 3059 | runnable.run(); |
| 3060 | } |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 3061 | } catch (RemoteException e) { |
| 3062 | } |
| 3063 | } |
| 3064 | }); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 3065 | if (dismissShade) { |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 3066 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */, |
| 3067 | true /* delayed*/); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 3068 | } |
| 3069 | return true; |
Adrian Roos | 4314f6d | 2014-05-28 14:10:27 +0200 | [diff] [blame] | 3070 | } |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3071 | }, cancelAction, afterKeyguardGone); |
Daniel Sandler | 3679bf5 | 2012-10-16 21:30:28 -0400 | [diff] [blame] | 3072 | } |
| 3073 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3074 | private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { |
| 3075 | public void onReceive(Context context, Intent intent) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 3076 | if (DEBUG) Log.v(TAG, "onReceive: " + intent); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3077 | String action = intent.getAction(); |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 3078 | if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) { |
Andrei Stingaceanu | 9d9294c | 2015-08-24 17:19:06 +0100 | [diff] [blame] | 3079 | getKeyboardShortcuts().dismissKeyboardShortcutsDialog(); |
Kenny Guy | 44fc65f | 2014-11-28 22:18:14 +0000 | [diff] [blame] | 3080 | if (isCurrentProfile(getSendingUserId())) { |
| 3081 | int flags = CommandQueue.FLAG_EXCLUDE_NONE; |
| 3082 | String reason = intent.getStringExtra("reason"); |
| 3083 | if (reason != null && reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) { |
| 3084 | flags |= CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL; |
| 3085 | } |
| 3086 | animateCollapsePanels(flags); |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 3087 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3088 | } |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 3089 | else if (Intent.ACTION_SCREEN_OFF.equals(action)) { |
John Spurlock | 1bbd49d | 2012-10-19 11:09:32 -0400 | [diff] [blame] | 3090 | notifyNavigationBarScreenOn(false); |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 3091 | notifyHeadsUpScreenOff(); |
John Spurlock | 4219726 | 2013-10-21 09:32:25 -0400 | [diff] [blame] | 3092 | finishBarAnimations(); |
Selim Cinek | ccd14fb | 2014-08-12 18:53:24 +0200 | [diff] [blame] | 3093 | resetUserExpandedStates(); |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 3094 | } |
Daniel Sandler | 7f3cf95 | 2012-08-31 14:57:09 -0400 | [diff] [blame] | 3095 | else if (Intent.ACTION_SCREEN_ON.equals(action)) { |
John Spurlock | 1bbd49d | 2012-10-19 11:09:32 -0400 | [diff] [blame] | 3096 | notifyNavigationBarScreenOn(true); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3097 | } |
Adrian Roos | 8e3e836 | 2015-07-16 19:42:22 -0700 | [diff] [blame] | 3098 | } |
| 3099 | }; |
| 3100 | |
| 3101 | private BroadcastReceiver mDemoReceiver = new BroadcastReceiver() { |
| 3102 | public void onReceive(Context context, Intent intent) { |
| 3103 | if (DEBUG) Log.v(TAG, "onReceive: " + intent); |
| 3104 | String action = intent.getAction(); |
| 3105 | if (ACTION_DEMO.equals(action)) { |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3106 | Bundle bundle = intent.getExtras(); |
| 3107 | if (bundle != null) { |
| 3108 | String command = bundle.getString("command", "").trim().toLowerCase(); |
| 3109 | if (command.length() > 0) { |
| 3110 | try { |
| 3111 | dispatchDemoCommand(command, bundle); |
| 3112 | } catch (Throwable t) { |
| 3113 | Log.w(TAG, "Error running demo command, intent=" + intent, t); |
| 3114 | } |
| 3115 | } |
| 3116 | } |
Adrian Roos | 8e3e836 | 2015-07-16 19:42:22 -0700 | [diff] [blame] | 3117 | } else if (ACTION_FAKE_ARTWORK.equals(action)) { |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 3118 | if (DEBUG_MEDIA_FAKE_ARTWORK) { |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 3119 | updateMediaMetaData(true, true); |
Dan Sandler | 16128f4 | 2014-05-21 12:48:22 -0400 | [diff] [blame] | 3120 | } |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3121 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3122 | } |
| 3123 | }; |
| 3124 | |
Selim Cinek | ccd14fb | 2014-08-12 18:53:24 +0200 | [diff] [blame] | 3125 | private void resetUserExpandedStates() { |
| 3126 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
| 3127 | final int notificationCount = activeNotifications.size(); |
| 3128 | for (int i = 0; i < notificationCount; i++) { |
| 3129 | NotificationData.Entry entry = activeNotifications.get(i); |
| 3130 | if (entry.row != null) { |
| 3131 | entry.row.resetUserExpansion(); |
| 3132 | } |
| 3133 | } |
| 3134 | } |
| 3135 | |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 3136 | @Override |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3137 | protected void dismissKeyguardThenExecute(OnDismissAction action, boolean afterKeyguardGone) { |
| 3138 | dismissKeyguardThenExecute(action, null /* cancelRunnable */, afterKeyguardGone); |
| 3139 | } |
| 3140 | |
Jason Monk | abe1974 | 2015-09-29 09:47:06 -0400 | [diff] [blame] | 3141 | public void dismissKeyguard() { |
| 3142 | mStatusBarKeyguardViewManager.dismiss(); |
| 3143 | } |
| 3144 | |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3145 | private void dismissKeyguardThenExecute(OnDismissAction action, Runnable cancelAction, |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 3146 | boolean afterKeyguardGone) { |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 3147 | if (mStatusBarKeyguardViewManager.isShowing()) { |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 3148 | mStatusBarKeyguardViewManager.dismissWithAction(action, cancelAction, |
| 3149 | afterKeyguardGone); |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 3150 | } else { |
| 3151 | action.onDismiss(); |
| 3152 | } |
| 3153 | } |
| 3154 | |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 3155 | // SystemUIService notifies SystemBars of configuration changes, which then calls down here |
| 3156 | @Override |
| 3157 | protected void onConfigurationChanged(Configuration newConfig) { |
| 3158 | super.onConfigurationChanged(newConfig); // calls refreshLayout |
| 3159 | |
| 3160 | if (DEBUG) { |
| 3161 | Log.v(TAG, "configuration changed: " + mContext.getResources().getConfiguration()); |
| 3162 | } |
Daniel Sandler | 7e8ae50 | 2013-10-10 23:38:19 -0400 | [diff] [blame] | 3163 | updateDisplaySize(); // populates mDisplayMetrics |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 3164 | |
| 3165 | updateResources(); |
| 3166 | repositionNavigationBar(); |
Jorim Jaggi | f641174 | 2014-08-05 17:10:43 +0000 | [diff] [blame] | 3167 | updateRowStates(); |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 3168 | mIconController.updateResources(); |
Jason Monk | 18f99d9 | 2014-09-11 13:36:42 -0400 | [diff] [blame] | 3169 | mScreenPinningRequest.onConfigurationChanged(); |
Jason Monk | 1c040db | 2015-07-20 09:45:54 -0400 | [diff] [blame] | 3170 | mNetworkController.onConfigurationChanged(); |
Daniel Sandler | 777dcde | 2013-09-30 10:21:45 -0400 | [diff] [blame] | 3171 | } |
| 3172 | |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 3173 | @Override |
| 3174 | public void userSwitched(int newUserId) { |
Chris Wren | a6d4fb6 | 2014-11-20 14:46:23 -0500 | [diff] [blame] | 3175 | super.userSwitched(newUserId); |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 3176 | if (MULTIUSER_DEBUG) mNotificationPanelDebugText.setText("USER " + newUserId); |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 3177 | animateCollapsePanels(); |
Adrian Roos | 31b844b | 2014-11-21 13:55:09 +0100 | [diff] [blame] | 3178 | updatePublicMode(); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 3179 | updateNotifications(); |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 3180 | resetUserSetupObserver(); |
John Spurlock | 89f060a | 2014-07-16 21:03:15 -0400 | [diff] [blame] | 3181 | setControllerUsers(); |
Julia Reynolds | 86ef8e2 | 2015-09-09 16:42:38 -0400 | [diff] [blame] | 3182 | clearCurrentMediaNotification(); |
Vadim Tryshev | 12a30e8 | 2016-02-12 15:39:28 -0800 | [diff] [blame] | 3183 | mLockscreenWallpaper.setCurrentUser(newUserId); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 3184 | updateMediaMetaData(true, false); |
John Spurlock | 89f060a | 2014-07-16 21:03:15 -0400 | [diff] [blame] | 3185 | } |
| 3186 | |
| 3187 | private void setControllerUsers() { |
| 3188 | if (mZenModeController != null) { |
| 3189 | mZenModeController.setUserId(mCurrentUserId); |
| 3190 | } |
Robin Lee | 63204ee | 2015-06-04 01:53:01 +0100 | [diff] [blame] | 3191 | if (mSecurityController != null) { |
| 3192 | mSecurityController.onUserSwitched(mCurrentUserId); |
| 3193 | } |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 3194 | } |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 3195 | |
| 3196 | private void resetUserSetupObserver() { |
| 3197 | mContext.getContentResolver().unregisterContentObserver(mUserSetupObserver); |
| 3198 | mUserSetupObserver.onChange(false); |
| 3199 | mContext.getContentResolver().registerContentObserver( |
| 3200 | Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE), true, |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 3201 | mUserSetupObserver, mCurrentUserId); |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 3202 | } |
| 3203 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3204 | /** |
| 3205 | * Reload some of our resources when the configuration changes. |
| 3206 | * |
| 3207 | * We don't reload everything when the configuration changes -- we probably |
| 3208 | * should, but getting that smooth is tough. Someday we'll fix that. In the |
| 3209 | * meantime, just update the things that we know change. |
| 3210 | */ |
| 3211 | void updateResources() { |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 3212 | // Update the quick setting tiles |
John Spurlock | 7e6809a | 2014-08-06 16:03:14 -0400 | [diff] [blame] | 3213 | if (mQSPanel != null) { |
| 3214 | mQSPanel.updateResources(); |
| 3215 | } |
Winson Chung | d63c5978 | 2012-09-05 17:34:41 -0700 | [diff] [blame] | 3216 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 3217 | loadDimens(); |
John Spurlock | 7e6809a | 2014-08-06 16:03:14 -0400 | [diff] [blame] | 3218 | |
| 3219 | if (mNotificationPanel != null) { |
| 3220 | mNotificationPanel.updateResources(); |
| 3221 | } |
Adrian Roos | 5fd872e | 2014-08-12 17:28:58 +0200 | [diff] [blame] | 3222 | if (mBrightnessMirrorController != null) { |
| 3223 | mBrightnessMirrorController.updateResources(); |
| 3224 | } |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 3225 | } |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 3226 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 3227 | protected void loadDimens() { |
| 3228 | final Resources res = mContext.getResources(); |
| 3229 | |
| 3230 | mNaturalBarHeight = res.getDimensionPixelSize( |
| 3231 | com.android.internal.R.dimen.status_bar_height); |
| 3232 | |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 3233 | mMaxAllowedKeyguardNotifications = res.getInteger(R.integer.keyguard_max_notification_count); |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 3234 | |
John Spurlock | 7e6809a | 2014-08-06 16:03:14 -0400 | [diff] [blame] | 3235 | if (DEBUG) Log.v(TAG, "updateResources"); |
John Spurlock | 804df70 | 2012-06-01 15:34:27 -0400 | [diff] [blame] | 3236 | } |
| 3237 | |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3238 | // Visibility reporting |
| 3239 | |
| 3240 | @Override |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 3241 | protected void handleVisibleToUserChanged(boolean visibleToUser) { |
| 3242 | if (visibleToUser) { |
| 3243 | super.handleVisibleToUserChanged(visibleToUser); |
| 3244 | startNotificationLogging(); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3245 | } else { |
Christoph Studer | 037e34c | 2014-04-30 20:06:04 +0200 | [diff] [blame] | 3246 | stopNotificationLogging(); |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 3247 | super.handleVisibleToUserChanged(visibleToUser); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3248 | } |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3249 | } |
| 3250 | |
Christoph Studer | 037e34c | 2014-04-30 20:06:04 +0200 | [diff] [blame] | 3251 | private void stopNotificationLogging() { |
| 3252 | // Report all notifications as invisible and turn down the |
| 3253 | // reporter. |
| 3254 | if (!mCurrentlyVisibleNotifications.isEmpty()) { |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 3255 | logNotificationVisibilityChanges(Collections.<NotificationVisibility>emptyList(), |
| 3256 | mCurrentlyVisibleNotifications); |
| 3257 | recycleAllVisibilityObjects(mCurrentlyVisibleNotifications); |
Christoph Studer | 037e34c | 2014-04-30 20:06:04 +0200 | [diff] [blame] | 3258 | } |
| 3259 | mHandler.removeCallbacks(mVisibilityReporter); |
| 3260 | mStackScroller.setChildLocationsChangedListener(null); |
| 3261 | } |
| 3262 | |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 3263 | private void startNotificationLogging() { |
| 3264 | mStackScroller.setChildLocationsChangedListener(mNotificationLocationsChangedListener); |
| 3265 | // Some transitions like mVisibleToUser=false -> mVisibleToUser=true don't |
| 3266 | // cause the scroller to emit child location events. Hence generate |
| 3267 | // one ourselves to guarantee that we're reporting visible |
| 3268 | // notifications. |
| 3269 | // (Note that in cases where the scroller does emit events, this |
| 3270 | // additional event doesn't break anything.) |
| 3271 | mNotificationLocationsChangedListener.onChildLocationsChanged(mStackScroller); |
Christoph Studer | 037e34c | 2014-04-30 20:06:04 +0200 | [diff] [blame] | 3272 | } |
| 3273 | |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3274 | private void logNotificationVisibilityChanges( |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 3275 | Collection<NotificationVisibility> newlyVisible, |
| 3276 | Collection<NotificationVisibility> noLongerVisible) { |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3277 | if (newlyVisible.isEmpty() && noLongerVisible.isEmpty()) { |
| 3278 | return; |
| 3279 | } |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 3280 | NotificationVisibility[] newlyVisibleAr = |
| 3281 | newlyVisible.toArray(new NotificationVisibility[newlyVisible.size()]); |
| 3282 | NotificationVisibility[] noLongerVisibleAr = |
| 3283 | noLongerVisible.toArray(new NotificationVisibility[noLongerVisible.size()]); |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3284 | try { |
| 3285 | mBarService.onNotificationVisibilityChanged(newlyVisibleAr, noLongerVisibleAr); |
| 3286 | } catch (RemoteException e) { |
| 3287 | // Ignore. |
| 3288 | } |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 3289 | |
| 3290 | final int N = newlyVisible.size(); |
Amith Yamasani | 7649567 | 2015-07-07 15:22:54 -0700 | [diff] [blame] | 3291 | if (N > 0) { |
| 3292 | String[] newlyVisibleKeyAr = new String[N]; |
| 3293 | for (int i = 0; i < N; i++) { |
| 3294 | newlyVisibleKeyAr[i] = newlyVisibleAr[i].key; |
| 3295 | } |
| 3296 | |
| 3297 | setNotificationsShown(newlyVisibleKeyAr); |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 3298 | } |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 3299 | } |
| 3300 | |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 3301 | // State logging |
| 3302 | |
| 3303 | private void logStateToEventlog() { |
| 3304 | boolean isShowing = mStatusBarKeyguardViewManager.isShowing(); |
| 3305 | boolean isOccluded = mStatusBarKeyguardViewManager.isOccluded(); |
| 3306 | boolean isBouncerShowing = mStatusBarKeyguardViewManager.isBouncerShowing(); |
| 3307 | boolean isSecure = mUnlockMethodCache.isMethodSecure(); |
Selim Cinek | e8bae62 | 2015-07-15 13:24:06 -0700 | [diff] [blame] | 3308 | boolean canSkipBouncer = mUnlockMethodCache.canSkipBouncer(); |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 3309 | int stateFingerprint = getLoggingFingerprint(mState, |
| 3310 | isShowing, |
| 3311 | isOccluded, |
| 3312 | isBouncerShowing, |
| 3313 | isSecure, |
Selim Cinek | e8bae62 | 2015-07-15 13:24:06 -0700 | [diff] [blame] | 3314 | canSkipBouncer); |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 3315 | if (stateFingerprint != mLastLoggedStateFingerprint) { |
| 3316 | EventLogTags.writeSysuiStatusBarState(mState, |
| 3317 | isShowing ? 1 : 0, |
| 3318 | isOccluded ? 1 : 0, |
| 3319 | isBouncerShowing ? 1 : 0, |
| 3320 | isSecure ? 1 : 0, |
Selim Cinek | e8bae62 | 2015-07-15 13:24:06 -0700 | [diff] [blame] | 3321 | canSkipBouncer ? 1 : 0); |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 3322 | mLastLoggedStateFingerprint = stateFingerprint; |
| 3323 | } |
| 3324 | } |
| 3325 | |
| 3326 | /** |
| 3327 | * Returns a fingerprint of fields logged to eventlog |
| 3328 | */ |
| 3329 | private static int getLoggingFingerprint(int statusBarState, boolean keyguardShowing, |
| 3330 | boolean keyguardOccluded, boolean bouncerShowing, boolean secure, |
| 3331 | boolean currentlyInsecure) { |
| 3332 | // Reserve 8 bits for statusBarState. We'll never go higher than |
| 3333 | // that, right? Riiiight. |
| 3334 | return (statusBarState & 0xFF) |
| 3335 | | ((keyguardShowing ? 1 : 0) << 8) |
| 3336 | | ((keyguardOccluded ? 1 : 0) << 9) |
| 3337 | | ((bouncerShowing ? 1 : 0) << 10) |
| 3338 | | ((secure ? 1 : 0) << 11) |
| 3339 | | ((currentlyInsecure ? 1 : 0) << 12); |
| 3340 | } |
| 3341 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3342 | // |
| 3343 | // tracing |
| 3344 | // |
| 3345 | |
| 3346 | void postStartTracing() { |
| 3347 | mHandler.postDelayed(mStartTracing, 3000); |
| 3348 | } |
| 3349 | |
| 3350 | void vibrate() { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 3351 | android.os.Vibrator vib = (android.os.Vibrator)mContext.getSystemService( |
| 3352 | Context.VIBRATOR_SERVICE); |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 3353 | vib.vibrate(250, VIBRATION_ATTRIBUTES); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3354 | } |
| 3355 | |
| 3356 | Runnable mStartTracing = new Runnable() { |
| 3357 | public void run() { |
| 3358 | vibrate(); |
| 3359 | SystemClock.sleep(250); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 3360 | Log.d(TAG, "startTracing"); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3361 | android.os.Debug.startMethodTracing("/data/statusbar-traces/trace"); |
| 3362 | mHandler.postDelayed(mStopTracing, 10000); |
| 3363 | } |
| 3364 | }; |
| 3365 | |
| 3366 | Runnable mStopTracing = new Runnable() { |
| 3367 | public void run() { |
| 3368 | android.os.Debug.stopMethodTracing(); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 3369 | Log.d(TAG, "stopTracing"); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3370 | vibrate(); |
| 3371 | } |
| 3372 | }; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 3373 | |
| 3374 | @Override |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 3375 | public boolean shouldDisableNavbarGestures() { |
Jorim Jaggi | 18976a5 | 2015-07-24 13:18:19 -0700 | [diff] [blame] | 3376 | return !isDeviceProvisioned() || (mDisabled1 & StatusBarManager.DISABLE_SEARCH) != 0; |
Jim Miller | 670d9dd | 2012-05-12 13:28:26 -0700 | [diff] [blame] | 3377 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 3378 | |
Jason Monk | ba2318e | 2015-12-08 09:04:23 -0500 | [diff] [blame] | 3379 | public void postQSRunnableDismissingKeyguard(final Runnable runnable) { |
| 3380 | mHandler.post(new Runnable() { |
| 3381 | @Override |
| 3382 | public void run() { |
| 3383 | mLeaveOpenOnKeyguardHide = true; |
| 3384 | executeRunnableDismissingKeyguard(runnable, null, false, true); |
| 3385 | } |
| 3386 | }); |
| 3387 | } |
| 3388 | |
Adrian Roos | 62692b2 | 2015-09-11 17:46:23 -0700 | [diff] [blame] | 3389 | public void postStartActivityDismissingKeyguard(final PendingIntent intent) { |
| 3390 | mHandler.post(new Runnable() { |
| 3391 | @Override |
| 3392 | public void run() { |
| 3393 | startPendingIntentDismissingKeyguard(intent); |
| 3394 | } |
| 3395 | }); |
| 3396 | } |
| 3397 | |
Jason Monk | ee43cdf | 2015-06-19 14:20:46 -0400 | [diff] [blame] | 3398 | public void postStartActivityDismissingKeyguard(final Intent intent, int delay) { |
John Spurlock | d47a3f3 | 2014-05-18 19:14:14 -0400 | [diff] [blame] | 3399 | mHandler.postDelayed(new Runnable() { |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 3400 | @Override |
| 3401 | public void run() { |
Jason Monk | ee43cdf | 2015-06-19 14:20:46 -0400 | [diff] [blame] | 3402 | handleStartActivityDismissingKeyguard(intent, true /*onlyProvisioned*/); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 3403 | } |
John Spurlock | d47a3f3 | 2014-05-18 19:14:14 -0400 | [diff] [blame] | 3404 | }, delay); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 3405 | } |
| 3406 | |
Jason Monk | ee43cdf | 2015-06-19 14:20:46 -0400 | [diff] [blame] | 3407 | private void handleStartActivityDismissingKeyguard(Intent intent, boolean onlyProvisioned) { |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 3408 | startActivityDismissingKeyguard(intent, onlyProvisioned, true /* dismissShade */); |
John Spurlock | de54700 | 2014-02-28 17:50:39 -0500 | [diff] [blame] | 3409 | } |
| 3410 | |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 3411 | private static class FastColorDrawable extends Drawable { |
| 3412 | private final int mColor; |
| 3413 | |
| 3414 | public FastColorDrawable(int color) { |
| 3415 | mColor = 0xff000000 | color; |
| 3416 | } |
| 3417 | |
| 3418 | @Override |
| 3419 | public void draw(Canvas canvas) { |
| 3420 | canvas.drawColor(mColor, PorterDuff.Mode.SRC); |
| 3421 | } |
| 3422 | |
| 3423 | @Override |
| 3424 | public void setAlpha(int alpha) { |
| 3425 | } |
| 3426 | |
| 3427 | @Override |
Chris Craik | bd3bfc5 | 2015-03-02 10:43:29 -0800 | [diff] [blame] | 3428 | public void setColorFilter(ColorFilter colorFilter) { |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 3429 | } |
| 3430 | |
| 3431 | @Override |
| 3432 | public int getOpacity() { |
| 3433 | return PixelFormat.OPAQUE; |
| 3434 | } |
| 3435 | |
| 3436 | @Override |
| 3437 | public void setBounds(int left, int top, int right, int bottom) { |
| 3438 | } |
| 3439 | |
| 3440 | @Override |
| 3441 | public void setBounds(Rect bounds) { |
| 3442 | } |
| 3443 | } |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 3444 | |
| 3445 | @Override |
| 3446 | public void destroy() { |
| 3447 | super.destroy(); |
| 3448 | if (mStatusBarWindow != null) { |
| 3449 | mWindowManager.removeViewImmediate(mStatusBarWindow); |
John Spurlock | ab847cf | 2014-01-15 14:13:59 -0500 | [diff] [blame] | 3450 | mStatusBarWindow = null; |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 3451 | } |
| 3452 | if (mNavigationBarView != null) { |
| 3453 | mWindowManager.removeViewImmediate(mNavigationBarView); |
John Spurlock | ab847cf | 2014-01-15 14:13:59 -0500 | [diff] [blame] | 3454 | mNavigationBarView = null; |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 3455 | } |
Jason Monk | 4ae97d3 | 2014-12-17 10:14:33 -0500 | [diff] [blame] | 3456 | if (mHandlerThread != null) { |
| 3457 | mHandlerThread.quitSafely(); |
| 3458 | mHandlerThread = null; |
| 3459 | } |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 3460 | mContext.unregisterReceiver(mBroadcastReceiver); |
Adrian Roos | 8e3e836 | 2015-07-16 19:42:22 -0700 | [diff] [blame] | 3461 | mContext.unregisterReceiver(mDemoReceiver); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 3462 | mAssistManager.destroy(); |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 3463 | |
| 3464 | final SignalClusterView signalCluster = |
| 3465 | (SignalClusterView) mStatusBarView.findViewById(R.id.signal_cluster); |
| 3466 | final SignalClusterView signalClusterKeyguard = |
| 3467 | (SignalClusterView) mKeyguardStatusBar.findViewById(R.id.signal_cluster); |
| 3468 | final SignalClusterView signalClusterQs = |
| 3469 | (SignalClusterView) mHeader.findViewById(R.id.signal_cluster); |
Jason Monk | 5e74517 | 2015-06-02 19:14:44 -0400 | [diff] [blame] | 3470 | mNetworkController.removeSignalCallback(signalCluster); |
| 3471 | mNetworkController.removeSignalCallback(signalClusterKeyguard); |
| 3472 | mNetworkController.removeSignalCallback(signalClusterQs); |
| 3473 | if (mQSPanel != null && mQSPanel.getHost() != null) { |
| 3474 | mQSPanel.getHost().destroy(); |
| 3475 | } |
John Spurlock | 5c45412 | 2013-06-17 07:35:46 -0400 | [diff] [blame] | 3476 | } |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3477 | |
| 3478 | private boolean mDemoModeAllowed; |
| 3479 | private boolean mDemoMode; |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3480 | |
| 3481 | @Override |
| 3482 | public void dispatchDemoCommand(String command, Bundle args) { |
| 3483 | if (!mDemoModeAllowed) { |
| 3484 | mDemoModeAllowed = Settings.Global.getInt(mContext.getContentResolver(), |
Jason Monk | 431ad73 | 2015-07-16 08:58:15 -0400 | [diff] [blame] | 3485 | DEMO_MODE_ALLOWED, 0) != 0; |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3486 | } |
| 3487 | if (!mDemoModeAllowed) return; |
| 3488 | if (command.equals(COMMAND_ENTER)) { |
| 3489 | mDemoMode = true; |
| 3490 | } else if (command.equals(COMMAND_EXIT)) { |
| 3491 | mDemoMode = false; |
| 3492 | checkBarModes(); |
| 3493 | } else if (!mDemoMode) { |
| 3494 | // automatically enter demo mode on first demo command |
| 3495 | dispatchDemoCommand(COMMAND_ENTER, new Bundle()); |
| 3496 | } |
| 3497 | boolean modeChange = command.equals(COMMAND_ENTER) || command.equals(COMMAND_EXIT); |
John Spurlock | bb4a702 | 2014-11-08 12:40:19 -0500 | [diff] [blame] | 3498 | if ((modeChange || command.equals(COMMAND_VOLUME)) && mVolumeComponent != null) { |
| 3499 | mVolumeComponent.dispatchDemoCommand(command, args); |
| 3500 | } |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3501 | if (modeChange || command.equals(COMMAND_CLOCK)) { |
| 3502 | dispatchDemoCommandToView(command, args, R.id.clock); |
| 3503 | } |
| 3504 | if (modeChange || command.equals(COMMAND_BATTERY)) { |
| 3505 | dispatchDemoCommandToView(command, args, R.id.battery); |
| 3506 | } |
| 3507 | if (modeChange || command.equals(COMMAND_STATUS)) { |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 3508 | mIconController.dispatchDemoCommand(command, args); |
| 3509 | |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3510 | } |
| 3511 | if (mNetworkController != null && (modeChange || command.equals(COMMAND_NETWORK))) { |
| 3512 | mNetworkController.dispatchDemoCommand(command, args); |
| 3513 | } |
John Spurlock | 7f42fc5 | 2014-01-14 16:20:39 -0500 | [diff] [blame] | 3514 | if (modeChange || command.equals(COMMAND_NOTIFICATIONS)) { |
| 3515 | View notifications = mStatusBarView == null ? null |
| 3516 | : mStatusBarView.findViewById(R.id.notification_icon_area); |
| 3517 | if (notifications != null) { |
| 3518 | String visible = args.getString("visible"); |
| 3519 | int vis = mDemoMode && "false".equals(visible) ? View.INVISIBLE : View.VISIBLE; |
| 3520 | notifications.setVisibility(vis); |
| 3521 | } |
| 3522 | } |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3523 | if (command.equals(COMMAND_BARS)) { |
| 3524 | String mode = args.getString("mode"); |
| 3525 | int barMode = "opaque".equals(mode) ? MODE_OPAQUE : |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3526 | "translucent".equals(mode) ? MODE_TRANSLUCENT : |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3527 | "semi-transparent".equals(mode) ? MODE_SEMI_TRANSPARENT : |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 3528 | "transparent".equals(mode) ? MODE_TRANSPARENT : |
| 3529 | "warning".equals(mode) ? MODE_WARNING : |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 3530 | -1; |
| 3531 | if (barMode != -1) { |
| 3532 | boolean animate = true; |
| 3533 | if (mStatusBarView != null) { |
| 3534 | mStatusBarView.getBarTransitions().transitionTo(barMode, animate); |
| 3535 | } |
| 3536 | if (mNavigationBarView != null) { |
| 3537 | mNavigationBarView.getBarTransitions().transitionTo(barMode, animate); |
| 3538 | } |
| 3539 | } |
| 3540 | } |
| 3541 | } |
| 3542 | |
| 3543 | private void dispatchDemoCommandToView(String command, Bundle args, int id) { |
| 3544 | if (mStatusBarView == null) return; |
| 3545 | View v = mStatusBarView.findViewById(id); |
| 3546 | if (v instanceof DemoMode) { |
| 3547 | ((DemoMode)v).dispatchDemoCommand(command, args); |
| 3548 | } |
| 3549 | } |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 3550 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 3551 | /** |
| 3552 | * @return The {@link StatusBarState} the status bar is in. |
| 3553 | */ |
| 3554 | public int getBarState() { |
| 3555 | return mState; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 3556 | } |
| 3557 | |
Chris Wren | 1689594 | 2015-06-23 11:22:20 -0400 | [diff] [blame] | 3558 | @Override |
| 3559 | protected boolean isPanelFullyCollapsed() { |
| 3560 | return mNotificationPanel.isFullyCollapsed(); |
| 3561 | } |
| 3562 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 3563 | public void showKeyguard() { |
Jorim Jaggi | 5e08e69 | 2014-10-03 15:17:20 -0700 | [diff] [blame] | 3564 | if (mLaunchTransitionFadingAway) { |
| 3565 | mNotificationPanel.animate().cancel(); |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 3566 | onLaunchTransitionFadingEnded(); |
Jorim Jaggi | 5e08e69 | 2014-10-03 15:17:20 -0700 | [diff] [blame] | 3567 | } |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 3568 | mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 3569 | if (mUserSwitcherController != null && mUserSwitcherController.useFullscreenUserSwitcher()) { |
| 3570 | setBarState(StatusBarState.FULLSCREEN_USER_SWITCHER); |
| 3571 | } else { |
| 3572 | setBarState(StatusBarState.KEYGUARD); |
| 3573 | } |
Jorim Jaggi | 98f8530 | 2014-08-07 17:45:04 +0200 | [diff] [blame] | 3574 | updateKeyguardState(false /* goingToFullShade */, false /* fromShadeLocked */); |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 3575 | if (!mDeviceInteractive) { |
Jorim Jaggi | d41083a | 2014-09-12 02:54:40 +0200 | [diff] [blame] | 3576 | |
| 3577 | // If the screen is off already, we need to disable touch events because these might |
| 3578 | // collapse the panel after we expanded it, and thus we would end up with a blank |
| 3579 | // Keyguard. |
| 3580 | mNotificationPanel.setTouchDisabled(true); |
| 3581 | } |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 3582 | if (mState == StatusBarState.KEYGUARD) { |
| 3583 | instantExpandNotificationsPanel(); |
| 3584 | } else if (mState == StatusBarState.FULLSCREEN_USER_SWITCHER) { |
| 3585 | instantCollapseNotificationPanel(); |
| 3586 | } |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 3587 | mLeaveOpenOnKeyguardHide = false; |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 3588 | if (mDraggedDownRow != null) { |
| 3589 | mDraggedDownRow.setUserLocked(false); |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 3590 | mDraggedDownRow.notifyHeightChanged(false /* needsAnimation */); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 3591 | mDraggedDownRow = null; |
| 3592 | } |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 3593 | mPendingRemoteInputView = null; |
Jorim Jaggi | 19695d9 | 2015-07-20 15:51:40 -0700 | [diff] [blame] | 3594 | mAssistManager.onLockscreenShown(); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 3595 | } |
| 3596 | |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 3597 | private void onLaunchTransitionFadingEnded() { |
| 3598 | mNotificationPanel.setAlpha(1.0f); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 3599 | mNotificationPanel.onAffordanceLaunchEnded(); |
| 3600 | releaseGestureWakeLock(); |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 3601 | runLaunchTransitionEndRunnable(); |
| 3602 | mLaunchTransitionFadingAway = false; |
| 3603 | mScrimController.forceHideScrims(false /* hide */); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 3604 | updateMediaMetaData(true /* metaDataChanged */, true); |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 3605 | } |
| 3606 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 3607 | public boolean isCollapsing() { |
| 3608 | return mNotificationPanel.isCollapsing(); |
| 3609 | } |
| 3610 | |
| 3611 | public void addPostCollapseAction(Runnable r) { |
| 3612 | mPostCollapseRunnables.add(r); |
| 3613 | } |
| 3614 | |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 3615 | public boolean isInLaunchTransition() { |
| 3616 | return mNotificationPanel.isLaunchTransitionRunning() |
| 3617 | || mNotificationPanel.isLaunchTransitionFinished(); |
| 3618 | } |
| 3619 | |
| 3620 | /** |
| 3621 | * Fades the content of the keyguard away after the launch transition is done. |
| 3622 | * |
| 3623 | * @param beforeFading the runnable to be run when the circle is fully expanded and the fading |
| 3624 | * starts |
| 3625 | * @param endRunnable the runnable to be run when the transition is done |
| 3626 | */ |
| 3627 | public void fadeKeyguardAfterLaunchTransition(final Runnable beforeFading, |
Jorim Jaggi | 5e08e69 | 2014-10-03 15:17:20 -0700 | [diff] [blame] | 3628 | Runnable endRunnable) { |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 3629 | mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); |
Jorim Jaggi | 5e08e69 | 2014-10-03 15:17:20 -0700 | [diff] [blame] | 3630 | mLaunchTransitionEndRunnable = endRunnable; |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 3631 | Runnable hideRunnable = new Runnable() { |
| 3632 | @Override |
| 3633 | public void run() { |
| 3634 | mLaunchTransitionFadingAway = true; |
| 3635 | if (beforeFading != null) { |
| 3636 | beforeFading.run(); |
| 3637 | } |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 3638 | mScrimController.forceHideScrims(true /* hide */); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 3639 | updateMediaMetaData(false, true); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 3640 | mNotificationPanel.setAlpha(1); |
| 3641 | mNotificationPanel.animate() |
| 3642 | .alpha(0) |
| 3643 | .setStartDelay(FADE_KEYGUARD_START_DELAY) |
| 3644 | .setDuration(FADE_KEYGUARD_DURATION) |
| 3645 | .withLayer() |
| 3646 | .withEndAction(new Runnable() { |
| 3647 | @Override |
| 3648 | public void run() { |
Selim Cinek | 37c110f | 2015-05-22 12:38:44 -0700 | [diff] [blame] | 3649 | onLaunchTransitionFadingEnded(); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 3650 | } |
| 3651 | }); |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 3652 | mIconController.appTransitionStarting(SystemClock.uptimeMillis(), |
| 3653 | StatusBarIconController.DEFAULT_TINT_ANIMATION_DURATION); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 3654 | } |
| 3655 | }; |
| 3656 | if (mNotificationPanel.isLaunchTransitionRunning()) { |
| 3657 | mNotificationPanel.setLaunchTransitionEndRunnable(hideRunnable); |
| 3658 | } else { |
| 3659 | hideRunnable.run(); |
| 3660 | } |
| 3661 | } |
| 3662 | |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 3663 | /** |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 3664 | * Fades the content of the Keyguard while we are dozing and makes it invisible when finished |
| 3665 | * fading. |
| 3666 | */ |
| 3667 | public void fadeKeyguardWhilePulsing() { |
| 3668 | mNotificationPanel.animate() |
| 3669 | .alpha(0f) |
| 3670 | .setStartDelay(0) |
| 3671 | .setDuration(FADE_KEYGUARD_DURATION_PULSING) |
Jorim Jaggi | ab45a21 | 2015-08-20 16:59:44 -0700 | [diff] [blame] | 3672 | .setInterpolator(ScrimController.KEYGUARD_FADE_OUT_INTERPOLATOR) |
| 3673 | .start(); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 3674 | } |
| 3675 | |
| 3676 | /** |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 3677 | * Starts the timeout when we try to start the affordances on Keyguard. We usually rely that |
| 3678 | * Keyguard goes away via fadeKeyguardAfterLaunchTransition, however, that might not happen |
| 3679 | * because the launched app crashed or something else went wrong. |
| 3680 | */ |
| 3681 | public void startLaunchTransitionTimeout() { |
| 3682 | mHandler.sendEmptyMessageDelayed(MSG_LAUNCH_TRANSITION_TIMEOUT, |
| 3683 | LAUNCH_TRANSITION_TIMEOUT_MS); |
| 3684 | } |
| 3685 | |
| 3686 | private void onLaunchTransitionTimeout() { |
| 3687 | Log.w(TAG, "Launch transition: Timeout!"); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 3688 | mNotificationPanel.onAffordanceLaunchEnded(); |
| 3689 | releaseGestureWakeLock(); |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 3690 | mNotificationPanel.resetViews(); |
| 3691 | } |
| 3692 | |
| 3693 | private void runLaunchTransitionEndRunnable() { |
| 3694 | if (mLaunchTransitionEndRunnable != null) { |
| 3695 | Runnable r = mLaunchTransitionEndRunnable; |
| 3696 | |
| 3697 | // mLaunchTransitionEndRunnable might call showKeyguard, which would execute it again, |
| 3698 | // which would lead to infinite recursion. Protect against it. |
| 3699 | mLaunchTransitionEndRunnable = null; |
| 3700 | r.run(); |
| 3701 | } |
| 3702 | } |
| 3703 | |
| 3704 | /** |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 3705 | * @return true if we would like to stay in the shade, false if it should go away entirely |
| 3706 | */ |
| 3707 | public boolean hideKeyguard() { |
| 3708 | boolean staying = mLeaveOpenOnKeyguardHide; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 3709 | setBarState(StatusBarState.SHADE); |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 3710 | View viewToClick = null; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 3711 | if (mLeaveOpenOnKeyguardHide) { |
| 3712 | mLeaveOpenOnKeyguardHide = false; |
Jorim Jaggi | 37c1180 | 2015-08-18 20:27:54 -0700 | [diff] [blame] | 3713 | long delay = calculateGoingToFullShadeDelay(); |
| 3714 | mNotificationPanel.animateToFullShade(delay); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 3715 | if (mDraggedDownRow != null) { |
| 3716 | mDraggedDownRow.setUserLocked(false); |
| 3717 | mDraggedDownRow = null; |
| 3718 | } |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 3719 | viewToClick = mPendingRemoteInputView; |
| 3720 | mPendingRemoteInputView = null; |
Jorim Jaggi | 37c1180 | 2015-08-18 20:27:54 -0700 | [diff] [blame] | 3721 | |
| 3722 | // Disable layout transitions in navbar for this transition because the load is just |
| 3723 | // too heavy for the CPU and GPU on any device. |
| 3724 | if (mNavigationBarView != null) { |
| 3725 | mNavigationBarView.setLayoutTransitionsEnabled(false); |
| 3726 | mNavigationBarView.postDelayed(new Runnable() { |
| 3727 | @Override |
| 3728 | public void run() { |
| 3729 | mNavigationBarView.setLayoutTransitionsEnabled(true); |
| 3730 | } |
| 3731 | }, delay + StackStateAnimator.ANIMATION_DURATION_GO_TO_FULL_SHADE); |
| 3732 | } |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 3733 | } else { |
| 3734 | instantCollapseNotificationPanel(); |
| 3735 | } |
Jorim Jaggi | 98f8530 | 2014-08-07 17:45:04 +0200 | [diff] [blame] | 3736 | updateKeyguardState(staying, false /* fromShadeLocked */); |
Jorim Jaggi | 1ecd7cd | 2014-11-03 16:18:03 +0100 | [diff] [blame] | 3737 | |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 3738 | if (viewToClick != null) { |
| 3739 | viewToClick.callOnClick(); |
| 3740 | } |
| 3741 | |
Jorim Jaggi | 1ecd7cd | 2014-11-03 16:18:03 +0100 | [diff] [blame] | 3742 | // Keyguard state has changed, but QS is not listening anymore. Make sure to update the tile |
| 3743 | // visibilities so next time we open the panel we know the correct height already. |
| 3744 | if (mQSPanel != null) { |
| 3745 | mQSPanel.refreshAllTiles(); |
| 3746 | } |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 3747 | mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 3748 | releaseGestureWakeLock(); |
| 3749 | mNotificationPanel.onAffordanceLaunchEnded(); |
Jorim Jaggi | 52429b4 | 2015-09-03 19:58:19 -0700 | [diff] [blame] | 3750 | mNotificationPanel.animate().cancel(); |
Jorim Jaggi | 9097885 | 2015-08-18 19:55:53 -0700 | [diff] [blame] | 3751 | mNotificationPanel.setAlpha(1f); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 3752 | return staying; |
| 3753 | } |
| 3754 | |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 3755 | private void releaseGestureWakeLock() { |
| 3756 | if (mGestureWakeLock.isHeld()) { |
| 3757 | mGestureWakeLock.release(); |
| 3758 | } |
| 3759 | } |
| 3760 | |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 3761 | public long calculateGoingToFullShadeDelay() { |
| 3762 | return mKeyguardFadingAwayDelay + mKeyguardFadingAwayDuration; |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 3763 | } |
| 3764 | |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 3765 | /** |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 3766 | * Notifies the status bar that Keyguard is going away very soon. |
| 3767 | */ |
| 3768 | public void keyguardGoingAway() { |
| 3769 | |
| 3770 | // Treat Keyguard exit animation as an app transition to achieve nice transition for status |
| 3771 | // bar. |
Adrian Roos | 46df1ca | 2015-09-11 12:38:43 -0700 | [diff] [blame] | 3772 | mKeyguardGoingAway = true; |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 3773 | mIconController.appTransitionPending(); |
| 3774 | } |
| 3775 | |
| 3776 | /** |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 3777 | * Notifies the status bar the Keyguard is fading away with the specified timings. |
| 3778 | * |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 3779 | * @param startTime the start time of the animations in uptime millis |
| 3780 | * @param delay the precalculated animation delay in miliseconds |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 3781 | * @param fadeoutDuration the duration of the exit animation, in milliseconds |
| 3782 | */ |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 3783 | public void setKeyguardFadingAway(long startTime, long delay, long fadeoutDuration) { |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 3784 | mKeyguardFadingAway = true; |
| 3785 | mKeyguardFadingAwayDelay = delay; |
| 3786 | mKeyguardFadingAwayDuration = fadeoutDuration; |
| 3787 | mWaitingForKeyguardExit = false; |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 3788 | mIconController.appTransitionStarting( |
| 3789 | startTime + fadeoutDuration |
| 3790 | - StatusBarIconController.DEFAULT_TINT_ANIMATION_DURATION, |
| 3791 | StatusBarIconController.DEFAULT_TINT_ANIMATION_DURATION); |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 3792 | disable(mDisabledUnmodified1, mDisabledUnmodified2, fadeoutDuration > 0 /* animate */); |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 3793 | } |
| 3794 | |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 3795 | public boolean isKeyguardFadingAway() { |
| 3796 | return mKeyguardFadingAway; |
| 3797 | } |
| 3798 | |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 3799 | /** |
| 3800 | * Notifies that the Keyguard fading away animation is done. |
| 3801 | */ |
| 3802 | public void finishKeyguardFadingAway() { |
| 3803 | mKeyguardFadingAway = false; |
Adrian Roos | 46df1ca | 2015-09-11 12:38:43 -0700 | [diff] [blame] | 3804 | mKeyguardGoingAway = false; |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 3805 | } |
| 3806 | |
Adrian Roos | d322f1a | 2015-04-23 15:19:45 -0700 | [diff] [blame] | 3807 | public void stopWaitingForKeyguardExit() { |
| 3808 | mWaitingForKeyguardExit = false; |
| 3809 | } |
| 3810 | |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 3811 | private void updatePublicMode() { |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 3812 | setLockscreenPublicMode( |
| 3813 | mStatusBarKeyguardViewManager.isShowing() && mStatusBarKeyguardViewManager |
| 3814 | .isSecure(mCurrentUserId)); |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 3815 | } |
| 3816 | |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 3817 | protected void updateKeyguardState(boolean goingToFullShade, boolean fromShadeLocked) { |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 3818 | if (mState == StatusBarState.KEYGUARD) { |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 3819 | mKeyguardIndicationController.setVisible(true); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 3820 | mNotificationPanel.resetViews(); |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 3821 | if (mKeyguardUserSwitcher != null) { |
| 3822 | mKeyguardUserSwitcher.setKeyguard(true, fromShadeLocked); |
| 3823 | } |
Selim Cinek | 80c2abe | 2015-06-17 15:37:30 -0700 | [diff] [blame] | 3824 | mStatusBarView.removePendingHideExpandedRunnables(); |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 3825 | } else { |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 3826 | mKeyguardIndicationController.setVisible(false); |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 3827 | if (mKeyguardUserSwitcher != null) { |
| 3828 | mKeyguardUserSwitcher.setKeyguard(false, |
| 3829 | goingToFullShade || |
| 3830 | mState == StatusBarState.SHADE_LOCKED || |
| 3831 | fromShadeLocked); |
| 3832 | } |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 3833 | } |
Jorim Jaggi | 2042ef2 | 2014-05-13 21:55:18 +0200 | [diff] [blame] | 3834 | if (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) { |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 3835 | mScrimController.setKeyguardShowing(true); |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 3836 | mIconPolicy.setKeyguardShowing(true); |
Jorim Jaggi | 2042ef2 | 2014-05-13 21:55:18 +0200 | [diff] [blame] | 3837 | } else { |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 3838 | mScrimController.setKeyguardShowing(false); |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 3839 | mIconPolicy.setKeyguardShowing(false); |
Jorim Jaggi | 2042ef2 | 2014-05-13 21:55:18 +0200 | [diff] [blame] | 3840 | } |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 3841 | |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 3842 | mNotificationPanel.setBarState(mState, mKeyguardFadingAway, goingToFullShade); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 3843 | updateDozingState(); |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 3844 | updatePublicMode(); |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 3845 | updateStackScrollerState(goingToFullShade, fromShadeLocked); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 3846 | updateNotifications(); |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 3847 | checkBarModes(); |
Adrian Roos | 5273832 | 2016-01-29 08:49:21 -0800 | [diff] [blame] | 3848 | updateMediaMetaData(false, mState != StatusBarState.KEYGUARD); |
John Spurlock | 657c62c | 2014-07-22 12:18:09 -0400 | [diff] [blame] | 3849 | mKeyguardMonitor.notifyKeyguardState(mStatusBarKeyguardViewManager.isShowing(), |
| 3850 | mStatusBarKeyguardViewManager.isSecure()); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 3851 | } |
| 3852 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 3853 | private void updateDozingState() { |
Jorim Jaggi | 4e857f4 | 2014-11-17 19:14:04 +0100 | [diff] [blame] | 3854 | boolean animate = !mDozing && mDozeScrimController.isPulsing(); |
| 3855 | mNotificationPanel.setDozing(mDozing, animate); |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 3856 | mStackScroller.setDark(mDozing, animate, mWakeUpTouchLocation); |
Jorim Jaggi | 048af1f | 2014-11-11 22:51:10 +0100 | [diff] [blame] | 3857 | mScrimController.setDozing(mDozing); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 3858 | |
| 3859 | // Immediately abort the dozing from the doze scrim controller in case of wake-and-unlock |
| 3860 | // for pulsing so the Keyguard fade-out animation scrim can take over. |
| 3861 | mDozeScrimController.setDozing(mDozing && |
| 3862 | mFingerprintUnlockController.getMode() |
| 3863 | != FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING, animate); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 3864 | } |
| 3865 | |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 3866 | public void updateStackScrollerState(boolean goingToFullShade, boolean fromShadeLocked) { |
John Spurlock | 4b3bda2 | 2014-05-22 14:32:20 -0400 | [diff] [blame] | 3867 | if (mStackScroller == null) return; |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 3868 | boolean onKeyguard = mState == StatusBarState.KEYGUARD; |
Jorim Jaggi | ae44128 | 2014-08-01 02:45:18 +0200 | [diff] [blame] | 3869 | mStackScroller.setHideSensitive(isLockscreenPublicMode(), goingToFullShade); |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 3870 | mStackScroller.setDimmed(onKeyguard, fromShadeLocked /* animate */); |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 3871 | mStackScroller.setExpandingEnabled(!onKeyguard); |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 3872 | ActivatableNotificationView activatedChild = mStackScroller.getActivatedChild(); |
| 3873 | mStackScroller.setActivatedChild(null); |
| 3874 | if (activatedChild != null) { |
| 3875 | activatedChild.makeInactive(false /* animate */); |
| 3876 | } |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 3877 | } |
| 3878 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 3879 | public void userActivity() { |
Jorim Jaggi | b690f0d | 2014-07-03 23:25:44 +0200 | [diff] [blame] | 3880 | if (mState == StatusBarState.KEYGUARD) { |
| 3881 | mKeyguardViewMediatorCallback.userActivity(); |
| 3882 | } |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 3883 | } |
| 3884 | |
Jorim Jaggi | df99351 | 2014-05-13 23:06:35 +0200 | [diff] [blame] | 3885 | public boolean interceptMediaKey(KeyEvent event) { |
| 3886 | return mState == StatusBarState.KEYGUARD |
| 3887 | && mStatusBarKeyguardViewManager.interceptMediaKey(event); |
| 3888 | } |
| 3889 | |
Jorim Jaggi | 8c8bcc1 | 2014-04-16 21:36:51 +0200 | [diff] [blame] | 3890 | public boolean onMenuPressed() { |
Selim Cinek | 2854019 | 2016-02-19 17:25:08 -0800 | [diff] [blame] | 3891 | if (mDeviceInteractive && mState != StatusBarState.SHADE |
| 3892 | && mStatusBarKeyguardViewManager.shouldDismissOnMenuPressed()) { |
| 3893 | animateCollapsePanels( |
| 3894 | CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL /* flags */, true /* force */); |
| 3895 | return true; |
| 3896 | } |
| 3897 | return false; |
Jorim Jaggi | 8c8bcc1 | 2014-04-16 21:36:51 +0200 | [diff] [blame] | 3898 | } |
| 3899 | |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 3900 | public void endAffordanceLaunch() { |
| 3901 | releaseGestureWakeLock(); |
| 3902 | mNotificationPanel.onAffordanceLaunchEnded(); |
| 3903 | } |
| 3904 | |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 3905 | public boolean onBackPressed() { |
Adrian Roos | 0002a45 | 2014-07-03 13:46:07 +0200 | [diff] [blame] | 3906 | if (mStatusBarKeyguardViewManager.onBackPressed()) { |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 3907 | return true; |
| 3908 | } |
Adrian Roos | 0002a45 | 2014-07-03 13:46:07 +0200 | [diff] [blame] | 3909 | if (mNotificationPanel.isQsExpanded()) { |
John Spurlock | f7ae442 | 2014-08-01 12:45:18 -0400 | [diff] [blame] | 3910 | if (mNotificationPanel.isQsDetailShowing()) { |
| 3911 | mNotificationPanel.closeQsDetail(); |
| 3912 | } else { |
| 3913 | mNotificationPanel.animateCloseQs(); |
| 3914 | } |
Adrian Roos | 0002a45 | 2014-07-03 13:46:07 +0200 | [diff] [blame] | 3915 | return true; |
| 3916 | } |
| 3917 | if (mState != StatusBarState.KEYGUARD && mState != StatusBarState.SHADE_LOCKED) { |
| 3918 | animateCollapsePanels(); |
| 3919 | return true; |
| 3920 | } |
| 3921 | return false; |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 3922 | } |
| 3923 | |
Jorim Jaggi | 3425076 | 2014-07-03 23:51:19 +0200 | [diff] [blame] | 3924 | public boolean onSpacePressed() { |
Xiyuan Xia | cc3a74f6 | 2015-07-22 14:16:34 -0700 | [diff] [blame] | 3925 | if (mDeviceInteractive && mState != StatusBarState.SHADE) { |
Jorim Jaggi | 4eedc1d | 2014-10-27 13:45:56 +0100 | [diff] [blame] | 3926 | animateCollapsePanels( |
| 3927 | CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL /* flags */, true /* force */); |
Jorim Jaggi | 3425076 | 2014-07-03 23:51:19 +0200 | [diff] [blame] | 3928 | return true; |
| 3929 | } |
| 3930 | return false; |
| 3931 | } |
| 3932 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 3933 | private void showBouncer() { |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 3934 | if (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) { |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 3935 | mWaitingForKeyguardExit = mStatusBarKeyguardViewManager.isShowing(); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 3936 | mStatusBarKeyguardViewManager.dismiss(); |
| 3937 | } |
| 3938 | } |
| 3939 | |
| 3940 | private void instantExpandNotificationsPanel() { |
Jorim Jaggi | c357ca2 | 2014-04-25 14:56:15 +0200 | [diff] [blame] | 3941 | |
Jorim Jaggi | 0a27be8 | 2014-06-11 03:22:39 +0200 | [diff] [blame] | 3942 | // Make our window larger and the panel expanded. |
Jorim Jaggi | fa505a7 | 2014-04-28 20:04:11 +0200 | [diff] [blame] | 3943 | makeExpandedVisible(true); |
Oren Blasberg | 8d3fea1 | 2015-07-10 14:21:44 -0700 | [diff] [blame] | 3944 | mNotificationPanel.expand(false /* animate */); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 3945 | } |
Adrian Roos | 5a46cd3 | 2014-04-03 16:51:58 +0200 | [diff] [blame] | 3946 | |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 3947 | private void instantCollapseNotificationPanel() { |
Selim Cinek | 6bb4a9b | 2014-10-09 17:48:05 -0700 | [diff] [blame] | 3948 | mNotificationPanel.instantCollapse(); |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 3949 | } |
| 3950 | |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 3951 | @Override |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 3952 | public void onActivated(ActivatableNotificationView view) { |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 3953 | EventLogTags.writeSysuiLockscreenGesture( |
| 3954 | EventLogConstants.SYSUI_LOCKSCREEN_GESTURE_TAP_NOTIFICATION_ACTIVATE, |
| 3955 | 0 /* lengthDp - N/A */, 0 /* velocityDp - N/A */); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 3956 | mKeyguardIndicationController.showTransientIndication(R.string.notification_tap_again); |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 3957 | ActivatableNotificationView previousView = mStackScroller.getActivatedChild(); |
| 3958 | if (previousView != null) { |
| 3959 | previousView.makeInactive(true /* animate */); |
| 3960 | } |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 3961 | mStackScroller.setActivatedChild(view); |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 3962 | } |
| 3963 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 3964 | /** |
| 3965 | * @param state The {@link StatusBarState} to set. |
| 3966 | */ |
| 3967 | public void setBarState(int state) { |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 3968 | // If we're visible and switched to SHADE_LOCKED (the user dragged |
| 3969 | // down on the lockscreen), clear notification LED, vibration, |
| 3970 | // ringing. |
| 3971 | // Other transitions are covered in handleVisibleToUserChanged(). |
Selim Cinek | 6577cae | 2015-08-31 16:15:49 -0700 | [diff] [blame] | 3972 | if (state != mState && mVisible && (state == StatusBarState.SHADE_LOCKED |
| 3973 | || (state == StatusBarState.SHADE && isGoingToNotificationShade()))) { |
| 3974 | clearNotificationEffects(); |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 3975 | } |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 3976 | mState = state; |
Selim Cinek | 9c4c414 | 2015-12-04 16:44:56 -0800 | [diff] [blame] | 3977 | mGroupManager.setStatusBarState(state); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 3978 | mFalsingManager.setStatusBarState(state); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 3979 | mStatusBarWindowManager.setStatusBarState(state); |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 3980 | updateDozing(); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 3981 | } |
| 3982 | |
Jorim Jaggi | c5dc0d0 | 2014-04-15 15:42:55 +0200 | [diff] [blame] | 3983 | @Override |
Selim Cinek | a32ab60 | 2014-06-11 15:06:01 +0200 | [diff] [blame] | 3984 | public void onActivationReset(ActivatableNotificationView view) { |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 3985 | if (view == mStackScroller.getActivatedChild()) { |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 3986 | mKeyguardIndicationController.hideTransientIndication(); |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 3987 | mStackScroller.setActivatedChild(null); |
| 3988 | } |
Jorim Jaggi | e70d31f | 2014-04-24 22:08:30 +0200 | [diff] [blame] | 3989 | } |
| 3990 | |
| 3991 | public void onTrackingStarted() { |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 3992 | runPostCollapseRunnables(); |
Jorim Jaggi | 9012958 | 2014-06-02 14:44:49 +0200 | [diff] [blame] | 3993 | } |
| 3994 | |
Selim Cinek | dbbcfbe | 2014-10-24 17:52:35 +0200 | [diff] [blame] | 3995 | public void onClosingFinished() { |
| 3996 | runPostCollapseRunnables(); |
| 3997 | } |
| 3998 | |
Jorim Jaggi | 9012958 | 2014-06-02 14:44:49 +0200 | [diff] [blame] | 3999 | public void onUnlockHintStarted() { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4000 | mFalsingManager.onUnlockHintStarted(); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4001 | mKeyguardIndicationController.showTransientIndication(R.string.keyguard_unlock); |
Jorim Jaggi | 9012958 | 2014-06-02 14:44:49 +0200 | [diff] [blame] | 4002 | } |
| 4003 | |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 4004 | public void onHintFinished() { |
Jorim Jaggi | 93a2bb2 | 2014-06-02 19:57:28 +0200 | [diff] [blame] | 4005 | // Delay the reset a bit so the user can read the text. |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4006 | mKeyguardIndicationController.hideTransientIndicationDelayed(HINT_RESET_DELAY_MS); |
Jorim Jaggi | e70d31f | 2014-04-24 22:08:30 +0200 | [diff] [blame] | 4007 | } |
| 4008 | |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 4009 | public void onCameraHintStarted() { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4010 | mFalsingManager.onCameraHintStarted(); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4011 | mKeyguardIndicationController.showTransientIndication(R.string.camera_hint); |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 4012 | } |
| 4013 | |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 4014 | public void onVoiceAssistHintStarted() { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4015 | mFalsingManager.onLeftAffordanceHintStarted(); |
Selim Cinek | e70d653 | 2015-04-24 16:46:13 -0700 | [diff] [blame] | 4016 | mKeyguardIndicationController.showTransientIndication(R.string.voice_hint); |
| 4017 | } |
| 4018 | |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 4019 | public void onPhoneHintStarted() { |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4020 | mFalsingManager.onLeftAffordanceHintStarted(); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 4021 | mKeyguardIndicationController.showTransientIndication(R.string.phone_hint); |
Jorim Jaggi | b3f0a2f | 2014-06-02 19:29:39 +0200 | [diff] [blame] | 4022 | } |
| 4023 | |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 4024 | public void onTrackingStopped(boolean expand) { |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 4025 | if (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) { |
Selim Cinek | e8bae62 | 2015-07-15 13:24:06 -0700 | [diff] [blame] | 4026 | if (!expand && !mUnlockMethodCache.canSkipBouncer()) { |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 4027 | showBouncer(); |
| 4028 | } |
| 4029 | } |
Jorim Jaggi | e70d31f | 2014-04-24 22:08:30 +0200 | [diff] [blame] | 4030 | } |
| 4031 | |
| 4032 | @Override |
Selim Cinek | 5f71bee | 2015-11-18 10:25:23 -0800 | [diff] [blame] | 4033 | protected int getMaxKeyguardNotifications(boolean recompute) { |
| 4034 | if (recompute) { |
| 4035 | mMaxKeyguardNotifications = Math.max(1, |
| 4036 | mNotificationPanel.computeMaxKeyguardNotifications( |
| 4037 | mMaxAllowedKeyguardNotifications)); |
| 4038 | return mMaxKeyguardNotifications; |
| 4039 | } |
| 4040 | return mMaxKeyguardNotifications; |
| 4041 | } |
| 4042 | |
| 4043 | public int getMaxKeyguardNotifications() { |
| 4044 | return getMaxKeyguardNotifications(false /* recompute */); |
Jorim Jaggi | d4a5744 | 2014-04-10 02:45:55 +0200 | [diff] [blame] | 4045 | } |
| 4046 | |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 4047 | public NavigationBarView getNavigationBarView() { |
| 4048 | return mNavigationBarView; |
| 4049 | } |
| 4050 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4051 | // ---------------------- DragDownHelper.OnDragDownListener ------------------------------------ |
| 4052 | |
| 4053 | @Override |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 4054 | public boolean onDraggedDown(View startingChild, int dragLengthY) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 4055 | if (hasActiveNotifications()) { |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 4056 | EventLogTags.writeSysuiLockscreenGesture( |
| 4057 | EventLogConstants.SYSUI_LOCKSCREEN_GESTURE_SWIPE_DOWN_FULL_SHADE, |
| 4058 | (int) (dragLengthY / mDisplayMetrics.density), |
| 4059 | 0 /* velocityDp - N/A */); |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 4060 | |
| 4061 | // We have notifications, go to locked shade. |
| 4062 | goToLockedShade(startingChild); |
| 4063 | return true; |
| 4064 | } else { |
| 4065 | |
| 4066 | // No notifications - abort gesture. |
| 4067 | return false; |
| 4068 | } |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4069 | } |
| 4070 | |
| 4071 | @Override |
Jorim Jaggi | d552d9d | 2014-05-07 19:41:13 +0200 | [diff] [blame] | 4072 | public void onDragDownReset() { |
| 4073 | mStackScroller.setDimmed(true /* dimmed */, true /* animated */); |
Selim Cinek | 177fd43 | 2015-11-18 11:53:47 -0800 | [diff] [blame] | 4074 | mStackScroller.resetScrollPosition(); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4075 | } |
| 4076 | |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 4077 | @Override |
Selim Cinek | 177fd43 | 2015-11-18 11:53:47 -0800 | [diff] [blame] | 4078 | public void onCrossedThreshold(boolean above) { |
| 4079 | mStackScroller.setDimmed(!above /* dimmed */, true /* animate */); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4080 | } |
| 4081 | |
Selim Cinek | 1408eb5 | 2014-06-02 14:45:38 +0200 | [diff] [blame] | 4082 | @Override |
| 4083 | public void onTouchSlopExceeded() { |
| 4084 | mStackScroller.removeLongPressCallback(); |
| 4085 | } |
| 4086 | |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 4087 | @Override |
| 4088 | public void setEmptyDragAmount(float amount) { |
| 4089 | mNotificationPanel.setEmptyDragAmount(amount); |
| 4090 | } |
| 4091 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4092 | /** |
| 4093 | * If secure with redaction: Show bouncer, go to unlocked shade. |
| 4094 | * |
Jorim Jaggi | 2042ef2 | 2014-05-13 21:55:18 +0200 | [diff] [blame] | 4095 | * <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] | 4096 | * |
| 4097 | * @param expandView The view to expand after going to the shade. |
| 4098 | */ |
| 4099 | public void goToLockedShade(View expandView) { |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4100 | ExpandableNotificationRow row = null; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4101 | if (expandView instanceof ExpandableNotificationRow) { |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4102 | row = (ExpandableNotificationRow) expandView; |
Selim Cinek | cb24ab8 | 2016-02-25 12:49:08 -0800 | [diff] [blame] | 4103 | row.setUserExpanded(true /* userExpanded */, true /* allowChildExpansion */); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4104 | } |
Adrian Roos | aee7046 | 2014-09-03 16:27:39 +0200 | [diff] [blame] | 4105 | boolean fullShadeNeedsBouncer = !userAllowsPrivateNotificationsInPublic(mCurrentUserId) |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4106 | || !mShowLockscreenNotifications || mFalsingManager.shouldEnforceBouncer(); |
Adrian Roos | aee7046 | 2014-09-03 16:27:39 +0200 | [diff] [blame] | 4107 | if (isLockscreenPublicMode() && fullShadeNeedsBouncer) { |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4108 | mLeaveOpenOnKeyguardHide = true; |
| 4109 | showBouncer(); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4110 | mDraggedDownRow = row; |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 4111 | mPendingRemoteInputView = null; |
Jorim Jaggi | 2042ef2 | 2014-05-13 21:55:18 +0200 | [diff] [blame] | 4112 | } else { |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4113 | mNotificationPanel.animateToFullShade(0 /* delay */); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4114 | setBarState(StatusBarState.SHADE_LOCKED); |
Jorim Jaggi | 98f8530 | 2014-08-07 17:45:04 +0200 | [diff] [blame] | 4115 | updateKeyguardState(false /* goingToFullShade */, false /* fromShadeLocked */); |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 4116 | } |
| 4117 | } |
| 4118 | |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 4119 | @Override |
Adrian Roos | 3aec638 | 2016-02-05 14:19:01 -0800 | [diff] [blame] | 4120 | protected void onLockedRemoteInput(ExpandableNotificationRow row, View clicked) { |
| 4121 | mLeaveOpenOnKeyguardHide = true; |
| 4122 | showBouncer(); |
| 4123 | mPendingRemoteInputView = clicked; |
| 4124 | } |
| 4125 | |
| 4126 | @Override |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 4127 | public void onExpandClicked(Entry clickedEntry, boolean nowExpanded) { |
| 4128 | mHeadsUpManager.setExpanded(clickedEntry, nowExpanded); |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 4129 | if (mState == StatusBarState.KEYGUARD && nowExpanded) { |
Selim Cinek | 31aada4 | 2015-12-18 17:51:15 -0800 | [diff] [blame] | 4130 | goToLockedShade(clickedEntry.row); |
Selim Cinek | 570981d | 2015-12-01 11:37:01 -0800 | [diff] [blame] | 4131 | } |
| 4132 | } |
| 4133 | |
Adrian Roos | 5a46cd3 | 2014-04-03 16:51:58 +0200 | [diff] [blame] | 4134 | /** |
Jorim Jaggi | 6539a83 | 2014-06-03 23:33:09 +0200 | [diff] [blame] | 4135 | * Goes back to the keyguard after hanging around in {@link StatusBarState#SHADE_LOCKED}. |
| 4136 | */ |
| 4137 | public void goToKeyguard() { |
| 4138 | if (mState == StatusBarState.SHADE_LOCKED) { |
Selim Cinek | d9acca5 | 2014-09-01 22:33:25 +0200 | [diff] [blame] | 4139 | mStackScroller.onGoToKeyguard(); |
Jorim Jaggi | 6539a83 | 2014-06-03 23:33:09 +0200 | [diff] [blame] | 4140 | setBarState(StatusBarState.KEYGUARD); |
Jorim Jaggi | 98f8530 | 2014-08-07 17:45:04 +0200 | [diff] [blame] | 4141 | updateKeyguardState(false /* goingToFullShade */, true /* fromShadeLocked*/); |
Jorim Jaggi | 6539a83 | 2014-06-03 23:33:09 +0200 | [diff] [blame] | 4142 | } |
| 4143 | } |
| 4144 | |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 4145 | public long getKeyguardFadingAwayDelay() { |
| 4146 | return mKeyguardFadingAwayDelay; |
| 4147 | } |
| 4148 | |
| 4149 | public long getKeyguardFadingAwayDuration() { |
| 4150 | return mKeyguardFadingAwayDuration; |
| 4151 | } |
| 4152 | |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4153 | @Override |
| 4154 | public void setBouncerShowing(boolean bouncerShowing) { |
| 4155 | super.setBouncerShowing(bouncerShowing); |
Adrian Roos | d0b2f7d | 2015-04-29 13:36:12 -0700 | [diff] [blame] | 4156 | mStatusBarView.setBouncerShowing(bouncerShowing); |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 4157 | disable(mDisabledUnmodified1, mDisabledUnmodified2, true /* animate */); |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 4158 | } |
| 4159 | |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4160 | public void onStartedGoingToSleep() { |
| 4161 | mStartedGoingToSleep = true; |
| 4162 | } |
| 4163 | |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4164 | public void onFinishedGoingToSleep() { |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4165 | mNotificationPanel.onAffordanceLaunchEnded(); |
| 4166 | releaseGestureWakeLock(); |
| 4167 | mLaunchCameraOnScreenTurningOn = false; |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4168 | mStartedGoingToSleep = false; |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4169 | mDeviceInteractive = false; |
| 4170 | mWakeUpComingFromTouch = false; |
| 4171 | mWakeUpTouchLocation = null; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4172 | mFalsingManager.onScreenOff(); |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 4173 | mStackScroller.setAnimationsEnabled(false); |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 4174 | updateVisibleToUser(); |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4175 | if (mLaunchCameraOnFinishedGoingToSleep) { |
| 4176 | mLaunchCameraOnFinishedGoingToSleep = false; |
| 4177 | |
| 4178 | // This gets executed before we will show Keyguard, so post it in order that the state |
| 4179 | // is correct. |
| 4180 | mHandler.post(new Runnable() { |
| 4181 | @Override |
| 4182 | public void run() { |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 4183 | onCameraLaunchGestureDetected(mLastCameraLaunchSource); |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4184 | } |
| 4185 | }); |
| 4186 | } |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 4187 | } |
| 4188 | |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4189 | public void onStartedWakingUp() { |
| 4190 | mDeviceInteractive = true; |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 4191 | mStackScroller.setAnimationsEnabled(true); |
Jorim Jaggi | d41083a | 2014-09-12 02:54:40 +0200 | [diff] [blame] | 4192 | mNotificationPanel.setTouchDisabled(false); |
Christoph Studer | e8e2865 | 2014-10-29 17:27:53 +0100 | [diff] [blame] | 4193 | updateVisibleToUser(); |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 4194 | } |
John Spurlock | d08f91f | 2014-05-23 11:00:34 -0400 | [diff] [blame] | 4195 | |
Jorim Jaggi | 9373911 | 2015-08-13 15:53:14 -0700 | [diff] [blame] | 4196 | public void onScreenTurningOn() { |
Selim Cinek | 1b6f819 | 2015-09-03 16:01:53 -0700 | [diff] [blame] | 4197 | mScreenTurningOn = true; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4198 | mFalsingManager.onScreenTurningOn(); |
Jorim Jaggi | 9373911 | 2015-08-13 15:53:14 -0700 | [diff] [blame] | 4199 | mNotificationPanel.onScreenTurningOn(); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4200 | if (mLaunchCameraOnScreenTurningOn) { |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 4201 | mNotificationPanel.launchCamera(false, mLastCameraLaunchSource); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4202 | mLaunchCameraOnScreenTurningOn = false; |
| 4203 | } |
Jorim Jaggi | 9373911 | 2015-08-13 15:53:14 -0700 | [diff] [blame] | 4204 | } |
| 4205 | |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 4206 | private void vibrateForCameraGesture() { |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4207 | // 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] | 4208 | mVibrator.vibrate(new long[]{0, 750L}, -1 /* repeat */); |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 4209 | } |
| 4210 | |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4211 | public void onScreenTurnedOn() { |
Selim Cinek | 1b6f819 | 2015-09-03 16:01:53 -0700 | [diff] [blame] | 4212 | mScreenTurningOn = false; |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4213 | mDozeScrimController.onScreenTurnedOn(); |
| 4214 | } |
| 4215 | |
Jason Monk | 815e057 | 2014-08-12 17:26:36 -0400 | [diff] [blame] | 4216 | /** |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 4217 | * Handles long press for back button. This exits screen pinning. |
Jason Monk | 815e057 | 2014-08-12 17:26:36 -0400 | [diff] [blame] | 4218 | */ |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 4219 | private boolean handleLongPressBack() { |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 4220 | try { |
| 4221 | IActivityManager activityManager = ActivityManagerNative.getDefault(); |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 4222 | if (activityManager.isInLockTaskMode()) { |
| 4223 | activityManager.stopLockTaskModeOnCurrent(); |
| 4224 | |
| 4225 | // When exiting refresh disabled flags. |
| 4226 | mNavigationBarView.setDisabledFlags(mDisabled1, true); |
| 4227 | return true; |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 4228 | } |
| 4229 | } catch (RemoteException e) { |
Jason Monk | 815e057 | 2014-08-12 17:26:36 -0400 | [diff] [blame] | 4230 | Log.d(TAG, "Unable to reach activity manager", e); |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 4231 | } |
Jorim Jaggi | 75b2597 | 2015-10-21 14:51:10 +0200 | [diff] [blame] | 4232 | return false; |
Jason Monk | 62515be | 2014-05-21 16:06:19 -0400 | [diff] [blame] | 4233 | } |
| 4234 | |
Winson | 3e7e3aa | 2015-09-22 14:22:58 -0700 | [diff] [blame] | 4235 | public void updateRecentsVisibility(boolean visible) { |
Winson Chung | 9214eff | 2014-06-12 13:59:25 -0700 | [diff] [blame] | 4236 | // Update the recents visibility flag |
| 4237 | if (visible) { |
| 4238 | mSystemUiVisibility |= View.RECENT_APPS_VISIBLE; |
| 4239 | } else { |
| 4240 | mSystemUiVisibility &= ~View.RECENT_APPS_VISIBLE; |
| 4241 | } |
| 4242 | notifyUiVisibilityChanged(mSystemUiVisibility); |
| 4243 | } |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4244 | |
Jason Monk | 5565cb4 | 2014-09-12 10:59:21 -0400 | [diff] [blame] | 4245 | @Override |
| 4246 | public void showScreenPinningRequest() { |
Jason Monk | 18f99d9 | 2014-09-11 13:36:42 -0400 | [diff] [blame] | 4247 | if (mKeyguardMonitor.isShowing()) { |
| 4248 | // Don't allow apps to trigger this from keyguard. |
| 4249 | return; |
| 4250 | } |
| 4251 | // Show screen pinning request, since this comes from an app, show 'no thanks', button. |
| 4252 | showScreenPinningRequest(true); |
| 4253 | } |
| 4254 | |
| 4255 | public void showScreenPinningRequest(boolean allowCancel) { |
| 4256 | mScreenPinningRequest.showPrompt(allowCancel); |
Jason Monk | 5565cb4 | 2014-09-12 10:59:21 -0400 | [diff] [blame] | 4257 | } |
| 4258 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 4259 | public boolean hasActiveNotifications() { |
| 4260 | return !mNotificationData.getActiveNotifications().isEmpty(); |
Jorim Jaggi | 48bc36a | 2014-07-25 23:16:04 +0200 | [diff] [blame] | 4261 | } |
| 4262 | |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 4263 | public void wakeUpIfDozing(long time, MotionEvent event) { |
Jorim Jaggi | 048af1f | 2014-11-11 22:51:10 +0100 | [diff] [blame] | 4264 | if (mDozing && mDozeScrimController.isPulsing()) { |
John Spurlock | 8b12f22 | 2014-09-09 11:54:11 -0400 | [diff] [blame] | 4265 | PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); |
Dianne Hackborn | 280a64e | 2015-07-13 14:48:08 -0700 | [diff] [blame] | 4266 | pm.wakeUp(time, "com.android.systemui:NODOZE"); |
Jorim Jaggi | 50ff3af | 2015-08-12 18:35:42 -0700 | [diff] [blame] | 4267 | mWakeUpComingFromTouch = true; |
| 4268 | mWakeUpTouchLocation = new PointF(event.getX(), event.getY()); |
Jorim Jaggi | 2a5e452 | 2014-11-24 21:45:20 +0100 | [diff] [blame] | 4269 | mNotificationPanel.setTouchDisabled(false); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 4270 | mStatusBarKeyguardViewManager.notifyDeviceWakeUpRequested(); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 4271 | mFalsingManager.onScreenOnFromTouch(); |
John Spurlock | 8b12f22 | 2014-09-09 11:54:11 -0400 | [diff] [blame] | 4272 | } |
| 4273 | } |
| 4274 | |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 4275 | @Override |
| 4276 | public void appTransitionPending() { |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4277 | |
| 4278 | // Use own timings when Keyguard is going away, see keyguardGoingAway and |
| 4279 | // setKeyguardFadingAway |
| 4280 | if (!mKeyguardFadingAway) { |
| 4281 | mIconController.appTransitionPending(); |
| 4282 | } |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 4283 | } |
| 4284 | |
| 4285 | @Override |
| 4286 | public void appTransitionCancelled() { |
| 4287 | mIconController.appTransitionCancelled(); |
| 4288 | } |
| 4289 | |
| 4290 | @Override |
| 4291 | public void appTransitionStarting(long startTime, long duration) { |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4292 | |
| 4293 | // Use own timings when Keyguard is going away, see keyguardGoingAway and |
Adrian Roos | 46df1ca | 2015-09-11 12:38:43 -0700 | [diff] [blame] | 4294 | // setKeyguardFadingAway. |
| 4295 | if (!mKeyguardGoingAway) { |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 4296 | mIconController.appTransitionStarting(startTime, duration); |
| 4297 | } |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 4298 | if (mIconPolicy != null) { |
| 4299 | mIconPolicy.appTransitionStarting(startTime, duration); |
| 4300 | } |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 4301 | } |
| 4302 | |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4303 | @Override |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 4304 | public void onCameraLaunchGestureDetected(int source) { |
| 4305 | mLastCameraLaunchSource = source; |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 4306 | if (mStartedGoingToSleep) { |
| 4307 | mLaunchCameraOnFinishedGoingToSleep = true; |
| 4308 | return; |
| 4309 | } |
Zhentao Sun | 04f9740 | 2015-08-26 17:37:30 -0700 | [diff] [blame] | 4310 | if (!mNotificationPanel.canCameraGestureBeLaunched( |
| 4311 | mStatusBarKeyguardViewManager.isShowing() && mExpandedVisible)) { |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4312 | return; |
| 4313 | } |
| 4314 | if (!mDeviceInteractive) { |
| 4315 | PowerManager pm = mContext.getSystemService(PowerManager.class); |
| 4316 | pm.wakeUp(SystemClock.uptimeMillis(), "com.android.systemui:CAMERA_GESTURE"); |
| 4317 | mStatusBarKeyguardViewManager.notifyDeviceWakeUpRequested(); |
| 4318 | } |
Selim Cinek | 69ff8af | 2015-08-25 19:03:48 -0700 | [diff] [blame] | 4319 | vibrateForCameraGesture(); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4320 | if (!mStatusBarKeyguardViewManager.isShowing()) { |
| 4321 | startActivity(KeyguardBottomAreaView.INSECURE_CAMERA_INTENT, |
| 4322 | true /* dismissShade */); |
| 4323 | } else { |
| 4324 | if (!mDeviceInteractive) { |
| 4325 | // Avoid flickering of the scrim when we instant launch the camera and the bouncer |
| 4326 | // comes on. |
| 4327 | mScrimController.dontAnimateBouncerChangesUntilNextFrame(); |
| 4328 | mGestureWakeLock.acquire(LAUNCH_TRANSITION_TIMEOUT_MS + 1000L); |
| 4329 | } |
Selim Cinek | 1b6f819 | 2015-09-03 16:01:53 -0700 | [diff] [blame] | 4330 | if (mScreenTurningOn || mStatusBarKeyguardViewManager.isScreenTurnedOn()) { |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 4331 | mNotificationPanel.launchCamera(mDeviceInteractive /* animate */, source); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 4332 | } else { |
| 4333 | // We need to defer the camera launch until the screen comes on, since otherwise |
| 4334 | // we will dismiss us too early since we are waiting on an activity to be drawn and |
| 4335 | // incorrectly get notified because of the screen on event (which resumes and pauses |
| 4336 | // some activities) |
| 4337 | mLaunchCameraOnScreenTurningOn = true; |
| 4338 | } |
| 4339 | } |
| 4340 | } |
| 4341 | |
Jaewan Kim | c552b04 | 2016-01-18 16:08:45 +0900 | [diff] [blame] | 4342 | @Override |
| 4343 | public void requestTvPictureInPicture() { |
| 4344 | // no-op. |
| 4345 | } |
| 4346 | |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 4347 | public void notifyFpAuthModeChanged() { |
| 4348 | updateDozing(); |
| 4349 | } |
| 4350 | |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 4351 | private void updateDozing() { |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 4352 | // When in wake-and-unlock while pulsing, keep dozing state until fully unlocked. |
| 4353 | mDozing = mDozingRequested && mState == StatusBarState.KEYGUARD |
| 4354 | || mFingerprintUnlockController.getMode() |
| 4355 | == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING; |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 4356 | updateDozingState(); |
| 4357 | } |
| 4358 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4359 | private final class ShadeUpdates { |
| 4360 | private final ArraySet<String> mVisibleNotifications = new ArraySet<String>(); |
| 4361 | private final ArraySet<String> mNewVisibleNotifications = new ArraySet<String>(); |
| 4362 | |
| 4363 | public void check() { |
| 4364 | mNewVisibleNotifications.clear(); |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 4365 | ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); |
| 4366 | for (int i = 0; i < activeNotifications.size(); i++) { |
| 4367 | final Entry entry = activeNotifications.get(i); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4368 | final boolean visible = entry.row != null |
| 4369 | && entry.row.getVisibility() == View.VISIBLE; |
| 4370 | if (visible) { |
| 4371 | mNewVisibleNotifications.add(entry.key + entry.notification.getPostTime()); |
| 4372 | } |
| 4373 | } |
| 4374 | final boolean updates = !mVisibleNotifications.containsAll(mNewVisibleNotifications); |
| 4375 | mVisibleNotifications.clear(); |
Dianne Hackborn | 497175b | 2014-07-01 12:56:08 -0700 | [diff] [blame] | 4376 | mVisibleNotifications.addAll(mNewVisibleNotifications); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4377 | |
| 4378 | // We have new notifications |
| 4379 | if (updates && mDozeServiceHost != null) { |
| 4380 | mDozeServiceHost.fireNewNotifications(); |
| 4381 | } |
| 4382 | } |
| 4383 | } |
| 4384 | |
Jorim Jaggi | 007f0e8 | 2015-08-14 13:56:01 -0700 | [diff] [blame] | 4385 | private final class DozeServiceHost extends KeyguardUpdateMonitorCallback implements DozeHost { |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4386 | // Amount of time to allow to update the time shown on the screen before releasing |
| 4387 | // the wakelock. This timeout is design to compensate for the fact that we don't |
| 4388 | // currently have a way to know when time display contents have actually been |
| 4389 | // refreshed once we've finished rendering a new frame. |
| 4390 | private static final long PROCESSING_TIME = 500; |
| 4391 | |
| 4392 | private final ArrayList<Callback> mCallbacks = new ArrayList<Callback>(); |
| 4393 | private final H mHandler = new H(); |
| 4394 | |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 4395 | // Keeps the last reported state by fireNotificationLight. |
| 4396 | private boolean mNotificationLightOn; |
| 4397 | |
John Spurlock | c6eed84 | 2014-08-25 12:19:41 -0400 | [diff] [blame] | 4398 | @Override |
| 4399 | public String toString() { |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 4400 | return "PSB.DozeServiceHost[mCallbacks=" + mCallbacks.size() + "]"; |
John Spurlock | 8b12f22 | 2014-09-09 11:54:11 -0400 | [diff] [blame] | 4401 | } |
| 4402 | |
John Spurlock | d96179e | 2014-08-21 16:43:45 -0400 | [diff] [blame] | 4403 | public void firePowerSaveChanged(boolean active) { |
| 4404 | for (Callback callback : mCallbacks) { |
| 4405 | callback.onPowerSaveChanged(active); |
| 4406 | } |
| 4407 | } |
| 4408 | |
John Spurlock | cad5768 | 2014-07-26 17:09:56 -0400 | [diff] [blame] | 4409 | public void fireBuzzBeepBlinked() { |
| 4410 | for (Callback callback : mCallbacks) { |
| 4411 | callback.onBuzzBeepBlinked(); |
| 4412 | } |
| 4413 | } |
| 4414 | |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 4415 | public void fireNotificationLight(boolean on) { |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 4416 | mNotificationLightOn = on; |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 4417 | for (Callback callback : mCallbacks) { |
| 4418 | callback.onNotificationLight(on); |
| 4419 | } |
| 4420 | } |
| 4421 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4422 | public void fireNewNotifications() { |
| 4423 | for (Callback callback : mCallbacks) { |
| 4424 | callback.onNewNotifications(); |
| 4425 | } |
| 4426 | } |
| 4427 | |
| 4428 | @Override |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 4429 | public void addCallback(@NonNull Callback callback) { |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4430 | mCallbacks.add(callback); |
| 4431 | } |
| 4432 | |
| 4433 | @Override |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 4434 | public void removeCallback(@NonNull Callback callback) { |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4435 | mCallbacks.remove(callback); |
| 4436 | } |
| 4437 | |
| 4438 | @Override |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 4439 | public void startDozing(@NonNull Runnable ready) { |
| 4440 | mHandler.obtainMessage(H.MSG_START_DOZING, ready).sendToTarget(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4441 | } |
| 4442 | |
| 4443 | @Override |
John Spurlock | eab28e6 | 2014-11-29 11:33:49 -0500 | [diff] [blame] | 4444 | public void pulseWhileDozing(@NonNull PulseCallback callback, int reason) { |
| 4445 | mHandler.obtainMessage(H.MSG_PULSE_WHILE_DOZING, reason, 0, callback).sendToTarget(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4446 | } |
| 4447 | |
| 4448 | @Override |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 4449 | public void stopDozing() { |
| 4450 | mHandler.obtainMessage(H.MSG_STOP_DOZING).sendToTarget(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4451 | } |
| 4452 | |
John Spurlock | d96179e | 2014-08-21 16:43:45 -0400 | [diff] [blame] | 4453 | @Override |
| 4454 | public boolean isPowerSaveActive() { |
| 4455 | return mBatteryController != null && mBatteryController.isPowerSave(); |
| 4456 | } |
| 4457 | |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 4458 | @Override |
Jorim Jaggi | 007f0e8 | 2015-08-14 13:56:01 -0700 | [diff] [blame] | 4459 | public boolean isPulsingBlocked() { |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 4460 | return mFingerprintUnlockController.getMode() |
| 4461 | == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK; |
Jorim Jaggi | 007f0e8 | 2015-08-14 13:56:01 -0700 | [diff] [blame] | 4462 | } |
| 4463 | |
| 4464 | @Override |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 4465 | public boolean isNotificationLightOn() { |
| 4466 | return mNotificationLightOn; |
| 4467 | } |
| 4468 | |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 4469 | private void handleStartDozing(@NonNull Runnable ready) { |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 4470 | if (!mDozingRequested) { |
| 4471 | mDozingRequested = true; |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 4472 | DozeLog.traceDozing(mContext, mDozing); |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 4473 | updateDozing(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4474 | } |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 4475 | ready.run(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4476 | } |
| 4477 | |
John Spurlock | eab28e6 | 2014-11-29 11:33:49 -0500 | [diff] [blame] | 4478 | private void handlePulseWhileDozing(@NonNull PulseCallback callback, int reason) { |
| 4479 | mDozeScrimController.pulse(callback, reason); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4480 | } |
| 4481 | |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 4482 | private void handleStopDozing() { |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 4483 | if (mDozingRequested) { |
| 4484 | mDozingRequested = false; |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 4485 | DozeLog.traceDozing(mContext, mDozing); |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 4486 | updateDozing(); |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4487 | } |
| 4488 | } |
| 4489 | |
| 4490 | private final class H extends Handler { |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 4491 | private static final int MSG_START_DOZING = 1; |
| 4492 | private static final int MSG_PULSE_WHILE_DOZING = 2; |
| 4493 | private static final int MSG_STOP_DOZING = 3; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4494 | |
| 4495 | @Override |
| 4496 | public void handleMessage(Message msg) { |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 4497 | switch (msg.what) { |
| 4498 | case MSG_START_DOZING: |
| 4499 | handleStartDozing((Runnable) msg.obj); |
| 4500 | break; |
| 4501 | case MSG_PULSE_WHILE_DOZING: |
John Spurlock | eab28e6 | 2014-11-29 11:33:49 -0500 | [diff] [blame] | 4502 | handlePulseWhileDozing((PulseCallback) msg.obj, msg.arg1); |
Jeff Brown | 4d69e22 | 2014-09-18 15:27:50 -0700 | [diff] [blame] | 4503 | break; |
| 4504 | case MSG_STOP_DOZING: |
| 4505 | handleStopDozing(); |
| 4506 | break; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 4507 | } |
| 4508 | } |
| 4509 | } |
| 4510 | } |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 4511 | } |