Release doze wake lock when doze dream is stopped
Before this CL, if the doze dream instance is replaced by another dream instance, the doze lock was never released. There is a check in the DreamManagerService#onDreamStopped path, that normally releases the doze lock in a normal wake up. But when the doze dream instance has been replaced by another dream instance, the doze dream token doesn't match the current dream token, and so the doze wake lock is never released. This causes the display to flicker right before entering AOD (dozing). This CL handles the case when a doze dream is replaced by a normal dream and releases the doze lock whenever a doze dream instance is stopped. Bug: 260094933 Test: manual - check that the flickering disappeared Change-Id: I3fdf10566ba57fadfa83a5d78038db68bf4a1150
This commit is contained in:
@@ -281,7 +281,10 @@ final class DreamController {
|
||||
new int[] {ACTIVITY_TYPE_DREAM});
|
||||
|
||||
mListener.onDreamStopped(dream.mToken);
|
||||
} else if (dream.mCanDoze && !mCurrentDream.mCanDoze) {
|
||||
mListener.stopDozing(dream.mToken);
|
||||
}
|
||||
|
||||
} finally {
|
||||
Trace.traceEnd(Trace.TRACE_TAG_POWER);
|
||||
}
|
||||
@@ -327,6 +330,7 @@ final class DreamController {
|
||||
*/
|
||||
public interface Listener {
|
||||
void onDreamStopped(Binder token);
|
||||
void stopDozing(Binder token);
|
||||
}
|
||||
|
||||
private final class DreamRecord implements DeathRecipient, ServiceConnection {
|
||||
|
||||
@@ -499,7 +499,12 @@ public final class DreamManagerService extends SystemService {
|
||||
}
|
||||
|
||||
synchronized (mLock) {
|
||||
if (mCurrentDream != null && mCurrentDream.token == token && mCurrentDream.isDozing) {
|
||||
if (mCurrentDream == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean sameDream = mCurrentDream.token == token;
|
||||
if ((sameDream && mCurrentDream.isDozing) || (!sameDream && !mCurrentDream.isDozing)) {
|
||||
mCurrentDream.isDozing = false;
|
||||
mDozeWakeLock.release();
|
||||
mPowerManagerInternal.setDozeOverrideFromDreamManager(
|
||||
@@ -768,6 +773,11 @@ public final class DreamManagerService extends SystemService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopDozing(Binder token) {
|
||||
stopDozingInternal(token);
|
||||
}
|
||||
};
|
||||
|
||||
private final ContentObserver mDozeEnabledObserver = new ContentObserver(null) {
|
||||
|
||||
Reference in New Issue
Block a user