Merge "Add api to change charging state update delay"

This commit is contained in:
TreeHugger Robot
2019-01-25 22:42:06 +00:00
committed by Android (Google) Code Review
7 changed files with 84 additions and 3 deletions

View File

@@ -16,6 +16,8 @@
package android.os;
import android.Manifest.permission;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.content.Context;
@@ -369,4 +371,26 @@ public class BatteryManager {
throw e.rethrowFromSystemServer();
}
}
/**
* Sets the delay for reporting battery state as charging after device is plugged in.
* This allows machine-learning or heuristics to delay the reporting and the corresponding
* broadcast, based on battery level, charging rate, and/or other parameters.
*
* @param delayMillis the delay in milliseconds, negative value to reset.
*
* @return True if the delay was set successfully.
*
* @see ACTION_CHARGING
* @hide
*/
@RequiresPermission(permission.POWER_SAVER)
@SystemApi
public boolean setChargingStateUpdateDelayMillis(int delayMillis) {
try {
return mBatteryStats.setChargingStateUpdateDelayMillis(delayMillis);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
}

View File

@@ -14280,6 +14280,17 @@ public final class Settings {
*/
public static final String APPOP_HISTORY_PARAMETERS =
"appop_history_parameters";
/**
* Delay for sending ACTION_CHARGING after device is plugged in.
* This is used as an override for constants defined in BatteryStatsImpl for
* ease of experimentation.
*
* @see com.android.internal.os.BatteryStatsImpl.Constants.KEY_BATTERY_CHARGED_DELAY_MS
* @hide
*/
public static final String BATTERY_CHARGING_STATE_UPDATE_DELAY =
"battery_charging_state_update_delay";
}
/**