From 39f0e4cd883f35f59dcb3330b22c6a922727fed4 Mon Sep 17 00:00:00 2001 From: Anthony Hugh Date: Wed, 13 Nov 2019 11:17:46 -0800 Subject: [PATCH] Delete SwitchToGuestTimer Feature was never used in production and we felt the experience was not the right one. So remove support for it to reduce maintenance burden and potential for buggy code. Fixes: 144382004 Test: Boot and see no crashes Test: Add lock to user and show UserPicker. Run adb command to put car into drive, wait 30 seconds and see no changes. adb shell dumpsys activity service com.android.car inject-vhal-event 0x11400400 8 adb shell dumpsys activity service com.android.car inject-vhal-event 0x11600207 30 Change-Id: I257df02a8f669899c7a49df12815b302ec5965bb --- .../CarSystemUI/res/values/integers_car.xml | 5 - .../systemui/statusbar/car/CarStatusBar.java | 28 ----- .../statusbar/car/SwitchToGuestTimer.java | 116 ------------------ packages/SystemUI/AndroidManifest.xml | 3 - 4 files changed, 152 deletions(-) delete mode 100644 packages/CarSystemUI/src/com/android/systemui/statusbar/car/SwitchToGuestTimer.java diff --git a/packages/CarSystemUI/res/values/integers_car.xml b/packages/CarSystemUI/res/values/integers_car.xml index d6c16cb4180bc..e53446e7c0574 100644 --- a/packages/CarSystemUI/res/values/integers_car.xml +++ b/packages/CarSystemUI/res/values/integers_car.xml @@ -20,11 +20,6 @@ 3 - - - -1 - 20 diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java index 10527b231169b..351416bff9324 100644 --- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java +++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java @@ -24,7 +24,6 @@ import android.animation.ValueAnimator; import android.annotation.Nullable; import android.app.ActivityManager; import android.car.Car; -import android.car.drivingstate.CarDrivingStateEvent; import android.car.drivingstate.CarUxRestrictionsManager; import android.car.hardware.power.CarPowerManager.CarPowerStateListener; import android.content.Context; @@ -175,10 +174,8 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt private final CarServiceProvider mCarServiceProvider; private DeviceProvisionedController mDeviceProvisionedController; - private DrivingStateHelper mDrivingStateHelper; private PowerManagerHelper mPowerManagerHelper; private FlingAnimationUtils mFlingAnimationUtils; - private SwitchToGuestTimer mSwitchToGuestTimer; private NotificationDataManager mNotificationDataManager; private NotificationClickHandlerFactory mNotificationClickHandlerFactory; private ScreenLifecycle mScreenLifecycle; @@ -432,15 +429,6 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt createBatteryController(); mCarBatteryController.startListening(); - // Used by onDrivingStateChanged and it can be called inside - // DrivingStateHelper.connectToCarService() - mSwitchToGuestTimer = new SwitchToGuestTimer(mContext); - - // Register a listener for driving state changes. - mDrivingStateHelper = mDrivingStateHelperLazy.get(); - mDrivingStateHelper.setCarDrivingStateEventListener(this::onDrivingStateChanged); - mDrivingStateHelper.connectToCarService(); - mPowerManagerHelper = mPowerManagerHelperLazy.get(); mPowerManagerHelper.setCarPowerStateListener(mCarPowerStateListener); mPowerManagerHelper.connectToCarService(); @@ -906,20 +894,6 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt } } - private void onDrivingStateChanged(CarDrivingStateEvent notUsed) { - // Check if we need to start the timer every time driving state changes. - startSwitchToGuestTimerIfDrivingOnKeyguard(); - } - - private void startSwitchToGuestTimerIfDrivingOnKeyguard() { - if (mDrivingStateHelper.isCurrentlyDriving() && mState != StatusBarState.SHADE) { - // We're driving while keyguard is up. - mSwitchToGuestTimer.start(); - } else { - mSwitchToGuestTimer.cancel(); - } - } - @Override protected void createUserSwitcher() { UserSwitcherController userSwitcherController = @@ -945,8 +919,6 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt public void onStateChanged(int newState) { super.onStateChanged(newState); - startSwitchToGuestTimerIfDrivingOnKeyguard(); - if (newState != StatusBarState.FULLSCREEN_USER_SWITCHER) { hideUserSwitcher(); } else { diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/SwitchToGuestTimer.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/SwitchToGuestTimer.java deleted file mode 100644 index 0c91cba433907..0000000000000 --- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/SwitchToGuestTimer.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.statusbar.car; - -import android.car.userlib.CarUserManagerHelper; -import android.content.Context; -import android.os.CountDownTimer; -import android.util.Log; - -import androidx.annotation.GuardedBy; - -import com.android.systemui.R; - -/** - * Wrapper for a countdown timer that switches to Guest if the user has been driving with - * the keyguard up for configurable number of seconds. - */ -public class SwitchToGuestTimer { - private static final String TAG = "SwitchToGuestTimer"; - - // After how many ms CountdownTimer.onTick gets triggered. - private static final int COUNTDOWN_INTERVAL_MS = 1000; - - private final CarUserManagerHelper mCarUserManagerHelper; - private final Object mTimerLock; - private final String mGuestName; - private final int mTimeoutMs; - private final boolean mEnabled; - - @GuardedBy("mTimerLock") - private CountDownTimer mSwitchToGuestTimer; - - public SwitchToGuestTimer(Context context) { - mCarUserManagerHelper = new CarUserManagerHelper(context); - mGuestName = context.getResources().getString(R.string.car_guest); - mTimeoutMs = context.getResources().getInteger(R.integer.driving_on_keyguard_timeout_ms); - - // Lock prevents multiple timers being started. - mTimerLock = new Object(); - - // If milliseconds to switch is a negative number, the feature is disabled. - mEnabled = mTimeoutMs >= 0; - } - - /** - * Starts the timer if it's not already running. - */ - public void start() { - if (!mEnabled) { - logD("Switching to guest after driving on keyguard is disabled."); - return; - } - - synchronized (mTimerLock) { - if (mSwitchToGuestTimer != null) { - logD("Timer is already running."); - return; - } - - mSwitchToGuestTimer = new CountDownTimer(mTimeoutMs, COUNTDOWN_INTERVAL_MS) { - @Override - public void onTick(long msUntilFinished) { - logD("Ms until switching to guest: " + Long.toString(msUntilFinished)); - } - - @Override - public void onFinish() { - mCarUserManagerHelper.startGuestSession(mGuestName); - cancel(); - } - }; - - logI("Starting timer"); - mSwitchToGuestTimer.start(); - } - } - - /** - * Cancels the running timer. - */ - public void cancel() { - synchronized (mTimerLock) { - if (mSwitchToGuestTimer != null) { - logI("Cancelling timer"); - mSwitchToGuestTimer.cancel(); - mSwitchToGuestTimer = null; - } - } - } - - private void logD(String message) { - if (Log.isLoggable(TAG, Log.DEBUG)) { - Log.d(TAG, message); - } - } - - private void logI(String message) { - if (Log.isLoggable(TAG, Log.INFO)) { - Log.i(TAG, message); - } - } -} diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index cd64a3880803d..ab433d26cb3d9 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -232,9 +232,6 @@ - - -