Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file |
| 5 | * except in compliance with the License. You may obtain a copy of the License at |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software distributed under the |
| 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 11 | * KIND, either express or implied. See the License for the specific language governing |
| 12 | * permissions and limitations under the License. |
| 13 | */ |
| 14 | |
| 15 | package com.android.systemui.globalactions; |
| 16 | |
Adrian Roos | edfab3b | 2018-03-08 18:39:20 +0100 | [diff] [blame] | 17 | import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; |
Adrian Roos | 2f05bb3 | 2018-02-19 16:42:27 +0100 | [diff] [blame] | 18 | import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; |
| 19 | |
Chad Brubaker | f4075fe | 2018-01-03 13:23:22 -0800 | [diff] [blame] | 20 | import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_USER_REQUEST; |
| 21 | import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_NOT_REQUIRED; |
Chad Brubaker | 4f28f0d | 2017-09-07 14:28:13 -0700 | [diff] [blame] | 22 | import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN; |
| 23 | |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 24 | import android.annotation.Nullable; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 25 | import android.app.ActivityManager; |
| 26 | import android.app.Dialog; |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 27 | import android.app.IActivityManager; |
Steve Elliott | 4c86885 | 2019-03-14 16:25:41 -0400 | [diff] [blame] | 28 | import android.app.PendingIntent; |
Steve Elliott | 53f12ae | 2019-05-13 17:14:15 -0400 | [diff] [blame] | 29 | import android.app.StatusBarManager; |
Lucas Dupin | c1cc759 | 2017-05-22 15:56:16 -0700 | [diff] [blame] | 30 | import android.app.WallpaperManager; |
Alex Chau | 0445885 | 2017-11-27 18:21:23 +0000 | [diff] [blame] | 31 | import android.app.admin.DevicePolicyManager; |
Pavel Grafov | 059021b | 2018-05-02 13:44:46 +0100 | [diff] [blame] | 32 | import android.app.trust.TrustManager; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 33 | import android.content.BroadcastReceiver; |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 34 | import android.content.ContentResolver; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 35 | import android.content.Context; |
| 36 | import android.content.DialogInterface; |
| 37 | import android.content.Intent; |
| 38 | import android.content.IntentFilter; |
| 39 | import android.content.pm.UserInfo; |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 40 | import android.content.res.Resources; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 41 | import android.database.ContentObserver; |
Matt Pietal | e0661b6 | 2020-01-29 14:35:31 -0500 | [diff] [blame] | 42 | import android.graphics.Color; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 43 | import android.graphics.drawable.Drawable; |
| 44 | import android.media.AudioManager; |
| 45 | import android.net.ConnectivityManager; |
Steve Elliott | 53f12ae | 2019-05-13 17:14:15 -0400 | [diff] [blame] | 46 | import android.os.Binder; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 47 | import android.os.Handler; |
Steve Elliott | 53f12ae | 2019-05-13 17:14:15 -0400 | [diff] [blame] | 48 | import android.os.IBinder; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 49 | import android.os.Message; |
| 50 | import android.os.RemoteException; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 51 | import android.os.SystemProperties; |
| 52 | import android.os.UserHandle; |
| 53 | import android.os.UserManager; |
| 54 | import android.os.Vibrator; |
| 55 | import android.provider.Settings; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 56 | import android.service.dreams.IDreamManager; |
Inseob Kim | 5e82f73 | 2019-11-08 15:08:38 +0900 | [diff] [blame] | 57 | import android.sysprop.TelephonyProperties; |
Fan Zhang | f991476 | 2019-11-01 15:58:38 -0700 | [diff] [blame] | 58 | import android.telecom.TelecomManager; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 59 | import android.telephony.PhoneStateListener; |
| 60 | import android.telephony.ServiceState; |
| 61 | import android.telephony.TelephonyManager; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 62 | import android.util.ArraySet; |
yuanjiahsu | 88363e9 | 2018-09-06 19:23:52 +0800 | [diff] [blame] | 63 | import android.util.FeatureFlagUtils; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 64 | import android.util.Log; |
Lucas Dupin | 448786c | 2017-07-24 17:44:25 -0700 | [diff] [blame] | 65 | import android.view.ContextThemeWrapper; |
Dave Mankoff | 8df818e | 2020-02-12 14:22:26 -0500 | [diff] [blame] | 66 | import android.view.IWindowManager; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 67 | import android.view.LayoutInflater; |
| 68 | import android.view.View; |
| 69 | import android.view.ViewGroup; |
Lucas Dupin | c1cc759 | 2017-05-22 15:56:16 -0700 | [diff] [blame] | 70 | import android.view.Window; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 71 | import android.view.WindowManager; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 72 | import android.view.accessibility.AccessibilityEvent; |
Steve Elliott | 9b87a44 | 2019-03-05 10:24:16 -0500 | [diff] [blame] | 73 | import android.widget.FrameLayout; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 74 | import android.widget.ImageView; |
| 75 | import android.widget.ImageView.ScaleType; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 76 | import android.widget.TextView; |
| 77 | |
Charles He | 9851a8d | 2017-10-10 17:31:30 +0100 | [diff] [blame] | 78 | import com.android.internal.R; |
| 79 | import com.android.internal.colorextraction.ColorExtractor; |
| 80 | import com.android.internal.colorextraction.ColorExtractor.GradientColors; |
Lucas Dupin | 2bd3af6 | 2019-03-25 17:44:28 -0700 | [diff] [blame] | 81 | import com.android.internal.colorextraction.drawable.ScrimDrawable; |
Charles He | 9851a8d | 2017-10-10 17:31:30 +0100 | [diff] [blame] | 82 | import com.android.internal.logging.MetricsLogger; |
| 83 | import com.android.internal.logging.nano.MetricsProto.MetricsEvent; |
Steve Elliott | 53f12ae | 2019-05-13 17:14:15 -0400 | [diff] [blame] | 84 | import com.android.internal.statusbar.IStatusBarService; |
Charles He | 9851a8d | 2017-10-10 17:31:30 +0100 | [diff] [blame] | 85 | import com.android.internal.util.EmergencyAffordanceManager; |
Beth Thibodeau | 5898ac4 | 2018-10-26 13:00:09 -0400 | [diff] [blame] | 86 | import com.android.internal.util.ScreenRecordHelper; |
Alison Cichowlas | a2cd19e | 2017-12-06 10:51:21 -0500 | [diff] [blame] | 87 | import com.android.internal.util.ScreenshotHelper; |
Steve Elliott | 48f75db | 2019-05-03 15:03:38 -0400 | [diff] [blame] | 88 | import com.android.internal.view.RotationPolicy; |
Charles He | 9851a8d | 2017-10-10 17:31:30 +0100 | [diff] [blame] | 89 | import com.android.internal.widget.LockPatternUtils; |
Charles He | 9851a8d | 2017-10-10 17:31:30 +0100 | [diff] [blame] | 90 | import com.android.systemui.Interpolators; |
Aaron Heuckroth | f708d47 | 2019-01-10 16:54:51 -0500 | [diff] [blame] | 91 | import com.android.systemui.MultiListLayout; |
Aaron Heuckroth | 57d60d2 | 2019-03-05 14:00:12 -0500 | [diff] [blame] | 92 | import com.android.systemui.MultiListLayout.MultiListAdapter; |
Fabian Kozynski | ff5e91f | 2019-09-24 15:38:08 -0400 | [diff] [blame] | 93 | import com.android.systemui.broadcast.BroadcastDispatcher; |
Charles He | 9851a8d | 2017-10-10 17:31:30 +0100 | [diff] [blame] | 94 | import com.android.systemui.colorextraction.SysuiColorExtractor; |
Fabian Kozynski | 0424ab1 | 2020-02-21 12:09:17 -0500 | [diff] [blame] | 95 | import com.android.systemui.controls.management.ControlsListingController; |
Matt Pietal | 2223179 | 2020-01-23 09:51:09 -0500 | [diff] [blame] | 96 | import com.android.systemui.controls.ui.ControlsUiController; |
Dave Mankoff | 8df818e | 2020-02-12 14:22:26 -0500 | [diff] [blame] | 97 | import com.android.systemui.dagger.qualifiers.Background; |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 98 | import com.android.systemui.dagger.qualifiers.Main; |
Steve Elliott | 4c86885 | 2019-03-14 16:25:41 -0400 | [diff] [blame] | 99 | import com.android.systemui.plugins.ActivityStarter; |
Charles He | 9851a8d | 2017-10-10 17:31:30 +0100 | [diff] [blame] | 100 | import com.android.systemui.plugins.GlobalActions.GlobalActionsManager; |
Steve Elliott | 9b87a44 | 2019-03-05 10:24:16 -0500 | [diff] [blame] | 101 | import com.android.systemui.plugins.GlobalActionsPanelPlugin; |
Lucas Dupin | 991415e | 2019-11-25 17:48:58 -0800 | [diff] [blame] | 102 | import com.android.systemui.statusbar.BlurUtils; |
Matt Pietal | 2223179 | 2020-01-23 09:51:09 -0500 | [diff] [blame] | 103 | import com.android.systemui.statusbar.phone.NotificationShadeWindowController; |
Lucas Dupin | 43d0124 | 2020-02-03 11:58:33 -0800 | [diff] [blame] | 104 | import com.android.systemui.statusbar.phone.ScrimController; |
Lucas Dupin | e5b7dc7 | 2018-10-02 15:18:05 -0700 | [diff] [blame] | 105 | import com.android.systemui.statusbar.policy.ConfigurationController; |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 106 | import com.android.systemui.statusbar.policy.KeyguardStateController; |
Shaotang Li | 5c42263 | 2018-07-04 14:18:40 +0800 | [diff] [blame] | 107 | import com.android.systemui.util.EmergencyDialerConstants; |
Aaron Heuckroth | 75e249f | 2019-02-01 15:59:57 -0500 | [diff] [blame] | 108 | import com.android.systemui.util.leak.RotationUtils; |
Julia Reynolds | 4241192 | 2017-11-08 11:19:09 -0500 | [diff] [blame] | 109 | import com.android.systemui.volume.SystemUIInterpolators.LogAccelerateInterpolator; |
Lucas Dupin | c1cc759 | 2017-05-22 15:56:16 -0700 | [diff] [blame] | 110 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 111 | import java.util.ArrayList; |
| 112 | import java.util.List; |
Dave Mankoff | 8df818e | 2020-02-12 14:22:26 -0500 | [diff] [blame] | 113 | import java.util.concurrent.Executor; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 114 | |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 115 | import javax.inject.Inject; |
| 116 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 117 | /** |
| 118 | * Helper to show the global actions dialog. Each item is an {@link Action} that |
| 119 | * may show depending on whether the keyguard is showing, and whether the device |
| 120 | * is provisioned. |
| 121 | */ |
Aaron Heuckroth | 57d60d2 | 2019-03-05 14:00:12 -0500 | [diff] [blame] | 122 | public class GlobalActionsDialog implements DialogInterface.OnDismissListener, |
| 123 | DialogInterface.OnShowListener, ConfigurationController.ConfigurationListener { |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 124 | |
| 125 | static public final String SYSTEM_DIALOG_REASON_KEY = "reason"; |
| 126 | static public final String SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions"; |
Lucas Dupin | 1d4a579 | 2018-04-02 15:14:59 -0700 | [diff] [blame] | 127 | static public final String SYSTEM_DIALOG_REASON_DREAM = "dream"; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 128 | |
| 129 | private static final String TAG = "GlobalActionsDialog"; |
| 130 | |
| 131 | private static final boolean SHOW_SILENT_TOGGLE = true; |
| 132 | |
| 133 | /* Valid settings for global actions keys. |
| 134 | * see config.xml config_globalActionList */ |
| 135 | private static final String GLOBAL_ACTION_KEY_POWER = "power"; |
| 136 | private static final String GLOBAL_ACTION_KEY_AIRPLANE = "airplane"; |
| 137 | private static final String GLOBAL_ACTION_KEY_BUGREPORT = "bugreport"; |
| 138 | private static final String GLOBAL_ACTION_KEY_SILENT = "silent"; |
| 139 | private static final String GLOBAL_ACTION_KEY_USERS = "users"; |
| 140 | private static final String GLOBAL_ACTION_KEY_SETTINGS = "settings"; |
| 141 | private static final String GLOBAL_ACTION_KEY_LOCKDOWN = "lockdown"; |
| 142 | private static final String GLOBAL_ACTION_KEY_VOICEASSIST = "voiceassist"; |
| 143 | private static final String GLOBAL_ACTION_KEY_ASSIST = "assist"; |
| 144 | private static final String GLOBAL_ACTION_KEY_RESTART = "restart"; |
Alex Chau | 0445885 | 2017-11-27 18:21:23 +0000 | [diff] [blame] | 145 | private static final String GLOBAL_ACTION_KEY_LOGOUT = "logout"; |
Wesley.CW Wang | 8d07276 | 2018-05-28 16:39:27 +0800 | [diff] [blame] | 146 | private static final String GLOBAL_ACTION_KEY_EMERGENCY = "emergency"; |
Alison Cichowlas | a2cd19e | 2017-12-06 10:51:21 -0500 | [diff] [blame] | 147 | private static final String GLOBAL_ACTION_KEY_SCREENSHOT = "screenshot"; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 148 | |
| 149 | private final Context mContext; |
| 150 | private final GlobalActionsManager mWindowManagerFuncs; |
| 151 | private final AudioManager mAudioManager; |
| 152 | private final IDreamManager mDreamManager; |
Alex Chau | 0445885 | 2017-11-27 18:21:23 +0000 | [diff] [blame] | 153 | private final DevicePolicyManager mDevicePolicyManager; |
Chad Brubaker | f4075fe | 2018-01-03 13:23:22 -0800 | [diff] [blame] | 154 | private final LockPatternUtils mLockPatternUtils; |
Fabian Kozynski | f6063ae | 2020-02-24 16:14:35 -0500 | [diff] [blame] | 155 | private final KeyguardStateController mKeyguardStateController; |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 156 | private final BroadcastDispatcher mBroadcastDispatcher; |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 157 | private final ContentResolver mContentResolver; |
| 158 | private final Resources mResources; |
Dave Mankoff | 8df818e | 2020-02-12 14:22:26 -0500 | [diff] [blame] | 159 | private final ConfigurationController mConfigurationController; |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 160 | private final UserManager mUserManager; |
| 161 | private final TrustManager mTrustManager; |
| 162 | private final IActivityManager mIActivityManager; |
| 163 | private final TelecomManager mTelecomManager; |
| 164 | private final MetricsLogger mMetricsLogger; |
Lucas Dupin | 991415e | 2019-11-25 17:48:58 -0800 | [diff] [blame] | 165 | private final BlurUtils mBlurUtils; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 166 | |
| 167 | private ArrayList<Action> mItems; |
| 168 | private ActionsDialog mDialog; |
| 169 | |
| 170 | private Action mSilentModeAction; |
| 171 | private ToggleAction mAirplaneModeOn; |
| 172 | |
| 173 | private MyAdapter mAdapter; |
| 174 | |
| 175 | private boolean mKeyguardShowing = false; |
| 176 | private boolean mDeviceProvisioned = false; |
| 177 | private ToggleAction.State mAirplaneState = ToggleAction.State.Off; |
| 178 | private boolean mIsWaitingForEcmExit = false; |
| 179 | private boolean mHasTelephony; |
| 180 | private boolean mHasVibrator; |
| 181 | private final boolean mShowSilentToggle; |
| 182 | private final EmergencyAffordanceManager mEmergencyAffordanceManager; |
Alison Cichowlas | a2cd19e | 2017-12-06 10:51:21 -0500 | [diff] [blame] | 183 | private final ScreenshotHelper mScreenshotHelper; |
Beth Thibodeau | 5898ac4 | 2018-10-26 13:00:09 -0400 | [diff] [blame] | 184 | private final ScreenRecordHelper mScreenRecordHelper; |
Steve Elliott | a3f520792 | 2019-03-18 13:37:22 -0400 | [diff] [blame] | 185 | private final ActivityStarter mActivityStarter; |
Lucas Dupin | 991415e | 2019-11-25 17:48:58 -0800 | [diff] [blame] | 186 | private final SysuiColorExtractor mSysuiColorExtractor; |
| 187 | private final IStatusBarService mStatusBarService; |
| 188 | private final NotificationShadeWindowController mNotificationShadeWindowController; |
Steve Elliott | a3f520792 | 2019-03-18 13:37:22 -0400 | [diff] [blame] | 189 | private GlobalActionsPanelPlugin mPanelPlugin; |
Matt Pietal | 2223179 | 2020-01-23 09:51:09 -0500 | [diff] [blame] | 190 | private ControlsUiController mControlsUiController; |
Dave Mankoff | 8df818e | 2020-02-12 14:22:26 -0500 | [diff] [blame] | 191 | private final IWindowManager mIWindowManager; |
| 192 | private final Executor mBackgroundExecutor; |
Fabian Kozynski | 0424ab1 | 2020-02-21 12:09:17 -0500 | [diff] [blame] | 193 | private final ControlsListingController mControlsListingController; |
| 194 | private boolean mAnyControlsProviders = false; |
Steve Elliott | 9b87a44 | 2019-03-05 10:24:16 -0500 | [diff] [blame] | 195 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 196 | /** |
| 197 | * @param context everything needs a context :( |
| 198 | */ |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 199 | @Inject |
| 200 | public GlobalActionsDialog(Context context, GlobalActionsManager windowManagerFuncs, |
| 201 | AudioManager audioManager, IDreamManager iDreamManager, |
| 202 | DevicePolicyManager devicePolicyManager, LockPatternUtils lockPatternUtils, |
Fabian Kozynski | f6063ae | 2020-02-24 16:14:35 -0500 | [diff] [blame] | 203 | BroadcastDispatcher broadcastDispatcher, |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 204 | ConnectivityManager connectivityManager, TelephonyManager telephonyManager, |
| 205 | ContentResolver contentResolver, @Nullable Vibrator vibrator, @Main Resources resources, |
| 206 | ConfigurationController configurationController, ActivityStarter activityStarter, |
| 207 | KeyguardStateController keyguardStateController, UserManager userManager, |
| 208 | TrustManager trustManager, IActivityManager iActivityManager, |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 209 | @Nullable TelecomManager telecomManager, MetricsLogger metricsLogger, |
Lucas Dupin | 991415e | 2019-11-25 17:48:58 -0800 | [diff] [blame] | 210 | BlurUtils blurUtils, SysuiColorExtractor colorExtractor, |
| 211 | IStatusBarService statusBarService, |
Matt Pietal | 2223179 | 2020-01-23 09:51:09 -0500 | [diff] [blame] | 212 | NotificationShadeWindowController notificationShadeWindowController, |
Dave Mankoff | 8df818e | 2020-02-12 14:22:26 -0500 | [diff] [blame] | 213 | ControlsUiController controlsUiController, IWindowManager iWindowManager, |
Fabian Kozynski | 0424ab1 | 2020-02-21 12:09:17 -0500 | [diff] [blame] | 214 | @Background Executor backgroundExecutor, |
| 215 | ControlsListingController controlsListingController) { |
Lucas Dupin | 448786c | 2017-07-24 17:44:25 -0700 | [diff] [blame] | 216 | mContext = new ContextThemeWrapper(context, com.android.systemui.R.style.qs_theme); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 217 | mWindowManagerFuncs = windowManagerFuncs; |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 218 | mAudioManager = audioManager; |
| 219 | mDreamManager = iDreamManager; |
| 220 | mDevicePolicyManager = devicePolicyManager; |
| 221 | mLockPatternUtils = lockPatternUtils; |
Fabian Kozynski | f6063ae | 2020-02-24 16:14:35 -0500 | [diff] [blame] | 222 | mKeyguardStateController = keyguardStateController; |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 223 | mBroadcastDispatcher = broadcastDispatcher; |
| 224 | mContentResolver = contentResolver; |
| 225 | mResources = resources; |
Dave Mankoff | 8df818e | 2020-02-12 14:22:26 -0500 | [diff] [blame] | 226 | mConfigurationController = configurationController; |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 227 | mUserManager = userManager; |
| 228 | mTrustManager = trustManager; |
| 229 | mIActivityManager = iActivityManager; |
| 230 | mTelecomManager = telecomManager; |
| 231 | mMetricsLogger = metricsLogger; |
Lucas Dupin | 991415e | 2019-11-25 17:48:58 -0800 | [diff] [blame] | 232 | mBlurUtils = blurUtils; |
| 233 | mSysuiColorExtractor = colorExtractor; |
| 234 | mStatusBarService = statusBarService; |
| 235 | mNotificationShadeWindowController = notificationShadeWindowController; |
Matt Pietal | 2223179 | 2020-01-23 09:51:09 -0500 | [diff] [blame] | 236 | mControlsUiController = controlsUiController; |
Dave Mankoff | 8df818e | 2020-02-12 14:22:26 -0500 | [diff] [blame] | 237 | mIWindowManager = iWindowManager; |
| 238 | mBackgroundExecutor = backgroundExecutor; |
Fabian Kozynski | 0424ab1 | 2020-02-21 12:09:17 -0500 | [diff] [blame] | 239 | mControlsListingController = controlsListingController; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 240 | |
| 241 | // receive broadcasts |
| 242 | IntentFilter filter = new IntentFilter(); |
| 243 | filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); |
| 244 | filter.addAction(Intent.ACTION_SCREEN_OFF); |
Jayachandran C | 142eae0 | 2019-12-13 19:29:20 -0800 | [diff] [blame] | 245 | filter.addAction(TelephonyManager.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED); |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 246 | mBroadcastDispatcher.registerReceiver(mBroadcastReceiver, filter); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 247 | |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 248 | mHasTelephony = connectivityManager.isNetworkSupported(ConnectivityManager.TYPE_MOBILE); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 249 | |
| 250 | // get notified of phone state changes |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 251 | telephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE); |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 252 | contentResolver.registerContentObserver( |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 253 | Settings.Global.getUriFor(Settings.Global.AIRPLANE_MODE_ON), true, |
| 254 | mAirplaneModeObserver); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 255 | mHasVibrator = vibrator != null && vibrator.hasVibrator(); |
| 256 | |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 257 | mShowSilentToggle = SHOW_SILENT_TOGGLE && !resources.getBoolean( |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 258 | R.bool.config_useFixedVolume); |
| 259 | |
| 260 | mEmergencyAffordanceManager = new EmergencyAffordanceManager(context); |
Alison Cichowlas | a2cd19e | 2017-12-06 10:51:21 -0500 | [diff] [blame] | 261 | mScreenshotHelper = new ScreenshotHelper(context); |
Beth Thibodeau | 5898ac4 | 2018-10-26 13:00:09 -0400 | [diff] [blame] | 262 | mScreenRecordHelper = new ScreenRecordHelper(context); |
Lucas Dupin | e5b7dc7 | 2018-10-02 15:18:05 -0700 | [diff] [blame] | 263 | |
Dave Mankoff | 8df818e | 2020-02-12 14:22:26 -0500 | [diff] [blame] | 264 | mConfigurationController.addCallback(this); |
Steve Elliott | 9b87a44 | 2019-03-05 10:24:16 -0500 | [diff] [blame] | 265 | |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 266 | mActivityStarter = activityStarter; |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 267 | keyguardStateController.addCallback(new KeyguardStateController.Callback() { |
| 268 | @Override |
| 269 | public void onUnlockedChanged() { |
| 270 | if (mDialog != null && mDialog.mPanelController != null) { |
| 271 | boolean locked = !keyguardStateController.canDismissLockScreen(); |
| 272 | mDialog.mPanelController.onDeviceLockStateChanged(locked); |
| 273 | } |
| 274 | } |
| 275 | }); |
Fabian Kozynski | 0424ab1 | 2020-02-21 12:09:17 -0500 | [diff] [blame] | 276 | |
| 277 | mControlsListingController.addCallback(list -> mAnyControlsProviders = !list.isEmpty()); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | /** |
| 281 | * Show the global actions dialog (creating if necessary) |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 282 | * |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 283 | * @param keyguardShowing True if keyguard is showing |
| 284 | */ |
Steve Elliott | a3f520792 | 2019-03-18 13:37:22 -0400 | [diff] [blame] | 285 | public void showDialog(boolean keyguardShowing, boolean isDeviceProvisioned, |
| 286 | GlobalActionsPanelPlugin panelPlugin) { |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 287 | mKeyguardShowing = keyguardShowing; |
| 288 | mDeviceProvisioned = isDeviceProvisioned; |
Steve Elliott | a3f520792 | 2019-03-18 13:37:22 -0400 | [diff] [blame] | 289 | mPanelPlugin = panelPlugin; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 290 | if (mDialog != null) { |
| 291 | mDialog.dismiss(); |
| 292 | mDialog = null; |
| 293 | // Show delayed, so that the dismiss of the previous dialog completes |
| 294 | mHandler.sendEmptyMessage(MESSAGE_SHOW); |
| 295 | } else { |
| 296 | handleShow(); |
| 297 | } |
| 298 | } |
| 299 | |
Charles He | 9851a8d | 2017-10-10 17:31:30 +0100 | [diff] [blame] | 300 | /** |
| 301 | * Dismiss the global actions dialog, if it's currently shown |
| 302 | */ |
| 303 | public void dismissDialog() { |
| 304 | mHandler.removeMessages(MESSAGE_DISMISS); |
| 305 | mHandler.sendEmptyMessage(MESSAGE_DISMISS); |
| 306 | } |
| 307 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 308 | private void awakenIfNecessary() { |
| 309 | if (mDreamManager != null) { |
| 310 | try { |
| 311 | if (mDreamManager.isDreaming()) { |
| 312 | mDreamManager.awaken(); |
| 313 | } |
| 314 | } catch (RemoteException e) { |
| 315 | // we tried |
| 316 | } |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | private void handleShow() { |
| 321 | awakenIfNecessary(); |
| 322 | mDialog = createDialog(); |
| 323 | prepareDialog(); |
| 324 | |
| 325 | // If we only have 1 item and it's a simple press action, just do this action. |
| 326 | if (mAdapter.getCount() == 1 |
| 327 | && mAdapter.getItem(0) instanceof SinglePressAction |
| 328 | && !(mAdapter.getItem(0) instanceof LongPressAction)) { |
| 329 | ((SinglePressAction) mAdapter.getItem(0)).onPress(); |
| 330 | } else { |
| 331 | WindowManager.LayoutParams attrs = mDialog.getWindow().getAttributes(); |
| 332 | attrs.setTitle("ActionsDialog"); |
Adrian Roos | 2f05bb3 | 2018-02-19 16:42:27 +0100 | [diff] [blame] | 333 | attrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 334 | mDialog.getWindow().setAttributes(attrs); |
| 335 | mDialog.show(); |
| 336 | mWindowManagerFuncs.onGlobalActionsShown(); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 337 | } |
| 338 | } |
| 339 | |
| 340 | /** |
| 341 | * Create the global actions dialog. |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 342 | * |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 343 | * @return A new dialog. |
| 344 | */ |
| 345 | private ActionsDialog createDialog() { |
| 346 | // Simple toggle style if there's no vibrator, otherwise use a tri-state |
| 347 | if (!mHasVibrator) { |
| 348 | mSilentModeAction = new SilentModeToggleAction(); |
| 349 | } else { |
Lucas Dupin | 40ec6b78 | 2018-06-05 19:07:16 -0700 | [diff] [blame] | 350 | mSilentModeAction = new SilentModeTriStateAction(mAudioManager, mHandler); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 351 | } |
Aran Ink | 780d450 | 2020-02-14 10:39:58 -0500 | [diff] [blame] | 352 | mAirplaneModeOn = new AirplaneModeAction(); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 353 | onAirplaneModeChanged(); |
| 354 | |
| 355 | mItems = new ArrayList<Action>(); |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 356 | String[] defaultActions = mResources.getStringArray(R.array.config_globalActionsList); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 357 | |
| 358 | ArraySet<String> addedKeys = new ArraySet<String>(); |
| 359 | for (int i = 0; i < defaultActions.length; i++) { |
| 360 | String actionKey = defaultActions[i]; |
| 361 | if (addedKeys.contains(actionKey)) { |
| 362 | // If we already have added this, don't add it again. |
| 363 | continue; |
| 364 | } |
| 365 | if (GLOBAL_ACTION_KEY_POWER.equals(actionKey)) { |
| 366 | mItems.add(new PowerAction()); |
| 367 | } else if (GLOBAL_ACTION_KEY_AIRPLANE.equals(actionKey)) { |
| 368 | mItems.add(mAirplaneModeOn); |
| 369 | } else if (GLOBAL_ACTION_KEY_BUGREPORT.equals(actionKey)) { |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 370 | if (Settings.Global.getInt(mContentResolver, |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 371 | Settings.Global.BUGREPORT_IN_POWER_MENU, 0) != 0 && isCurrentUserOwner()) { |
| 372 | mItems.add(new BugReportAction()); |
| 373 | } |
| 374 | } else if (GLOBAL_ACTION_KEY_SILENT.equals(actionKey)) { |
| 375 | if (mShowSilentToggle) { |
| 376 | mItems.add(mSilentModeAction); |
| 377 | } |
| 378 | } else if (GLOBAL_ACTION_KEY_USERS.equals(actionKey)) { |
| 379 | if (SystemProperties.getBoolean("fw.power_user_switcher", false)) { |
| 380 | addUsersToMenu(mItems); |
| 381 | } |
| 382 | } else if (GLOBAL_ACTION_KEY_SETTINGS.equals(actionKey)) { |
| 383 | mItems.add(getSettingsAction()); |
| 384 | } else if (GLOBAL_ACTION_KEY_LOCKDOWN.equals(actionKey)) { |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 385 | if (Settings.Secure.getIntForUser(mContentResolver, |
Chad Brubaker | 02cd6cf | 2018-05-01 14:59:33 -0700 | [diff] [blame] | 386 | Settings.Secure.LOCKDOWN_IN_POWER_MENU, 0, getCurrentUser().id) != 0 |
Chad Brubaker | f4075fe | 2018-01-03 13:23:22 -0800 | [diff] [blame] | 387 | && shouldDisplayLockdown()) { |
Chad Brubaker | 4f28f0d | 2017-09-07 14:28:13 -0700 | [diff] [blame] | 388 | mItems.add(getLockdownAction()); |
| 389 | } |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 390 | } else if (GLOBAL_ACTION_KEY_VOICEASSIST.equals(actionKey)) { |
| 391 | mItems.add(getVoiceAssistAction()); |
| 392 | } else if (GLOBAL_ACTION_KEY_ASSIST.equals(actionKey)) { |
| 393 | mItems.add(getAssistAction()); |
| 394 | } else if (GLOBAL_ACTION_KEY_RESTART.equals(actionKey)) { |
| 395 | mItems.add(new RestartAction()); |
Alison Cichowlas | a2cd19e | 2017-12-06 10:51:21 -0500 | [diff] [blame] | 396 | } else if (GLOBAL_ACTION_KEY_SCREENSHOT.equals(actionKey)) { |
| 397 | mItems.add(new ScreenshotAction()); |
Alex Chau | 0445885 | 2017-11-27 18:21:23 +0000 | [diff] [blame] | 398 | } else if (GLOBAL_ACTION_KEY_LOGOUT.equals(actionKey)) { |
Alex Chau | d795827 | 2017-12-08 11:30:52 +0000 | [diff] [blame] | 399 | if (mDevicePolicyManager.isLogoutEnabled() |
Alex Chau | 0445885 | 2017-11-27 18:21:23 +0000 | [diff] [blame] | 400 | && getCurrentUser().id != UserHandle.USER_SYSTEM) { |
| 401 | mItems.add(new LogoutAction()); |
Alex Chau | 0445885 | 2017-11-27 18:21:23 +0000 | [diff] [blame] | 402 | } |
Wesley.CW Wang | a9de792 | 2018-07-06 15:26:21 +0800 | [diff] [blame] | 403 | } else if (GLOBAL_ACTION_KEY_EMERGENCY.equals(actionKey)) { |
Aaron Heuckroth | c834340 | 2019-03-13 16:27:15 -0400 | [diff] [blame] | 404 | if (!mEmergencyAffordanceManager.needsEmergencyAffordance()) { |
Wesley.CW Wang | a9de792 | 2018-07-06 15:26:21 +0800 | [diff] [blame] | 405 | mItems.add(new EmergencyDialerAction()); |
| 406 | } |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 407 | } else { |
| 408 | Log.e(TAG, "Invalid global action key " + actionKey); |
| 409 | } |
| 410 | // Add here so we don't add more than one. |
| 411 | addedKeys.add(actionKey); |
| 412 | } |
| 413 | |
| 414 | if (mEmergencyAffordanceManager.needsEmergencyAffordance()) { |
Aaron Heuckroth | c834340 | 2019-03-13 16:27:15 -0400 | [diff] [blame] | 415 | mItems.add(new EmergencyAffordanceAction()); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | mAdapter = new MyAdapter(); |
| 419 | |
Steve Elliott | 9b87a44 | 2019-03-05 10:24:16 -0500 | [diff] [blame] | 420 | GlobalActionsPanelPlugin.PanelViewController panelViewController = |
Steve Elliott | a3f520792 | 2019-03-18 13:37:22 -0400 | [diff] [blame] | 421 | mPanelPlugin != null |
| 422 | ? mPanelPlugin.onPanelShown( |
Steve Elliott | 4c86885 | 2019-03-14 16:25:41 -0400 | [diff] [blame] | 423 | new GlobalActionsPanelPlugin.Callbacks() { |
| 424 | @Override |
| 425 | public void dismissGlobalActionsMenu() { |
Steve Elliott | c3147e2 | 2019-11-20 19:34:57 -0500 | [diff] [blame] | 426 | dismissDialog(); |
Steve Elliott | 4c86885 | 2019-03-14 16:25:41 -0400 | [diff] [blame] | 427 | } |
| 428 | |
| 429 | @Override |
| 430 | public void startPendingIntentDismissingKeyguard( |
| 431 | PendingIntent intent) { |
| 432 | mActivityStarter |
| 433 | .startPendingIntentDismissingKeyguard(intent); |
| 434 | } |
Steve Elliott | e2a2e9b | 2019-04-30 21:31:03 -0400 | [diff] [blame] | 435 | }, |
Fabian Kozynski | f6063ae | 2020-02-24 16:14:35 -0500 | [diff] [blame] | 436 | !mKeyguardStateController.isUnlocked()) |
Steve Elliott | 9b87a44 | 2019-03-05 10:24:16 -0500 | [diff] [blame] | 437 | : null; |
Steve Elliott | 02bbaaa | 2019-05-01 16:55:33 -0400 | [diff] [blame] | 438 | |
Lucas Dupin | 991415e | 2019-11-25 17:48:58 -0800 | [diff] [blame] | 439 | ActionsDialog dialog = new ActionsDialog(mContext, mAdapter, panelViewController, |
| 440 | mBlurUtils, mSysuiColorExtractor, mStatusBarService, |
Matt Pietal | 2223179 | 2020-01-23 09:51:09 -0500 | [diff] [blame] | 441 | mNotificationShadeWindowController, |
Matt Pietal | e0661b6 | 2020-01-29 14:35:31 -0500 | [diff] [blame] | 442 | shouldShowControls() ? mControlsUiController : null); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 443 | dialog.setCanceledOnTouchOutside(false); // Handled by the custom class. |
Lucas Dupin | c1cc759 | 2017-05-22 15:56:16 -0700 | [diff] [blame] | 444 | dialog.setKeyguardShowing(mKeyguardShowing); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 445 | |
| 446 | dialog.setOnDismissListener(this); |
Shaotang Li | 786da90 | 2018-08-02 11:18:00 +0800 | [diff] [blame] | 447 | dialog.setOnShowListener(this); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 448 | |
| 449 | return dialog; |
| 450 | } |
| 451 | |
Chad Brubaker | f4075fe | 2018-01-03 13:23:22 -0800 | [diff] [blame] | 452 | private boolean shouldDisplayLockdown() { |
Chad Brubaker | f4075fe | 2018-01-03 13:23:22 -0800 | [diff] [blame] | 453 | // Lockdown is meaningless without a place to go. |
Fabian Kozynski | f6063ae | 2020-02-24 16:14:35 -0500 | [diff] [blame] | 454 | if (!mKeyguardStateController.isMethodSecure()) { |
Chad Brubaker | f4075fe | 2018-01-03 13:23:22 -0800 | [diff] [blame] | 455 | return false; |
| 456 | } |
| 457 | |
Fabian Kozynski | f6063ae | 2020-02-24 16:14:35 -0500 | [diff] [blame] | 458 | int userId = getCurrentUser().id; |
Chad Brubaker | f4075fe | 2018-01-03 13:23:22 -0800 | [diff] [blame] | 459 | // Only show the lockdown button if the device isn't locked down (for whatever reason). |
| 460 | int state = mLockPatternUtils.getStrongAuthForUser(userId); |
| 461 | return (state == STRONG_AUTH_NOT_REQUIRED |
| 462 | || state == SOME_AUTH_REQUIRED_AFTER_USER_REQUEST); |
| 463 | } |
| 464 | |
Lucas Dupin | e5b7dc7 | 2018-10-02 15:18:05 -0700 | [diff] [blame] | 465 | @Override |
| 466 | public void onUiModeChanged() { |
| 467 | mContext.getTheme().applyStyle(mContext.getThemeResId(), true); |
Lucas Dupin | a4e12ba | 2019-04-18 11:56:28 -0700 | [diff] [blame] | 468 | if (mDialog != null && mDialog.isShowing()) { |
Aaron Heuckroth | 4ef3a54 | 2019-04-01 14:17:23 -0400 | [diff] [blame] | 469 | mDialog.refreshDialog(); |
| 470 | } |
Lucas Dupin | e5b7dc7 | 2018-10-02 15:18:05 -0700 | [diff] [blame] | 471 | } |
| 472 | |
| 473 | public void destroy() { |
Dave Mankoff | 8df818e | 2020-02-12 14:22:26 -0500 | [diff] [blame] | 474 | mConfigurationController.removeCallback(this); |
Lucas Dupin | e5b7dc7 | 2018-10-02 15:18:05 -0700 | [diff] [blame] | 475 | } |
| 476 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 477 | private final class PowerAction extends SinglePressAction implements LongPressAction { |
| 478 | private PowerAction() { |
| 479 | super(R.drawable.ic_lock_power_off, |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 480 | R.string.global_action_power_off); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 481 | } |
| 482 | |
| 483 | @Override |
| 484 | public boolean onLongPress() { |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 485 | if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) { |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 486 | mWindowManagerFuncs.reboot(true); |
| 487 | return true; |
| 488 | } |
| 489 | return false; |
| 490 | } |
| 491 | |
| 492 | @Override |
| 493 | public boolean showDuringKeyguard() { |
| 494 | return true; |
| 495 | } |
| 496 | |
| 497 | @Override |
| 498 | public boolean showBeforeProvisioning() { |
| 499 | return true; |
| 500 | } |
| 501 | |
| 502 | @Override |
| 503 | public void onPress() { |
| 504 | // shutdown by making sure radio and power are handled accordingly. |
| 505 | mWindowManagerFuncs.shutdown(); |
| 506 | } |
| 507 | } |
| 508 | |
Aaron Heuckroth | c834340 | 2019-03-13 16:27:15 -0400 | [diff] [blame] | 509 | private abstract class EmergencyAction extends SinglePressAction { |
| 510 | EmergencyAction(int iconResId, int messageResId) { |
| 511 | super(iconResId, messageResId); |
| 512 | } |
| 513 | |
| 514 | @Override |
| 515 | public boolean shouldBeSeparated() { |
Aran Ink | 780d450 | 2020-02-14 10:39:58 -0500 | [diff] [blame] | 516 | return true; |
Aaron Heuckroth | c834340 | 2019-03-13 16:27:15 -0400 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | @Override |
| 520 | public View create( |
| 521 | Context context, View convertView, ViewGroup parent, LayoutInflater inflater) { |
| 522 | View v = super.create(context, convertView, parent, inflater); |
| 523 | int textColor; |
| 524 | if (shouldBeSeparated()) { |
| 525 | textColor = v.getResources().getColor( |
| 526 | com.android.systemui.R.color.global_actions_alert_text); |
| 527 | } else { |
| 528 | textColor = v.getResources().getColor( |
| 529 | com.android.systemui.R.color.global_actions_text); |
| 530 | } |
| 531 | TextView messageView = v.findViewById(R.id.message); |
| 532 | messageView.setTextColor(textColor); |
Aaron Heuckroth | 3f2d8b5 | 2019-04-05 13:27:51 -0400 | [diff] [blame] | 533 | messageView.setSelected(true); // necessary for marquee to work |
Aaron Heuckroth | c834340 | 2019-03-13 16:27:15 -0400 | [diff] [blame] | 534 | ImageView icon = (ImageView) v.findViewById(R.id.icon); |
| 535 | icon.getDrawable().setTint(textColor); |
| 536 | return v; |
| 537 | } |
| 538 | |
| 539 | @Override |
| 540 | public boolean showDuringKeyguard() { |
| 541 | return true; |
| 542 | } |
| 543 | |
| 544 | @Override |
| 545 | public boolean showBeforeProvisioning() { |
| 546 | return true; |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | private class EmergencyAffordanceAction extends EmergencyAction { |
| 551 | EmergencyAffordanceAction() { |
| 552 | super(R.drawable.emergency_icon, |
| 553 | R.string.global_action_emergency); |
| 554 | } |
| 555 | |
| 556 | @Override |
| 557 | public void onPress() { |
| 558 | mEmergencyAffordanceManager.performEmergencyCall(); |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | private class EmergencyDialerAction extends EmergencyAction { |
Wesley.CW Wang | a9de792 | 2018-07-06 15:26:21 +0800 | [diff] [blame] | 563 | private EmergencyDialerAction() { |
Aran Ink | 5019526 | 2019-05-30 10:55:37 -0400 | [diff] [blame] | 564 | super(com.android.systemui.R.drawable.ic_emergency_star, |
Wesley.CW Wang | 3004fcb | 2018-06-15 16:24:57 +0800 | [diff] [blame] | 565 | R.string.global_action_emergency); |
Wesley.CW Wang | 8d07276 | 2018-05-28 16:39:27 +0800 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | @Override |
| 569 | public void onPress() { |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 570 | mMetricsLogger.action(MetricsEvent.ACTION_EMERGENCY_DIALER_FROM_POWER_MENU); |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 571 | if (mTelecomManager != null) { |
| 572 | Intent intent = mTelecomManager.createLaunchEmergencyDialerIntent( |
| 573 | null /* number */); |
| 574 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 575 | | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS |
| 576 | | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| 577 | intent.putExtra(EmergencyDialerConstants.EXTRA_ENTRY_TYPE, |
| 578 | EmergencyDialerConstants.ENTRY_TYPE_POWER_MENU); |
| 579 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
| 580 | } |
Wesley.CW Wang | 8d07276 | 2018-05-28 16:39:27 +0800 | [diff] [blame] | 581 | } |
Wesley.CW Wang | 8d07276 | 2018-05-28 16:39:27 +0800 | [diff] [blame] | 582 | } |
| 583 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 584 | private final class RestartAction extends SinglePressAction implements LongPressAction { |
| 585 | private RestartAction() { |
| 586 | super(R.drawable.ic_restart, R.string.global_action_restart); |
| 587 | } |
| 588 | |
| 589 | @Override |
| 590 | public boolean onLongPress() { |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 591 | if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) { |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 592 | mWindowManagerFuncs.reboot(true); |
| 593 | return true; |
| 594 | } |
| 595 | return false; |
| 596 | } |
| 597 | |
| 598 | @Override |
| 599 | public boolean showDuringKeyguard() { |
| 600 | return true; |
| 601 | } |
| 602 | |
| 603 | @Override |
| 604 | public boolean showBeforeProvisioning() { |
| 605 | return true; |
| 606 | } |
| 607 | |
| 608 | @Override |
| 609 | public void onPress() { |
| 610 | mWindowManagerFuncs.reboot(false); |
| 611 | } |
| 612 | } |
| 613 | |
Beth Thibodeau | 5898ac4 | 2018-10-26 13:00:09 -0400 | [diff] [blame] | 614 | private class ScreenshotAction extends SinglePressAction implements LongPressAction { |
Alison Cichowlas | a2cd19e | 2017-12-06 10:51:21 -0500 | [diff] [blame] | 615 | public ScreenshotAction() { |
| 616 | super(R.drawable.ic_screenshot, R.string.global_action_screenshot); |
| 617 | } |
| 618 | |
| 619 | @Override |
| 620 | public void onPress() { |
| 621 | // Add a little delay before executing, to give the |
| 622 | // dialog a chance to go away before it takes a |
| 623 | // screenshot. |
| 624 | // TODO: instead, omit global action dialog layer |
| 625 | mHandler.postDelayed(new Runnable() { |
| 626 | @Override |
| 627 | public void run() { |
James O'Leary | fa5bb7a | 2019-09-05 13:43:29 -0400 | [diff] [blame] | 628 | mScreenshotHelper.takeScreenshot(1, true, true, mHandler, null); |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 629 | mMetricsLogger.action(MetricsEvent.ACTION_SCREENSHOT_POWER_MENU); |
Alison Cichowlas | a2cd19e | 2017-12-06 10:51:21 -0500 | [diff] [blame] | 630 | } |
| 631 | }, 500); |
| 632 | } |
| 633 | |
| 634 | @Override |
| 635 | public boolean showDuringKeyguard() { |
| 636 | return true; |
| 637 | } |
| 638 | |
| 639 | @Override |
| 640 | public boolean showBeforeProvisioning() { |
| 641 | return false; |
| 642 | } |
Beth Thibodeau | 5898ac4 | 2018-10-26 13:00:09 -0400 | [diff] [blame] | 643 | |
| 644 | @Override |
| 645 | public boolean onLongPress() { |
| 646 | if (FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SCREENRECORD_LONG_PRESS)) { |
| 647 | mScreenRecordHelper.launchRecordPrompt(); |
| 648 | } else { |
| 649 | onPress(); |
| 650 | } |
| 651 | return true; |
| 652 | } |
Alison Cichowlas | a2cd19e | 2017-12-06 10:51:21 -0500 | [diff] [blame] | 653 | } |
| 654 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 655 | private class BugReportAction extends SinglePressAction implements LongPressAction { |
| 656 | |
| 657 | public BugReportAction() { |
| 658 | super(R.drawable.ic_lock_bugreport, R.string.bugreport_title); |
| 659 | } |
| 660 | |
| 661 | @Override |
| 662 | public void onPress() { |
| 663 | // don't actually trigger the bugreport if we are running stability |
| 664 | // tests via monkey |
| 665 | if (ActivityManager.isUserAMonkey()) { |
| 666 | return; |
| 667 | } |
| 668 | // Add a little delay before executing, to give the |
| 669 | // dialog a chance to go away before it takes a |
| 670 | // screenshot. |
| 671 | mHandler.postDelayed(new Runnable() { |
| 672 | @Override |
| 673 | public void run() { |
| 674 | try { |
| 675 | // Take an "interactive" bugreport. |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 676 | mMetricsLogger.action( |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 677 | MetricsEvent.ACTION_BUGREPORT_FROM_POWER_MENU_INTERACTIVE); |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 678 | if (!mIActivityManager.launchBugReportHandlerApp()) { |
Paul Chang | c40f578 | 2019-11-04 18:55:31 +0800 | [diff] [blame] | 679 | Log.w(TAG, "Bugreport handler could not be launched"); |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 680 | mIActivityManager.requestInteractiveBugReport(); |
Paul Chang | c40f578 | 2019-11-04 18:55:31 +0800 | [diff] [blame] | 681 | } |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 682 | } catch (RemoteException e) { |
| 683 | } |
| 684 | } |
| 685 | }, 500); |
| 686 | } |
| 687 | |
| 688 | @Override |
| 689 | public boolean onLongPress() { |
| 690 | // don't actually trigger the bugreport if we are running stability |
| 691 | // tests via monkey |
| 692 | if (ActivityManager.isUserAMonkey()) { |
| 693 | return false; |
| 694 | } |
| 695 | try { |
| 696 | // Take a "full" bugreport. |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 697 | mMetricsLogger.action(MetricsEvent.ACTION_BUGREPORT_FROM_POWER_MENU_FULL); |
| 698 | mIActivityManager.requestFullBugReport(); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 699 | } catch (RemoteException e) { |
| 700 | } |
| 701 | return false; |
| 702 | } |
| 703 | |
| 704 | public boolean showDuringKeyguard() { |
| 705 | return true; |
| 706 | } |
| 707 | |
| 708 | @Override |
| 709 | public boolean showBeforeProvisioning() { |
| 710 | return false; |
| 711 | } |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 712 | } |
| 713 | |
Alex Chau | 0445885 | 2017-11-27 18:21:23 +0000 | [diff] [blame] | 714 | private final class LogoutAction extends SinglePressAction { |
| 715 | private LogoutAction() { |
| 716 | super(R.drawable.ic_logout, R.string.global_action_logout); |
| 717 | } |
| 718 | |
| 719 | @Override |
| 720 | public boolean showDuringKeyguard() { |
| 721 | return true; |
| 722 | } |
| 723 | |
| 724 | @Override |
| 725 | public boolean showBeforeProvisioning() { |
| 726 | return false; |
| 727 | } |
| 728 | |
| 729 | @Override |
| 730 | public void onPress() { |
| 731 | // Add a little delay before executing, to give the dialog a chance to go away before |
| 732 | // switching user |
| 733 | mHandler.postDelayed(() -> { |
| 734 | try { |
Alex Chau | edb6a01 | 2018-01-26 12:52:43 +0000 | [diff] [blame] | 735 | int currentUserId = getCurrentUser().id; |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 736 | mIActivityManager.switchUser(UserHandle.USER_SYSTEM); |
| 737 | mIActivityManager.stopUser(currentUserId, true /*force*/, null); |
Alex Chau | 0445885 | 2017-11-27 18:21:23 +0000 | [diff] [blame] | 738 | } catch (RemoteException re) { |
| 739 | Log.e(TAG, "Couldn't logout user " + re); |
| 740 | } |
| 741 | }, 500); |
| 742 | } |
| 743 | } |
| 744 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 745 | private Action getSettingsAction() { |
| 746 | return new SinglePressAction(R.drawable.ic_settings, |
| 747 | R.string.global_action_settings) { |
| 748 | |
| 749 | @Override |
| 750 | public void onPress() { |
| 751 | Intent intent = new Intent(Settings.ACTION_SETTINGS); |
| 752 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| 753 | mContext.startActivity(intent); |
| 754 | } |
| 755 | |
| 756 | @Override |
| 757 | public boolean showDuringKeyguard() { |
| 758 | return true; |
| 759 | } |
| 760 | |
| 761 | @Override |
| 762 | public boolean showBeforeProvisioning() { |
| 763 | return true; |
| 764 | } |
| 765 | }; |
| 766 | } |
| 767 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 768 | private Action getAssistAction() { |
| 769 | return new SinglePressAction(R.drawable.ic_action_assist_focused, |
| 770 | R.string.global_action_assist) { |
| 771 | @Override |
| 772 | public void onPress() { |
| 773 | Intent intent = new Intent(Intent.ACTION_ASSIST); |
| 774 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| 775 | mContext.startActivity(intent); |
| 776 | } |
| 777 | |
| 778 | @Override |
| 779 | public boolean showDuringKeyguard() { |
| 780 | return true; |
| 781 | } |
| 782 | |
| 783 | @Override |
| 784 | public boolean showBeforeProvisioning() { |
| 785 | return true; |
| 786 | } |
| 787 | }; |
| 788 | } |
| 789 | |
| 790 | private Action getVoiceAssistAction() { |
| 791 | return new SinglePressAction(R.drawable.ic_voice_search, |
| 792 | R.string.global_action_voice_assist) { |
| 793 | @Override |
| 794 | public void onPress() { |
| 795 | Intent intent = new Intent(Intent.ACTION_VOICE_ASSIST); |
| 796 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| 797 | mContext.startActivity(intent); |
| 798 | } |
| 799 | |
| 800 | @Override |
| 801 | public boolean showDuringKeyguard() { |
| 802 | return true; |
| 803 | } |
| 804 | |
| 805 | @Override |
| 806 | public boolean showBeforeProvisioning() { |
| 807 | return true; |
| 808 | } |
| 809 | }; |
| 810 | } |
| 811 | |
| 812 | private Action getLockdownAction() { |
Alison Cichowlas | 2112543 | 2018-05-16 15:40:45 -0400 | [diff] [blame] | 813 | return new SinglePressAction(R.drawable.ic_lock_lockdown, |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 814 | R.string.global_action_lockdown) { |
| 815 | |
| 816 | @Override |
| 817 | public void onPress() { |
Dave Mankoff | 8df818e | 2020-02-12 14:22:26 -0500 | [diff] [blame] | 818 | mLockPatternUtils.requireStrongAuth(STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN, |
| 819 | UserHandle.USER_ALL); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 820 | try { |
Dave Mankoff | 8df818e | 2020-02-12 14:22:26 -0500 | [diff] [blame] | 821 | mIWindowManager.lockNow(null); |
Pavel Grafov | 059021b | 2018-05-02 13:44:46 +0100 | [diff] [blame] | 822 | // Lock profiles (if any) on the background thread. |
Dave Mankoff | 8df818e | 2020-02-12 14:22:26 -0500 | [diff] [blame] | 823 | mBackgroundExecutor.execute(() -> lockProfiles()); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 824 | } catch (RemoteException e) { |
| 825 | Log.e(TAG, "Error while trying to lock device.", e); |
| 826 | } |
| 827 | } |
| 828 | |
| 829 | @Override |
| 830 | public boolean showDuringKeyguard() { |
| 831 | return true; |
| 832 | } |
| 833 | |
| 834 | @Override |
| 835 | public boolean showBeforeProvisioning() { |
| 836 | return false; |
| 837 | } |
| 838 | }; |
| 839 | } |
| 840 | |
Pavel Grafov | 059021b | 2018-05-02 13:44:46 +0100 | [diff] [blame] | 841 | private void lockProfiles() { |
Pavel Grafov | 059021b | 2018-05-02 13:44:46 +0100 | [diff] [blame] | 842 | final int currentUserId = getCurrentUser().id; |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 843 | final int[] profileIds = mUserManager.getEnabledProfileIds(currentUserId); |
Pavel Grafov | 059021b | 2018-05-02 13:44:46 +0100 | [diff] [blame] | 844 | for (final int id : profileIds) { |
| 845 | if (id != currentUserId) { |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 846 | mTrustManager.setDeviceLockedForUser(id, true); |
Pavel Grafov | 059021b | 2018-05-02 13:44:46 +0100 | [diff] [blame] | 847 | } |
| 848 | } |
| 849 | } |
| 850 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 851 | private UserInfo getCurrentUser() { |
| 852 | try { |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 853 | return mIActivityManager.getCurrentUser(); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 854 | } catch (RemoteException re) { |
| 855 | return null; |
| 856 | } |
| 857 | } |
| 858 | |
| 859 | private boolean isCurrentUserOwner() { |
| 860 | UserInfo currentUser = getCurrentUser(); |
| 861 | return currentUser == null || currentUser.isPrimary(); |
| 862 | } |
| 863 | |
| 864 | private void addUsersToMenu(ArrayList<Action> items) { |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 865 | if (mUserManager.isUserSwitcherEnabled()) { |
| 866 | List<UserInfo> users = mUserManager.getUsers(); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 867 | UserInfo currentUser = getCurrentUser(); |
| 868 | for (final UserInfo user : users) { |
| 869 | if (user.supportsSwitchToByUser()) { |
| 870 | boolean isCurrentUser = currentUser == null |
| 871 | ? user.id == 0 : (currentUser.id == user.id); |
| 872 | Drawable icon = user.iconPath != null ? Drawable.createFromPath(user.iconPath) |
| 873 | : null; |
| 874 | SinglePressAction switchToUser = new SinglePressAction( |
| 875 | R.drawable.ic_menu_cc, icon, |
| 876 | (user.name != null ? user.name : "Primary") |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 877 | + (isCurrentUser ? " \u2714" : "")) { |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 878 | public void onPress() { |
| 879 | try { |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 880 | mIActivityManager.switchUser(user.id); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 881 | } catch (RemoteException re) { |
| 882 | Log.e(TAG, "Couldn't switch user " + re); |
| 883 | } |
| 884 | } |
| 885 | |
| 886 | public boolean showDuringKeyguard() { |
| 887 | return true; |
| 888 | } |
| 889 | |
| 890 | public boolean showBeforeProvisioning() { |
| 891 | return false; |
| 892 | } |
| 893 | }; |
| 894 | items.add(switchToUser); |
| 895 | } |
| 896 | } |
| 897 | } |
| 898 | } |
| 899 | |
| 900 | private void prepareDialog() { |
| 901 | refreshSilentMode(); |
| 902 | mAirplaneModeOn.updateState(mAirplaneState); |
| 903 | mAdapter.notifyDataSetChanged(); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 904 | if (mShowSilentToggle) { |
| 905 | IntentFilter filter = new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION); |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 906 | mBroadcastDispatcher.registerReceiver(mRingerModeReceiver, filter); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 907 | } |
| 908 | } |
| 909 | |
| 910 | private void refreshSilentMode() { |
| 911 | if (!mHasVibrator) { |
| 912 | final boolean silentModeOn = |
| 913 | mAudioManager.getRingerMode() != AudioManager.RINGER_MODE_NORMAL; |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 914 | ((ToggleAction) mSilentModeAction).updateState( |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 915 | silentModeOn ? ToggleAction.State.On : ToggleAction.State.Off); |
| 916 | } |
| 917 | } |
| 918 | |
| 919 | /** {@inheritDoc} */ |
| 920 | public void onDismiss(DialogInterface dialog) { |
Steve Elliott | c3147e2 | 2019-11-20 19:34:57 -0500 | [diff] [blame] | 921 | if (mDialog == dialog) { |
| 922 | mDialog = null; |
| 923 | } |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 924 | mWindowManagerFuncs.onGlobalActionsHidden(); |
| 925 | if (mShowSilentToggle) { |
| 926 | try { |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 927 | mBroadcastDispatcher.unregisterReceiver(mRingerModeReceiver); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 928 | } catch (IllegalArgumentException ie) { |
| 929 | // ignore this |
| 930 | Log.w(TAG, ie); |
| 931 | } |
| 932 | } |
| 933 | } |
| 934 | |
| 935 | /** {@inheritDoc} */ |
Shaotang Li | 786da90 | 2018-08-02 11:18:00 +0800 | [diff] [blame] | 936 | public void onShow(DialogInterface dialog) { |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 937 | mMetricsLogger.visible(MetricsEvent.POWER_MENU); |
Shaotang Li | 786da90 | 2018-08-02 11:18:00 +0800 | [diff] [blame] | 938 | } |
| 939 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 940 | /** |
| 941 | * The adapter used for the list within the global actions dialog, taking |
| 942 | * into account whether the keyguard is showing via |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 943 | * {@link com.android.systemui.globalactions.GlobalActionsDialog#mKeyguardShowing} and whether |
| 944 | * the device is provisioned |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 945 | * via {@link com.android.systemui.globalactions.GlobalActionsDialog#mDeviceProvisioned}. |
| 946 | */ |
Aaron Heuckroth | 57d60d2 | 2019-03-05 14:00:12 -0500 | [diff] [blame] | 947 | public class MyAdapter extends MultiListAdapter { |
Aaron Heuckroth | 5e28f8c8 | 2019-04-24 13:26:12 -0400 | [diff] [blame] | 948 | private int countItems(boolean separated) { |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 949 | int count = 0; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 950 | for (int i = 0; i < mItems.size(); i++) { |
| 951 | final Action action = mItems.get(i); |
| 952 | |
Aaron Heuckroth | 5e28f8c8 | 2019-04-24 13:26:12 -0400 | [diff] [blame] | 953 | if (shouldBeShown(action) && action.shouldBeSeparated() == separated) { |
| 954 | count++; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 955 | } |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 956 | } |
| 957 | return count; |
| 958 | } |
| 959 | |
Aaron Heuckroth | 5e28f8c8 | 2019-04-24 13:26:12 -0400 | [diff] [blame] | 960 | private boolean shouldBeShown(Action action) { |
| 961 | if (mKeyguardShowing && !action.showDuringKeyguard()) { |
| 962 | return false; |
| 963 | } |
| 964 | if (!mDeviceProvisioned && !action.showBeforeProvisioning()) { |
| 965 | return false; |
| 966 | } |
| 967 | return true; |
| 968 | } |
| 969 | |
| 970 | @Override |
| 971 | public int countSeparatedItems() { |
| 972 | return countItems(true); |
| 973 | } |
| 974 | |
| 975 | @Override |
| 976 | public int countListItems() { |
| 977 | return countItems(false); |
| 978 | } |
| 979 | |
| 980 | @Override |
| 981 | public int getCount() { |
| 982 | return countSeparatedItems() + countListItems(); |
| 983 | } |
| 984 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 985 | @Override |
| 986 | public boolean isEnabled(int position) { |
| 987 | return getItem(position).isEnabled(); |
| 988 | } |
| 989 | |
Aaron Heuckroth | 57d60d2 | 2019-03-05 14:00:12 -0500 | [diff] [blame] | 990 | @Override |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 991 | public boolean areAllItemsEnabled() { |
| 992 | return false; |
| 993 | } |
| 994 | |
Aaron Heuckroth | 57d60d2 | 2019-03-05 14:00:12 -0500 | [diff] [blame] | 995 | @Override |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 996 | public Action getItem(int position) { |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 997 | int filteredPos = 0; |
| 998 | for (int i = 0; i < mItems.size(); i++) { |
| 999 | final Action action = mItems.get(i); |
Aaron Heuckroth | 5e28f8c8 | 2019-04-24 13:26:12 -0400 | [diff] [blame] | 1000 | if (!shouldBeShown(action)) { |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1001 | continue; |
| 1002 | } |
| 1003 | if (filteredPos == position) { |
| 1004 | return action; |
| 1005 | } |
| 1006 | filteredPos++; |
| 1007 | } |
| 1008 | |
| 1009 | throw new IllegalArgumentException("position " + position |
| 1010 | + " out of range of showable actions" |
| 1011 | + ", filtered count=" + getCount() |
| 1012 | + ", keyguardshowing=" + mKeyguardShowing |
| 1013 | + ", provisioned=" + mDeviceProvisioned); |
| 1014 | } |
| 1015 | |
| 1016 | |
| 1017 | public long getItemId(int position) { |
| 1018 | return position; |
| 1019 | } |
| 1020 | |
Aaron Heuckroth | 57d60d2 | 2019-03-05 14:00:12 -0500 | [diff] [blame] | 1021 | @Override |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1022 | public View getView(int position, View convertView, ViewGroup parent) { |
| 1023 | Action action = getItem(position); |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1024 | View view = action.create(mContext, convertView, parent, LayoutInflater.from(mContext)); |
Aaron Heuckroth | 5e28f8c8 | 2019-04-24 13:26:12 -0400 | [diff] [blame] | 1025 | view.setOnClickListener(v -> onClickItem(position)); |
Aran Ink | b4199d9 | 2020-02-07 13:25:21 -0500 | [diff] [blame] | 1026 | if (action instanceof LongPressAction) { |
| 1027 | view.setOnLongClickListener(v -> onLongClickItem(position)); |
| 1028 | } |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1029 | return view; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1030 | } |
Aaron Heuckroth | 57d60d2 | 2019-03-05 14:00:12 -0500 | [diff] [blame] | 1031 | |
| 1032 | @Override |
| 1033 | public boolean onLongClickItem(int position) { |
| 1034 | final Action action = mAdapter.getItem(position); |
| 1035 | if (action instanceof LongPressAction) { |
Aran Ink | baa2586 | 2019-06-11 15:48:55 -0400 | [diff] [blame] | 1036 | if (mDialog != null) { |
| 1037 | mDialog.dismiss(); |
| 1038 | } else { |
| 1039 | Log.w(TAG, "Action long-clicked while mDialog is null."); |
| 1040 | } |
Aaron Heuckroth | 57d60d2 | 2019-03-05 14:00:12 -0500 | [diff] [blame] | 1041 | return ((LongPressAction) action).onLongPress(); |
| 1042 | } |
| 1043 | return false; |
| 1044 | } |
| 1045 | |
| 1046 | @Override |
| 1047 | public void onClickItem(int position) { |
| 1048 | Action item = mAdapter.getItem(position); |
| 1049 | if (!(item instanceof SilentModeTriStateAction)) { |
Aran Ink | baa2586 | 2019-06-11 15:48:55 -0400 | [diff] [blame] | 1050 | if (mDialog != null) { |
| 1051 | mDialog.dismiss(); |
| 1052 | } else { |
| 1053 | Log.w(TAG, "Action clicked while mDialog is null."); |
| 1054 | } |
| 1055 | item.onPress(); |
Aaron Heuckroth | 57d60d2 | 2019-03-05 14:00:12 -0500 | [diff] [blame] | 1056 | } |
Aaron Heuckroth | 57d60d2 | 2019-03-05 14:00:12 -0500 | [diff] [blame] | 1057 | } |
Aaron Heuckroth | 5e28f8c8 | 2019-04-24 13:26:12 -0400 | [diff] [blame] | 1058 | |
| 1059 | @Override |
| 1060 | public boolean shouldBeSeparated(int position) { |
| 1061 | return getItem(position).shouldBeSeparated(); |
| 1062 | } |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1063 | } |
| 1064 | |
| 1065 | // note: the scheme below made more sense when we were planning on having |
| 1066 | // 8 different things in the global actions dialog. seems overkill with |
| 1067 | // only 3 items now, but may as well keep this flexible approach so it will |
| 1068 | // be easy should someone decide at the last minute to include something |
| 1069 | // else, such as 'enable wifi', or 'enable bluetooth' |
| 1070 | |
| 1071 | /** |
| 1072 | * What each item in the global actions dialog must be able to support. |
| 1073 | */ |
Aaron Heuckroth | 57d60d2 | 2019-03-05 14:00:12 -0500 | [diff] [blame] | 1074 | public interface Action { |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1075 | /** |
| 1076 | * @return Text that will be announced when dialog is created. null |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1077 | * for none. |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1078 | */ |
| 1079 | CharSequence getLabelForAccessibility(Context context); |
| 1080 | |
| 1081 | View create(Context context, View convertView, ViewGroup parent, LayoutInflater inflater); |
| 1082 | |
| 1083 | void onPress(); |
| 1084 | |
| 1085 | /** |
| 1086 | * @return whether this action should appear in the dialog when the keygaurd |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1087 | * is showing. |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1088 | */ |
| 1089 | boolean showDuringKeyguard(); |
| 1090 | |
| 1091 | /** |
| 1092 | * @return whether this action should appear in the dialog before the |
Aaron Heuckroth | 57d60d2 | 2019-03-05 14:00:12 -0500 | [diff] [blame] | 1093 | * device is provisioned.onlongpress |
| 1094 | * |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1095 | */ |
| 1096 | boolean showBeforeProvisioning(); |
| 1097 | |
| 1098 | boolean isEnabled(); |
Aaron Heuckroth | f708d47 | 2019-01-10 16:54:51 -0500 | [diff] [blame] | 1099 | |
| 1100 | default boolean shouldBeSeparated() { |
| 1101 | return false; |
| 1102 | } |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1103 | } |
| 1104 | |
| 1105 | /** |
| 1106 | * An action that also supports long press. |
| 1107 | */ |
| 1108 | private interface LongPressAction extends Action { |
| 1109 | boolean onLongPress(); |
| 1110 | } |
| 1111 | |
| 1112 | /** |
| 1113 | * A single press action maintains no state, just responds to a press |
| 1114 | * and takes an action. |
| 1115 | */ |
Matt Pietal | e0661b6 | 2020-01-29 14:35:31 -0500 | [diff] [blame] | 1116 | |
| 1117 | private abstract class SinglePressAction implements Action { |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1118 | private final int mIconResId; |
| 1119 | private final Drawable mIcon; |
| 1120 | private final int mMessageResId; |
| 1121 | private final CharSequence mMessage; |
| 1122 | |
| 1123 | protected SinglePressAction(int iconResId, int messageResId) { |
| 1124 | mIconResId = iconResId; |
| 1125 | mMessageResId = messageResId; |
| 1126 | mMessage = null; |
| 1127 | mIcon = null; |
| 1128 | } |
| 1129 | |
| 1130 | protected SinglePressAction(int iconResId, Drawable icon, CharSequence message) { |
| 1131 | mIconResId = iconResId; |
| 1132 | mMessageResId = 0; |
| 1133 | mMessage = message; |
| 1134 | mIcon = icon; |
| 1135 | } |
| 1136 | |
| 1137 | public boolean isEnabled() { |
| 1138 | return true; |
| 1139 | } |
| 1140 | |
| 1141 | public String getStatus() { |
| 1142 | return null; |
| 1143 | } |
| 1144 | |
| 1145 | abstract public void onPress(); |
| 1146 | |
| 1147 | public CharSequence getLabelForAccessibility(Context context) { |
| 1148 | if (mMessage != null) { |
| 1149 | return mMessage; |
| 1150 | } else { |
| 1151 | return context.getString(mMessageResId); |
| 1152 | } |
| 1153 | } |
| 1154 | |
Aaron Heuckroth | 166392f | 2019-01-17 16:50:59 -0500 | [diff] [blame] | 1155 | protected int getActionLayoutId(Context context) { |
Matt Pietal | e0661b6 | 2020-01-29 14:35:31 -0500 | [diff] [blame] | 1156 | if (shouldShowControls()) { |
Matt Pietal | fd3b6cb | 2020-01-08 09:43:54 -0500 | [diff] [blame] | 1157 | return com.android.systemui.R.layout.global_actions_grid_item_v2; |
| 1158 | } |
Aaron Heuckroth | c792661 | 2019-04-02 14:21:57 -0400 | [diff] [blame] | 1159 | return com.android.systemui.R.layout.global_actions_grid_item; |
Aaron Heuckroth | 166392f | 2019-01-17 16:50:59 -0500 | [diff] [blame] | 1160 | } |
| 1161 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1162 | public View create( |
| 1163 | Context context, View convertView, ViewGroup parent, LayoutInflater inflater) { |
Aaron Heuckroth | 166392f | 2019-01-17 16:50:59 -0500 | [diff] [blame] | 1164 | View v = inflater.inflate(getActionLayoutId(context), parent, |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1165 | false); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1166 | |
| 1167 | ImageView icon = (ImageView) v.findViewById(R.id.icon); |
| 1168 | TextView messageView = (TextView) v.findViewById(R.id.message); |
Aaron Heuckroth | 3f2d8b5 | 2019-04-05 13:27:51 -0400 | [diff] [blame] | 1169 | messageView.setSelected(true); // necessary for marquee to work |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1170 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1171 | if (mIcon != null) { |
| 1172 | icon.setImageDrawable(mIcon); |
| 1173 | icon.setScaleType(ScaleType.CENTER_CROP); |
| 1174 | } else if (mIconResId != 0) { |
| 1175 | icon.setImageDrawable(context.getDrawable(mIconResId)); |
| 1176 | } |
| 1177 | if (mMessage != null) { |
| 1178 | messageView.setText(mMessage); |
| 1179 | } else { |
| 1180 | messageView.setText(mMessageResId); |
| 1181 | } |
| 1182 | |
| 1183 | return v; |
| 1184 | } |
| 1185 | } |
| 1186 | |
| 1187 | /** |
| 1188 | * A toggle action knows whether it is on or off, and displays an icon |
| 1189 | * and status message accordingly. |
| 1190 | */ |
| 1191 | private static abstract class ToggleAction implements Action { |
| 1192 | |
| 1193 | enum State { |
| 1194 | Off(false), |
| 1195 | TurningOn(true), |
| 1196 | TurningOff(true), |
| 1197 | On(false); |
| 1198 | |
| 1199 | private final boolean inTransition; |
| 1200 | |
| 1201 | State(boolean intermediate) { |
| 1202 | inTransition = intermediate; |
| 1203 | } |
| 1204 | |
| 1205 | public boolean inTransition() { |
| 1206 | return inTransition; |
| 1207 | } |
| 1208 | } |
| 1209 | |
| 1210 | protected State mState = State.Off; |
| 1211 | |
| 1212 | // prefs |
| 1213 | protected int mEnabledIconResId; |
| 1214 | protected int mDisabledIconResid; |
| 1215 | protected int mMessageResId; |
| 1216 | protected int mEnabledStatusMessageResId; |
| 1217 | protected int mDisabledStatusMessageResId; |
| 1218 | |
| 1219 | /** |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1220 | * @param enabledIconResId The icon for when this action is on. |
| 1221 | * @param disabledIconResid The icon for when this action is off. |
| 1222 | * @param message The general information message, e.g 'Silent Mode' |
| 1223 | * @param enabledStatusMessageResId The on status message, e.g 'sound disabled' |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1224 | * @param disabledStatusMessageResId The off status message, e.g. 'sound enabled' |
| 1225 | */ |
| 1226 | public ToggleAction(int enabledIconResId, |
| 1227 | int disabledIconResid, |
| 1228 | int message, |
| 1229 | int enabledStatusMessageResId, |
| 1230 | int disabledStatusMessageResId) { |
| 1231 | mEnabledIconResId = enabledIconResId; |
| 1232 | mDisabledIconResid = disabledIconResid; |
| 1233 | mMessageResId = message; |
| 1234 | mEnabledStatusMessageResId = enabledStatusMessageResId; |
| 1235 | mDisabledStatusMessageResId = disabledStatusMessageResId; |
| 1236 | } |
| 1237 | |
| 1238 | /** |
| 1239 | * Override to make changes to resource IDs just before creating the |
| 1240 | * View. |
| 1241 | */ |
| 1242 | void willCreate() { |
| 1243 | |
| 1244 | } |
| 1245 | |
| 1246 | @Override |
| 1247 | public CharSequence getLabelForAccessibility(Context context) { |
| 1248 | return context.getString(mMessageResId); |
| 1249 | } |
| 1250 | |
| 1251 | public View create(Context context, View convertView, ViewGroup parent, |
| 1252 | LayoutInflater inflater) { |
| 1253 | willCreate(); |
| 1254 | |
Koji Fukui | 5c010ee | 2019-12-24 16:12:07 +0900 | [diff] [blame] | 1255 | View v = inflater.inflate(com.android.systemui.R |
| 1256 | .layout.global_actions_grid_item, parent, false); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1257 | |
| 1258 | ImageView icon = (ImageView) v.findViewById(R.id.icon); |
| 1259 | TextView messageView = (TextView) v.findViewById(R.id.message); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1260 | final boolean enabled = isEnabled(); |
Koji Fukui | 5c010ee | 2019-12-24 16:12:07 +0900 | [diff] [blame] | 1261 | boolean on = ((mState == State.On) || (mState == State.TurningOn)); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1262 | |
| 1263 | if (messageView != null) { |
Koji Fukui | 5c010ee | 2019-12-24 16:12:07 +0900 | [diff] [blame] | 1264 | messageView.setText(on ? mEnabledStatusMessageResId : mDisabledStatusMessageResId); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1265 | messageView.setEnabled(enabled); |
Aaron Heuckroth | 3f2d8b5 | 2019-04-05 13:27:51 -0400 | [diff] [blame] | 1266 | messageView.setSelected(true); // necessary for marquee to work |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1267 | } |
| 1268 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1269 | if (icon != null) { |
| 1270 | icon.setImageDrawable(context.getDrawable( |
| 1271 | (on ? mEnabledIconResId : mDisabledIconResid))); |
| 1272 | icon.setEnabled(enabled); |
| 1273 | } |
| 1274 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1275 | v.setEnabled(enabled); |
| 1276 | |
| 1277 | return v; |
| 1278 | } |
| 1279 | |
| 1280 | public final void onPress() { |
| 1281 | if (mState.inTransition()) { |
| 1282 | Log.w(TAG, "shouldn't be able to toggle when in transition"); |
| 1283 | return; |
| 1284 | } |
| 1285 | |
| 1286 | final boolean nowOn = !(mState == State.On); |
| 1287 | onToggle(nowOn); |
| 1288 | changeStateFromPress(nowOn); |
| 1289 | } |
| 1290 | |
| 1291 | public boolean isEnabled() { |
| 1292 | return !mState.inTransition(); |
| 1293 | } |
| 1294 | |
| 1295 | /** |
| 1296 | * Implementations may override this if their state can be in on of the intermediate |
| 1297 | * states until some notification is received (e.g airplane mode is 'turning off' until |
| 1298 | * we know the wireless connections are back online |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1299 | * |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1300 | * @param buttonOn Whether the button was turned on or off |
| 1301 | */ |
| 1302 | protected void changeStateFromPress(boolean buttonOn) { |
| 1303 | mState = buttonOn ? State.On : State.Off; |
| 1304 | } |
| 1305 | |
| 1306 | abstract void onToggle(boolean on); |
| 1307 | |
| 1308 | public void updateState(State state) { |
| 1309 | mState = state; |
| 1310 | } |
| 1311 | } |
| 1312 | |
Aran Ink | 780d450 | 2020-02-14 10:39:58 -0500 | [diff] [blame] | 1313 | private class AirplaneModeAction extends ToggleAction { |
| 1314 | AirplaneModeAction() { |
| 1315 | super( |
| 1316 | R.drawable.ic_lock_airplane_mode, |
| 1317 | R.drawable.ic_lock_airplane_mode_off, |
| 1318 | R.string.global_actions_toggle_airplane_mode, |
| 1319 | R.string.global_actions_airplane_mode_on_status, |
| 1320 | R.string.global_actions_airplane_mode_off_status); |
| 1321 | } |
| 1322 | void onToggle(boolean on) { |
| 1323 | if (mHasTelephony && TelephonyProperties.in_ecm_mode().orElse(false)) { |
| 1324 | mIsWaitingForEcmExit = true; |
| 1325 | // Launch ECM exit dialog |
| 1326 | Intent ecmDialogIntent = |
| 1327 | new Intent(TelephonyManager.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null); |
| 1328 | ecmDialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 1329 | mContext.startActivity(ecmDialogIntent); |
| 1330 | } else { |
| 1331 | changeAirplaneModeSystemSetting(on); |
| 1332 | } |
| 1333 | } |
| 1334 | |
| 1335 | @Override |
| 1336 | protected void changeStateFromPress(boolean buttonOn) { |
| 1337 | if (!mHasTelephony) return; |
| 1338 | |
| 1339 | // In ECM mode airplane state cannot be changed |
| 1340 | if (!TelephonyProperties.in_ecm_mode().orElse(false)) { |
| 1341 | mState = buttonOn ? State.TurningOn : State.TurningOff; |
| 1342 | mAirplaneState = mState; |
| 1343 | } |
| 1344 | } |
| 1345 | |
| 1346 | public boolean showDuringKeyguard() { |
| 1347 | return true; |
| 1348 | } |
| 1349 | |
| 1350 | public boolean showBeforeProvisioning() { |
| 1351 | return false; |
| 1352 | } |
| 1353 | } |
| 1354 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1355 | private class SilentModeToggleAction extends ToggleAction { |
| 1356 | public SilentModeToggleAction() { |
| 1357 | super(R.drawable.ic_audio_vol_mute, |
| 1358 | R.drawable.ic_audio_vol, |
| 1359 | R.string.global_action_toggle_silent_mode, |
| 1360 | R.string.global_action_silent_mode_on_status, |
| 1361 | R.string.global_action_silent_mode_off_status); |
| 1362 | } |
| 1363 | |
| 1364 | void onToggle(boolean on) { |
| 1365 | if (on) { |
| 1366 | mAudioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT); |
| 1367 | } else { |
| 1368 | mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL); |
| 1369 | } |
| 1370 | } |
| 1371 | |
| 1372 | public boolean showDuringKeyguard() { |
| 1373 | return true; |
| 1374 | } |
| 1375 | |
| 1376 | public boolean showBeforeProvisioning() { |
| 1377 | return false; |
| 1378 | } |
| 1379 | } |
| 1380 | |
| 1381 | private static class SilentModeTriStateAction implements Action, View.OnClickListener { |
| 1382 | |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1383 | private final int[] ITEM_IDS = {R.id.option1, R.id.option2, R.id.option3}; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1384 | |
| 1385 | private final AudioManager mAudioManager; |
| 1386 | private final Handler mHandler; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1387 | |
Lucas Dupin | 40ec6b78 | 2018-06-05 19:07:16 -0700 | [diff] [blame] | 1388 | SilentModeTriStateAction(AudioManager audioManager, Handler handler) { |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1389 | mAudioManager = audioManager; |
| 1390 | mHandler = handler; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1391 | } |
| 1392 | |
| 1393 | private int ringerModeToIndex(int ringerMode) { |
| 1394 | // They just happen to coincide |
| 1395 | return ringerMode; |
| 1396 | } |
| 1397 | |
| 1398 | private int indexToRingerMode(int index) { |
| 1399 | // They just happen to coincide |
| 1400 | return index; |
| 1401 | } |
| 1402 | |
| 1403 | @Override |
| 1404 | public CharSequence getLabelForAccessibility(Context context) { |
| 1405 | return null; |
| 1406 | } |
| 1407 | |
| 1408 | public View create(Context context, View convertView, ViewGroup parent, |
| 1409 | LayoutInflater inflater) { |
| 1410 | View v = inflater.inflate(R.layout.global_actions_silent_mode, parent, false); |
| 1411 | |
| 1412 | int selectedIndex = ringerModeToIndex(mAudioManager.getRingerMode()); |
| 1413 | for (int i = 0; i < 3; i++) { |
| 1414 | View itemView = v.findViewById(ITEM_IDS[i]); |
| 1415 | itemView.setSelected(selectedIndex == i); |
| 1416 | // Set up click handler |
| 1417 | itemView.setTag(i); |
| 1418 | itemView.setOnClickListener(this); |
| 1419 | } |
| 1420 | return v; |
| 1421 | } |
| 1422 | |
| 1423 | public void onPress() { |
| 1424 | } |
| 1425 | |
| 1426 | public boolean showDuringKeyguard() { |
| 1427 | return true; |
| 1428 | } |
| 1429 | |
| 1430 | public boolean showBeforeProvisioning() { |
| 1431 | return false; |
| 1432 | } |
| 1433 | |
| 1434 | public boolean isEnabled() { |
| 1435 | return true; |
| 1436 | } |
| 1437 | |
| 1438 | void willCreate() { |
| 1439 | } |
| 1440 | |
| 1441 | public void onClick(View v) { |
| 1442 | if (!(v.getTag() instanceof Integer)) return; |
| 1443 | |
| 1444 | int index = (Integer) v.getTag(); |
| 1445 | mAudioManager.setRingerMode(indexToRingerMode(index)); |
| 1446 | mHandler.sendEmptyMessageDelayed(MESSAGE_DISMISS, DIALOG_DISMISS_DELAY); |
| 1447 | } |
| 1448 | } |
| 1449 | |
| 1450 | private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { |
| 1451 | public void onReceive(Context context, Intent intent) { |
| 1452 | String action = intent.getAction(); |
| 1453 | if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action) |
| 1454 | || Intent.ACTION_SCREEN_OFF.equals(action)) { |
| 1455 | String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY); |
| 1456 | if (!SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS.equals(reason)) { |
Lucas Dupin | 1d4a579 | 2018-04-02 15:14:59 -0700 | [diff] [blame] | 1457 | mHandler.sendMessage(mHandler.obtainMessage(MESSAGE_DISMISS, reason)); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1458 | } |
Jayachandran C | 142eae0 | 2019-12-13 19:29:20 -0800 | [diff] [blame] | 1459 | } else if (TelephonyManager.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED.equals(action)) { |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1460 | // Airplane mode can be changed after ECM exits if airplane toggle button |
| 1461 | // is pressed during ECM mode |
Daniel Bright | 4bcbfce | 2020-01-09 21:58:16 -0800 | [diff] [blame] | 1462 | if (!(intent.getBooleanExtra(TelephonyManager.EXTRA_PHONE_IN_ECM_STATE, false)) |
| 1463 | && mIsWaitingForEcmExit) { |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1464 | mIsWaitingForEcmExit = false; |
| 1465 | changeAirplaneModeSystemSetting(true); |
| 1466 | } |
| 1467 | } |
| 1468 | } |
| 1469 | }; |
| 1470 | |
| 1471 | PhoneStateListener mPhoneStateListener = new PhoneStateListener() { |
| 1472 | @Override |
| 1473 | public void onServiceStateChanged(ServiceState serviceState) { |
| 1474 | if (!mHasTelephony) return; |
| 1475 | final boolean inAirplaneMode = serviceState.getState() == ServiceState.STATE_POWER_OFF; |
| 1476 | mAirplaneState = inAirplaneMode ? ToggleAction.State.On : ToggleAction.State.Off; |
| 1477 | mAirplaneModeOn.updateState(mAirplaneState); |
| 1478 | mAdapter.notifyDataSetChanged(); |
| 1479 | } |
| 1480 | }; |
| 1481 | |
| 1482 | private BroadcastReceiver mRingerModeReceiver = new BroadcastReceiver() { |
| 1483 | @Override |
| 1484 | public void onReceive(Context context, Intent intent) { |
| 1485 | if (intent.getAction().equals(AudioManager.RINGER_MODE_CHANGED_ACTION)) { |
| 1486 | mHandler.sendEmptyMessage(MESSAGE_REFRESH); |
| 1487 | } |
| 1488 | } |
| 1489 | }; |
| 1490 | |
| 1491 | private ContentObserver mAirplaneModeObserver = new ContentObserver(new Handler()) { |
| 1492 | @Override |
| 1493 | public void onChange(boolean selfChange) { |
| 1494 | onAirplaneModeChanged(); |
| 1495 | } |
| 1496 | }; |
| 1497 | |
| 1498 | private static final int MESSAGE_DISMISS = 0; |
| 1499 | private static final int MESSAGE_REFRESH = 1; |
| 1500 | private static final int MESSAGE_SHOW = 2; |
| 1501 | private static final int DIALOG_DISMISS_DELAY = 300; // ms |
| 1502 | |
| 1503 | private Handler mHandler = new Handler() { |
| 1504 | public void handleMessage(Message msg) { |
| 1505 | switch (msg.what) { |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1506 | case MESSAGE_DISMISS: |
| 1507 | if (mDialog != null) { |
Lucas Dupin | 1d4a579 | 2018-04-02 15:14:59 -0700 | [diff] [blame] | 1508 | if (SYSTEM_DIALOG_REASON_DREAM.equals(msg.obj)) { |
| 1509 | mDialog.dismissImmediately(); |
| 1510 | } else { |
| 1511 | mDialog.dismiss(); |
| 1512 | } |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1513 | mDialog = null; |
| 1514 | } |
| 1515 | break; |
| 1516 | case MESSAGE_REFRESH: |
| 1517 | refreshSilentMode(); |
| 1518 | mAdapter.notifyDataSetChanged(); |
| 1519 | break; |
| 1520 | case MESSAGE_SHOW: |
| 1521 | handleShow(); |
| 1522 | break; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1523 | } |
| 1524 | } |
| 1525 | }; |
| 1526 | |
| 1527 | private void onAirplaneModeChanged() { |
| 1528 | // Let the service state callbacks handle the state. |
| 1529 | if (mHasTelephony) return; |
| 1530 | |
| 1531 | boolean airplaneModeOn = Settings.Global.getInt( |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 1532 | mContentResolver, |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1533 | Settings.Global.AIRPLANE_MODE_ON, |
| 1534 | 0) == 1; |
| 1535 | mAirplaneState = airplaneModeOn ? ToggleAction.State.On : ToggleAction.State.Off; |
| 1536 | mAirplaneModeOn.updateState(mAirplaneState); |
| 1537 | } |
| 1538 | |
| 1539 | /** |
| 1540 | * Change the airplane mode system setting |
| 1541 | */ |
| 1542 | private void changeAirplaneModeSystemSetting(boolean on) { |
| 1543 | Settings.Global.putInt( |
Dave Mankoff | c88a2d7 | 2020-01-10 15:59:31 -0500 | [diff] [blame] | 1544 | mContentResolver, |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1545 | Settings.Global.AIRPLANE_MODE_ON, |
| 1546 | on ? 1 : 0); |
| 1547 | Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); |
| 1548 | intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); |
| 1549 | intent.putExtra("state", on); |
| 1550 | mContext.sendBroadcastAsUser(intent, UserHandle.ALL); |
| 1551 | if (!mHasTelephony) { |
| 1552 | mAirplaneState = on ? ToggleAction.State.On : ToggleAction.State.Off; |
| 1553 | } |
| 1554 | } |
| 1555 | |
Lucas Dupin | c1cc759 | 2017-05-22 15:56:16 -0700 | [diff] [blame] | 1556 | private static final class ActionsDialog extends Dialog implements DialogInterface, |
| 1557 | ColorExtractor.OnColorsChangedListener { |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1558 | |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1559 | private final Context mContext; |
| 1560 | private final MyAdapter mAdapter; |
Steve Elliott | 53f12ae | 2019-05-13 17:14:15 -0400 | [diff] [blame] | 1561 | private final IStatusBarService mStatusBarService; |
| 1562 | private final IBinder mToken = new Binder(); |
Aaron Heuckroth | 75e249f | 2019-02-01 15:59:57 -0500 | [diff] [blame] | 1563 | private MultiListLayout mGlobalActionsLayout; |
Steve Elliott | e9e7e1f | 2019-03-18 15:54:59 -0400 | [diff] [blame] | 1564 | private Drawable mBackgroundDrawable; |
Lucas Dupin | 2bd3af6 | 2019-03-25 17:44:28 -0700 | [diff] [blame] | 1565 | private final SysuiColorExtractor mColorExtractor; |
Steve Elliott | 9b87a44 | 2019-03-05 10:24:16 -0500 | [diff] [blame] | 1566 | private final GlobalActionsPanelPlugin.PanelViewController mPanelController; |
Lucas Dupin | c1cc759 | 2017-05-22 15:56:16 -0700 | [diff] [blame] | 1567 | private boolean mKeyguardShowing; |
Beverly | 526d2d6 | 2018-08-15 12:55:33 -0400 | [diff] [blame] | 1568 | private boolean mShowing; |
Steve Elliott | e9e7e1f | 2019-03-18 15:54:59 -0400 | [diff] [blame] | 1569 | private float mScrimAlpha; |
Steve Elliott | 48f75db | 2019-05-03 15:03:38 -0400 | [diff] [blame] | 1570 | private ResetOrientationData mResetOrientationData; |
Steve Elliott | ff2c0d9 | 2019-07-30 15:09:54 -0400 | [diff] [blame] | 1571 | private boolean mHadTopUi; |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 1572 | private final NotificationShadeWindowController mNotificationShadeWindowController; |
Lucas Dupin | 991415e | 2019-11-25 17:48:58 -0800 | [diff] [blame] | 1573 | private final BlurUtils mBlurUtils; |
Matt Pietal | 2223179 | 2020-01-23 09:51:09 -0500 | [diff] [blame] | 1574 | |
| 1575 | private ControlsUiController mControlsUiController; |
| 1576 | private ViewGroup mControlsView; |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1577 | |
Aaron Heuckroth | f19d272 | 2019-03-11 17:06:02 -0400 | [diff] [blame] | 1578 | ActionsDialog(Context context, MyAdapter adapter, |
Lucas Dupin | 991415e | 2019-11-25 17:48:58 -0800 | [diff] [blame] | 1579 | GlobalActionsPanelPlugin.PanelViewController plugin, BlurUtils blurUtils, |
| 1580 | SysuiColorExtractor sysuiColorExtractor, IStatusBarService statusBarService, |
| 1581 | NotificationShadeWindowController notificationShadeWindowController, |
Matt Pietal | 2223179 | 2020-01-23 09:51:09 -0500 | [diff] [blame] | 1582 | ControlsUiController controlsUiController) { |
Lucas Dupin | c1cc759 | 2017-05-22 15:56:16 -0700 | [diff] [blame] | 1583 | super(context, com.android.systemui.R.style.Theme_SystemUI_Dialog_GlobalActions); |
Lucas Dupin | 448786c | 2017-07-24 17:44:25 -0700 | [diff] [blame] | 1584 | mContext = context; |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1585 | mAdapter = adapter; |
Lucas Dupin | 991415e | 2019-11-25 17:48:58 -0800 | [diff] [blame] | 1586 | mBlurUtils = blurUtils; |
| 1587 | mColorExtractor = sysuiColorExtractor; |
| 1588 | mStatusBarService = statusBarService; |
| 1589 | mNotificationShadeWindowController = notificationShadeWindowController; |
Matt Pietal | 2223179 | 2020-01-23 09:51:09 -0500 | [diff] [blame] | 1590 | mControlsUiController = controlsUiController; |
Lucas Dupin | c1cc759 | 2017-05-22 15:56:16 -0700 | [diff] [blame] | 1591 | |
| 1592 | // Window initialization |
| 1593 | Window window = getWindow(); |
| 1594 | window.requestFeature(Window.FEATURE_NO_TITLE); |
Adrian Roos | edfab3b | 2018-03-08 18:39:20 +0100 | [diff] [blame] | 1595 | // Inflate the decor view, so the attributes below are not overwritten by the theme. |
| 1596 | window.getDecorView(); |
| 1597 | window.getAttributes().systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| 1598 | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
| 1599 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; |
| 1600 | window.setLayout(MATCH_PARENT, MATCH_PARENT); |
| 1601 | window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); |
Alison Cichowlas | 4f19f4a | 2017-07-25 10:56:16 -0400 | [diff] [blame] | 1602 | window.addFlags( |
| 1603 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
Lucas Dupin | c1cc759 | 2017-05-22 15:56:16 -0700 | [diff] [blame] | 1604 | | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
Adrian Roos | edfab3b | 2018-03-08 18:39:20 +0100 | [diff] [blame] | 1605 | | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR |
Lucas Dupin | c1cc759 | 2017-05-22 15:56:16 -0700 | [diff] [blame] | 1606 | | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
| 1607 | | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
| 1608 | | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); |
Lucas Dupin | c1cc759 | 2017-05-22 15:56:16 -0700 | [diff] [blame] | 1609 | window.setType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY); |
Tiger Huang | 5272444 | 2020-01-20 21:38:42 +0800 | [diff] [blame] | 1610 | window.getAttributes().setFitInsetsTypes(0 /* types */); |
Aaron Heuckroth | 75e249f | 2019-02-01 15:59:57 -0500 | [diff] [blame] | 1611 | setTitle(R.string.global_actions); |
Steve Elliott | 9b87a44 | 2019-03-05 10:24:16 -0500 | [diff] [blame] | 1612 | |
| 1613 | mPanelController = plugin; |
Steve Elliott | e9e7e1f | 2019-03-18 15:54:59 -0400 | [diff] [blame] | 1614 | initializeLayout(); |
Steve Elliott | 9b87a44 | 2019-03-05 10:24:16 -0500 | [diff] [blame] | 1615 | } |
| 1616 | |
Aaron Heuckroth | c792661 | 2019-04-02 14:21:57 -0400 | [diff] [blame] | 1617 | private boolean shouldUsePanel() { |
Aran Ink | 3f59455 | 2019-05-13 14:29:35 -0400 | [diff] [blame] | 1618 | return mPanelController != null && mPanelController.getPanelContent() != null; |
Aaron Heuckroth | c792661 | 2019-04-02 14:21:57 -0400 | [diff] [blame] | 1619 | } |
| 1620 | |
| 1621 | private void initializePanel() { |
Steve Elliott | 48f75db | 2019-05-03 15:03:38 -0400 | [diff] [blame] | 1622 | int rotation = RotationUtils.getRotation(mContext); |
| 1623 | boolean rotationLocked = RotationPolicy.isRotationLocked(mContext); |
| 1624 | if (rotation != RotationUtils.ROTATION_NONE) { |
| 1625 | if (rotationLocked) { |
| 1626 | if (mResetOrientationData == null) { |
| 1627 | mResetOrientationData = new ResetOrientationData(); |
| 1628 | mResetOrientationData.locked = true; |
| 1629 | mResetOrientationData.rotation = rotation; |
| 1630 | } |
| 1631 | |
| 1632 | // Unlock rotation, so user can choose to rotate to portrait to see the panel. |
Steve Elliott | e05817f | 2019-05-17 14:39:53 -0400 | [diff] [blame] | 1633 | // This call is posted so that the rotation does not change until post-layout, |
| 1634 | // otherwise onConfigurationChanged() may not get invoked. |
| 1635 | mGlobalActionsLayout.post(() -> |
| 1636 | RotationPolicy.setRotationLockAtAngle( |
| 1637 | mContext, false, RotationUtils.ROTATION_NONE)); |
Steve Elliott | 48f75db | 2019-05-03 15:03:38 -0400 | [diff] [blame] | 1638 | } |
| 1639 | } else { |
| 1640 | if (!rotationLocked) { |
| 1641 | if (mResetOrientationData == null) { |
| 1642 | mResetOrientationData = new ResetOrientationData(); |
| 1643 | mResetOrientationData.locked = false; |
| 1644 | } |
| 1645 | |
| 1646 | // Lock to portrait, so the user doesn't accidentally hide the panel. |
Steve Elliott | e05817f | 2019-05-17 14:39:53 -0400 | [diff] [blame] | 1647 | // This call is posted so that the rotation does not change until post-layout, |
| 1648 | // otherwise onConfigurationChanged() may not get invoked. |
| 1649 | mGlobalActionsLayout.post(() -> |
| 1650 | RotationPolicy.setRotationLockAtAngle( |
| 1651 | mContext, true, RotationUtils.ROTATION_NONE)); |
Steve Elliott | 48f75db | 2019-05-03 15:03:38 -0400 | [diff] [blame] | 1652 | } |
| 1653 | |
Steve Elliott | 53f12ae | 2019-05-13 17:14:15 -0400 | [diff] [blame] | 1654 | // Disable rotation suggestions, if enabled |
| 1655 | setRotationSuggestionsEnabled(false); |
| 1656 | |
Steve Elliott | 300b48f | 2019-05-29 14:13:50 -0400 | [diff] [blame] | 1657 | FrameLayout panelContainer = |
| 1658 | findViewById(com.android.systemui.R.id.global_actions_panel_container); |
Steve Elliott | 48f75db | 2019-05-03 15:03:38 -0400 | [diff] [blame] | 1659 | FrameLayout.LayoutParams panelParams = |
| 1660 | new FrameLayout.LayoutParams( |
| 1661 | FrameLayout.LayoutParams.MATCH_PARENT, |
Steve Elliott | 300b48f | 2019-05-29 14:13:50 -0400 | [diff] [blame] | 1662 | FrameLayout.LayoutParams.MATCH_PARENT); |
Steve Elliott | 48f75db | 2019-05-03 15:03:38 -0400 | [diff] [blame] | 1663 | panelContainer.addView(mPanelController.getPanelContent(), panelParams); |
Steve Elliott | 48f75db | 2019-05-03 15:03:38 -0400 | [diff] [blame] | 1664 | } |
Aaron Heuckroth | 75e249f | 2019-02-01 15:59:57 -0500 | [diff] [blame] | 1665 | } |
| 1666 | |
| 1667 | private void initializeLayout() { |
| 1668 | setContentView(getGlobalActionsLayoutId(mContext)); |
Steve Elliott | 300b48f | 2019-05-29 14:13:50 -0400 | [diff] [blame] | 1669 | fixNavBarClipping(); |
Matt Pietal | 2223179 | 2020-01-23 09:51:09 -0500 | [diff] [blame] | 1670 | mControlsView = findViewById(com.android.systemui.R.id.global_actions_controls); |
Steve Elliott | e9e7e1f | 2019-03-18 15:54:59 -0400 | [diff] [blame] | 1671 | mGlobalActionsLayout = findViewById(com.android.systemui.R.id.global_actions_view); |
Aaron Heuckroth | f708d47 | 2019-01-10 16:54:51 -0500 | [diff] [blame] | 1672 | mGlobalActionsLayout.setOutsideTouchListener(view -> dismiss()); |
Aaron Heuckroth | f708d47 | 2019-01-10 16:54:51 -0500 | [diff] [blame] | 1673 | mGlobalActionsLayout.setListViewAccessibilityDelegate(new View.AccessibilityDelegate() { |
Phil Weaver | 9054e09 | 2018-04-27 16:28:50 -0700 | [diff] [blame] | 1674 | @Override |
| 1675 | public boolean dispatchPopulateAccessibilityEvent( |
| 1676 | View host, AccessibilityEvent event) { |
| 1677 | // Populate the title here, just as Activity does |
| 1678 | event.getText().add(mContext.getString(R.string.global_actions)); |
| 1679 | return true; |
| 1680 | } |
| 1681 | }); |
Aaron Heuckroth | 4ea2fdb | 2019-02-14 16:28:35 -0500 | [diff] [blame] | 1682 | mGlobalActionsLayout.setRotationListener(this::onRotate); |
Aaron Heuckroth | 57d60d2 | 2019-03-05 14:00:12 -0500 | [diff] [blame] | 1683 | mGlobalActionsLayout.setAdapter(mAdapter); |
Steve Elliott | e9e7e1f | 2019-03-18 15:54:59 -0400 | [diff] [blame] | 1684 | |
Aran Ink | 0609026 | 2020-03-03 13:23:17 -0500 | [diff] [blame^] | 1685 | View globalActionsParent = (View) mGlobalActionsLayout.getParent(); |
| 1686 | globalActionsParent.setOnClickListener(v -> dismiss()); |
| 1687 | |
| 1688 | // add fall-through dismiss handling to root view |
| 1689 | View rootView = findViewById(com.android.systemui.R.id.global_actions_grid_root); |
| 1690 | if (rootView != null) { |
| 1691 | rootView.setOnClickListener(v -> dismiss()); |
| 1692 | } |
| 1693 | |
Steve Elliott | 86ef628 | 2019-05-08 14:45:04 -0400 | [diff] [blame] | 1694 | if (shouldUsePanel()) { |
Steve Elliott | c59eb34 | 2019-04-23 16:59:06 -0400 | [diff] [blame] | 1695 | initializePanel(); |
Steve Elliott | e9e7e1f | 2019-03-18 15:54:59 -0400 | [diff] [blame] | 1696 | } |
Steve Elliott | 86ef628 | 2019-05-08 14:45:04 -0400 | [diff] [blame] | 1697 | if (mBackgroundDrawable == null) { |
| 1698 | mBackgroundDrawable = new ScrimDrawable(); |
Lucas Dupin | 43d0124 | 2020-02-03 11:58:33 -0800 | [diff] [blame] | 1699 | mScrimAlpha = ScrimController.BUSY_SCRIM_ALPHA; |
Steve Elliott | 86ef628 | 2019-05-08 14:45:04 -0400 | [diff] [blame] | 1700 | } |
Steve Elliott | e9e7e1f | 2019-03-18 15:54:59 -0400 | [diff] [blame] | 1701 | getWindow().setBackgroundDrawable(mBackgroundDrawable); |
Steve Elliott | 9b87a44 | 2019-03-05 10:24:16 -0500 | [diff] [blame] | 1702 | } |
| 1703 | |
Steve Elliott | 300b48f | 2019-05-29 14:13:50 -0400 | [diff] [blame] | 1704 | private void fixNavBarClipping() { |
| 1705 | ViewGroup content = findViewById(android.R.id.content); |
| 1706 | content.setClipChildren(false); |
| 1707 | content.setClipToPadding(false); |
| 1708 | ViewGroup contentParent = (ViewGroup) content.getParent(); |
| 1709 | contentParent.setClipChildren(false); |
| 1710 | contentParent.setClipToPadding(false); |
| 1711 | } |
| 1712 | |
Aaron Heuckroth | 166392f | 2019-01-17 16:50:59 -0500 | [diff] [blame] | 1713 | private int getGlobalActionsLayoutId(Context context) { |
Matt Pietal | 2223179 | 2020-01-23 09:51:09 -0500 | [diff] [blame] | 1714 | if (mControlsUiController != null) { |
Matt Pietal | fd3b6cb | 2020-01-08 09:43:54 -0500 | [diff] [blame] | 1715 | return com.android.systemui.R.layout.global_actions_grid_v2; |
| 1716 | } |
| 1717 | |
Steve Elliott | dc16563 | 2019-05-23 14:26:31 -0400 | [diff] [blame] | 1718 | int rotation = RotationUtils.getRotation(context); |
| 1719 | boolean useGridLayout = isForceGridEnabled(context) |
| 1720 | || (shouldUsePanel() && rotation == RotationUtils.ROTATION_NONE); |
| 1721 | if (rotation == RotationUtils.ROTATION_SEASCAPE) { |
Aaron Heuckroth | e2d92ac | 2019-05-01 10:44:59 -0400 | [diff] [blame] | 1722 | if (useGridLayout) { |
Aaron Heuckroth | 75e249f | 2019-02-01 15:59:57 -0500 | [diff] [blame] | 1723 | return com.android.systemui.R.layout.global_actions_grid_seascape; |
Aaron Heuckroth | e2d92ac | 2019-05-01 10:44:59 -0400 | [diff] [blame] | 1724 | } else { |
| 1725 | return com.android.systemui.R.layout.global_actions_column_seascape; |
Aaron Heuckroth | 75e249f | 2019-02-01 15:59:57 -0500 | [diff] [blame] | 1726 | } |
Aaron Heuckroth | e2d92ac | 2019-05-01 10:44:59 -0400 | [diff] [blame] | 1727 | } else { |
| 1728 | if (useGridLayout) { |
| 1729 | return com.android.systemui.R.layout.global_actions_grid; |
| 1730 | } else { |
| 1731 | return com.android.systemui.R.layout.global_actions_column; |
| 1732 | } |
Aaron Heuckroth | 166392f | 2019-01-17 16:50:59 -0500 | [diff] [blame] | 1733 | } |
Aaron Heuckroth | 166392f | 2019-01-17 16:50:59 -0500 | [diff] [blame] | 1734 | } |
| 1735 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1736 | @Override |
| 1737 | protected void onStart() { |
| 1738 | super.setCanceledOnTouchOutside(true); |
| 1739 | super.onStart(); |
Aaron Heuckroth | 57d60d2 | 2019-03-05 14:00:12 -0500 | [diff] [blame] | 1740 | mGlobalActionsLayout.updateList(); |
Lucas Dupin | c1cc759 | 2017-05-22 15:56:16 -0700 | [diff] [blame] | 1741 | |
Lucas Dupin | 2bd3af6 | 2019-03-25 17:44:28 -0700 | [diff] [blame] | 1742 | if (mBackgroundDrawable instanceof ScrimDrawable) { |
Steve Elliott | 9b87a44 | 2019-03-05 10:24:16 -0500 | [diff] [blame] | 1743 | mColorExtractor.addOnColorsChangedListener(this); |
Lucas Dupin | 2bd3af6 | 2019-03-25 17:44:28 -0700 | [diff] [blame] | 1744 | GradientColors colors = mColorExtractor.getNeutralColors(); |
Steve Elliott | 9b87a44 | 2019-03-05 10:24:16 -0500 | [diff] [blame] | 1745 | updateColors(colors, false /* animate */); |
| 1746 | } |
Lucas Dupin | b5f59fe | 2017-09-14 17:09:39 -0700 | [diff] [blame] | 1747 | } |
| 1748 | |
| 1749 | /** |
| 1750 | * Updates background and system bars according to current GradientColors. |
| 1751 | * @param colors Colors and hints to use. |
| 1752 | * @param animate Interpolates gradient if true, just sets otherwise. |
| 1753 | */ |
| 1754 | private void updateColors(GradientColors colors, boolean animate) { |
Lucas Dupin | 2bd3af6 | 2019-03-25 17:44:28 -0700 | [diff] [blame] | 1755 | if (!(mBackgroundDrawable instanceof ScrimDrawable)) { |
Steve Elliott | 9b87a44 | 2019-03-05 10:24:16 -0500 | [diff] [blame] | 1756 | return; |
| 1757 | } |
Lucas Dupin | ba2b48a | 2020-02-06 09:28:06 -0800 | [diff] [blame] | 1758 | ((ScrimDrawable) mBackgroundDrawable).setColor(colors.supportsDarkText() ? Color.WHITE |
| 1759 | : Color.BLACK, animate); |
Lucas Dupin | b5f59fe | 2017-09-14 17:09:39 -0700 | [diff] [blame] | 1760 | View decorView = getWindow().getDecorView(); |
| 1761 | if (colors.supportsDarkText()) { |
| 1762 | decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR | |
Steve Elliott | 9b87a44 | 2019-03-05 10:24:16 -0500 | [diff] [blame] | 1763 | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); |
Lucas Dupin | b5f59fe | 2017-09-14 17:09:39 -0700 | [diff] [blame] | 1764 | } else { |
| 1765 | decorView.setSystemUiVisibility(0); |
| 1766 | } |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1767 | } |
| 1768 | |
| 1769 | @Override |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1770 | protected void onStop() { |
| 1771 | super.onStop(); |
Lucas Dupin | c1cc759 | 2017-05-22 15:56:16 -0700 | [diff] [blame] | 1772 | mColorExtractor.removeOnColorsChangedListener(this); |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1773 | } |
| 1774 | |
| 1775 | @Override |
| 1776 | public void show() { |
| 1777 | super.show(); |
Beverly | 526d2d6 | 2018-08-15 12:55:33 -0400 | [diff] [blame] | 1778 | mShowing = true; |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 1779 | mHadTopUi = mNotificationShadeWindowController.getForceHasTopUi(); |
| 1780 | mNotificationShadeWindowController.setForceHasTopUi(true); |
Steve Elliott | 9b87a44 | 2019-03-05 10:24:16 -0500 | [diff] [blame] | 1781 | mBackgroundDrawable.setAlpha(0); |
Aaron Heuckroth | c792661 | 2019-04-02 14:21:57 -0400 | [diff] [blame] | 1782 | mGlobalActionsLayout.setTranslationX(mGlobalActionsLayout.getAnimationOffsetX()); |
| 1783 | mGlobalActionsLayout.setTranslationY(mGlobalActionsLayout.getAnimationOffsetY()); |
Aaron Heuckroth | f708d47 | 2019-01-10 16:54:51 -0500 | [diff] [blame] | 1784 | mGlobalActionsLayout.setAlpha(0); |
| 1785 | mGlobalActionsLayout.animate() |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1786 | .alpha(1) |
| 1787 | .translationX(0) |
Aaron Heuckroth | c792661 | 2019-04-02 14:21:57 -0400 | [diff] [blame] | 1788 | .translationY(0) |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1789 | .setDuration(300) |
Lucas Dupin | de9db42 | 2017-07-19 17:15:41 -0700 | [diff] [blame] | 1790 | .setInterpolator(Interpolators.FAST_OUT_SLOW_IN) |
Lucas Dupin | c1cc759 | 2017-05-22 15:56:16 -0700 | [diff] [blame] | 1791 | .setUpdateListener(animation -> { |
Lucas Dupin | 991415e | 2019-11-25 17:48:58 -0800 | [diff] [blame] | 1792 | float animatedValue = animation.getAnimatedFraction(); |
| 1793 | int alpha = (int) (animatedValue * mScrimAlpha * 255); |
Steve Elliott | 9b87a44 | 2019-03-05 10:24:16 -0500 | [diff] [blame] | 1794 | mBackgroundDrawable.setAlpha(alpha); |
Lucas Dupin | 991415e | 2019-11-25 17:48:58 -0800 | [diff] [blame] | 1795 | mBlurUtils.applyBlur(mGlobalActionsLayout.getViewRootImpl(), |
| 1796 | mBlurUtils.radiusForRatio(animatedValue)); |
Lucas Dupin | c1cc759 | 2017-05-22 15:56:16 -0700 | [diff] [blame] | 1797 | }) |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1798 | .start(); |
Matt Pietal | 2223179 | 2020-01-23 09:51:09 -0500 | [diff] [blame] | 1799 | if (mControlsUiController != null) { |
| 1800 | mControlsUiController.show(mControlsView); |
| 1801 | } |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1802 | } |
| 1803 | |
| 1804 | @Override |
| 1805 | public void dismiss() { |
Beverly | 526d2d6 | 2018-08-15 12:55:33 -0400 | [diff] [blame] | 1806 | if (!mShowing) { |
| 1807 | return; |
| 1808 | } |
| 1809 | mShowing = false; |
Matt Pietal | 2223179 | 2020-01-23 09:51:09 -0500 | [diff] [blame] | 1810 | if (mControlsUiController != null) mControlsUiController.hide(); |
Aaron Heuckroth | f708d47 | 2019-01-10 16:54:51 -0500 | [diff] [blame] | 1811 | mGlobalActionsLayout.setTranslationX(0); |
Aaron Heuckroth | c792661 | 2019-04-02 14:21:57 -0400 | [diff] [blame] | 1812 | mGlobalActionsLayout.setTranslationY(0); |
Aaron Heuckroth | f708d47 | 2019-01-10 16:54:51 -0500 | [diff] [blame] | 1813 | mGlobalActionsLayout.setAlpha(1); |
| 1814 | mGlobalActionsLayout.animate() |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1815 | .alpha(0) |
Aaron Heuckroth | c792661 | 2019-04-02 14:21:57 -0400 | [diff] [blame] | 1816 | .translationX(mGlobalActionsLayout.getAnimationOffsetX()) |
| 1817 | .translationY(mGlobalActionsLayout.getAnimationOffsetY()) |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1818 | .setDuration(300) |
Steve Elliott | ff2c0d9 | 2019-07-30 15:09:54 -0400 | [diff] [blame] | 1819 | .withEndAction(this::completeDismiss) |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1820 | .setInterpolator(new LogAccelerateInterpolator()) |
Lucas Dupin | c1cc759 | 2017-05-22 15:56:16 -0700 | [diff] [blame] | 1821 | .setUpdateListener(animation -> { |
Lucas Dupin | 991415e | 2019-11-25 17:48:58 -0800 | [diff] [blame] | 1822 | float animatedValue = 1f - animation.getAnimatedFraction(); |
| 1823 | int alpha = (int) (animatedValue * mScrimAlpha * 255); |
Steve Elliott | 9b87a44 | 2019-03-05 10:24:16 -0500 | [diff] [blame] | 1824 | mBackgroundDrawable.setAlpha(alpha); |
Lucas Dupin | 991415e | 2019-11-25 17:48:58 -0800 | [diff] [blame] | 1825 | mBlurUtils.applyBlur(mGlobalActionsLayout.getViewRootImpl(), |
| 1826 | mBlurUtils.radiusForRatio(animatedValue)); |
Lucas Dupin | c1cc759 | 2017-05-22 15:56:16 -0700 | [diff] [blame] | 1827 | }) |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1828 | .start(); |
Steve Elliott | 48f75db | 2019-05-03 15:03:38 -0400 | [diff] [blame] | 1829 | dismissPanel(); |
| 1830 | resetOrientation(); |
Jason Monk | 16fbd9d | 2017-04-27 14:28:49 -0400 | [diff] [blame] | 1831 | } |
| 1832 | |
Lucas Dupin | 1d4a579 | 2018-04-02 15:14:59 -0700 | [diff] [blame] | 1833 | void dismissImmediately() { |
Beverly | 526d2d6 | 2018-08-15 12:55:33 -0400 | [diff] [blame] | 1834 | mShowing = false; |
Matt Pietal | 019feaa | 2020-01-31 14:51:37 -0500 | [diff] [blame] | 1835 | if (mControlsUiController != null) mControlsUiController.hide(); |
Steve Elliott | 48f75db | 2019-05-03 15:03:38 -0400 | [diff] [blame] | 1836 | dismissPanel(); |
| 1837 | resetOrientation(); |
Steve Elliott | ff2c0d9 | 2019-07-30 15:09:54 -0400 | [diff] [blame] | 1838 | completeDismiss(); |
| 1839 | } |
| 1840 | |
| 1841 | private void completeDismiss() { |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 1842 | mNotificationShadeWindowController.setForceHasTopUi(mHadTopUi); |
Steve Elliott | ff2c0d9 | 2019-07-30 15:09:54 -0400 | [diff] [blame] | 1843 | super.dismiss(); |
Steve Elliott | 48f75db | 2019-05-03 15:03:38 -0400 | [diff] [blame] | 1844 | } |
| 1845 | |
| 1846 | private void dismissPanel() { |
Steve Elliott | 2d206d3 | 2019-03-14 16:30:33 -0400 | [diff] [blame] | 1847 | if (mPanelController != null) { |
| 1848 | mPanelController.onDismissed(); |
| 1849 | } |
Lucas Dupin | 1d4a579 | 2018-04-02 15:14:59 -0700 | [diff] [blame] | 1850 | } |
| 1851 | |
Steve Elliott | 53f12ae | 2019-05-13 17:14:15 -0400 | [diff] [blame] | 1852 | private void setRotationSuggestionsEnabled(boolean enabled) { |
| 1853 | try { |
| 1854 | final int userId = Binder.getCallingUserHandle().getIdentifier(); |
| 1855 | final int what = enabled |
| 1856 | ? StatusBarManager.DISABLE2_NONE |
| 1857 | : StatusBarManager.DISABLE2_ROTATE_SUGGESTIONS; |
| 1858 | mStatusBarService.disable2ForUser(what, mToken, mContext.getPackageName(), userId); |
| 1859 | } catch (RemoteException ex) { |
| 1860 | throw ex.rethrowFromSystemServer(); |
| 1861 | } |
| 1862 | } |
| 1863 | |
Steve Elliott | 48f75db | 2019-05-03 15:03:38 -0400 | [diff] [blame] | 1864 | private void resetOrientation() { |
| 1865 | if (mResetOrientationData != null) { |
| 1866 | RotationPolicy.setRotationLockAtAngle(mContext, mResetOrientationData.locked, |
| 1867 | mResetOrientationData.rotation); |
| 1868 | } |
Steve Elliott | 53f12ae | 2019-05-13 17:14:15 -0400 | [diff] [blame] | 1869 | setRotationSuggestionsEnabled(true); |
Steve Elliott | 48f75db | 2019-05-03 15:03:38 -0400 | [diff] [blame] | 1870 | } |
| 1871 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1872 | @Override |
Lucas Dupin | 7aaa353 | 2017-05-28 08:51:07 -0700 | [diff] [blame] | 1873 | public void onColorsChanged(ColorExtractor extractor, int which) { |
Lucas Dupin | c1cc759 | 2017-05-22 15:56:16 -0700 | [diff] [blame] | 1874 | if (mKeyguardShowing) { |
| 1875 | if ((WallpaperManager.FLAG_LOCK & which) != 0) { |
Lucas Dupin | b5f59fe | 2017-09-14 17:09:39 -0700 | [diff] [blame] | 1876 | updateColors(extractor.getColors(WallpaperManager.FLAG_LOCK), |
| 1877 | true /* animate */); |
Lucas Dupin | c1cc759 | 2017-05-22 15:56:16 -0700 | [diff] [blame] | 1878 | } |
| 1879 | } else { |
| 1880 | if ((WallpaperManager.FLAG_SYSTEM & which) != 0) { |
Lucas Dupin | b5f59fe | 2017-09-14 17:09:39 -0700 | [diff] [blame] | 1881 | updateColors(extractor.getColors(WallpaperManager.FLAG_SYSTEM), |
| 1882 | true /* animate */); |
Lucas Dupin | c1cc759 | 2017-05-22 15:56:16 -0700 | [diff] [blame] | 1883 | } |
| 1884 | } |
| 1885 | } |
| 1886 | |
| 1887 | public void setKeyguardShowing(boolean keyguardShowing) { |
| 1888 | mKeyguardShowing = keyguardShowing; |
| 1889 | } |
Aaron Heuckroth | 4ea2fdb | 2019-02-14 16:28:35 -0500 | [diff] [blame] | 1890 | |
Aaron Heuckroth | 4ef3a54 | 2019-04-01 14:17:23 -0400 | [diff] [blame] | 1891 | public void refreshDialog() { |
| 1892 | initializeLayout(); |
| 1893 | mGlobalActionsLayout.updateList(); |
| 1894 | } |
| 1895 | |
Aaron Heuckroth | 4ea2fdb | 2019-02-14 16:28:35 -0500 | [diff] [blame] | 1896 | public void onRotate(int from, int to) { |
Aaron Heuckroth | e2d92ac | 2019-05-01 10:44:59 -0400 | [diff] [blame] | 1897 | if (mShowing) { |
Aaron Heuckroth | 4ef3a54 | 2019-04-01 14:17:23 -0400 | [diff] [blame] | 1898 | refreshDialog(); |
Aaron Heuckroth | 4ea2fdb | 2019-02-14 16:28:35 -0500 | [diff] [blame] | 1899 | } |
| 1900 | } |
Steve Elliott | 48f75db | 2019-05-03 15:03:38 -0400 | [diff] [blame] | 1901 | |
| 1902 | private static class ResetOrientationData { |
| 1903 | public boolean locked; |
| 1904 | public int rotation; |
| 1905 | } |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1906 | } |
Aaron Heuckroth | 75e249f | 2019-02-01 15:59:57 -0500 | [diff] [blame] | 1907 | |
| 1908 | /** |
Aran Ink | 93dd25c | 2019-05-09 14:42:14 -0400 | [diff] [blame] | 1909 | * Determines whether or not debug mode has been activated for the Global Actions Panel. |
| 1910 | */ |
| 1911 | private static boolean isPanelDebugModeEnabled(Context context) { |
| 1912 | return Settings.Secure.getInt(context.getContentResolver(), |
| 1913 | Settings.Secure.GLOBAL_ACTIONS_PANEL_DEBUG_ENABLED, 0) == 1; |
| 1914 | } |
| 1915 | |
| 1916 | /** |
Aaron Heuckroth | c792661 | 2019-04-02 14:21:57 -0400 | [diff] [blame] | 1917 | * Determines whether or not the Global Actions menu should be forced to |
| 1918 | * use the newer grid-style layout. |
Aaron Heuckroth | 75e249f | 2019-02-01 15:59:57 -0500 | [diff] [blame] | 1919 | */ |
Aaron Heuckroth | c792661 | 2019-04-02 14:21:57 -0400 | [diff] [blame] | 1920 | private static boolean isForceGridEnabled(Context context) { |
Aran Ink | 93dd25c | 2019-05-09 14:42:14 -0400 | [diff] [blame] | 1921 | return isPanelDebugModeEnabled(context); |
Aaron Heuckroth | 75e249f | 2019-02-01 15:59:57 -0500 | [diff] [blame] | 1922 | } |
Aaron Heuckroth | f19d272 | 2019-03-11 17:06:02 -0400 | [diff] [blame] | 1923 | |
Matt Pietal | e0661b6 | 2020-01-29 14:35:31 -0500 | [diff] [blame] | 1924 | private boolean shouldShowControls() { |
Fabian Kozynski | f6063ae | 2020-02-24 16:14:35 -0500 | [diff] [blame] | 1925 | return mKeyguardStateController.isUnlocked() |
Fabian Kozynski | 0424ab1 | 2020-02-21 12:09:17 -0500 | [diff] [blame] | 1926 | && mControlsUiController.getAvailable() |
| 1927 | && mAnyControlsProviders; |
Matt Pietal | fd3b6cb | 2020-01-08 09:43:54 -0500 | [diff] [blame] | 1928 | } |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 1929 | } |