summaryrefslogtreecommitdiff
path: root/packages/CarSystemUI/src
diff options
context:
space:
mode:
authorkwaky <kwaky@google.com>2020-06-12 13:18:54 -0700
committerkwaky <kwaky@google.com>2020-06-12 14:01:24 -0700
commit12930e8ddce8620923ec6d887a3bc355fa4b2240 (patch)
treef7bf67102c22d0bb0ddae8465c409a71bd70718a /packages/CarSystemUI/src
parente4c1cb514c9cc472ee5a519bf4f8416f1fa90d45 (diff)
Hide UserSwitchTransitionView if it is not hidden within timeout.
This prevents being stuck in the Loading screen even if the proper User Lifecycle event was not broadcast. Test: Unit Tests + Manual -- Verify that the UserSwitchTransitionView is hidden after the timeout threshold when the UserLifecycleEvent listener is not registered. Bug: 158705895 Change-Id: I895f04bda395bac271b01fbb414a8bf484348324
Diffstat (limited to 'packages/CarSystemUI/src')
-rw-r--r--packages/CarSystemUI/src/com/android/systemui/car/userswitcher/UserSwitchTransitionViewController.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/packages/CarSystemUI/src/com/android/systemui/car/userswitcher/UserSwitchTransitionViewController.java b/packages/CarSystemUI/src/com/android/systemui/car/userswitcher/UserSwitchTransitionViewController.java
index 8aa7b6389d85..45f3d342fb6e 100644
--- a/packages/CarSystemUI/src/com/android/systemui/car/userswitcher/UserSwitchTransitionViewController.java
+++ b/packages/CarSystemUI/src/com/android/systemui/car/userswitcher/UserSwitchTransitionViewController.java
@@ -33,6 +33,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import com.android.internal.annotations.GuardedBy;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.settingslib.drawable.CircleFramedDrawable;
import com.android.systemui.R;
import com.android.systemui.car.window.OverlayViewController;
@@ -49,12 +50,22 @@ import javax.inject.Singleton;
public class UserSwitchTransitionViewController extends OverlayViewController {
private static final String TAG = "UserSwitchTransition";
private static final String ENABLE_DEVELOPER_MESSAGE_TRUE = "true";
+ private static final boolean DEBUG = false;
private final Context mContext;
private final Handler mHandler;
private final Resources mResources;
private final UserManager mUserManager;
private final IWindowManager mWindowManagerService;
+ private final int mWindowShownTimeoutMs;
+ private final Runnable mWindowShownTimeoutCallback = () -> {
+ if (DEBUG) {
+ Log.w(TAG, "Window was not hidden within " + getWindowShownTimeoutMs() + " ms, so it"
+ + "was hidden by mWindowShownTimeoutCallback.");
+ }
+
+ handleHide();
+ };
@GuardedBy("this")
private boolean mShowing;
@@ -76,6 +87,8 @@ public class UserSwitchTransitionViewController extends OverlayViewController {
mResources = resources;
mUserManager = userManager;
mWindowManagerService = windowManagerService;
+ mWindowShownTimeoutMs = mResources.getInteger(
+ R.integer.config_userSwitchTransitionViewShownTimeoutMs);
}
/**
@@ -98,6 +111,9 @@ public class UserSwitchTransitionViewController extends OverlayViewController {
populateDialog(mPreviousUserId, newUserId);
// next time a new user is selected, this current new user will be the previous user.
mPreviousUserId = newUserId;
+ // In case the window is still showing after WINDOW_SHOWN_TIMEOUT_MS, then hide the
+ // window and log a warning message.
+ mHandler.postDelayed(mWindowShownTimeoutCallback, mWindowShownTimeoutMs);
});
}
@@ -105,6 +121,12 @@ public class UserSwitchTransitionViewController extends OverlayViewController {
if (!mShowing) return;
mShowing = false;
mHandler.post(this::stop);
+ mHandler.removeCallbacks(mWindowShownTimeoutCallback);
+ }
+
+ @VisibleForTesting
+ int getWindowShownTimeoutMs() {
+ return mWindowShownTimeoutMs;
}
private void populateDialog(@UserIdInt int previousUserId, @UserIdInt int newUserId) {