Merge "Treat fg service alarms like bg service alarms under FAS" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
de38aa102d
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user