blob: cc1b9e8f9c492d93f4f2efc7dd056826e82cbe42 [file] [log] [blame]
Jason Monk361915c2017-03-21 20:33:59 -04001/*
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
15package com.android.systemui.globalactions;
16
Adrian Roosedfab3b2018-03-08 18:39:20 +010017import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
Adrian Roos2f05bb32018-02-19 16:42:27 +010018import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
19
Chad Brubakerf4075fe2018-01-03 13:23:22 -080020import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_USER_REQUEST;
21import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_NOT_REQUIRED;
Chad Brubaker4f28f0d2017-09-07 14:28:13 -070022import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN;
23
Jason Monk361915c2017-03-21 20:33:59 -040024import android.app.ActivityManager;
25import android.app.Dialog;
Chad Brubakerf4075fe2018-01-03 13:23:22 -080026import android.app.KeyguardManager;
Lucas Dupinc1cc7592017-05-22 15:56:16 -070027import android.app.WallpaperManager;
Alex Chau04458852017-11-27 18:21:23 +000028import android.app.admin.DevicePolicyManager;
Pavel Grafov059021b2018-05-02 13:44:46 +010029import android.app.trust.TrustManager;
Jason Monk361915c2017-03-21 20:33:59 -040030import android.content.BroadcastReceiver;
31import android.content.Context;
32import android.content.DialogInterface;
33import android.content.Intent;
34import android.content.IntentFilter;
35import android.content.pm.UserInfo;
36import android.database.ContentObserver;
Lucas Dupinc1cc7592017-05-22 15:56:16 -070037import android.graphics.Point;
Jason Monk361915c2017-03-21 20:33:59 -040038import android.graphics.drawable.Drawable;
39import android.media.AudioManager;
40import android.net.ConnectivityManager;
41import android.os.Build;
Jason Monk361915c2017-03-21 20:33:59 -040042import android.os.Handler;
43import android.os.Message;
44import android.os.RemoteException;
45import android.os.ServiceManager;
46import android.os.SystemProperties;
47import android.os.UserHandle;
48import android.os.UserManager;
49import android.os.Vibrator;
50import android.provider.Settings;
51import android.service.dreams.DreamService;
52import android.service.dreams.IDreamManager;
53import android.telephony.PhoneStateListener;
54import android.telephony.ServiceState;
55import android.telephony.TelephonyManager;
56import android.text.TextUtils;
57import android.util.ArraySet;
58import android.util.Log;
Lucas Dupin448786c2017-07-24 17:44:25 -070059import android.view.ContextThemeWrapper;
Jason Monk361915c2017-03-21 20:33:59 -040060import android.view.LayoutInflater;
61import android.view.View;
62import android.view.ViewGroup;
Lucas Dupinc1cc7592017-05-22 15:56:16 -070063import android.view.Window;
Jason Monk361915c2017-03-21 20:33:59 -040064import android.view.WindowManager;
65import android.view.WindowManagerGlobal;
66import android.view.accessibility.AccessibilityEvent;
Jason Monk16fbd9d2017-04-27 14:28:49 -040067import android.widget.AdapterView.OnItemLongClickListener;
Jason Monk361915c2017-03-21 20:33:59 -040068import android.widget.BaseAdapter;
Wesley.CW Wang3004fcb2018-06-15 16:24:57 +080069import android.widget.FrameLayout;
Jason Monk361915c2017-03-21 20:33:59 -040070import android.widget.ImageView;
71import android.widget.ImageView.ScaleType;
Jason Monk16fbd9d2017-04-27 14:28:49 -040072import android.widget.LinearLayout;
Jason Monk361915c2017-03-21 20:33:59 -040073import android.widget.TextView;
74
Charles He9851a8d2017-10-10 17:31:30 +010075import com.android.internal.R;
76import com.android.internal.colorextraction.ColorExtractor;
77import com.android.internal.colorextraction.ColorExtractor.GradientColors;
Lucas Dupine2292a92017-07-06 14:35:30 -070078import com.android.internal.colorextraction.drawable.GradientDrawable;
Charles He9851a8d2017-10-10 17:31:30 +010079import com.android.internal.logging.MetricsLogger;
80import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
81import com.android.internal.telephony.TelephonyIntents;
82import com.android.internal.telephony.TelephonyProperties;
83import com.android.internal.util.EmergencyAffordanceManager;
Alison Cichowlasa2cd19e2017-12-06 10:51:21 -050084import com.android.internal.util.ScreenshotHelper;
Charles He9851a8d2017-10-10 17:31:30 +010085import com.android.internal.widget.LockPatternUtils;
86import com.android.systemui.Dependency;
87import com.android.systemui.HardwareUiLayout;
88import com.android.systemui.Interpolators;
89import com.android.systemui.colorextraction.SysuiColorExtractor;
90import com.android.systemui.plugins.GlobalActions.GlobalActionsManager;
91import com.android.systemui.statusbar.phone.ScrimController;
Shaotang Li5c422632018-07-04 14:18:40 +080092import com.android.systemui.util.EmergencyDialerConstants;
Julia Reynolds42411922017-11-08 11:19:09 -050093import com.android.systemui.volume.SystemUIInterpolators.LogAccelerateInterpolator;
Lucas Dupinc1cc7592017-05-22 15:56:16 -070094
Jason Monk361915c2017-03-21 20:33:59 -040095import java.util.ArrayList;
96import java.util.List;
97
98/**
99 * Helper to show the global actions dialog. Each item is an {@link Action} that
100 * may show depending on whether the keyguard is showing, and whether the device
101 * is provisioned.
102 */
Charles He9851a8d2017-10-10 17:31:30 +0100103class GlobalActionsDialog implements DialogInterface.OnDismissListener,
Shaotang Li786da902018-08-02 11:18:00 +0800104 DialogInterface.OnClickListener, DialogInterface.OnShowListener {
Jason Monk361915c2017-03-21 20:33:59 -0400105
106 static public final String SYSTEM_DIALOG_REASON_KEY = "reason";
107 static public final String SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions";
Lucas Dupin1d4a5792018-04-02 15:14:59 -0700108 static public final String SYSTEM_DIALOG_REASON_DREAM = "dream";
Jason Monk361915c2017-03-21 20:33:59 -0400109
110 private static final String TAG = "GlobalActionsDialog";
111
112 private static final boolean SHOW_SILENT_TOGGLE = true;
113
114 /* Valid settings for global actions keys.
115 * see config.xml config_globalActionList */
116 private static final String GLOBAL_ACTION_KEY_POWER = "power";
117 private static final String GLOBAL_ACTION_KEY_AIRPLANE = "airplane";
118 private static final String GLOBAL_ACTION_KEY_BUGREPORT = "bugreport";
119 private static final String GLOBAL_ACTION_KEY_SILENT = "silent";
120 private static final String GLOBAL_ACTION_KEY_USERS = "users";
121 private static final String GLOBAL_ACTION_KEY_SETTINGS = "settings";
122 private static final String GLOBAL_ACTION_KEY_LOCKDOWN = "lockdown";
123 private static final String GLOBAL_ACTION_KEY_VOICEASSIST = "voiceassist";
124 private static final String GLOBAL_ACTION_KEY_ASSIST = "assist";
125 private static final String GLOBAL_ACTION_KEY_RESTART = "restart";
Alex Chau04458852017-11-27 18:21:23 +0000126 private static final String GLOBAL_ACTION_KEY_LOGOUT = "logout";
Wesley.CW Wang8d072762018-05-28 16:39:27 +0800127 private static final String GLOBAL_ACTION_KEY_EMERGENCY = "emergency";
Alison Cichowlasa2cd19e2017-12-06 10:51:21 -0500128 private static final String GLOBAL_ACTION_KEY_SCREENSHOT = "screenshot";
Jason Monk361915c2017-03-21 20:33:59 -0400129
130 private final Context mContext;
131 private final GlobalActionsManager mWindowManagerFuncs;
132 private final AudioManager mAudioManager;
133 private final IDreamManager mDreamManager;
Alex Chau04458852017-11-27 18:21:23 +0000134 private final DevicePolicyManager mDevicePolicyManager;
Chad Brubakerf4075fe2018-01-03 13:23:22 -0800135 private final LockPatternUtils mLockPatternUtils;
136 private final KeyguardManager mKeyguardManager;
Jason Monk361915c2017-03-21 20:33:59 -0400137
138 private ArrayList<Action> mItems;
139 private ActionsDialog mDialog;
140
141 private Action mSilentModeAction;
142 private ToggleAction mAirplaneModeOn;
143
144 private MyAdapter mAdapter;
145
146 private boolean mKeyguardShowing = false;
147 private boolean mDeviceProvisioned = false;
148 private ToggleAction.State mAirplaneState = ToggleAction.State.Off;
149 private boolean mIsWaitingForEcmExit = false;
150 private boolean mHasTelephony;
151 private boolean mHasVibrator;
Alex Chau04458852017-11-27 18:21:23 +0000152 private boolean mHasLogoutButton;
Chad Brubaker72a73ea2018-01-26 15:56:55 -0800153 private boolean mHasLockdownButton;
Wesley.CW Wanga9de7922018-07-06 15:26:21 +0800154 private boolean mSeparatedEmergencyButtonEnabled;
Jason Monk361915c2017-03-21 20:33:59 -0400155 private final boolean mShowSilentToggle;
156 private final EmergencyAffordanceManager mEmergencyAffordanceManager;
Alison Cichowlasa2cd19e2017-12-06 10:51:21 -0500157 private final ScreenshotHelper mScreenshotHelper;
Jason Monk361915c2017-03-21 20:33:59 -0400158
159 /**
160 * @param context everything needs a context :(
161 */
162 public GlobalActionsDialog(Context context, GlobalActionsManager windowManagerFuncs) {
Lucas Dupin448786c2017-07-24 17:44:25 -0700163 mContext = new ContextThemeWrapper(context, com.android.systemui.R.style.qs_theme);
Jason Monk361915c2017-03-21 20:33:59 -0400164 mWindowManagerFuncs = windowManagerFuncs;
165 mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
166 mDreamManager = IDreamManager.Stub.asInterface(
167 ServiceManager.getService(DreamService.DREAM_SERVICE));
Alex Chau04458852017-11-27 18:21:23 +0000168 mDevicePolicyManager = (DevicePolicyManager) mContext.getSystemService(
169 Context.DEVICE_POLICY_SERVICE);
Chad Brubakerf4075fe2018-01-03 13:23:22 -0800170 mLockPatternUtils = new LockPatternUtils(mContext);
171 mKeyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
Jason Monk361915c2017-03-21 20:33:59 -0400172
173 // receive broadcasts
174 IntentFilter filter = new IntentFilter();
175 filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
176 filter.addAction(Intent.ACTION_SCREEN_OFF);
177 filter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
178 context.registerReceiver(mBroadcastReceiver, filter);
179
180 ConnectivityManager cm = (ConnectivityManager)
181 context.getSystemService(Context.CONNECTIVITY_SERVICE);
182 mHasTelephony = cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE);
183
184 // get notified of phone state changes
185 TelephonyManager telephonyManager =
186 (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
187 telephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE);
188 mContext.getContentResolver().registerContentObserver(
189 Settings.Global.getUriFor(Settings.Global.AIRPLANE_MODE_ON), true,
190 mAirplaneModeObserver);
191 Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
192 mHasVibrator = vibrator != null && vibrator.hasVibrator();
193
194 mShowSilentToggle = SHOW_SILENT_TOGGLE && !mContext.getResources().getBoolean(
195 R.bool.config_useFixedVolume);
196
197 mEmergencyAffordanceManager = new EmergencyAffordanceManager(context);
Alison Cichowlasa2cd19e2017-12-06 10:51:21 -0500198 mScreenshotHelper = new ScreenshotHelper(context);
Jason Monk361915c2017-03-21 20:33:59 -0400199 }
200
201 /**
202 * Show the global actions dialog (creating if necessary)
Jason Monk16fbd9d2017-04-27 14:28:49 -0400203 *
Jason Monk361915c2017-03-21 20:33:59 -0400204 * @param keyguardShowing True if keyguard is showing
205 */
206 public void showDialog(boolean keyguardShowing, boolean isDeviceProvisioned) {
207 mKeyguardShowing = keyguardShowing;
208 mDeviceProvisioned = isDeviceProvisioned;
209 if (mDialog != null) {
210 mDialog.dismiss();
211 mDialog = null;
212 // Show delayed, so that the dismiss of the previous dialog completes
213 mHandler.sendEmptyMessage(MESSAGE_SHOW);
214 } else {
215 handleShow();
216 }
217 }
218
Charles He9851a8d2017-10-10 17:31:30 +0100219 /**
220 * Dismiss the global actions dialog, if it's currently shown
221 */
222 public void dismissDialog() {
223 mHandler.removeMessages(MESSAGE_DISMISS);
224 mHandler.sendEmptyMessage(MESSAGE_DISMISS);
225 }
226
Jason Monk361915c2017-03-21 20:33:59 -0400227 private void awakenIfNecessary() {
228 if (mDreamManager != null) {
229 try {
230 if (mDreamManager.isDreaming()) {
231 mDreamManager.awaken();
232 }
233 } catch (RemoteException e) {
234 // we tried
235 }
236 }
237 }
238
239 private void handleShow() {
240 awakenIfNecessary();
241 mDialog = createDialog();
242 prepareDialog();
243
244 // If we only have 1 item and it's a simple press action, just do this action.
245 if (mAdapter.getCount() == 1
246 && mAdapter.getItem(0) instanceof SinglePressAction
247 && !(mAdapter.getItem(0) instanceof LongPressAction)) {
248 ((SinglePressAction) mAdapter.getItem(0)).onPress();
249 } else {
250 WindowManager.LayoutParams attrs = mDialog.getWindow().getAttributes();
251 attrs.setTitle("ActionsDialog");
Adrian Roos2f05bb32018-02-19 16:42:27 +0100252 attrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
Jason Monk361915c2017-03-21 20:33:59 -0400253 mDialog.getWindow().setAttributes(attrs);
254 mDialog.show();
255 mWindowManagerFuncs.onGlobalActionsShown();
Jason Monk361915c2017-03-21 20:33:59 -0400256 }
257 }
258
259 /**
260 * Create the global actions dialog.
Jason Monk16fbd9d2017-04-27 14:28:49 -0400261 *
Jason Monk361915c2017-03-21 20:33:59 -0400262 * @return A new dialog.
263 */
264 private ActionsDialog createDialog() {
265 // Simple toggle style if there's no vibrator, otherwise use a tri-state
266 if (!mHasVibrator) {
267 mSilentModeAction = new SilentModeToggleAction();
268 } else {
Lucas Dupin40ec6b782018-06-05 19:07:16 -0700269 mSilentModeAction = new SilentModeTriStateAction(mAudioManager, mHandler);
Jason Monk361915c2017-03-21 20:33:59 -0400270 }
271 mAirplaneModeOn = new ToggleAction(
272 R.drawable.ic_lock_airplane_mode,
273 R.drawable.ic_lock_airplane_mode_off,
274 R.string.global_actions_toggle_airplane_mode,
275 R.string.global_actions_airplane_mode_on_status,
276 R.string.global_actions_airplane_mode_off_status) {
277
278 void onToggle(boolean on) {
279 if (mHasTelephony && Boolean.parseBoolean(
280 SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE))) {
281 mIsWaitingForEcmExit = true;
282 // Launch ECM exit dialog
283 Intent ecmDialogIntent =
284 new Intent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null);
285 ecmDialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
286 mContext.startActivity(ecmDialogIntent);
287 } else {
288 changeAirplaneModeSystemSetting(on);
289 }
290 }
291
292 @Override
293 protected void changeStateFromPress(boolean buttonOn) {
294 if (!mHasTelephony) return;
295
296 // In ECM mode airplane state cannot be changed
297 if (!(Boolean.parseBoolean(
298 SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE)))) {
299 mState = buttonOn ? State.TurningOn : State.TurningOff;
300 mAirplaneState = mState;
301 }
302 }
303
304 public boolean showDuringKeyguard() {
305 return true;
306 }
307
308 public boolean showBeforeProvisioning() {
309 return false;
310 }
311 };
312 onAirplaneModeChanged();
313
314 mItems = new ArrayList<Action>();
315 String[] defaultActions = mContext.getResources().getStringArray(
316 R.array.config_globalActionsList);
317
318 ArraySet<String> addedKeys = new ArraySet<String>();
Alex Chau04458852017-11-27 18:21:23 +0000319 mHasLogoutButton = false;
Chad Brubaker72a73ea2018-01-26 15:56:55 -0800320 mHasLockdownButton = false;
Wesley.CW Wanga9de7922018-07-06 15:26:21 +0800321 mSeparatedEmergencyButtonEnabled = Settings.Global.getInt(mContext.getContentResolver(),
322 Settings.Global.FASTER_EMERGENCY_PHONE_CALL_ENABLED, 0) != 0;
Jason Monk361915c2017-03-21 20:33:59 -0400323 for (int i = 0; i < defaultActions.length; i++) {
324 String actionKey = defaultActions[i];
325 if (addedKeys.contains(actionKey)) {
326 // If we already have added this, don't add it again.
327 continue;
328 }
329 if (GLOBAL_ACTION_KEY_POWER.equals(actionKey)) {
330 mItems.add(new PowerAction());
331 } else if (GLOBAL_ACTION_KEY_AIRPLANE.equals(actionKey)) {
332 mItems.add(mAirplaneModeOn);
333 } else if (GLOBAL_ACTION_KEY_BUGREPORT.equals(actionKey)) {
334 if (Settings.Global.getInt(mContext.getContentResolver(),
335 Settings.Global.BUGREPORT_IN_POWER_MENU, 0) != 0 && isCurrentUserOwner()) {
336 mItems.add(new BugReportAction());
337 }
338 } else if (GLOBAL_ACTION_KEY_SILENT.equals(actionKey)) {
339 if (mShowSilentToggle) {
340 mItems.add(mSilentModeAction);
341 }
342 } else if (GLOBAL_ACTION_KEY_USERS.equals(actionKey)) {
343 if (SystemProperties.getBoolean("fw.power_user_switcher", false)) {
344 addUsersToMenu(mItems);
345 }
346 } else if (GLOBAL_ACTION_KEY_SETTINGS.equals(actionKey)) {
347 mItems.add(getSettingsAction());
348 } else if (GLOBAL_ACTION_KEY_LOCKDOWN.equals(actionKey)) {
Chad Brubaker02cd6cf2018-05-01 14:59:33 -0700349 if (Settings.Secure.getIntForUser(mContext.getContentResolver(),
350 Settings.Secure.LOCKDOWN_IN_POWER_MENU, 0, getCurrentUser().id) != 0
Chad Brubakerf4075fe2018-01-03 13:23:22 -0800351 && shouldDisplayLockdown()) {
Chad Brubaker4f28f0d2017-09-07 14:28:13 -0700352 mItems.add(getLockdownAction());
Chad Brubaker72a73ea2018-01-26 15:56:55 -0800353 mHasLockdownButton = true;
Chad Brubaker4f28f0d2017-09-07 14:28:13 -0700354 }
Jason Monk361915c2017-03-21 20:33:59 -0400355 } else if (GLOBAL_ACTION_KEY_VOICEASSIST.equals(actionKey)) {
356 mItems.add(getVoiceAssistAction());
357 } else if (GLOBAL_ACTION_KEY_ASSIST.equals(actionKey)) {
358 mItems.add(getAssistAction());
359 } else if (GLOBAL_ACTION_KEY_RESTART.equals(actionKey)) {
360 mItems.add(new RestartAction());
Alison Cichowlasa2cd19e2017-12-06 10:51:21 -0500361 } else if (GLOBAL_ACTION_KEY_SCREENSHOT.equals(actionKey)) {
362 mItems.add(new ScreenshotAction());
Alex Chau04458852017-11-27 18:21:23 +0000363 } else if (GLOBAL_ACTION_KEY_LOGOUT.equals(actionKey)) {
Alex Chaud7958272017-12-08 11:30:52 +0000364 if (mDevicePolicyManager.isLogoutEnabled()
Alex Chau04458852017-11-27 18:21:23 +0000365 && getCurrentUser().id != UserHandle.USER_SYSTEM) {
366 mItems.add(new LogoutAction());
367 mHasLogoutButton = true;
368 }
Wesley.CW Wanga9de7922018-07-06 15:26:21 +0800369 } else if (GLOBAL_ACTION_KEY_EMERGENCY.equals(actionKey)) {
370 if (mSeparatedEmergencyButtonEnabled
371 && !mEmergencyAffordanceManager.needsEmergencyAffordance()) {
372 mItems.add(new EmergencyDialerAction());
373 }
Jason Monk361915c2017-03-21 20:33:59 -0400374 } else {
375 Log.e(TAG, "Invalid global action key " + actionKey);
376 }
377 // Add here so we don't add more than one.
378 addedKeys.add(actionKey);
379 }
380
381 if (mEmergencyAffordanceManager.needsEmergencyAffordance()) {
382 mItems.add(getEmergencyAction());
383 }
384
385 mAdapter = new MyAdapter();
386
Lucas Dupin1d4a5792018-04-02 15:14:59 -0700387 OnItemLongClickListener onItemLongClickListener = (parent, view, position, id) -> {
388 final Action action = mAdapter.getItem(position);
389 if (action instanceof LongPressAction) {
390 mDialog.dismiss();
391 return ((LongPressAction) action).onLongPress();
Jason Monk16fbd9d2017-04-27 14:28:49 -0400392 }
Lucas Dupin1d4a5792018-04-02 15:14:59 -0700393 return false;
Jason Monk16fbd9d2017-04-27 14:28:49 -0400394 };
Wesley.CW Wang3004fcb2018-06-15 16:24:57 +0800395 ActionsDialog dialog = new ActionsDialog(mContext, this, mAdapter, onItemLongClickListener,
Wesley.CW Wanga9de7922018-07-06 15:26:21 +0800396 mSeparatedEmergencyButtonEnabled);
Jason Monk361915c2017-03-21 20:33:59 -0400397 dialog.setCanceledOnTouchOutside(false); // Handled by the custom class.
Lucas Dupinc1cc7592017-05-22 15:56:16 -0700398 dialog.setKeyguardShowing(mKeyguardShowing);
Jason Monk361915c2017-03-21 20:33:59 -0400399
400 dialog.setOnDismissListener(this);
Shaotang Li786da902018-08-02 11:18:00 +0800401 dialog.setOnShowListener(this);
Jason Monk361915c2017-03-21 20:33:59 -0400402
403 return dialog;
404 }
405
Chad Brubakerf4075fe2018-01-03 13:23:22 -0800406 private boolean shouldDisplayLockdown() {
407 int userId = getCurrentUser().id;
408 // Lockdown is meaningless without a place to go.
409 if (!mKeyguardManager.isDeviceSecure(userId)) {
410 return false;
411 }
412
413 // Only show the lockdown button if the device isn't locked down (for whatever reason).
414 int state = mLockPatternUtils.getStrongAuthForUser(userId);
415 return (state == STRONG_AUTH_NOT_REQUIRED
416 || state == SOME_AUTH_REQUIRED_AFTER_USER_REQUEST);
417 }
418
Jason Monk361915c2017-03-21 20:33:59 -0400419 private final class PowerAction extends SinglePressAction implements LongPressAction {
420 private PowerAction() {
421 super(R.drawable.ic_lock_power_off,
Jason Monk16fbd9d2017-04-27 14:28:49 -0400422 R.string.global_action_power_off);
Jason Monk361915c2017-03-21 20:33:59 -0400423 }
424
425 @Override
426 public boolean onLongPress() {
427 UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
428 if (!um.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {
429 mWindowManagerFuncs.reboot(true);
430 return true;
431 }
432 return false;
433 }
434
435 @Override
436 public boolean showDuringKeyguard() {
437 return true;
438 }
439
440 @Override
441 public boolean showBeforeProvisioning() {
442 return true;
443 }
444
445 @Override
446 public void onPress() {
447 // shutdown by making sure radio and power are handled accordingly.
448 mWindowManagerFuncs.shutdown();
449 }
450 }
451
Wesley.CW Wanga9de7922018-07-06 15:26:21 +0800452 private class EmergencyDialerAction extends SinglePressAction {
Wesley.CW Wanga9de7922018-07-06 15:26:21 +0800453 private EmergencyDialerAction() {
454 super(R.drawable.ic_faster_emergency,
Wesley.CW Wang3004fcb2018-06-15 16:24:57 +0800455 R.string.global_action_emergency);
Wesley.CW Wang8d072762018-05-28 16:39:27 +0800456 }
457
458 @Override
459 public void onPress() {
Shaotang Li786da902018-08-02 11:18:00 +0800460 MetricsLogger.action(mContext, MetricsEvent.ACTION_EMERGENCY_DIALER_FROM_POWER_MENU);
Shaotang Li5c422632018-07-04 14:18:40 +0800461 Intent intent = new Intent(EmergencyDialerConstants.ACTION_DIAL);
Wesley.CW Wang8d072762018-05-28 16:39:27 +0800462 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
Shaotang Li5c422632018-07-04 14:18:40 +0800463 intent.putExtra(EmergencyDialerConstants.EXTRA_ENTRY_TYPE,
464 EmergencyDialerConstants.ENTRY_TYPE_POWER_MENU);
Wesley.CW Wang8d072762018-05-28 16:39:27 +0800465 mContext.startActivityAsUser(intent, UserHandle.CURRENT);
466 }
467
468 @Override
469 public boolean showDuringKeyguard() {
470 return true;
471 }
472
473 @Override
474 public boolean showBeforeProvisioning() {
475 return true;
476 }
477 }
478
Jason Monk361915c2017-03-21 20:33:59 -0400479 private final class RestartAction extends SinglePressAction implements LongPressAction {
480 private RestartAction() {
481 super(R.drawable.ic_restart, R.string.global_action_restart);
482 }
483
484 @Override
485 public boolean onLongPress() {
486 UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
487 if (!um.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {
488 mWindowManagerFuncs.reboot(true);
489 return true;
490 }
491 return false;
492 }
493
494 @Override
495 public boolean showDuringKeyguard() {
496 return true;
497 }
498
499 @Override
500 public boolean showBeforeProvisioning() {
501 return true;
502 }
503
504 @Override
505 public void onPress() {
506 mWindowManagerFuncs.reboot(false);
507 }
508 }
509
510
Alison Cichowlasa2cd19e2017-12-06 10:51:21 -0500511 private class ScreenshotAction extends SinglePressAction {
512 public ScreenshotAction() {
513 super(R.drawable.ic_screenshot, R.string.global_action_screenshot);
514 }
515
516 @Override
517 public void onPress() {
518 // Add a little delay before executing, to give the
519 // dialog a chance to go away before it takes a
520 // screenshot.
521 // TODO: instead, omit global action dialog layer
522 mHandler.postDelayed(new Runnable() {
523 @Override
524 public void run() {
525 mScreenshotHelper.takeScreenshot(1, true, true, mHandler);
526 MetricsLogger.action(mContext,
527 MetricsEvent.ACTION_SCREENSHOT_POWER_MENU);
528 }
529 }, 500);
530 }
531
532 @Override
533 public boolean showDuringKeyguard() {
534 return true;
535 }
536
537 @Override
538 public boolean showBeforeProvisioning() {
539 return false;
540 }
541 }
542
Jason Monk361915c2017-03-21 20:33:59 -0400543 private class BugReportAction extends SinglePressAction implements LongPressAction {
544
545 public BugReportAction() {
546 super(R.drawable.ic_lock_bugreport, R.string.bugreport_title);
547 }
548
549 @Override
550 public void onPress() {
551 // don't actually trigger the bugreport if we are running stability
552 // tests via monkey
553 if (ActivityManager.isUserAMonkey()) {
554 return;
555 }
556 // Add a little delay before executing, to give the
557 // dialog a chance to go away before it takes a
558 // screenshot.
559 mHandler.postDelayed(new Runnable() {
560 @Override
561 public void run() {
562 try {
563 // Take an "interactive" bugreport.
564 MetricsLogger.action(mContext,
565 MetricsEvent.ACTION_BUGREPORT_FROM_POWER_MENU_INTERACTIVE);
566 ActivityManager.getService().requestBugReport(
567 ActivityManager.BUGREPORT_OPTION_INTERACTIVE);
568 } catch (RemoteException e) {
569 }
570 }
571 }, 500);
572 }
573
574 @Override
575 public boolean onLongPress() {
576 // don't actually trigger the bugreport if we are running stability
577 // tests via monkey
578 if (ActivityManager.isUserAMonkey()) {
579 return false;
580 }
581 try {
582 // Take a "full" bugreport.
583 MetricsLogger.action(mContext, MetricsEvent.ACTION_BUGREPORT_FROM_POWER_MENU_FULL);
584 ActivityManager.getService().requestBugReport(
585 ActivityManager.BUGREPORT_OPTION_FULL);
586 } catch (RemoteException e) {
587 }
588 return false;
589 }
590
591 public boolean showDuringKeyguard() {
592 return true;
593 }
594
595 @Override
596 public boolean showBeforeProvisioning() {
597 return false;
598 }
599
600 @Override
601 public String getStatus() {
602 return mContext.getString(
603 R.string.bugreport_status,
604 Build.VERSION.RELEASE,
605 Build.ID);
606 }
607 }
608
Alex Chau04458852017-11-27 18:21:23 +0000609 private final class LogoutAction extends SinglePressAction {
610 private LogoutAction() {
611 super(R.drawable.ic_logout, R.string.global_action_logout);
612 }
613
614 @Override
615 public boolean showDuringKeyguard() {
616 return true;
617 }
618
619 @Override
620 public boolean showBeforeProvisioning() {
621 return false;
622 }
623
624 @Override
625 public void onPress() {
626 // Add a little delay before executing, to give the dialog a chance to go away before
627 // switching user
628 mHandler.postDelayed(() -> {
629 try {
Alex Chauedb6a012018-01-26 12:52:43 +0000630 int currentUserId = getCurrentUser().id;
Alex Chau04458852017-11-27 18:21:23 +0000631 ActivityManager.getService().switchUser(UserHandle.USER_SYSTEM);
Alex Chauedb6a012018-01-26 12:52:43 +0000632 ActivityManager.getService().stopUser(currentUserId, true /*force*/, null);
Alex Chau04458852017-11-27 18:21:23 +0000633 } catch (RemoteException re) {
634 Log.e(TAG, "Couldn't logout user " + re);
635 }
636 }, 500);
637 }
638 }
639
Jason Monk361915c2017-03-21 20:33:59 -0400640 private Action getSettingsAction() {
641 return new SinglePressAction(R.drawable.ic_settings,
642 R.string.global_action_settings) {
643
644 @Override
645 public void onPress() {
646 Intent intent = new Intent(Settings.ACTION_SETTINGS);
647 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
648 mContext.startActivity(intent);
649 }
650
651 @Override
652 public boolean showDuringKeyguard() {
653 return true;
654 }
655
656 @Override
657 public boolean showBeforeProvisioning() {
658 return true;
659 }
660 };
661 }
662
663 private Action getEmergencyAction() {
Wesley.CW Wanga9de7922018-07-06 15:26:21 +0800664 Drawable emergencyIcon = mContext.getDrawable(R.drawable.emergency_icon);
665 if(!mSeparatedEmergencyButtonEnabled) {
666 // use un-colored legacy treatment
667 emergencyIcon.setTintList(null);
668 }
669
Jason Monk361915c2017-03-21 20:33:59 -0400670 return new SinglePressAction(R.drawable.emergency_icon,
671 R.string.global_action_emergency) {
672 @Override
673 public void onPress() {
674 mEmergencyAffordanceManager.performEmergencyCall();
675 }
676
677 @Override
678 public boolean showDuringKeyguard() {
679 return true;
680 }
681
682 @Override
683 public boolean showBeforeProvisioning() {
684 return true;
685 }
686 };
687 }
688
689 private Action getAssistAction() {
690 return new SinglePressAction(R.drawable.ic_action_assist_focused,
691 R.string.global_action_assist) {
692 @Override
693 public void onPress() {
694 Intent intent = new Intent(Intent.ACTION_ASSIST);
695 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
696 mContext.startActivity(intent);
697 }
698
699 @Override
700 public boolean showDuringKeyguard() {
701 return true;
702 }
703
704 @Override
705 public boolean showBeforeProvisioning() {
706 return true;
707 }
708 };
709 }
710
711 private Action getVoiceAssistAction() {
712 return new SinglePressAction(R.drawable.ic_voice_search,
713 R.string.global_action_voice_assist) {
714 @Override
715 public void onPress() {
716 Intent intent = new Intent(Intent.ACTION_VOICE_ASSIST);
717 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
718 mContext.startActivity(intent);
719 }
720
721 @Override
722 public boolean showDuringKeyguard() {
723 return true;
724 }
725
726 @Override
727 public boolean showBeforeProvisioning() {
728 return true;
729 }
730 };
731 }
732
733 private Action getLockdownAction() {
Alison Cichowlas21125432018-05-16 15:40:45 -0400734 return new SinglePressAction(R.drawable.ic_lock_lockdown,
Jason Monk361915c2017-03-21 20:33:59 -0400735 R.string.global_action_lockdown) {
736
737 @Override
738 public void onPress() {
Chad Brubaker4f28f0d2017-09-07 14:28:13 -0700739 new LockPatternUtils(mContext)
740 .requireStrongAuth(STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN,
741 UserHandle.USER_ALL);
Jason Monk361915c2017-03-21 20:33:59 -0400742 try {
743 WindowManagerGlobal.getWindowManagerService().lockNow(null);
Pavel Grafov059021b2018-05-02 13:44:46 +0100744 // Lock profiles (if any) on the background thread.
745 final Handler bgHandler = new Handler(Dependency.get(Dependency.BG_LOOPER));
746 bgHandler.post(() -> lockProfiles());
Jason Monk361915c2017-03-21 20:33:59 -0400747 } catch (RemoteException e) {
748 Log.e(TAG, "Error while trying to lock device.", e);
749 }
750 }
751
752 @Override
753 public boolean showDuringKeyguard() {
754 return true;
755 }
756
757 @Override
758 public boolean showBeforeProvisioning() {
759 return false;
760 }
761 };
762 }
763
Pavel Grafov059021b2018-05-02 13:44:46 +0100764 private void lockProfiles() {
765 final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
766 final TrustManager tm = (TrustManager) mContext.getSystemService(Context.TRUST_SERVICE);
767 final int currentUserId = getCurrentUser().id;
768 final int[] profileIds = um.getEnabledProfileIds(currentUserId);
769 for (final int id : profileIds) {
770 if (id != currentUserId) {
771 tm.setDeviceLockedForUser(id, true);
772 }
773 }
774 }
775
Jason Monk361915c2017-03-21 20:33:59 -0400776 private UserInfo getCurrentUser() {
777 try {
778 return ActivityManager.getService().getCurrentUser();
779 } catch (RemoteException re) {
780 return null;
781 }
782 }
783
784 private boolean isCurrentUserOwner() {
785 UserInfo currentUser = getCurrentUser();
786 return currentUser == null || currentUser.isPrimary();
787 }
788
789 private void addUsersToMenu(ArrayList<Action> items) {
790 UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
791 if (um.isUserSwitcherEnabled()) {
792 List<UserInfo> users = um.getUsers();
793 UserInfo currentUser = getCurrentUser();
794 for (final UserInfo user : users) {
795 if (user.supportsSwitchToByUser()) {
796 boolean isCurrentUser = currentUser == null
797 ? user.id == 0 : (currentUser.id == user.id);
798 Drawable icon = user.iconPath != null ? Drawable.createFromPath(user.iconPath)
799 : null;
800 SinglePressAction switchToUser = new SinglePressAction(
801 R.drawable.ic_menu_cc, icon,
802 (user.name != null ? user.name : "Primary")
Jason Monk16fbd9d2017-04-27 14:28:49 -0400803 + (isCurrentUser ? " \u2714" : "")) {
Jason Monk361915c2017-03-21 20:33:59 -0400804 public void onPress() {
805 try {
806 ActivityManager.getService().switchUser(user.id);
807 } catch (RemoteException re) {
808 Log.e(TAG, "Couldn't switch user " + re);
809 }
810 }
811
812 public boolean showDuringKeyguard() {
813 return true;
814 }
815
816 public boolean showBeforeProvisioning() {
817 return false;
818 }
819 };
820 items.add(switchToUser);
821 }
822 }
823 }
824 }
825
826 private void prepareDialog() {
827 refreshSilentMode();
828 mAirplaneModeOn.updateState(mAirplaneState);
829 mAdapter.notifyDataSetChanged();
Jason Monk361915c2017-03-21 20:33:59 -0400830 if (mShowSilentToggle) {
831 IntentFilter filter = new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION);
832 mContext.registerReceiver(mRingerModeReceiver, filter);
833 }
834 }
835
836 private void refreshSilentMode() {
837 if (!mHasVibrator) {
838 final boolean silentModeOn =
839 mAudioManager.getRingerMode() != AudioManager.RINGER_MODE_NORMAL;
Jason Monk16fbd9d2017-04-27 14:28:49 -0400840 ((ToggleAction) mSilentModeAction).updateState(
Jason Monk361915c2017-03-21 20:33:59 -0400841 silentModeOn ? ToggleAction.State.On : ToggleAction.State.Off);
842 }
843 }
844
845 /** {@inheritDoc} */
846 public void onDismiss(DialogInterface dialog) {
847 mWindowManagerFuncs.onGlobalActionsHidden();
848 if (mShowSilentToggle) {
849 try {
850 mContext.unregisterReceiver(mRingerModeReceiver);
851 } catch (IllegalArgumentException ie) {
852 // ignore this
853 Log.w(TAG, ie);
854 }
855 }
856 }
857
858 /** {@inheritDoc} */
859 public void onClick(DialogInterface dialog, int which) {
Jason Monkfd279662017-06-29 19:37:48 -0400860 Action item = mAdapter.getItem(which);
Jason Monkb4302182017-08-04 13:39:17 -0400861 if (!(item instanceof SilentModeTriStateAction)) {
Jason Monk361915c2017-03-21 20:33:59 -0400862 dialog.dismiss();
863 }
Jason Monkfd279662017-06-29 19:37:48 -0400864 item.onPress();
Jason Monk361915c2017-03-21 20:33:59 -0400865 }
866
Shaotang Li786da902018-08-02 11:18:00 +0800867 /** {@inheritDoc} */
868 public void onShow(DialogInterface dialog) {
869 MetricsLogger.visible(mContext, MetricsEvent.POWER_MENU);
870 }
871
Jason Monk361915c2017-03-21 20:33:59 -0400872 /**
873 * The adapter used for the list within the global actions dialog, taking
874 * into account whether the keyguard is showing via
Jason Monk16fbd9d2017-04-27 14:28:49 -0400875 * {@link com.android.systemui.globalactions.GlobalActionsDialog#mKeyguardShowing} and whether
876 * the device is provisioned
Jason Monk361915c2017-03-21 20:33:59 -0400877 * via {@link com.android.systemui.globalactions.GlobalActionsDialog#mDeviceProvisioned}.
878 */
879 private class MyAdapter extends BaseAdapter {
880
881 public int getCount() {
882 int count = 0;
883
884 for (int i = 0; i < mItems.size(); i++) {
885 final Action action = mItems.get(i);
886
887 if (mKeyguardShowing && !action.showDuringKeyguard()) {
888 continue;
889 }
890 if (!mDeviceProvisioned && !action.showBeforeProvisioning()) {
891 continue;
892 }
893 count++;
894 }
895 return count;
896 }
897
898 @Override
899 public boolean isEnabled(int position) {
900 return getItem(position).isEnabled();
901 }
902
903 @Override
904 public boolean areAllItemsEnabled() {
905 return false;
906 }
907
908 public Action getItem(int position) {
909
910 int filteredPos = 0;
911 for (int i = 0; i < mItems.size(); i++) {
912 final Action action = mItems.get(i);
913 if (mKeyguardShowing && !action.showDuringKeyguard()) {
914 continue;
915 }
916 if (!mDeviceProvisioned && !action.showBeforeProvisioning()) {
917 continue;
918 }
919 if (filteredPos == position) {
920 return action;
921 }
922 filteredPos++;
923 }
924
925 throw new IllegalArgumentException("position " + position
926 + " out of range of showable actions"
927 + ", filtered count=" + getCount()
928 + ", keyguardshowing=" + mKeyguardShowing
929 + ", provisioned=" + mDeviceProvisioned);
930 }
931
932
933 public long getItemId(int position) {
934 return position;
935 }
936
937 public View getView(int position, View convertView, ViewGroup parent) {
938 Action action = getItem(position);
Jason Monk16fbd9d2017-04-27 14:28:49 -0400939 View view = action.create(mContext, convertView, parent, LayoutInflater.from(mContext));
Alison Cichowlas3be52db2018-03-06 19:48:06 -0500940 // Everything but screenshot, the last item, gets white background.
941 if (position == getCount() - 1) {
Jason Monk16fbd9d2017-04-27 14:28:49 -0400942 HardwareUiLayout.get(parent).setDivisionView(view);
943 }
944 return view;
Jason Monk361915c2017-03-21 20:33:59 -0400945 }
946 }
947
948 // note: the scheme below made more sense when we were planning on having
949 // 8 different things in the global actions dialog. seems overkill with
950 // only 3 items now, but may as well keep this flexible approach so it will
951 // be easy should someone decide at the last minute to include something
952 // else, such as 'enable wifi', or 'enable bluetooth'
953
954 /**
955 * What each item in the global actions dialog must be able to support.
956 */
957 private interface Action {
958 /**
959 * @return Text that will be announced when dialog is created. null
Jason Monk16fbd9d2017-04-27 14:28:49 -0400960 * for none.
Jason Monk361915c2017-03-21 20:33:59 -0400961 */
962 CharSequence getLabelForAccessibility(Context context);
963
964 View create(Context context, View convertView, ViewGroup parent, LayoutInflater inflater);
965
966 void onPress();
967
968 /**
969 * @return whether this action should appear in the dialog when the keygaurd
Jason Monk16fbd9d2017-04-27 14:28:49 -0400970 * is showing.
Jason Monk361915c2017-03-21 20:33:59 -0400971 */
972 boolean showDuringKeyguard();
973
974 /**
975 * @return whether this action should appear in the dialog before the
Jason Monk16fbd9d2017-04-27 14:28:49 -0400976 * device is provisioned.
Jason Monk361915c2017-03-21 20:33:59 -0400977 */
978 boolean showBeforeProvisioning();
979
980 boolean isEnabled();
981 }
982
983 /**
984 * An action that also supports long press.
985 */
986 private interface LongPressAction extends Action {
987 boolean onLongPress();
988 }
989
990 /**
991 * A single press action maintains no state, just responds to a press
992 * and takes an action.
993 */
994 private static abstract class SinglePressAction implements Action {
995 private final int mIconResId;
996 private final Drawable mIcon;
997 private final int mMessageResId;
998 private final CharSequence mMessage;
999
1000 protected SinglePressAction(int iconResId, int messageResId) {
1001 mIconResId = iconResId;
1002 mMessageResId = messageResId;
1003 mMessage = null;
1004 mIcon = null;
1005 }
1006
1007 protected SinglePressAction(int iconResId, Drawable icon, CharSequence message) {
1008 mIconResId = iconResId;
1009 mMessageResId = 0;
1010 mMessage = message;
1011 mIcon = icon;
1012 }
1013
1014 public boolean isEnabled() {
1015 return true;
1016 }
1017
1018 public String getStatus() {
1019 return null;
1020 }
1021
1022 abstract public void onPress();
1023
1024 public CharSequence getLabelForAccessibility(Context context) {
1025 if (mMessage != null) {
1026 return mMessage;
1027 } else {
1028 return context.getString(mMessageResId);
1029 }
1030 }
1031
1032 public View create(
1033 Context context, View convertView, ViewGroup parent, LayoutInflater inflater) {
Jason Monk16fbd9d2017-04-27 14:28:49 -04001034 View v = inflater.inflate(com.android.systemui.R.layout.global_actions_item, parent,
1035 false);
Jason Monk361915c2017-03-21 20:33:59 -04001036
1037 ImageView icon = (ImageView) v.findViewById(R.id.icon);
1038 TextView messageView = (TextView) v.findViewById(R.id.message);
1039
1040 TextView statusView = (TextView) v.findViewById(R.id.status);
1041 final String status = getStatus();
1042 if (!TextUtils.isEmpty(status)) {
1043 statusView.setText(status);
1044 } else {
1045 statusView.setVisibility(View.GONE);
1046 }
1047 if (mIcon != null) {
1048 icon.setImageDrawable(mIcon);
1049 icon.setScaleType(ScaleType.CENTER_CROP);
1050 } else if (mIconResId != 0) {
1051 icon.setImageDrawable(context.getDrawable(mIconResId));
1052 }
1053 if (mMessage != null) {
1054 messageView.setText(mMessage);
1055 } else {
1056 messageView.setText(mMessageResId);
1057 }
1058
1059 return v;
1060 }
1061 }
1062
1063 /**
1064 * A toggle action knows whether it is on or off, and displays an icon
1065 * and status message accordingly.
1066 */
1067 private static abstract class ToggleAction implements Action {
1068
1069 enum State {
1070 Off(false),
1071 TurningOn(true),
1072 TurningOff(true),
1073 On(false);
1074
1075 private final boolean inTransition;
1076
1077 State(boolean intermediate) {
1078 inTransition = intermediate;
1079 }
1080
1081 public boolean inTransition() {
1082 return inTransition;
1083 }
1084 }
1085
1086 protected State mState = State.Off;
1087
1088 // prefs
1089 protected int mEnabledIconResId;
1090 protected int mDisabledIconResid;
1091 protected int mMessageResId;
1092 protected int mEnabledStatusMessageResId;
1093 protected int mDisabledStatusMessageResId;
1094
1095 /**
Jason Monk16fbd9d2017-04-27 14:28:49 -04001096 * @param enabledIconResId The icon for when this action is on.
1097 * @param disabledIconResid The icon for when this action is off.
1098 * @param message The general information message, e.g 'Silent Mode'
1099 * @param enabledStatusMessageResId The on status message, e.g 'sound disabled'
Jason Monk361915c2017-03-21 20:33:59 -04001100 * @param disabledStatusMessageResId The off status message, e.g. 'sound enabled'
1101 */
1102 public ToggleAction(int enabledIconResId,
1103 int disabledIconResid,
1104 int message,
1105 int enabledStatusMessageResId,
1106 int disabledStatusMessageResId) {
1107 mEnabledIconResId = enabledIconResId;
1108 mDisabledIconResid = disabledIconResid;
1109 mMessageResId = message;
1110 mEnabledStatusMessageResId = enabledStatusMessageResId;
1111 mDisabledStatusMessageResId = disabledStatusMessageResId;
1112 }
1113
1114 /**
1115 * Override to make changes to resource IDs just before creating the
1116 * View.
1117 */
1118 void willCreate() {
1119
1120 }
1121
1122 @Override
1123 public CharSequence getLabelForAccessibility(Context context) {
1124 return context.getString(mMessageResId);
1125 }
1126
1127 public View create(Context context, View convertView, ViewGroup parent,
1128 LayoutInflater inflater) {
1129 willCreate();
1130
1131 View v = inflater.inflate(R
Jason Monk16fbd9d2017-04-27 14:28:49 -04001132 .layout.global_actions_item, parent, false);
Jason Monk361915c2017-03-21 20:33:59 -04001133
1134 ImageView icon = (ImageView) v.findViewById(R.id.icon);
1135 TextView messageView = (TextView) v.findViewById(R.id.message);
1136 TextView statusView = (TextView) v.findViewById(R.id.status);
1137 final boolean enabled = isEnabled();
1138
1139 if (messageView != null) {
1140 messageView.setText(mMessageResId);
1141 messageView.setEnabled(enabled);
1142 }
1143
1144 boolean on = ((mState == State.On) || (mState == State.TurningOn));
1145 if (icon != null) {
1146 icon.setImageDrawable(context.getDrawable(
1147 (on ? mEnabledIconResId : mDisabledIconResid)));
1148 icon.setEnabled(enabled);
1149 }
1150
1151 if (statusView != null) {
1152 statusView.setText(on ? mEnabledStatusMessageResId : mDisabledStatusMessageResId);
1153 statusView.setVisibility(View.VISIBLE);
1154 statusView.setEnabled(enabled);
1155 }
1156 v.setEnabled(enabled);
1157
1158 return v;
1159 }
1160
1161 public final void onPress() {
1162 if (mState.inTransition()) {
1163 Log.w(TAG, "shouldn't be able to toggle when in transition");
1164 return;
1165 }
1166
1167 final boolean nowOn = !(mState == State.On);
1168 onToggle(nowOn);
1169 changeStateFromPress(nowOn);
1170 }
1171
1172 public boolean isEnabled() {
1173 return !mState.inTransition();
1174 }
1175
1176 /**
1177 * Implementations may override this if their state can be in on of the intermediate
1178 * states until some notification is received (e.g airplane mode is 'turning off' until
1179 * we know the wireless connections are back online
Jason Monk16fbd9d2017-04-27 14:28:49 -04001180 *
Jason Monk361915c2017-03-21 20:33:59 -04001181 * @param buttonOn Whether the button was turned on or off
1182 */
1183 protected void changeStateFromPress(boolean buttonOn) {
1184 mState = buttonOn ? State.On : State.Off;
1185 }
1186
1187 abstract void onToggle(boolean on);
1188
1189 public void updateState(State state) {
1190 mState = state;
1191 }
1192 }
1193
1194 private class SilentModeToggleAction extends ToggleAction {
1195 public SilentModeToggleAction() {
1196 super(R.drawable.ic_audio_vol_mute,
1197 R.drawable.ic_audio_vol,
1198 R.string.global_action_toggle_silent_mode,
1199 R.string.global_action_silent_mode_on_status,
1200 R.string.global_action_silent_mode_off_status);
1201 }
1202
1203 void onToggle(boolean on) {
1204 if (on) {
1205 mAudioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
1206 } else {
1207 mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
1208 }
1209 }
1210
1211 public boolean showDuringKeyguard() {
1212 return true;
1213 }
1214
1215 public boolean showBeforeProvisioning() {
1216 return false;
1217 }
1218 }
1219
1220 private static class SilentModeTriStateAction implements Action, View.OnClickListener {
1221
Jason Monk16fbd9d2017-04-27 14:28:49 -04001222 private final int[] ITEM_IDS = {R.id.option1, R.id.option2, R.id.option3};
Jason Monk361915c2017-03-21 20:33:59 -04001223
1224 private final AudioManager mAudioManager;
1225 private final Handler mHandler;
Jason Monk361915c2017-03-21 20:33:59 -04001226
Lucas Dupin40ec6b782018-06-05 19:07:16 -07001227 SilentModeTriStateAction(AudioManager audioManager, Handler handler) {
Jason Monk361915c2017-03-21 20:33:59 -04001228 mAudioManager = audioManager;
1229 mHandler = handler;
Jason Monk361915c2017-03-21 20:33:59 -04001230 }
1231
1232 private int ringerModeToIndex(int ringerMode) {
1233 // They just happen to coincide
1234 return ringerMode;
1235 }
1236
1237 private int indexToRingerMode(int index) {
1238 // They just happen to coincide
1239 return index;
1240 }
1241
1242 @Override
1243 public CharSequence getLabelForAccessibility(Context context) {
1244 return null;
1245 }
1246
1247 public View create(Context context, View convertView, ViewGroup parent,
1248 LayoutInflater inflater) {
1249 View v = inflater.inflate(R.layout.global_actions_silent_mode, parent, false);
1250
1251 int selectedIndex = ringerModeToIndex(mAudioManager.getRingerMode());
1252 for (int i = 0; i < 3; i++) {
1253 View itemView = v.findViewById(ITEM_IDS[i]);
1254 itemView.setSelected(selectedIndex == i);
1255 // Set up click handler
1256 itemView.setTag(i);
1257 itemView.setOnClickListener(this);
1258 }
1259 return v;
1260 }
1261
1262 public void onPress() {
1263 }
1264
1265 public boolean showDuringKeyguard() {
1266 return true;
1267 }
1268
1269 public boolean showBeforeProvisioning() {
1270 return false;
1271 }
1272
1273 public boolean isEnabled() {
1274 return true;
1275 }
1276
1277 void willCreate() {
1278 }
1279
1280 public void onClick(View v) {
1281 if (!(v.getTag() instanceof Integer)) return;
1282
1283 int index = (Integer) v.getTag();
1284 mAudioManager.setRingerMode(indexToRingerMode(index));
1285 mHandler.sendEmptyMessageDelayed(MESSAGE_DISMISS, DIALOG_DISMISS_DELAY);
1286 }
1287 }
1288
1289 private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
1290 public void onReceive(Context context, Intent intent) {
1291 String action = intent.getAction();
1292 if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)
1293 || Intent.ACTION_SCREEN_OFF.equals(action)) {
1294 String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY);
1295 if (!SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS.equals(reason)) {
Lucas Dupin1d4a5792018-04-02 15:14:59 -07001296 mHandler.sendMessage(mHandler.obtainMessage(MESSAGE_DISMISS, reason));
Jason Monk361915c2017-03-21 20:33:59 -04001297 }
1298 } else if (TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED.equals(action)) {
1299 // Airplane mode can be changed after ECM exits if airplane toggle button
1300 // is pressed during ECM mode
1301 if (!(intent.getBooleanExtra("PHONE_IN_ECM_STATE", false)) &&
1302 mIsWaitingForEcmExit) {
1303 mIsWaitingForEcmExit = false;
1304 changeAirplaneModeSystemSetting(true);
1305 }
1306 }
1307 }
1308 };
1309
1310 PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
1311 @Override
1312 public void onServiceStateChanged(ServiceState serviceState) {
1313 if (!mHasTelephony) return;
1314 final boolean inAirplaneMode = serviceState.getState() == ServiceState.STATE_POWER_OFF;
1315 mAirplaneState = inAirplaneMode ? ToggleAction.State.On : ToggleAction.State.Off;
1316 mAirplaneModeOn.updateState(mAirplaneState);
1317 mAdapter.notifyDataSetChanged();
1318 }
1319 };
1320
1321 private BroadcastReceiver mRingerModeReceiver = new BroadcastReceiver() {
1322 @Override
1323 public void onReceive(Context context, Intent intent) {
1324 if (intent.getAction().equals(AudioManager.RINGER_MODE_CHANGED_ACTION)) {
1325 mHandler.sendEmptyMessage(MESSAGE_REFRESH);
1326 }
1327 }
1328 };
1329
1330 private ContentObserver mAirplaneModeObserver = new ContentObserver(new Handler()) {
1331 @Override
1332 public void onChange(boolean selfChange) {
1333 onAirplaneModeChanged();
1334 }
1335 };
1336
1337 private static final int MESSAGE_DISMISS = 0;
1338 private static final int MESSAGE_REFRESH = 1;
1339 private static final int MESSAGE_SHOW = 2;
1340 private static final int DIALOG_DISMISS_DELAY = 300; // ms
1341
1342 private Handler mHandler = new Handler() {
1343 public void handleMessage(Message msg) {
1344 switch (msg.what) {
Jason Monk16fbd9d2017-04-27 14:28:49 -04001345 case MESSAGE_DISMISS:
1346 if (mDialog != null) {
Lucas Dupin1d4a5792018-04-02 15:14:59 -07001347 if (SYSTEM_DIALOG_REASON_DREAM.equals(msg.obj)) {
1348 mDialog.dismissImmediately();
1349 } else {
1350 mDialog.dismiss();
1351 }
Jason Monk16fbd9d2017-04-27 14:28:49 -04001352 mDialog = null;
1353 }
1354 break;
1355 case MESSAGE_REFRESH:
1356 refreshSilentMode();
1357 mAdapter.notifyDataSetChanged();
1358 break;
1359 case MESSAGE_SHOW:
1360 handleShow();
1361 break;
Jason Monk361915c2017-03-21 20:33:59 -04001362 }
1363 }
1364 };
1365
1366 private void onAirplaneModeChanged() {
1367 // Let the service state callbacks handle the state.
1368 if (mHasTelephony) return;
1369
1370 boolean airplaneModeOn = Settings.Global.getInt(
1371 mContext.getContentResolver(),
1372 Settings.Global.AIRPLANE_MODE_ON,
1373 0) == 1;
1374 mAirplaneState = airplaneModeOn ? ToggleAction.State.On : ToggleAction.State.Off;
1375 mAirplaneModeOn.updateState(mAirplaneState);
1376 }
1377
1378 /**
1379 * Change the airplane mode system setting
1380 */
1381 private void changeAirplaneModeSystemSetting(boolean on) {
1382 Settings.Global.putInt(
1383 mContext.getContentResolver(),
1384 Settings.Global.AIRPLANE_MODE_ON,
1385 on ? 1 : 0);
1386 Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
1387 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
1388 intent.putExtra("state", on);
1389 mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
1390 if (!mHasTelephony) {
1391 mAirplaneState = on ? ToggleAction.State.On : ToggleAction.State.Off;
1392 }
1393 }
1394
Lucas Dupinc1cc7592017-05-22 15:56:16 -07001395 private static final class ActionsDialog extends Dialog implements DialogInterface,
1396 ColorExtractor.OnColorsChangedListener {
Jason Monk361915c2017-03-21 20:33:59 -04001397
Jason Monk16fbd9d2017-04-27 14:28:49 -04001398 private final Context mContext;
1399 private final MyAdapter mAdapter;
1400 private final LinearLayout mListView;
Wesley.CW Wang3004fcb2018-06-15 16:24:57 +08001401 private final FrameLayout mSeparatedView;
Jason Monk16fbd9d2017-04-27 14:28:49 -04001402 private final HardwareUiLayout mHardwareLayout;
1403 private final OnClickListener mClickListener;
1404 private final OnItemLongClickListener mLongClickListener;
Lucas Dupinc1cc7592017-05-22 15:56:16 -07001405 private final GradientDrawable mGradientDrawable;
1406 private final ColorExtractor mColorExtractor;
1407 private boolean mKeyguardShowing;
Wesley.CW Wang3004fcb2018-06-15 16:24:57 +08001408 private boolean mShouldDisplaySeparatedButton;
Beverly526d2d62018-08-15 12:55:33 -04001409 private boolean mShowing;
Jason Monk16fbd9d2017-04-27 14:28:49 -04001410
1411 public ActionsDialog(Context context, OnClickListener clickListener, MyAdapter adapter,
Wesley.CW Wang3004fcb2018-06-15 16:24:57 +08001412 OnItemLongClickListener longClickListener, boolean shouldDisplaySeparatedButton) {
Lucas Dupinc1cc7592017-05-22 15:56:16 -07001413 super(context, com.android.systemui.R.style.Theme_SystemUI_Dialog_GlobalActions);
Lucas Dupin448786c2017-07-24 17:44:25 -07001414 mContext = context;
Jason Monk16fbd9d2017-04-27 14:28:49 -04001415 mAdapter = adapter;
1416 mClickListener = clickListener;
1417 mLongClickListener = longClickListener;
Lucas Dupinc1cc7592017-05-22 15:56:16 -07001418 mGradientDrawable = new GradientDrawable(mContext);
Lucas Dupin1ead7fc2017-05-24 14:14:44 -07001419 mColorExtractor = Dependency.get(SysuiColorExtractor.class);
Wesley.CW Wang3004fcb2018-06-15 16:24:57 +08001420 mShouldDisplaySeparatedButton = shouldDisplaySeparatedButton;
Lucas Dupinc1cc7592017-05-22 15:56:16 -07001421
1422 // Window initialization
1423 Window window = getWindow();
1424 window.requestFeature(Window.FEATURE_NO_TITLE);
Adrian Roosedfab3b2018-03-08 18:39:20 +01001425 // Inflate the decor view, so the attributes below are not overwritten by the theme.
1426 window.getDecorView();
1427 window.getAttributes().systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
1428 | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
1429 | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
1430 window.setLayout(MATCH_PARENT, MATCH_PARENT);
1431 window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
Alison Cichowlas4f19f4a2017-07-25 10:56:16 -04001432 window.addFlags(
1433 WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
Lucas Dupinc1cc7592017-05-22 15:56:16 -07001434 | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
Adrian Roosedfab3b2018-03-08 18:39:20 +01001435 | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
Lucas Dupinc1cc7592017-05-22 15:56:16 -07001436 | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
1437 | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
1438 | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
1439 window.setBackgroundDrawable(mGradientDrawable);
1440 window.setType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY);
1441
Jason Monk16fbd9d2017-04-27 14:28:49 -04001442 setContentView(com.android.systemui.R.layout.global_actions_wrapped);
Jason Monk16fbd9d2017-04-27 14:28:49 -04001443 mListView = findViewById(android.R.id.list);
Wesley.CW Wang3004fcb2018-06-15 16:24:57 +08001444 mSeparatedView = findViewById(com.android.systemui.R.id.separated_button);
1445 if (!mShouldDisplaySeparatedButton) {
1446 mSeparatedView.setVisibility(View.GONE);
1447 }
Jason Monk16fbd9d2017-04-27 14:28:49 -04001448 mHardwareLayout = HardwareUiLayout.get(mListView);
1449 mHardwareLayout.setOutsideTouchListener(view -> dismiss());
Wesley.CW Wang3004fcb2018-06-15 16:24:57 +08001450 mHardwareLayout.setHasSeparatedButton(mShouldDisplaySeparatedButton);
Phil Weaver8583ae82018-02-13 11:01:24 -08001451 setTitle(R.string.global_actions);
Phil Weaver9054e092018-04-27 16:28:50 -07001452 mListView.setAccessibilityDelegate(new View.AccessibilityDelegate() {
1453 @Override
1454 public boolean dispatchPopulateAccessibilityEvent(
1455 View host, AccessibilityEvent event) {
1456 // Populate the title here, just as Activity does
1457 event.getText().add(mContext.getString(R.string.global_actions));
1458 return true;
1459 }
1460 });
Jason Monk361915c2017-03-21 20:33:59 -04001461 }
1462
Jason Monk16fbd9d2017-04-27 14:28:49 -04001463 private void updateList() {
1464 mListView.removeAllViews();
Wesley.CW Wang3004fcb2018-06-15 16:24:57 +08001465 mSeparatedView.removeAllViews();
Jason Monk16fbd9d2017-04-27 14:28:49 -04001466 for (int i = 0; i < mAdapter.getCount(); i++) {
Wesley.CW Wang3004fcb2018-06-15 16:24:57 +08001467 ViewGroup parentView = mShouldDisplaySeparatedButton && i == mAdapter.getCount() - 1
1468 ? mSeparatedView : mListView;
1469 View v = mAdapter.getView(i, null, parentView);
Jason Monk16fbd9d2017-04-27 14:28:49 -04001470 final int pos = i;
1471 v.setOnClickListener(view -> mClickListener.onClick(this, pos));
1472 v.setOnLongClickListener(view ->
1473 mLongClickListener.onItemLongClick(null, v, pos, 0));
Wesley.CW Wang3004fcb2018-06-15 16:24:57 +08001474 parentView.addView(v);
Jason Monk16fbd9d2017-04-27 14:28:49 -04001475 }
Jason Monk361915c2017-03-21 20:33:59 -04001476 }
1477
1478 @Override
1479 protected void onStart() {
1480 super.setCanceledOnTouchOutside(true);
1481 super.onStart();
Jason Monk16fbd9d2017-04-27 14:28:49 -04001482 updateList();
Lucas Dupinc1cc7592017-05-22 15:56:16 -07001483
1484 Point displaySize = new Point();
1485 mContext.getDisplay().getRealSize(displaySize);
1486 mColorExtractor.addOnColorsChangedListener(this);
1487 mGradientDrawable.setScreenSize(displaySize.x, displaySize.y);
1488 GradientColors colors = mColorExtractor.getColors(mKeyguardShowing ?
1489 WallpaperManager.FLAG_LOCK : WallpaperManager.FLAG_SYSTEM);
Lucas Dupinb5f59fe2017-09-14 17:09:39 -07001490 updateColors(colors, false /* animate */);
1491 }
1492
1493 /**
1494 * Updates background and system bars according to current GradientColors.
1495 * @param colors Colors and hints to use.
1496 * @param animate Interpolates gradient if true, just sets otherwise.
1497 */
1498 private void updateColors(GradientColors colors, boolean animate) {
1499 mGradientDrawable.setColors(colors, animate);
1500 View decorView = getWindow().getDecorView();
1501 if (colors.supportsDarkText()) {
1502 decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR |
1503 View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
1504 } else {
1505 decorView.setSystemUiVisibility(0);
1506 }
Jason Monk361915c2017-03-21 20:33:59 -04001507 }
1508
1509 @Override
Jason Monk16fbd9d2017-04-27 14:28:49 -04001510 protected void onStop() {
1511 super.onStop();
Lucas Dupinc1cc7592017-05-22 15:56:16 -07001512 mColorExtractor.removeOnColorsChangedListener(this);
Jason Monk16fbd9d2017-04-27 14:28:49 -04001513 }
1514
1515 @Override
1516 public void show() {
1517 super.show();
Beverly526d2d62018-08-15 12:55:33 -04001518 mShowing = true;
Lucas Dupinc1cc7592017-05-22 15:56:16 -07001519 mGradientDrawable.setAlpha(0);
Jason Monk16fbd9d2017-04-27 14:28:49 -04001520 mHardwareLayout.setTranslationX(getAnimTranslation());
1521 mHardwareLayout.setAlpha(0);
1522 mHardwareLayout.animate()
1523 .alpha(1)
1524 .translationX(0)
1525 .setDuration(300)
Lucas Dupinde9db422017-07-19 17:15:41 -07001526 .setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
Lucas Dupinc1cc7592017-05-22 15:56:16 -07001527 .setUpdateListener(animation -> {
1528 int alpha = (int) ((Float) animation.getAnimatedValue()
1529 * ScrimController.GRADIENT_SCRIM_ALPHA * 255);
1530 mGradientDrawable.setAlpha(alpha);
1531 })
Jason Monka7af3b62017-07-07 11:35:13 -04001532 .withEndAction(() -> getWindow().getDecorView().requestAccessibilityFocus())
Jason Monk16fbd9d2017-04-27 14:28:49 -04001533 .start();
1534 }
1535
1536 @Override
1537 public void dismiss() {
Beverly526d2d62018-08-15 12:55:33 -04001538 if (!mShowing) {
1539 return;
1540 }
1541 mShowing = false;
Jason Monk16fbd9d2017-04-27 14:28:49 -04001542 mHardwareLayout.setTranslationX(0);
1543 mHardwareLayout.setAlpha(1);
1544 mHardwareLayout.animate()
1545 .alpha(0)
1546 .translationX(getAnimTranslation())
1547 .setDuration(300)
1548 .withEndAction(() -> super.dismiss())
1549 .setInterpolator(new LogAccelerateInterpolator())
Lucas Dupinc1cc7592017-05-22 15:56:16 -07001550 .setUpdateListener(animation -> {
1551 int alpha = (int) ((1f - (Float) animation.getAnimatedValue())
1552 * ScrimController.GRADIENT_SCRIM_ALPHA * 255);
1553 mGradientDrawable.setAlpha(alpha);
1554 })
Jason Monk16fbd9d2017-04-27 14:28:49 -04001555 .start();
1556 }
1557
Lucas Dupin1d4a5792018-04-02 15:14:59 -07001558 void dismissImmediately() {
1559 super.dismiss();
Beverly526d2d62018-08-15 12:55:33 -04001560 mShowing = false;
Lucas Dupin1d4a5792018-04-02 15:14:59 -07001561 }
1562
Jason Monk16fbd9d2017-04-27 14:28:49 -04001563 private float getAnimTranslation() {
1564 return getContext().getResources().getDimension(
1565 com.android.systemui.R.dimen.global_actions_panel_width) / 2;
Jason Monk361915c2017-03-21 20:33:59 -04001566 }
1567
1568 @Override
Lucas Dupin7aaa3532017-05-28 08:51:07 -07001569 public void onColorsChanged(ColorExtractor extractor, int which) {
Lucas Dupinc1cc7592017-05-22 15:56:16 -07001570 if (mKeyguardShowing) {
1571 if ((WallpaperManager.FLAG_LOCK & which) != 0) {
Lucas Dupinb5f59fe2017-09-14 17:09:39 -07001572 updateColors(extractor.getColors(WallpaperManager.FLAG_LOCK),
1573 true /* animate */);
Lucas Dupinc1cc7592017-05-22 15:56:16 -07001574 }
1575 } else {
1576 if ((WallpaperManager.FLAG_SYSTEM & which) != 0) {
Lucas Dupinb5f59fe2017-09-14 17:09:39 -07001577 updateColors(extractor.getColors(WallpaperManager.FLAG_SYSTEM),
1578 true /* animate */);
Lucas Dupinc1cc7592017-05-22 15:56:16 -07001579 }
1580 }
1581 }
1582
1583 public void setKeyguardShowing(boolean keyguardShowing) {
1584 mKeyguardShowing = keyguardShowing;
1585 }
Jason Monk361915c2017-03-21 20:33:59 -04001586 }
1587}