fix wrong sleep entry for display state change
- a missing break in switch - case brought the issue.
- remove rearview camera case from PowerManagement :
android display will be kept on, so there is no need to
handle rear view camera case specially.
- fix possible bug of checking display on. Only handle
DISPLAY_ON to on.
bug: 27142874, 26718816
Change-Id: Ie5a804be434a466cc67d81725ee2e9c56e693d5f
diff --git a/service/src/com/android/car/CarPowerManagementService.java b/service/src/com/android/car/CarPowerManagementService.java
index 3220bea..e748cc2 100644
--- a/service/src/com/android/car/CarPowerManagementService.java
+++ b/service/src/com/android/car/CarPowerManagementService.java
@@ -123,8 +123,6 @@
@GuardedBy("this")
private PowerState mCurrentState;
@GuardedBy("this")
- private boolean mRearviewCameraActive = false; //TODO plumb this from rearview camera HAL
- @GuardedBy("this")
private Timer mTimer;
@GuardedBy("this")
private long mProcessingStartTime;
@@ -307,13 +305,8 @@
notifyPowerOn(false);
break;
case PowerHalService.STATE_ON_FULL:
- if (isRearviewCameraActive()) {
- handleFullOnWithRearviewCameraActive(state);
- notifyPowerOn(false);
- } else {
- handleFullOn(state);
- notifyPowerOn(true);
- }
+ handleFullOn(state);
+ notifyPowerOn(true);
break;
case PowerHalService.STATE_SHUTDOWN_PREPARE:
handleShutdownPrepare(state);
@@ -331,12 +324,6 @@
mSystemInterface.setDisplayState(true);
}
- private void handleFullOnWithRearviewCameraActive(PowerState newState) {
- setCurrentState(newState);
- // just hold the wakelock but do not turn display on.
- mSystemInterface.switchToPartialWakeLock();
- }
-
@VisibleForTesting
protected void notifyPowerOn(boolean displayOn) {
for (PowerEventProcessingHandlerWrapper wrapper : mPowerEventProcessingHandlers) {
@@ -531,10 +518,6 @@
//TODO
}
- private synchronized boolean isRearviewCameraActive() {
- return mRearviewCameraActive;
- }
-
private boolean shouldDoFakeShutdown() {
ICarImpl carImpl = ICarImpl.getInstance(mContext);
if (!carImpl.isInMocking()) {
@@ -619,6 +602,7 @@
break;
case MSG_MAIN_DISPLAY_STATE_CHANGE:
doHandleMainDisplayStateChange((Boolean) msg.obj);
+ break;
case MSG_PROCESSING_COMPLETE:
doHandleProcessingComplete(msg.arg1 == 1);
break;
@@ -669,20 +653,18 @@
}
if (on) {
switchToFullWakeLock();
- if (!isMainDisplayOn()) {
- mPowerManager.wakeUp(SystemClock.uptimeMillis());
- }
+ Log.i(CarLog.TAG_POWER, "on display");
+ mPowerManager.wakeUp(SystemClock.uptimeMillis());
} else {
switchToPartialWakeLock();
- if (isMainDisplayOn()) {
- mPowerManager.goToSleep(SystemClock.uptimeMillis());
- }
+ Log.i(CarLog.TAG_POWER, "off display");
+ mPowerManager.goToSleep(SystemClock.uptimeMillis());
}
}
private boolean isMainDisplayOn() {
Display disp = mDisplayManager.getDisplay(Display.DEFAULT_DISPLAY);
- return disp.getState() != Display.STATE_OFF;
+ return disp.getState() == Display.STATE_ON;
}
@Override