Merge "Treat fg service alarms like bg service alarms under FAS" into pi-dev

This commit is contained in:
TreeHugger Robot
2018-05-11 03:14:33 +00:00
committed by Android (Google) Code Review
2 changed files with 15 additions and 9 deletions

View File

@@ -3023,20 +3023,26 @@ class AlarmManagerService extends SystemService {
}
private boolean isBackgroundRestricted(Alarm alarm) {
final boolean allowWhileIdle = (alarm.flags & FLAG_ALLOW_WHILE_IDLE) != 0;
boolean exemptOnBatterySaver = (alarm.flags & FLAG_ALLOW_WHILE_IDLE) != 0;
if (alarm.alarmClock != null) {
// Don't block alarm clocks
// Don't defer alarm clocks
return false;
}
if (alarm.operation != null
&& (alarm.operation.isActivity() || alarm.operation.isForegroundService())) {
// Don't block starting foreground components
return false;
if (alarm.operation != null) {
if (alarm.operation.isActivity()) {
// Don't defer starting actual UI
return false;
}
if (alarm.operation.isForegroundService()) {
// FG service alarms are nearly as important; consult AST policy
exemptOnBatterySaver = true;
}
}
final String sourcePackage = alarm.sourcePackage;
final int sourceUid = alarm.creatorUid;
return (mAppStateTracker != null) &&
mAppStateTracker.areAlarmsRestricted(sourceUid, sourcePackage, allowWhileIdle);
mAppStateTracker.areAlarmsRestricted(sourceUid, sourcePackage,
exemptOnBatterySaver);
}
private native long init();

View File

@@ -1056,9 +1056,9 @@ public class AppStateTracker {
* @return whether alarms should be restricted for a UID package-name.
*/
public boolean areAlarmsRestricted(int uid, @NonNull String packageName,
boolean allowWhileIdle) {
boolean isExemptOnBatterySaver) {
return isRestricted(uid, packageName, /*useTempWhitelistToo=*/ false,
/* exemptOnBatterySaver =*/ allowWhileIdle);
isExemptOnBatterySaver);
}
/**