Merge "Extreme battery saver: Log BS state in the event log."
This commit is contained in:
committed by
Android (Google) Code Review
commit
9e0aba647c
@@ -32,9 +32,11 @@ option java_package com.android.server
|
||||
# The device is being asked to go into a soft sleep (typically by the ungaze gesture).
|
||||
# It logs the time remaining before the device would've normally gone to sleep without the request.
|
||||
2731 power_soft_sleep_requested (savedwaketimems|2)
|
||||
# Power save state has changed. See BatterySaverController.java for the details.
|
||||
2739 battery_saver_mode (prevOffOrOn|1|5),(nowOffOrOn|1|5),(interactive|1|5),(features|3|5)
|
||||
|
||||
#
|
||||
# Leave IDs through 2739 for more power logs (2730 used by battery_discharge above)
|
||||
# Leave IDs through 2740 for more power logs (2730 used by battery_discharge above)
|
||||
#
|
||||
|
||||
|
||||
|
||||
@@ -86,6 +86,12 @@ public class BatterySaverPolicy extends ContentObserver {
|
||||
@GuardedBy("mLock")
|
||||
private String mDeviceSpecificSettingsSource; // For dump() only.
|
||||
|
||||
/**
|
||||
* A short string describing which battery saver is now enabled, which we dump in the eventlog.
|
||||
*/
|
||||
@GuardedBy("mLock")
|
||||
private String mEventLogKeys;
|
||||
|
||||
/**
|
||||
* {@code true} if vibration is disabled in battery saver mode.
|
||||
*
|
||||
@@ -354,6 +360,27 @@ public class BatterySaverPolicy extends ContentObserver {
|
||||
|
||||
mFilesForNoninteractive = (new CpuFrequencies()).parseString(
|
||||
parser.getString(KEY_CPU_FREQ_NONINTERACTIVE, "")).toSysFileMap();
|
||||
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (mForceAllAppsStandby) sb.append("A");
|
||||
if (mForceBackgroundCheck) sb.append("B");
|
||||
|
||||
if (mVibrationDisabled) sb.append("v");
|
||||
if (mAnimationDisabled) sb.append("a");
|
||||
if (mSoundTriggerDisabled) sb.append("s");
|
||||
if (mFullBackupDeferred) sb.append("F");
|
||||
if (mKeyValueBackupDeferred) sb.append("K");
|
||||
if (!mFireWallDisabled) sb.append("f");
|
||||
if (!mDataSaverDisabled) sb.append("d");
|
||||
if (!mAdjustBrightnessDisabled) sb.append("b");
|
||||
|
||||
if (mLaunchBoostDisabled) sb.append("l");
|
||||
if (mOptionalSensorsDisabled) sb.append("S");
|
||||
|
||||
sb.append(mGpsMode);
|
||||
|
||||
mEventLogKeys = sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -431,6 +458,12 @@ public class BatterySaverPolicy extends ContentObserver {
|
||||
}
|
||||
}
|
||||
|
||||
public String toEventLogString() {
|
||||
synchronized (mLock) {
|
||||
return mEventLogKeys;
|
||||
}
|
||||
}
|
||||
|
||||
public void dump(PrintWriter pw) {
|
||||
synchronized (mLock) {
|
||||
pw.println();
|
||||
|
||||
@@ -45,6 +45,7 @@ import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
||||
import com.android.internal.notification.SystemNotificationChannels;
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.internal.util.Preconditions;
|
||||
import com.android.server.EventLogTags;
|
||||
import com.android.server.LocalServices;
|
||||
import com.android.server.power.BatterySaverPolicy;
|
||||
import com.android.server.power.BatterySaverPolicy.BatterySaverPolicyListener;
|
||||
@@ -77,6 +78,12 @@ public class BatterySaverController implements BatterySaverPolicyListener {
|
||||
@GuardedBy("mLock")
|
||||
private boolean mEnabled;
|
||||
|
||||
/**
|
||||
* Previously enabled or not; only for the event logging. Only use it from
|
||||
* {@link #handleBatterySaverStateChanged}.
|
||||
*/
|
||||
private boolean mPreviouslyEnabled;
|
||||
|
||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
@@ -213,12 +220,18 @@ public class BatterySaverController implements BatterySaverPolicyListener {
|
||||
final ArrayMap<String, String> fileValues;
|
||||
|
||||
synchronized (mLock) {
|
||||
Slog.i(TAG, "Battery saver " + (mEnabled ? "enabled" : "disabled")
|
||||
+ ": isInteractive=" + isInteractive);
|
||||
EventLogTags.writeBatterySaverMode(
|
||||
mPreviouslyEnabled ? 1 : 0, // Previously off or on.
|
||||
mEnabled ? 1 : 0, // Now off or on.
|
||||
isInteractive ? 1 : 0, // Device interactive state.
|
||||
mEnabled ? mBatterySaverPolicy.toEventLogString() : "");
|
||||
mPreviouslyEnabled = mEnabled;
|
||||
|
||||
listeners = mListeners.toArray(new LowPowerModeListener[mListeners.size()]);
|
||||
|
||||
enabled = mEnabled;
|
||||
|
||||
|
||||
if (enabled) {
|
||||
fileValues = mBatterySaverPolicy.getFileValues(isInteractive);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user