Merge "DOZE instead of DOZE_AOD when batterySaver=active" into tm-dev

This commit is contained in:
TreeHugger Robot
2022-03-21 15:36:43 +00:00
committed by Android (Google) Code Review
5 changed files with 20 additions and 7 deletions

View File

@@ -319,9 +319,10 @@ public class DozeLog implements Dumpable {
/**
* Appends the doze state that was suppressed to the doze event log
* @param suppressedState The {@link DozeMachine.State} that was suppressed
* @param reason what suppressed always on
*/
public void traceAlwaysOnSuppressed(DozeMachine.State suppressedState) {
mLogger.logAlwaysOnSuppressed(suppressedState);
public void traceAlwaysOnSuppressed(DozeMachine.State suppressedState, String reason) {
mLogger.logAlwaysOnSuppressed(suppressedState, reason);
}
/**

View File

@@ -267,11 +267,12 @@ class DozeLogger @Inject constructor(
})
}
fun logAlwaysOnSuppressed(state: DozeMachine.State) {
fun logAlwaysOnSuppressed(state: DozeMachine.State, reason: String) {
buffer.log(TAG, INFO, {
str1 = state.name
str2 = reason
}, {
"Always-on state suppressed, suppressed state=$str1"
"Always-on state suppressed, suppressed state=$str1 reason=$str2"
})
}

View File

@@ -358,8 +358,13 @@ public class DozeMachine {
return State.FINISH;
}
if (mDozeHost.isAlwaysOnSuppressed() && requestedState.isAlwaysOn()) {
Log.i(TAG, "Doze is suppressed. Suppressing state: " + requestedState);
mDozeLog.traceAlwaysOnSuppressed(requestedState);
Log.i(TAG, "Doze is suppressed by an app. Suppressing state: " + requestedState);
mDozeLog.traceAlwaysOnSuppressed(requestedState, "app");
return State.DOZE;
}
if (mDozeHost.isPowerSaveActive() && requestedState.isAlwaysOn()) {
Log.i(TAG, "Doze is suppressed by battery saver. Suppressing state: " + requestedState);
mDozeLog.traceAlwaysOnSuppressed(requestedState, "batterySaver");
return State.DOZE;
}
if ((mState == State.DOZE_AOD_PAUSED || mState == State.DOZE_AOD_PAUSING

View File

@@ -136,6 +136,8 @@ public class DozeService extends DreamService
@Override
public void setDozeScreenState(int state) {
super.setDozeScreenState(state);
mDozeMachine.onScreenState(state);
if (mDozeMachine != null) {
mDozeMachine.onScreenState(state);
}
}
}

View File

@@ -166,6 +166,8 @@ public class DozeSuppressor implements DozeMachine.Part {
private DozeHost.Callback mHostCallback = new DozeHost.Callback() {
@Override
public void onPowerSaveChanged(boolean active) {
// handles suppression changes, while DozeMachine#transitionPolicy handles gating
// transitions to DOZE_AOD
DozeMachine.State nextState = null;
if (mDozeHost.isPowerSaveActive()) {
nextState = DozeMachine.State.DOZE;
@@ -182,6 +184,8 @@ public class DozeSuppressor implements DozeMachine.Part {
@Override
public void onAlwaysOnSuppressedChanged(boolean suppressed) {
// handles suppression changes, while DozeMachine#transitionPolicy handles gating
// transitions to DOZE_AOD
final DozeMachine.State nextState;
if (mConfig.alwaysOnEnabled(UserHandle.USER_CURRENT) && !suppressed) {
nextState = DozeMachine.State.DOZE_AOD;