Merge "Workaround for doze/AOD problem with global wakefulness" into tm-qpr-dev am: 05857f6045
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20004881 Change-Id: Idf2a621fe68a9d7dee398ad49f76189471b7d9ee Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -2197,6 +2197,15 @@ public final class PowerManagerService extends SystemService
|
|||||||
if (sQuiescent) {
|
if (sQuiescent) {
|
||||||
mDirty |= DIRTY_QUIESCENT;
|
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;
|
break;
|
||||||
|
|
||||||
case WAKEFULNESS_ASLEEP:
|
case WAKEFULNESS_ASLEEP:
|
||||||
|
|||||||
@@ -1928,6 +1928,50 @@ public class PowerManagerServiceTest {
|
|||||||
verify(mDreamManagerInternalMock).startDream(eq(true), anyString());
|
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
|
@Test
|
||||||
public void testLastSleepTime_notUpdatedWhenDreaming() {
|
public void testLastSleepTime_notUpdatedWhenDreaming() {
|
||||||
createService();
|
createService();
|
||||||
|
|||||||
Reference in New Issue
Block a user