Merge "Workaround for doze/AOD problem with global wakefulness" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
05857f6045
@@ -2197,6 +2197,15 @@ public final class PowerManagerService extends SystemService
|
||||
if (sQuiescent) {
|
||||
mDirty |= DIRTY_QUIESCENT;
|
||||
}
|
||||
PowerGroup defaultGroup = mPowerGroups.get(Display.DEFAULT_DISPLAY_GROUP);
|
||||
if (defaultGroup.getWakefulnessLocked() == WAKEFULNESS_DOZING) {
|
||||
// Workaround for b/187231320 where the AOD can get stuck in a "half on /
|
||||
// half off" state when a non-default-group VirtualDisplay causes the global
|
||||
// wakefulness to change to awake, even though the default display is
|
||||
// dozing. We set sandman summoned to restart dreaming to get it unstuck.
|
||||
// TODO(b/255688811) - fix this so that AOD never gets interrupted at all.
|
||||
defaultGroup.setSandmanSummonedLocked(true);
|
||||
}
|
||||
break;
|
||||
|
||||
case WAKEFULNESS_ASLEEP:
|
||||
|
||||
@@ -1928,6 +1928,50 @@ public class PowerManagerServiceTest {
|
||||
verify(mDreamManagerInternalMock).startDream(eq(true), anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiDisplay_defaultDozing_addNewDisplayDefaultGoesBackToDoze() {
|
||||
final int nonDefaultDisplayGroupId = Display.DEFAULT_DISPLAY_GROUP + 1;
|
||||
final int nonDefaultDisplay = Display.DEFAULT_DISPLAY + 1;
|
||||
final AtomicReference<DisplayManagerInternal.DisplayGroupListener> listener =
|
||||
new AtomicReference<>();
|
||||
doAnswer((Answer<Void>) invocation -> {
|
||||
listener.set(invocation.getArgument(0));
|
||||
return null;
|
||||
}).when(mDisplayManagerInternalMock).registerDisplayGroupListener(any());
|
||||
final DisplayInfo info = new DisplayInfo();
|
||||
info.displayGroupId = nonDefaultDisplayGroupId;
|
||||
when(mDisplayManagerInternalMock.getDisplayInfo(nonDefaultDisplay)).thenReturn(info);
|
||||
|
||||
doAnswer(inv -> {
|
||||
when(mDreamManagerInternalMock.isDreaming()).thenReturn(true);
|
||||
return null;
|
||||
}).when(mDreamManagerInternalMock).startDream(anyBoolean(), anyString());
|
||||
|
||||
createService();
|
||||
startSystem();
|
||||
|
||||
assertThat(mService.getWakefulnessLocked(Display.DEFAULT_DISPLAY_GROUP)).isEqualTo(
|
||||
WAKEFULNESS_AWAKE);
|
||||
|
||||
forceDozing();
|
||||
advanceTime(500);
|
||||
|
||||
assertThat(mService.getWakefulnessLocked(Display.DEFAULT_DISPLAY_GROUP)).isEqualTo(
|
||||
WAKEFULNESS_DOZING);
|
||||
assertThat(mService.getGlobalWakefulnessLocked()).isEqualTo(WAKEFULNESS_DOZING);
|
||||
verify(mDreamManagerInternalMock).startDream(eq(true), anyString());
|
||||
|
||||
listener.get().onDisplayGroupAdded(nonDefaultDisplayGroupId);
|
||||
advanceTime(500);
|
||||
|
||||
assertThat(mService.getGlobalWakefulnessLocked()).isEqualTo(WAKEFULNESS_AWAKE);
|
||||
assertThat(mService.getWakefulnessLocked(nonDefaultDisplayGroupId)).isEqualTo(
|
||||
WAKEFULNESS_AWAKE);
|
||||
assertThat(mService.getWakefulnessLocked(Display.DEFAULT_DISPLAY_GROUP)).isEqualTo(
|
||||
WAKEFULNESS_DOZING);
|
||||
verify(mDreamManagerInternalMock, times(2)).startDream(eq(true), anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLastSleepTime_notUpdatedWhenDreaming() {
|
||||
createService();
|
||||
|
||||
Reference in New Issue
Block a user