blob: ff3af17bb61d90d692509ce87537e9a171a0cf8d [file] [log] [blame]
Jim Millerdcb3d842012-08-23 19:18:12 -07001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Jim Miller5ecd8112013-01-09 18:50:26 -080017package com.android.keyguard;
Jim Millerdcb3d842012-08-23 19:18:12 -070018
Alex Chauff7653d2018-02-01 17:18:08 +000019import android.app.ActivityManager;
Jose Lima235510e2014-08-13 12:50:01 -070020import android.app.AlarmManager;
Alex Chauff7653d2018-02-01 17:18:08 +000021import android.app.IActivityManager;
Jim Millerdcb3d842012-08-23 19:18:12 -070022import android.content.Context;
Lucas Dupinb21fb802018-03-07 11:37:25 -080023import android.content.res.ColorStateList;
Jorim Jaggie210cc82014-08-12 23:44:59 +020024import android.content.res.Configuration;
Jim Miller0c486892013-10-11 16:21:45 -070025import android.content.res.Resources;
Lucas Dupin76d38e72017-05-13 22:04:22 -070026import android.graphics.Color;
Geoffrey Pitschc239fef2017-07-14 09:55:16 -040027import android.os.Handler;
28import android.os.Looper;
Alex Chauff7653d2018-02-01 17:18:08 +000029import android.os.RemoteException;
Adrian Roos9dd16eb2015-01-08 16:20:49 +010030import android.os.UserHandle;
Lucas Dupin76d38e72017-05-13 22:04:22 -070031import android.support.v4.graphics.ColorUtils;
Jim Milleredc74ab2012-11-06 21:46:11 -080032import android.text.TextUtils;
Jim Miller38ab2772013-10-08 15:32:09 -070033import android.text.format.DateFormat;
Lucas Dupin6bd86012017-12-05 17:58:57 -080034import android.util.ArraySet;
Jim Millerdcb3d842012-08-23 19:18:12 -070035import android.util.AttributeSet;
Jim Miller20daffd2013-10-07 14:59:53 -070036import android.util.Log;
Jim Milleredc74ab2012-11-06 21:46:11 -080037import android.util.Slog;
Jorim Jaggie210cc82014-08-12 23:44:59 +020038import android.util.TypedValue;
Jim Milleredc74ab2012-11-06 21:46:11 -080039import android.view.View;
Adrian Roos7907ff22017-01-17 15:44:11 -080040import android.view.ViewGroup;
Jim Millerdcb3d842012-08-23 19:18:12 -070041import android.widget.GridLayout;
Jim Miller38ab2772013-10-08 15:32:09 -070042import android.widget.TextClock;
Jim Milleredc74ab2012-11-06 21:46:11 -080043import android.widget.TextView;
Jim Millerdcb3d842012-08-23 19:18:12 -070044
Michael Jurka1254f2f2012-10-25 11:44:31 -070045import com.android.internal.widget.LockPatternUtils;
46
Lucas Dupin6bd86012017-12-05 17:58:57 -080047import com.google.android.collect.Sets;
48
Chris Wren56018e52013-01-15 10:59:43 -050049import java.util.Locale;
50
Jim Millerdcb3d842012-08-23 19:18:12 -070051public class KeyguardStatusView extends GridLayout {
Jorim Jaggi5cf17872014-03-26 18:31:48 +010052 private static final boolean DEBUG = KeyguardConstants.DEBUG;
Jim Milleredc74ab2012-11-06 21:46:11 -080053 private static final String TAG = "KeyguardStatusView";
Geoffrey Pitschc239fef2017-07-14 09:55:16 -040054 private static final int MARQUEE_DELAY_MS = 2000;
Jim Milleredc74ab2012-11-06 21:46:11 -080055
Adrian Roos9dd16eb2015-01-08 16:20:49 +010056 private final LockPatternUtils mLockPatternUtils;
Alex Chauff7653d2018-02-01 17:18:08 +000057 private final IActivityManager mIActivityManager;
Lucas Dupin6bd86012017-12-05 17:58:57 -080058 private final float mSmallClockScale;
59 private final float mWidgetPadding;
Jim Milleredc74ab2012-11-06 21:46:11 -080060
Alex Chauff7653d2018-02-01 17:18:08 +000061 private TextView mLogoutView;
Jim Miller0c486892013-10-11 16:21:45 -070062 private TextClock mClockView;
Lucas Dupin6bd86012017-12-05 17:58:57 -080063 private View mClockSeparator;
Jorim Jaggi93afa1d2014-06-03 20:56:32 +020064 private TextView mOwnerInfo;
Adrian Roos7907ff22017-01-17 15:44:11 -080065 private ViewGroup mClockContainer;
Lucas Dupin957e50c2017-10-10 11:23:27 -070066 private KeyguardSliceView mKeyguardSlice;
Geoffrey Pitschc239fef2017-07-14 09:55:16 -040067 private Runnable mPendingMarqueeStart;
68 private Handler mHandler;
Jim Milleredc74ab2012-11-06 21:46:11 -080069
Lucas Dupin6bd86012017-12-05 17:58:57 -080070 private ArraySet<View> mVisibleInDoze;
Adrian Roosd83e9992017-03-16 15:17:57 -070071 private boolean mPulsing;
Adrian Roos7f910722017-07-12 19:15:59 +020072 private float mDarkAmount = 0;
Lucas Dupin76d38e72017-05-13 22:04:22 -070073 private int mTextColor;
Adrian Roosd83e9992017-03-16 15:17:57 -070074
Jim Milleredc74ab2012-11-06 21:46:11 -080075 private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
76
77 @Override
78 public void onTimeChanged() {
79 refresh();
80 }
81
82 @Override
Jorim Jaggi5cf17872014-03-26 18:31:48 +010083 public void onKeyguardVisibilityChanged(boolean showing) {
Jim Milleredc74ab2012-11-06 21:46:11 -080084 if (showing) {
85 if (DEBUG) Slog.v(TAG, "refresh statusview showing:" + showing);
86 refresh();
Jorim Jaggi93afa1d2014-06-03 20:56:32 +020087 updateOwnerInfo();
Alex Chauff7653d2018-02-01 17:18:08 +000088 updateLogoutView();
Jim Milleredc74ab2012-11-06 21:46:11 -080089 }
Jorim Jaggi5cf17872014-03-26 18:31:48 +010090 }
Jim Miller20daffd2013-10-07 14:59:53 -070091
Jim Miller38ab2772013-10-08 15:32:09 -070092 @Override
Jorim Jaggi0d210f62015-07-10 14:24:44 -070093 public void onStartedWakingUp() {
Jim Miller20daffd2013-10-07 14:59:53 -070094 setEnableMarquee(true);
Jorim Jaggi5cf17872014-03-26 18:31:48 +010095 }
Jim Miller20daffd2013-10-07 14:59:53 -070096
Jim Miller38ab2772013-10-08 15:32:09 -070097 @Override
Jorim Jaggi0d210f62015-07-10 14:24:44 -070098 public void onFinishedGoingToSleep(int why) {
Jim Miller20daffd2013-10-07 14:59:53 -070099 setEnableMarquee(false);
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100100 }
Jorim Jaggic7dea6e2014-07-26 14:36:57 +0200101
102 @Override
103 public void onUserSwitchComplete(int userId) {
104 refresh();
Adrian Roose32dac82014-07-28 15:58:50 +0200105 updateOwnerInfo();
Alex Chauff7653d2018-02-01 17:18:08 +0000106 updateLogoutView();
107 }
108
109 @Override
110 public void onLogoutEnabledChanged() {
111 updateLogoutView();
Jorim Jaggic7dea6e2014-07-26 14:36:57 +0200112 }
Jim Milleredc74ab2012-11-06 21:46:11 -0800113 };
Jim Miller6212cc02012-09-05 17:35:31 -0700114
Jim Millerdcb3d842012-08-23 19:18:12 -0700115 public KeyguardStatusView(Context context) {
116 this(context, null, 0);
117 }
118
119 public KeyguardStatusView(Context context, AttributeSet attrs) {
120 this(context, attrs, 0);
121 }
122
123 public KeyguardStatusView(Context context, AttributeSet attrs, int defStyle) {
124 super(context, attrs, defStyle);
Alex Chauff7653d2018-02-01 17:18:08 +0000125 mIActivityManager = ActivityManager.getService();
Adrian Roos9dd16eb2015-01-08 16:20:49 +0100126 mLockPatternUtils = new LockPatternUtils(getContext());
Geoffrey Pitschc239fef2017-07-14 09:55:16 -0400127 mHandler = new Handler(Looper.myLooper());
Lucas Dupin6bd86012017-12-05 17:58:57 -0800128 mSmallClockScale = getResources().getDimension(R.dimen.widget_small_font_size)
129 / getResources().getDimension(R.dimen.widget_big_font_size);
130 mWidgetPadding = getResources().getDimension(R.dimen.widget_vertical_padding);
Jim Millerdcb3d842012-08-23 19:18:12 -0700131 }
132
Jim Miller20daffd2013-10-07 14:59:53 -0700133 private void setEnableMarquee(boolean enabled) {
Geoffrey Pitschc239fef2017-07-14 09:55:16 -0400134 if (DEBUG) Log.v(TAG, "Schedule setEnableMarquee: " + (enabled ? "Enable" : "Disable"));
135 if (enabled) {
136 if (mPendingMarqueeStart == null) {
137 mPendingMarqueeStart = () -> {
138 setEnableMarqueeImpl(true);
139 mPendingMarqueeStart = null;
140 };
141 mHandler.postDelayed(mPendingMarqueeStart, MARQUEE_DELAY_MS);
142 }
143 } else {
144 if (mPendingMarqueeStart != null) {
145 mHandler.removeCallbacks(mPendingMarqueeStart);
146 mPendingMarqueeStart = null;
147 }
148 setEnableMarqueeImpl(false);
149 }
150 }
151
152 private void setEnableMarqueeImpl(boolean enabled) {
Jim Miller20daffd2013-10-07 14:59:53 -0700153 if (DEBUG) Log.v(TAG, (enabled ? "Enable" : "Disable") + " transport text marquee");
John Spurlock1e6eb172014-07-13 11:59:50 -0400154 if (mOwnerInfo != null) mOwnerInfo.setSelected(enabled);
Jim Miller20daffd2013-10-07 14:59:53 -0700155 }
156
Jim Milleredc74ab2012-11-06 21:46:11 -0800157 @Override
158 protected void onFinishInflate() {
159 super.onFinishInflate();
Alex Chauff7653d2018-02-01 17:18:08 +0000160 mLogoutView = findViewById(R.id.logout);
161 mLogoutView.setOnClickListener(this::onLogoutClicked);
162
Alan Viverette51efddb2017-04-05 10:00:01 -0400163 mClockContainer = findViewById(R.id.keyguard_clock_container);
Alan Viverette51efddb2017-04-05 10:00:01 -0400164 mClockView = findViewById(R.id.clock_view);
Selim Cinek9c4a7072014-11-21 17:44:34 +0100165 mClockView.setShowCurrentUserTime(true);
Adrian Roosb670f4b2017-07-20 20:06:54 +0200166 if (KeyguardClockAccessibilityDelegate.isNeeded(mContext)) {
167 mClockView.setAccessibilityDelegate(new KeyguardClockAccessibilityDelegate(mContext));
168 }
Alan Viverette51efddb2017-04-05 10:00:01 -0400169 mOwnerInfo = findViewById(R.id.owner_info);
Lucas Dupin957e50c2017-10-10 11:23:27 -0700170 mKeyguardSlice = findViewById(R.id.keyguard_status_area);
Lucas Dupin6bd86012017-12-05 17:58:57 -0800171 mClockSeparator = findViewById(R.id.clock_separator);
Lucas Dupin4272f442018-01-13 22:00:35 -0800172 mVisibleInDoze = Sets.newArraySet(mClockView, mKeyguardSlice, mClockSeparator);
Lucas Dupin76d38e72017-05-13 22:04:22 -0700173 mTextColor = mClockView.getCurrentTextColor();
Adrian Roos9dd16eb2015-01-08 16:20:49 +0100174
Lucas Dupin6bd86012017-12-05 17:58:57 -0800175 mKeyguardSlice.setListener(this::onSliceContentChanged);
176 onSliceContentChanged(mKeyguardSlice.hasHeader());
177
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700178 boolean shouldMarquee = KeyguardUpdateMonitor.getInstance(mContext).isDeviceInteractive();
179 setEnableMarquee(shouldMarquee);
Jim Milleredc74ab2012-11-06 21:46:11 -0800180 refresh();
Jorim Jaggi93afa1d2014-06-03 20:56:32 +0200181 updateOwnerInfo();
Alex Chauff7653d2018-02-01 17:18:08 +0000182 updateLogoutView();
Jorim Jaggicc12a9d2014-05-26 01:55:29 +0200183
184 // Disable elegant text height because our fancy colon makes the ymin value huge for no
185 // reason.
186 mClockView.setElegantTextHeight(false);
Jim Milleredc74ab2012-11-06 21:46:11 -0800187 }
188
Lucas Dupin6bd86012017-12-05 17:58:57 -0800189 private void onSliceContentChanged(boolean hasHeader) {
Lucas Dupin6bf7b642018-01-22 18:56:24 -0800190 final boolean smallClock = hasHeader || mPulsing;
191 final float clockScale = smallClock ? mSmallClockScale : 1;
Lucas Dupin6bd86012017-12-05 17:58:57 -0800192 float translation = (mClockView.getHeight() - (mClockView.getHeight() * clockScale)) / 2f;
Lucas Dupin6bf7b642018-01-22 18:56:24 -0800193 if (smallClock) {
Lucas Dupin6bd86012017-12-05 17:58:57 -0800194 translation -= mWidgetPadding;
195 }
196 mClockView.setTranslationY(translation);
197 mClockView.setScaleX(clockScale);
198 mClockView.setScaleY(clockScale);
Lucas Dupin6bf7b642018-01-22 18:56:24 -0800199 mClockSeparator.setVisibility(hasHeader && !mPulsing ? VISIBLE : GONE);
Lucas Dupin6bd86012017-12-05 17:58:57 -0800200 }
201
Jorim Jaggie210cc82014-08-12 23:44:59 +0200202 @Override
203 protected void onConfigurationChanged(Configuration newConfig) {
204 super.onConfigurationChanged(newConfig);
205 mClockView.setTextSize(TypedValue.COMPLEX_UNIT_PX,
206 getResources().getDimensionPixelSize(R.dimen.widget_big_font_size));
Selim Cinekb6143c12016-07-14 16:32:23 -0700207 // Some layouts like burmese have a different margin for the clock
208 MarginLayoutParams layoutParams = (MarginLayoutParams) mClockView.getLayoutParams();
209 layoutParams.bottomMargin = getResources().getDimensionPixelSize(
210 R.dimen.bottom_text_spacing_digital);
211 mClockView.setLayoutParams(layoutParams);
Jorim Jaggiad15b492017-05-30 18:01:49 -0700212 if (mOwnerInfo != null) {
213 mOwnerInfo.setTextSize(TypedValue.COMPLEX_UNIT_PX,
214 getResources().getDimensionPixelSize(R.dimen.widget_label_font_size));
215 }
Jorim Jaggie210cc82014-08-12 23:44:59 +0200216 }
217
Jorim Jaggid09def7512014-09-02 18:36:45 +0200218 public void refreshTime() {
Lucas Dupinf9583c42018-04-05 22:20:44 -0700219 mClockView.refresh();
Jorim Jaggid09def7512014-09-02 18:36:45 +0200220 }
Jim Miller0c486892013-10-11 16:21:45 -0700221
Jorim Jaggid09def7512014-09-02 18:36:45 +0200222 private void refresh() {
Lucas Dupinca46ae92018-04-02 11:05:09 -0700223 Patterns.update(mContext);
Jorim Jaggid09def7512014-09-02 18:36:45 +0200224 refreshTime();
Jim Milleredc74ab2012-11-06 21:46:11 -0800225 }
226
Adrian Roosc934c432017-01-13 11:44:56 -0800227 public int getClockBottom() {
Alex Chauff7653d2018-02-01 17:18:08 +0000228 if (mOwnerInfo != null && mOwnerInfo.getVisibility() == VISIBLE) {
229 return mOwnerInfo.getBottom();
230 } else {
231 return mClockContainer.getBottom();
232 }
233 }
234
235 public int getLogoutButtonHeight() {
236 return mLogoutView.getVisibility() == VISIBLE ? mLogoutView.getHeight() : 0;
Adrian Roosc934c432017-01-13 11:44:56 -0800237 }
238
Lucas Dupin987f1932017-05-13 21:02:52 -0700239 public float getClockTextSize() {
240 return mClockView.getTextSize();
241 }
242
Alex Chauff7653d2018-02-01 17:18:08 +0000243 private void updateLogoutView() {
244 mLogoutView.setVisibility(shouldShowLogout() ? VISIBLE : GONE);
245 // Logout button will stay in language of user 0 if we don't set that manually.
246 mLogoutView.setText(mContext.getResources().getString(
247 com.android.internal.R.string.global_action_logout));
248 }
249
Jorim Jaggi93afa1d2014-06-03 20:56:32 +0200250 private void updateOwnerInfo() {
John Spurlock1e6eb172014-07-13 11:59:50 -0400251 if (mOwnerInfo == null) return;
Jorim Jaggi93afa1d2014-06-03 20:56:32 +0200252 String ownerInfo = getOwnerInfo();
253 if (!TextUtils.isEmpty(ownerInfo)) {
254 mOwnerInfo.setVisibility(View.VISIBLE);
255 mOwnerInfo.setText(ownerInfo);
256 } else {
257 mOwnerInfo.setVisibility(View.GONE);
258 }
259 }
260
Jim Milleredc74ab2012-11-06 21:46:11 -0800261 @Override
262 protected void onAttachedToWindow() {
263 super.onAttachedToWindow();
264 KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mInfoCallback);
265 }
266
267 @Override
268 protected void onDetachedFromWindow() {
269 super.onDetachedFromWindow();
270 KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mInfoCallback);
271 }
272
Jorim Jaggi93afa1d2014-06-03 20:56:32 +0200273 private String getOwnerInfo() {
Jorim Jaggi93afa1d2014-06-03 20:56:32 +0200274 String info = null;
Andrei Stingaceanu04e245b2015-11-12 12:15:56 +0000275 if (mLockPatternUtils.isDeviceOwnerInfoEnabled()) {
276 // Use the device owner information set by device policy client via
277 // device policy manager.
278 info = mLockPatternUtils.getDeviceOwnerInfo();
279 } else {
280 // Use the current user owner information if enabled.
281 final boolean ownerInfoEnabled = mLockPatternUtils.isOwnerInfoEnabled(
282 KeyguardUpdateMonitor.getCurrentUser());
283 if (ownerInfoEnabled) {
284 info = mLockPatternUtils.getOwnerInfo(KeyguardUpdateMonitor.getCurrentUser());
285 }
Jorim Jaggi93afa1d2014-06-03 20:56:32 +0200286 }
287 return info;
288 }
289
Selim Cinekf99d0002014-06-13 07:36:01 +0200290 @Override
291 public boolean hasOverlappingRendering() {
292 return false;
293 }
294
John Spurlock385a63d2013-10-30 19:40:48 -0400295 // DateFormat.getBestDateTimePattern is extremely expensive, and refresh is called often.
296 // This is an optimization to ensure we only recompute the patterns when the inputs change.
297 private static final class Patterns {
John Spurlock385a63d2013-10-30 19:40:48 -0400298 static String clockView12;
299 static String clockView24;
300 static String cacheKey;
301
Lucas Dupinca46ae92018-04-02 11:05:09 -0700302 static void update(Context context) {
John Spurlock385a63d2013-10-30 19:40:48 -0400303 final Locale locale = Locale.getDefault();
304 final Resources res = context.getResources();
John Spurlock385a63d2013-10-30 19:40:48 -0400305 final String clockView12Skel = res.getString(R.string.clock_12hr_format);
306 final String clockView24Skel = res.getString(R.string.clock_24hr_format);
Lucas Dupinca46ae92018-04-02 11:05:09 -0700307 final String key = locale.toString() + clockView12Skel + clockView24Skel;
John Spurlock385a63d2013-10-30 19:40:48 -0400308 if (key.equals(cacheKey)) return;
309
John Spurlock385a63d2013-10-30 19:40:48 -0400310 clockView12 = DateFormat.getBestDateTimePattern(locale, clockView12Skel);
311 // CLDR insists on adding an AM/PM indicator even though it wasn't in the skeleton
312 // format. The following code removes the AM/PM indicator if we didn't want it.
313 if (!clockView12Skel.contains("a")) {
314 clockView12 = clockView12.replaceAll("a", "").trim();
315 }
316
317 clockView24 = DateFormat.getBestDateTimePattern(locale, clockView24Skel);
318
Jorim Jaggicc12a9d2014-05-26 01:55:29 +0200319 // Use fancy colon.
320 clockView24 = clockView24.replace(':', '\uee01');
321 clockView12 = clockView12.replace(':', '\uee01');
322
John Spurlock385a63d2013-10-30 19:40:48 -0400323 cacheKey = key;
324 }
325 }
Adrian Roos7907ff22017-01-17 15:44:11 -0800326
Lucas Dupin4272f442018-01-13 22:00:35 -0800327 public void setDarkAmount(float darkAmount) {
Lucas Dupin76d38e72017-05-13 22:04:22 -0700328 if (mDarkAmount == darkAmount) {
Adrian Roos52414e32017-04-28 09:23:19 -0700329 return;
330 }
Lucas Dupin76d38e72017-05-13 22:04:22 -0700331 mDarkAmount = darkAmount;
Adrian Roosd83e9992017-03-16 15:17:57 -0700332
Lucas Dupin76d38e72017-05-13 22:04:22 -0700333 boolean dark = darkAmount == 1;
Alex Chauff7653d2018-02-01 17:18:08 +0000334 mLogoutView.setAlpha(dark ? 0 : 1);
Adrian Roos7907ff22017-01-17 15:44:11 -0800335 final int N = mClockContainer.getChildCount();
336 for (int i = 0; i < N; i++) {
337 View child = mClockContainer.getChildAt(i);
Lucas Dupin6bd86012017-12-05 17:58:57 -0800338 if (mVisibleInDoze.contains(child)) {
Adrian Roos7907ff22017-01-17 15:44:11 -0800339 continue;
340 }
341 child.setAlpha(dark ? 0 : 1);
342 }
Adrian Roos8e130f02017-07-20 15:14:25 +0200343 if (mOwnerInfo != null) {
344 mOwnerInfo.setAlpha(dark ? 0 : 1);
345 }
346
Lucas Dupin6bd86012017-12-05 17:58:57 -0800347 final int blendedTextColor = ColorUtils.blendARGB(mTextColor, Color.WHITE, darkAmount);
Adrian Roosd83e9992017-03-16 15:17:57 -0700348 updateDozeVisibleViews();
Lucas Dupin957e50c2017-10-10 11:23:27 -0700349 mKeyguardSlice.setDark(darkAmount);
Lucas Dupin6bd86012017-12-05 17:58:57 -0800350 mClockView.setTextColor(blendedTextColor);
Lucas Dupinb21fb802018-03-07 11:37:25 -0800351 mClockSeparator.setBackgroundTintList(ColorStateList.valueOf(blendedTextColor));
Adrian Roos7907ff22017-01-17 15:44:11 -0800352 }
Adrian Roosd83e9992017-03-16 15:17:57 -0700353
354 public void setPulsing(boolean pulsing) {
355 mPulsing = pulsing;
Lucas Dupin2c5fce62018-03-05 19:06:00 -0800356 mKeyguardSlice.setHideContent(pulsing);
Lucas Dupin6bf7b642018-01-22 18:56:24 -0800357 onSliceContentChanged(mKeyguardSlice.hasHeader());
Adrian Roosd83e9992017-03-16 15:17:57 -0700358 updateDozeVisibleViews();
359 }
360
361 private void updateDozeVisibleViews() {
362 for (View child : mVisibleInDoze) {
Lucas Dupin76d38e72017-05-13 22:04:22 -0700363 child.setAlpha(mDarkAmount == 1 && mPulsing ? 0.8f : 1);
Adrian Roosd83e9992017-03-16 15:17:57 -0700364 }
365 }
Alex Chauff7653d2018-02-01 17:18:08 +0000366
367 private boolean shouldShowLogout() {
368 return KeyguardUpdateMonitor.getInstance(mContext).isLogoutEnabled()
369 && KeyguardUpdateMonitor.getCurrentUser() != UserHandle.USER_SYSTEM;
370 }
371
372 private void onLogoutClicked(View view) {
373 int currentUserId = KeyguardUpdateMonitor.getCurrentUser();
374 try {
375 mIActivityManager.switchUser(UserHandle.USER_SYSTEM);
376 mIActivityManager.stopUser(currentUserId, true /*force*/, null);
377 } catch (RemoteException re) {
378 Log.e(TAG, "Failed to logout user", re);
379 }
380 }
Jim Millerdcb3d842012-08-23 19:18:12 -0700381}