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