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