Loading services/core/java/com/android/server/display/LogicalDisplayMapper.java +17 −7 Original line number Original line Diff line number Diff line Loading @@ -177,6 +177,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { private Layout mCurrentLayout = null; private Layout mCurrentLayout = null; private int mDeviceState = DeviceStateManager.INVALID_DEVICE_STATE; private int mDeviceState = DeviceStateManager.INVALID_DEVICE_STATE; private int mPendingDeviceState = DeviceStateManager.INVALID_DEVICE_STATE; private int mPendingDeviceState = DeviceStateManager.INVALID_DEVICE_STATE; private int mDeviceStateToBeAppliedAfterBoot = DeviceStateManager.INVALID_DEVICE_STATE; private boolean mBootCompleted = false; private boolean mBootCompleted = false; private boolean mInteractive; private boolean mInteractive; Loading Loading @@ -373,6 +374,12 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { ipw.println("mDeviceStatesOnWhichToWakeUp=" + mDeviceStatesOnWhichToWakeUp); ipw.println("mDeviceStatesOnWhichToWakeUp=" + mDeviceStatesOnWhichToWakeUp); ipw.println("mDeviceStatesOnWhichToSleep=" + mDeviceStatesOnWhichToSleep); ipw.println("mDeviceStatesOnWhichToSleep=" + mDeviceStatesOnWhichToSleep); ipw.println("mInteractive=" + mInteractive); ipw.println("mInteractive=" + mInteractive); ipw.println("mBootCompleted=" + mBootCompleted); ipw.println(); ipw.println("mDeviceState=" + mDeviceState); ipw.println("mPendingDeviceState=" + mPendingDeviceState); ipw.println("mDeviceStateToBeAppliedAfterBoot=" + mDeviceStateToBeAppliedAfterBoot); final int logicalDisplayCount = mLogicalDisplays.size(); final int logicalDisplayCount = mLogicalDisplays.size(); ipw.println(); ipw.println(); Loading Loading @@ -403,10 +410,6 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { } } void setDeviceStateLocked(int state, boolean isOverrideActive) { void setDeviceStateLocked(int state, boolean isOverrideActive) { Slog.i(TAG, "Requesting Transition to state: " + state + ", from state=" + mDeviceState + ", interactive=" + mInteractive + ", mBootCompleted=" + mBootCompleted); mPendingDeviceState = state; if (!mBootCompleted) { if (!mBootCompleted) { // The boot animation might still be in progress, we do not want to switch states now // The boot animation might still be in progress, we do not want to switch states now // as the boot animation would end up with an incorrect size. // as the boot animation would end up with an incorrect size. Loading @@ -414,14 +417,19 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { Slog.d(TAG, "Postponing transition to state: " + mPendingDeviceState Slog.d(TAG, "Postponing transition to state: " + mPendingDeviceState + " until boot is completed"); + " until boot is completed"); } } mDeviceStateToBeAppliedAfterBoot = state; return; return; } } Slog.i(TAG, "Requesting Transition to state: " + state + ", from state=" + mDeviceState + ", interactive=" + mInteractive + ", mBootCompleted=" + mBootCompleted); // As part of a state transition, we may need to turn off some displays temporarily so that // As part of a state transition, we may need to turn off some displays temporarily so that // the transition is smooth. Plus, on some devices, only one internal displays can be // the transition is smooth. Plus, on some devices, only one internal displays can be // on at a time. We use LogicalDisplay.setIsInTransition to mark a display that needs to be // on at a time. We use LogicalDisplay.setIsInTransition to mark a display that needs to be // temporarily turned off. // temporarily turned off. resetLayoutLocked(mDeviceState, state, /* transitionValue= */ true); resetLayoutLocked(mDeviceState, state, /* transitionValue= */ true); mPendingDeviceState = state; mDeviceStateToBeAppliedAfterBoot = DeviceStateManager.INVALID_DEVICE_STATE; final boolean wakeDevice = shouldDeviceBeWoken(mPendingDeviceState, mDeviceState, final boolean wakeDevice = shouldDeviceBeWoken(mPendingDeviceState, mDeviceState, mInteractive, mBootCompleted); mInteractive, mBootCompleted); final boolean sleepDevice = shouldDeviceBePutToSleep(mPendingDeviceState, mDeviceState, final boolean sleepDevice = shouldDeviceBePutToSleep(mPendingDeviceState, mDeviceState, Loading Loading @@ -468,8 +476,9 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { void onBootCompleted() { void onBootCompleted() { synchronized (mSyncRoot) { synchronized (mSyncRoot) { mBootCompleted = true; mBootCompleted = true; if (mPendingDeviceState != DeviceStateManager.INVALID_DEVICE_STATE) { if (mDeviceStateToBeAppliedAfterBoot != DeviceStateManager.INVALID_DEVICE_STATE) { setDeviceStateLocked(mPendingDeviceState, /* isOverrideActive= */ false); setDeviceStateLocked(mDeviceStateToBeAppliedAfterBoot, /* isOverrideActive= */ false); } } } } } } Loading Loading @@ -524,7 +533,8 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { @VisibleForTesting @VisibleForTesting boolean shouldDeviceBePutToSleep(int pendingState, int currentState, boolean isOverrideActive, boolean shouldDeviceBePutToSleep(int pendingState, int currentState, boolean isOverrideActive, boolean isInteractive, boolean isBootCompleted) { boolean isInteractive, boolean isBootCompleted) { return mDeviceStatesOnWhichToSleep.get(pendingState) return currentState != DeviceStateManager.INVALID_DEVICE_STATE && mDeviceStatesOnWhichToSleep.get(pendingState) && !mDeviceStatesOnWhichToSleep.get(currentState) && !mDeviceStatesOnWhichToSleep.get(currentState) && !isOverrideActive && !isOverrideActive && isInteractive && isBootCompleted; && isInteractive && isBootCompleted; Loading services/tests/servicestests/src/com/android/server/display/LogicalDisplayMapperTest.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -691,6 +691,7 @@ public class LogicalDisplayMapperTest { // 2) Mark the displays as STATE_OFF so that it can continue with transition // 2) Mark the displays as STATE_OFF so that it can continue with transition // 3) Send DISPLAY_DEVICE_EVENT_CHANGE to inform the mapper of the new display state // 3) Send DISPLAY_DEVICE_EVENT_CHANGE to inform the mapper of the new display state // 4) Dispatch handler events. // 4) Dispatch handler events. mLogicalDisplayMapper.onBootCompleted(); mLogicalDisplayMapper.setDeviceStateLocked(0, false); mLogicalDisplayMapper.setDeviceStateLocked(0, false); mDisplayDeviceRepo.onDisplayDeviceEvent(device3, DISPLAY_DEVICE_EVENT_CHANGED); mDisplayDeviceRepo.onDisplayDeviceEvent(device3, DISPLAY_DEVICE_EVENT_CHANGED); advanceTime(1000); advanceTime(1000); Loading Loading
services/core/java/com/android/server/display/LogicalDisplayMapper.java +17 −7 Original line number Original line Diff line number Diff line Loading @@ -177,6 +177,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { private Layout mCurrentLayout = null; private Layout mCurrentLayout = null; private int mDeviceState = DeviceStateManager.INVALID_DEVICE_STATE; private int mDeviceState = DeviceStateManager.INVALID_DEVICE_STATE; private int mPendingDeviceState = DeviceStateManager.INVALID_DEVICE_STATE; private int mPendingDeviceState = DeviceStateManager.INVALID_DEVICE_STATE; private int mDeviceStateToBeAppliedAfterBoot = DeviceStateManager.INVALID_DEVICE_STATE; private boolean mBootCompleted = false; private boolean mBootCompleted = false; private boolean mInteractive; private boolean mInteractive; Loading Loading @@ -373,6 +374,12 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { ipw.println("mDeviceStatesOnWhichToWakeUp=" + mDeviceStatesOnWhichToWakeUp); ipw.println("mDeviceStatesOnWhichToWakeUp=" + mDeviceStatesOnWhichToWakeUp); ipw.println("mDeviceStatesOnWhichToSleep=" + mDeviceStatesOnWhichToSleep); ipw.println("mDeviceStatesOnWhichToSleep=" + mDeviceStatesOnWhichToSleep); ipw.println("mInteractive=" + mInteractive); ipw.println("mInteractive=" + mInteractive); ipw.println("mBootCompleted=" + mBootCompleted); ipw.println(); ipw.println("mDeviceState=" + mDeviceState); ipw.println("mPendingDeviceState=" + mPendingDeviceState); ipw.println("mDeviceStateToBeAppliedAfterBoot=" + mDeviceStateToBeAppliedAfterBoot); final int logicalDisplayCount = mLogicalDisplays.size(); final int logicalDisplayCount = mLogicalDisplays.size(); ipw.println(); ipw.println(); Loading Loading @@ -403,10 +410,6 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { } } void setDeviceStateLocked(int state, boolean isOverrideActive) { void setDeviceStateLocked(int state, boolean isOverrideActive) { Slog.i(TAG, "Requesting Transition to state: " + state + ", from state=" + mDeviceState + ", interactive=" + mInteractive + ", mBootCompleted=" + mBootCompleted); mPendingDeviceState = state; if (!mBootCompleted) { if (!mBootCompleted) { // The boot animation might still be in progress, we do not want to switch states now // The boot animation might still be in progress, we do not want to switch states now // as the boot animation would end up with an incorrect size. // as the boot animation would end up with an incorrect size. Loading @@ -414,14 +417,19 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { Slog.d(TAG, "Postponing transition to state: " + mPendingDeviceState Slog.d(TAG, "Postponing transition to state: " + mPendingDeviceState + " until boot is completed"); + " until boot is completed"); } } mDeviceStateToBeAppliedAfterBoot = state; return; return; } } Slog.i(TAG, "Requesting Transition to state: " + state + ", from state=" + mDeviceState + ", interactive=" + mInteractive + ", mBootCompleted=" + mBootCompleted); // As part of a state transition, we may need to turn off some displays temporarily so that // As part of a state transition, we may need to turn off some displays temporarily so that // the transition is smooth. Plus, on some devices, only one internal displays can be // the transition is smooth. Plus, on some devices, only one internal displays can be // on at a time. We use LogicalDisplay.setIsInTransition to mark a display that needs to be // on at a time. We use LogicalDisplay.setIsInTransition to mark a display that needs to be // temporarily turned off. // temporarily turned off. resetLayoutLocked(mDeviceState, state, /* transitionValue= */ true); resetLayoutLocked(mDeviceState, state, /* transitionValue= */ true); mPendingDeviceState = state; mDeviceStateToBeAppliedAfterBoot = DeviceStateManager.INVALID_DEVICE_STATE; final boolean wakeDevice = shouldDeviceBeWoken(mPendingDeviceState, mDeviceState, final boolean wakeDevice = shouldDeviceBeWoken(mPendingDeviceState, mDeviceState, mInteractive, mBootCompleted); mInteractive, mBootCompleted); final boolean sleepDevice = shouldDeviceBePutToSleep(mPendingDeviceState, mDeviceState, final boolean sleepDevice = shouldDeviceBePutToSleep(mPendingDeviceState, mDeviceState, Loading Loading @@ -468,8 +476,9 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { void onBootCompleted() { void onBootCompleted() { synchronized (mSyncRoot) { synchronized (mSyncRoot) { mBootCompleted = true; mBootCompleted = true; if (mPendingDeviceState != DeviceStateManager.INVALID_DEVICE_STATE) { if (mDeviceStateToBeAppliedAfterBoot != DeviceStateManager.INVALID_DEVICE_STATE) { setDeviceStateLocked(mPendingDeviceState, /* isOverrideActive= */ false); setDeviceStateLocked(mDeviceStateToBeAppliedAfterBoot, /* isOverrideActive= */ false); } } } } } } Loading Loading @@ -524,7 +533,8 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { @VisibleForTesting @VisibleForTesting boolean shouldDeviceBePutToSleep(int pendingState, int currentState, boolean isOverrideActive, boolean shouldDeviceBePutToSleep(int pendingState, int currentState, boolean isOverrideActive, boolean isInteractive, boolean isBootCompleted) { boolean isInteractive, boolean isBootCompleted) { return mDeviceStatesOnWhichToSleep.get(pendingState) return currentState != DeviceStateManager.INVALID_DEVICE_STATE && mDeviceStatesOnWhichToSleep.get(pendingState) && !mDeviceStatesOnWhichToSleep.get(currentState) && !mDeviceStatesOnWhichToSleep.get(currentState) && !isOverrideActive && !isOverrideActive && isInteractive && isBootCompleted; && isInteractive && isBootCompleted; Loading
services/tests/servicestests/src/com/android/server/display/LogicalDisplayMapperTest.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -691,6 +691,7 @@ public class LogicalDisplayMapperTest { // 2) Mark the displays as STATE_OFF so that it can continue with transition // 2) Mark the displays as STATE_OFF so that it can continue with transition // 3) Send DISPLAY_DEVICE_EVENT_CHANGE to inform the mapper of the new display state // 3) Send DISPLAY_DEVICE_EVENT_CHANGE to inform the mapper of the new display state // 4) Dispatch handler events. // 4) Dispatch handler events. mLogicalDisplayMapper.onBootCompleted(); mLogicalDisplayMapper.setDeviceStateLocked(0, false); mLogicalDisplayMapper.setDeviceStateLocked(0, false); mDisplayDeviceRepo.onDisplayDeviceEvent(device3, DISPLAY_DEVICE_EVENT_CHANGED); mDisplayDeviceRepo.onDisplayDeviceEvent(device3, DISPLAY_DEVICE_EVENT_CHANGED); advanceTime(1000); advanceTime(1000); Loading