FGS PendingIntent also use BroadcastOptions' temp allowlist duration.
For FGS PendingIntent, if the BroadcastOptions parameter passed in PendingIntentRecord.send() call has a non-zero temp allowlist duration, treat this duration the same as the FGS PendingIntent's temp allowlist duration. Previously only setExact() alarm's "broadcasts" are exempt from BG-FGS-start restriction using BroadcastOptions. This CL exempts setExact() alarm's "FGS PendingIntent" from BG-FGS-start restriction. BYPASS_INCLUSIVE_LANGUAGE_REASON=Pre-existing API Bug: 193011829 Test: b/193011829 POC app, with this fix, ForegroundServiceStartNotAllowedException is not seen. Change-Id: Ifb095a8bcc458ab27c9259ca4af4d759835f2e1c
This commit is contained in:
@@ -24,6 +24,7 @@ import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NA
|
||||
import android.annotation.Nullable;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityOptions;
|
||||
import android.app.BroadcastOptions;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.IIntentReceiver;
|
||||
import android.content.IIntentSender;
|
||||
@@ -408,6 +409,18 @@ public final class PendingIntentRecord extends IIntentSender.Stub {
|
||||
}
|
||||
controller.mAmInternal.tempAllowlistForPendingIntent(callingPid, callingUid,
|
||||
uid, duration.duration, duration.type, duration.reasonCode, tag.toString());
|
||||
} else if (key.type == ActivityManager.INTENT_SENDER_FOREGROUND_SERVICE
|
||||
&& options != null) {
|
||||
// If this is a getForegroundService() type pending intent, use its BroadcastOptions
|
||||
// temp allowlist duration as its pending intent temp allowlist duration.
|
||||
BroadcastOptions brOptions = new BroadcastOptions(options);
|
||||
if (brOptions.getTemporaryAppAllowlistDuration() > 0) {
|
||||
controller.mAmInternal.tempAllowlistForPendingIntent(callingPid, callingUid,
|
||||
uid, brOptions.getTemporaryAppAllowlistDuration(),
|
||||
brOptions.getTemporaryAppAllowlistType(),
|
||||
brOptions.getTemporaryAppAllowlistReasonCode(),
|
||||
brOptions.getTemporaryAppAllowlistReason());
|
||||
}
|
||||
}
|
||||
|
||||
boolean sendFinish = finishedReceiver != null;
|
||||
|
||||
Reference in New Issue
Block a user