From 3f652cb990b991552dfc7057e3b3552655f236c7 Mon Sep 17 00:00:00 2001 From: Alec Mouri Date: Wed, 17 Feb 2021 00:18:55 +0000 Subject: [PATCH] Revert "Remove Dependency.get from KeyguardStatusView." Revert submission 13536242-b179775696-depenency-get-keyguard Reason for revert: Candidate reversion for broken tests: b/180440298 Reverted Changes: I6d0271692:Add ViewController to CarrierText. I4d9a4a21f:Add Controller for Emergency Button. I4c76d99f9:Remove Dependency.get from KeyguardSliceTextView. I730593fcf:Add injection to ClockProvider. Ifbb93e624:Remove Dependency.get from KeyguardStatusView. I237215456:Remove final calls to Dependency.get from keyguard... Change-Id: Ic6d3e290592a146af71e728cef469faed5177b9a --- .../android/keyguard/KeyguardStatusView.java | 19 +++++++++++++++++-- .../KeyguardStatusViewController.java | 18 +++++------------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java index 5db4f9e61140d..fea152abe36ae 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java @@ -34,6 +34,7 @@ import android.widget.TextView; import androidx.core.graphics.ColorUtils; import com.android.internal.widget.LockPatternUtils; +import com.android.systemui.Dependency; import com.android.systemui.R; import java.io.FileDescriptor; @@ -55,6 +56,7 @@ public class KeyguardStatusView extends GridLayout { private final IActivityManager mIActivityManager; private TextView mLogoutView; + private boolean mCanShowLogout = true; // by default, try to show the logout button here private KeyguardClockSwitch mClockView; private TextView mOwnerInfo; private boolean mCanShowOwnerInfo = true; // by default, try to show the owner information here @@ -128,6 +130,11 @@ public class KeyguardStatusView extends GridLayout { } } + void setCanShowLogout(boolean canShowLogout) { + mCanShowLogout = canShowLogout; + updateLogoutView(); + } + @Override protected void onFinishInflate() { super.onFinishInflate(); @@ -152,7 +159,10 @@ public class KeyguardStatusView extends GridLayout { mKeyguardSlice.setContentChangeListener(this::onSliceContentChanged); onSliceContentChanged(); + boolean shouldMarquee = Dependency.get(KeyguardUpdateMonitor.class).isDeviceInteractive(); + setEnableMarquee(shouldMarquee); updateOwnerInfo(); + updateLogoutView(); updateDark(); } @@ -199,11 +209,11 @@ public class KeyguardStatusView extends GridLayout { return mOwnerInfo.getVisibility() == VISIBLE ? mOwnerInfo.getHeight() : 0; } - void updateLogoutView(boolean shouldShowLogout) { + void updateLogoutView() { if (mLogoutView == null) { return; } - mLogoutView.setVisibility(shouldShowLogout ? VISIBLE : GONE); + mLogoutView.setVisibility(mCanShowLogout && shouldShowLogout() ? VISIBLE : GONE); // Logout button will stay in language of user 0 if we don't set that manually. mLogoutView.setText(mContext.getResources().getString( com.android.internal.R.string.global_action_logout)); @@ -303,6 +313,11 @@ public class KeyguardStatusView extends GridLayout { } } + private boolean shouldShowLogout() { + return Dependency.get(KeyguardUpdateMonitor.class).isLogoutEnabled() + && KeyguardUpdateMonitor.getCurrentUser() != UserHandle.USER_SYSTEM; + } + private void onLogoutClicked(View view) { int currentUserId = KeyguardUpdateMonitor.getCurrentUser(); try { diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java index bfe7f8c7ebd88..6fb6760be653b 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java @@ -16,7 +16,6 @@ package com.android.keyguard; -import android.os.UserHandle; import android.util.Slog; import android.view.View; @@ -79,8 +78,6 @@ public class KeyguardStatusViewController extends ViewController