blob: a3ffa40ee19a1f40af2bc4d798d8f16ac6836176 [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;
Jorim Jaggie210cc82014-08-12 23:44:59 +020023import android.content.res.Configuration;
Jim Miller0c486892013-10-11 16:21:45 -070024import android.content.res.Resources;
Lucas Dupin76d38e72017-05-13 22:04:22 -070025import android.graphics.Color;
Geoffrey Pitschc239fef2017-07-14 09:55:16 -040026import android.os.Handler;
27import android.os.Looper;
Alex Chauff7653d2018-02-01 17:18:08 +000028import android.os.RemoteException;
Adrian Roos9dd16eb2015-01-08 16:20:49 +010029import android.os.UserHandle;
Lucas Dupin76d38e72017-05-13 22:04:22 -070030import android.support.v4.graphics.ColorUtils;
Jim Milleredc74ab2012-11-06 21:46:11 -080031import android.text.TextUtils;
Jim Miller38ab2772013-10-08 15:32:09 -070032import android.text.format.DateFormat;
Lucas Dupin6bd86012017-12-05 17:58:57 -080033import android.util.ArraySet;
Jim Millerdcb3d842012-08-23 19:18:12 -070034import android.util.AttributeSet;
Jim Miller20daffd2013-10-07 14:59:53 -070035import android.util.Log;
Jim Milleredc74ab2012-11-06 21:46:11 -080036import android.util.Slog;
Jorim Jaggie210cc82014-08-12 23:44:59 +020037import android.util.TypedValue;
Jim Milleredc74ab2012-11-06 21:46:11 -080038import android.view.View;
Adrian Roos7907ff22017-01-17 15:44:11 -080039import android.view.ViewGroup;
Jim Millerdcb3d842012-08-23 19:18:12 -070040import android.widget.GridLayout;
Jim Miller38ab2772013-10-08 15:32:09 -070041import android.widget.TextClock;
Jim Milleredc74ab2012-11-06 21:46:11 -080042import android.widget.TextView;
Jim Millerdcb3d842012-08-23 19:18:12 -070043
Michael Jurka1254f2f2012-10-25 11:44:31 -070044import com.android.internal.widget.LockPatternUtils;
45
Lucas Dupin6bd86012017-12-05 17:58:57 -080046import com.google.android.collect.Sets;
47
Chris Wren56018e52013-01-15 10:59:43 -050048import java.util.Locale;
49
Jim Millerdcb3d842012-08-23 19:18:12 -070050public class KeyguardStatusView extends GridLayout {
Jorim Jaggi5cf17872014-03-26 18:31:48 +010051 private static final boolean DEBUG = KeyguardConstants.DEBUG;
Jim Milleredc74ab2012-11-06 21:46:11 -080052 private static final String TAG = "KeyguardStatusView";
Geoffrey Pitschc239fef2017-07-14 09:55:16 -040053 private static final int MARQUEE_DELAY_MS = 2000;
Jim Milleredc74ab2012-11-06 21:46:11 -080054
Adrian Roos9dd16eb2015-01-08 16:20:49 +010055 private final LockPatternUtils mLockPatternUtils;
56 private final AlarmManager mAlarmManager;
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);
Adrian Roos9dd16eb2015-01-08 16:20:49 +0100125 mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Alex Chauff7653d2018-02-01 17:18:08 +0000126 mIActivityManager = ActivityManager.getService();
Adrian Roos9dd16eb2015-01-08 16:20:49 +0100127 mLockPatternUtils = new LockPatternUtils(getContext());
Geoffrey Pitschc239fef2017-07-14 09:55:16 -0400128 mHandler = new Handler(Looper.myLooper());
Lucas Dupin6bd86012017-12-05 17:58:57 -0800129 mSmallClockScale = getResources().getDimension(R.dimen.widget_small_font_size)
130 / getResources().getDimension(R.dimen.widget_big_font_size);
131 mWidgetPadding = getResources().getDimension(R.dimen.widget_vertical_padding);
Jim Millerdcb3d842012-08-23 19:18:12 -0700132 }
133
Jim Miller20daffd2013-10-07 14:59:53 -0700134 private void setEnableMarquee(boolean enabled) {
Geoffrey Pitschc239fef2017-07-14 09:55:16 -0400135 if (DEBUG) Log.v(TAG, "Schedule setEnableMarquee: " + (enabled ? "Enable" : "Disable"));
136 if (enabled) {
137 if (mPendingMarqueeStart == null) {
138 mPendingMarqueeStart = () -> {
139 setEnableMarqueeImpl(true);
140 mPendingMarqueeStart = null;
141 };
142 mHandler.postDelayed(mPendingMarqueeStart, MARQUEE_DELAY_MS);
143 }
144 } else {
145 if (mPendingMarqueeStart != null) {
146 mHandler.removeCallbacks(mPendingMarqueeStart);
147 mPendingMarqueeStart = null;
148 }
149 setEnableMarqueeImpl(false);
150 }
151 }
152
153 private void setEnableMarqueeImpl(boolean enabled) {
Jim Miller20daffd2013-10-07 14:59:53 -0700154 if (DEBUG) Log.v(TAG, (enabled ? "Enable" : "Disable") + " transport text marquee");
John Spurlock1e6eb172014-07-13 11:59:50 -0400155 if (mOwnerInfo != null) mOwnerInfo.setSelected(enabled);
Jim Miller20daffd2013-10-07 14:59:53 -0700156 }
157
Jim Milleredc74ab2012-11-06 21:46:11 -0800158 @Override
159 protected void onFinishInflate() {
160 super.onFinishInflate();
Alex Chauff7653d2018-02-01 17:18:08 +0000161 mLogoutView = findViewById(R.id.logout);
162 mLogoutView.setOnClickListener(this::onLogoutClicked);
163
Alan Viverette51efddb2017-04-05 10:00:01 -0400164 mClockContainer = findViewById(R.id.keyguard_clock_container);
Alan Viverette51efddb2017-04-05 10:00:01 -0400165 mClockView = findViewById(R.id.clock_view);
Selim Cinek9c4a7072014-11-21 17:44:34 +0100166 mClockView.setShowCurrentUserTime(true);
Adrian Roosb670f4b2017-07-20 20:06:54 +0200167 if (KeyguardClockAccessibilityDelegate.isNeeded(mContext)) {
168 mClockView.setAccessibilityDelegate(new KeyguardClockAccessibilityDelegate(mContext));
169 }
Alan Viverette51efddb2017-04-05 10:00:01 -0400170 mOwnerInfo = findViewById(R.id.owner_info);
Lucas Dupin957e50c2017-10-10 11:23:27 -0700171 mKeyguardSlice = findViewById(R.id.keyguard_status_area);
Lucas Dupin6bd86012017-12-05 17:58:57 -0800172 mClockSeparator = findViewById(R.id.clock_separator);
Lucas Dupin4272f442018-01-13 22:00:35 -0800173 mVisibleInDoze = Sets.newArraySet(mClockView, mKeyguardSlice, mClockSeparator);
Lucas Dupin76d38e72017-05-13 22:04:22 -0700174 mTextColor = mClockView.getCurrentTextColor();
Adrian Roos9dd16eb2015-01-08 16:20:49 +0100175
Lucas Dupin6bd86012017-12-05 17:58:57 -0800176 mKeyguardSlice.setListener(this::onSliceContentChanged);
177 onSliceContentChanged(mKeyguardSlice.hasHeader());
178
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700179 boolean shouldMarquee = KeyguardUpdateMonitor.getInstance(mContext).isDeviceInteractive();
180 setEnableMarquee(shouldMarquee);
Jim Milleredc74ab2012-11-06 21:46:11 -0800181 refresh();
Jorim Jaggi93afa1d2014-06-03 20:56:32 +0200182 updateOwnerInfo();
Alex Chauff7653d2018-02-01 17:18:08 +0000183 updateLogoutView();
Jorim Jaggicc12a9d2014-05-26 01:55:29 +0200184
185 // Disable elegant text height because our fancy colon makes the ymin value huge for no
186 // reason.
187 mClockView.setElegantTextHeight(false);
Jim Milleredc74ab2012-11-06 21:46:11 -0800188 }
189
Lucas Dupin6bd86012017-12-05 17:58:57 -0800190 private void onSliceContentChanged(boolean hasHeader) {
Lucas Dupin6bf7b642018-01-22 18:56:24 -0800191 final boolean smallClock = hasHeader || mPulsing;
192 final float clockScale = smallClock ? mSmallClockScale : 1;
Lucas Dupin6bd86012017-12-05 17:58:57 -0800193 float translation = (mClockView.getHeight() - (mClockView.getHeight() * clockScale)) / 2f;
Lucas Dupin6bf7b642018-01-22 18:56:24 -0800194 if (smallClock) {
Lucas Dupin6bd86012017-12-05 17:58:57 -0800195 translation -= mWidgetPadding;
196 }
197 mClockView.setTranslationY(translation);
198 mClockView.setScaleX(clockScale);
199 mClockView.setScaleY(clockScale);
Lucas Dupin6bf7b642018-01-22 18:56:24 -0800200 mClockSeparator.setVisibility(hasHeader && !mPulsing ? VISIBLE : GONE);
Lucas Dupin6bd86012017-12-05 17:58:57 -0800201 }
202
Jorim Jaggie210cc82014-08-12 23:44:59 +0200203 @Override
204 protected void onConfigurationChanged(Configuration newConfig) {
205 super.onConfigurationChanged(newConfig);
206 mClockView.setTextSize(TypedValue.COMPLEX_UNIT_PX,
207 getResources().getDimensionPixelSize(R.dimen.widget_big_font_size));
Selim Cinekb6143c12016-07-14 16:32:23 -0700208 // Some layouts like burmese have a different margin for the clock
209 MarginLayoutParams layoutParams = (MarginLayoutParams) mClockView.getLayoutParams();
210 layoutParams.bottomMargin = getResources().getDimensionPixelSize(
211 R.dimen.bottom_text_spacing_digital);
212 mClockView.setLayoutParams(layoutParams);
Jorim Jaggiad15b492017-05-30 18:01:49 -0700213 if (mOwnerInfo != null) {
214 mOwnerInfo.setTextSize(TypedValue.COMPLEX_UNIT_PX,
215 getResources().getDimensionPixelSize(R.dimen.widget_label_font_size));
216 }
Jorim Jaggie210cc82014-08-12 23:44:59 +0200217 }
218
Jorim Jaggid09def7512014-09-02 18:36:45 +0200219 public void refreshTime() {
John Spurlock385a63d2013-10-30 19:40:48 -0400220 mClockView.setFormat12Hour(Patterns.clockView12);
221 mClockView.setFormat24Hour(Patterns.clockView24);
Jorim Jaggid09def7512014-09-02 18:36:45 +0200222 }
Jim Miller0c486892013-10-11 16:21:45 -0700223
Jorim Jaggid09def7512014-09-02 18:36:45 +0200224 private void refresh() {
Adrian Roos9dd16eb2015-01-08 16:20:49 +0100225 AlarmManager.AlarmClockInfo nextAlarm =
226 mAlarmManager.getNextAlarmClock(UserHandle.USER_CURRENT);
Jorim Jaggid09def7512014-09-02 18:36:45 +0200227 Patterns.update(mContext, nextAlarm != null);
228
229 refreshTime();
Jim Milleredc74ab2012-11-06 21:46:11 -0800230 }
231
Adrian Roosc934c432017-01-13 11:44:56 -0800232 public int getClockBottom() {
Alex Chauff7653d2018-02-01 17:18:08 +0000233 if (mOwnerInfo != null && mOwnerInfo.getVisibility() == VISIBLE) {
234 return mOwnerInfo.getBottom();
235 } else {
236 return mClockContainer.getBottom();
237 }
238 }
239
240 public int getLogoutButtonHeight() {
241 return mLogoutView.getVisibility() == VISIBLE ? mLogoutView.getHeight() : 0;
Adrian Roosc934c432017-01-13 11:44:56 -0800242 }
243
Lucas Dupin987f1932017-05-13 21:02:52 -0700244 public float getClockTextSize() {
245 return mClockView.getTextSize();
246 }
247
Alex Chauff7653d2018-02-01 17:18:08 +0000248 private void updateLogoutView() {
249 mLogoutView.setVisibility(shouldShowLogout() ? VISIBLE : GONE);
250 // Logout button will stay in language of user 0 if we don't set that manually.
251 mLogoutView.setText(mContext.getResources().getString(
252 com.android.internal.R.string.global_action_logout));
253 }
254
Jorim Jaggi93afa1d2014-06-03 20:56:32 +0200255 private void updateOwnerInfo() {
John Spurlock1e6eb172014-07-13 11:59:50 -0400256 if (mOwnerInfo == null) return;
Jorim Jaggi93afa1d2014-06-03 20:56:32 +0200257 String ownerInfo = getOwnerInfo();
258 if (!TextUtils.isEmpty(ownerInfo)) {
259 mOwnerInfo.setVisibility(View.VISIBLE);
260 mOwnerInfo.setText(ownerInfo);
261 } else {
262 mOwnerInfo.setVisibility(View.GONE);
263 }
264 }
265
Jim Milleredc74ab2012-11-06 21:46:11 -0800266 @Override
267 protected void onAttachedToWindow() {
268 super.onAttachedToWindow();
269 KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mInfoCallback);
270 }
271
272 @Override
273 protected void onDetachedFromWindow() {
274 super.onDetachedFromWindow();
275 KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mInfoCallback);
276 }
277
Jorim Jaggi93afa1d2014-06-03 20:56:32 +0200278 private String getOwnerInfo() {
Jorim Jaggi93afa1d2014-06-03 20:56:32 +0200279 String info = null;
Andrei Stingaceanu04e245b2015-11-12 12:15:56 +0000280 if (mLockPatternUtils.isDeviceOwnerInfoEnabled()) {
281 // Use the device owner information set by device policy client via
282 // device policy manager.
283 info = mLockPatternUtils.getDeviceOwnerInfo();
284 } else {
285 // Use the current user owner information if enabled.
286 final boolean ownerInfoEnabled = mLockPatternUtils.isOwnerInfoEnabled(
287 KeyguardUpdateMonitor.getCurrentUser());
288 if (ownerInfoEnabled) {
289 info = mLockPatternUtils.getOwnerInfo(KeyguardUpdateMonitor.getCurrentUser());
290 }
Jorim Jaggi93afa1d2014-06-03 20:56:32 +0200291 }
292 return info;
293 }
294
Selim Cinekf99d0002014-06-13 07:36:01 +0200295 @Override
296 public boolean hasOverlappingRendering() {
297 return false;
298 }
299
John Spurlock385a63d2013-10-30 19:40:48 -0400300 // DateFormat.getBestDateTimePattern is extremely expensive, and refresh is called often.
301 // This is an optimization to ensure we only recompute the patterns when the inputs change.
302 private static final class Patterns {
Adrian Roos59de4f32017-05-31 15:22:38 -0700303 static String dateViewSkel;
John Spurlock385a63d2013-10-30 19:40:48 -0400304 static String clockView12;
305 static String clockView24;
306 static String cacheKey;
307
Jorim Jaggic7dea6e2014-07-26 14:36:57 +0200308 static void update(Context context, boolean hasAlarm) {
John Spurlock385a63d2013-10-30 19:40:48 -0400309 final Locale locale = Locale.getDefault();
310 final Resources res = context.getResources();
Adrian Roos59de4f32017-05-31 15:22:38 -0700311 dateViewSkel = res.getString(hasAlarm
Jorim Jaggic7dea6e2014-07-26 14:36:57 +0200312 ? R.string.abbrev_wday_month_day_no_year_alarm
313 : R.string.abbrev_wday_month_day_no_year);
John Spurlock385a63d2013-10-30 19:40:48 -0400314 final String clockView12Skel = res.getString(R.string.clock_12hr_format);
315 final String clockView24Skel = res.getString(R.string.clock_24hr_format);
316 final String key = locale.toString() + dateViewSkel + clockView12Skel + clockView24Skel;
317 if (key.equals(cacheKey)) return;
318
John Spurlock385a63d2013-10-30 19:40:48 -0400319 clockView12 = DateFormat.getBestDateTimePattern(locale, clockView12Skel);
320 // CLDR insists on adding an AM/PM indicator even though it wasn't in the skeleton
321 // format. The following code removes the AM/PM indicator if we didn't want it.
322 if (!clockView12Skel.contains("a")) {
323 clockView12 = clockView12.replaceAll("a", "").trim();
324 }
325
326 clockView24 = DateFormat.getBestDateTimePattern(locale, clockView24Skel);
327
Jorim Jaggicc12a9d2014-05-26 01:55:29 +0200328 // Use fancy colon.
329 clockView24 = clockView24.replace(':', '\uee01');
330 clockView12 = clockView12.replace(':', '\uee01');
331
John Spurlock385a63d2013-10-30 19:40:48 -0400332 cacheKey = key;
333 }
334 }
Adrian Roos7907ff22017-01-17 15:44:11 -0800335
Lucas Dupin4272f442018-01-13 22:00:35 -0800336 public void setDarkAmount(float darkAmount) {
Lucas Dupin76d38e72017-05-13 22:04:22 -0700337 if (mDarkAmount == darkAmount) {
Adrian Roos52414e32017-04-28 09:23:19 -0700338 return;
339 }
Lucas Dupin76d38e72017-05-13 22:04:22 -0700340 mDarkAmount = darkAmount;
Adrian Roosd83e9992017-03-16 15:17:57 -0700341
Lucas Dupin76d38e72017-05-13 22:04:22 -0700342 boolean dark = darkAmount == 1;
Alex Chauff7653d2018-02-01 17:18:08 +0000343 mLogoutView.setAlpha(dark ? 0 : 1);
Adrian Roos7907ff22017-01-17 15:44:11 -0800344 final int N = mClockContainer.getChildCount();
345 for (int i = 0; i < N; i++) {
346 View child = mClockContainer.getChildAt(i);
Lucas Dupin6bd86012017-12-05 17:58:57 -0800347 if (mVisibleInDoze.contains(child)) {
Adrian Roos7907ff22017-01-17 15:44:11 -0800348 continue;
349 }
350 child.setAlpha(dark ? 0 : 1);
351 }
Adrian Roos8e130f02017-07-20 15:14:25 +0200352 if (mOwnerInfo != null) {
353 mOwnerInfo.setAlpha(dark ? 0 : 1);
354 }
355
Lucas Dupin6bd86012017-12-05 17:58:57 -0800356 final int blendedTextColor = ColorUtils.blendARGB(mTextColor, Color.WHITE, darkAmount);
Adrian Roosd83e9992017-03-16 15:17:57 -0700357 updateDozeVisibleViews();
Lucas Dupin957e50c2017-10-10 11:23:27 -0700358 mKeyguardSlice.setDark(darkAmount);
Lucas Dupin6bd86012017-12-05 17:58:57 -0800359 mClockView.setTextColor(blendedTextColor);
360 mClockSeparator.setBackgroundColor(blendedTextColor);
Adrian Roos7907ff22017-01-17 15:44:11 -0800361 }
Adrian Roosd83e9992017-03-16 15:17:57 -0700362
363 public void setPulsing(boolean pulsing) {
364 mPulsing = pulsing;
Lucas Dupin2c5fce62018-03-05 19:06:00 -0800365 mKeyguardSlice.setHideContent(pulsing);
Lucas Dupin6bf7b642018-01-22 18:56:24 -0800366 onSliceContentChanged(mKeyguardSlice.hasHeader());
Adrian Roosd83e9992017-03-16 15:17:57 -0700367 updateDozeVisibleViews();
368 }
369
370 private void updateDozeVisibleViews() {
371 for (View child : mVisibleInDoze) {
Lucas Dupin76d38e72017-05-13 22:04:22 -0700372 child.setAlpha(mDarkAmount == 1 && mPulsing ? 0.8f : 1);
Adrian Roosd83e9992017-03-16 15:17:57 -0700373 }
374 }
Alex Chauff7653d2018-02-01 17:18:08 +0000375
376 private boolean shouldShowLogout() {
377 return KeyguardUpdateMonitor.getInstance(mContext).isLogoutEnabled()
378 && KeyguardUpdateMonitor.getCurrentUser() != UserHandle.USER_SYSTEM;
379 }
380
381 private void onLogoutClicked(View view) {
382 int currentUserId = KeyguardUpdateMonitor.getCurrentUser();
383 try {
384 mIActivityManager.switchUser(UserHandle.USER_SYSTEM);
385 mIActivityManager.stopUser(currentUserId, true /*force*/, null);
386 } catch (RemoteException re) {
387 Log.e(TAG, "Failed to logout user", re);
388 }
389 }
Jim Millerdcb3d842012-08-23 19:18:12 -0700390}