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 98191ea21f608..f944d553b282c 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; @@ -179,10 +178,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; @@ -440,15 +437,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(); @@ -914,20 +902,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 = @@ -953,8 +927,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 @@ - - -