Debian Codegraph @

core/java/android/app/BroadcastOptions.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package android.app;
18
19 import android.annotation.IntDef;
20 import android.annotation.IntRange;
21 import android.annotation.NonNull;
22 import android.annotation.Nullable;
23 import android.annotation.RequiresPermission;
24 import android.annotation.SystemApi;
25 import android.annotation.TestApi;
26 import android.app.compat.CompatChanges;
27 import android.compat.annotation.ChangeId;
28 import android.compat.annotation.Disabled;
29 import android.compat.annotation.EnabledSince;
30 import android.content.BroadcastReceiver;
31 import android.content.Intent;
32 import android.content.IntentFilter;
33 import android.os.Build;
34 import android.os.Bundle;
35 import android.os.BundleMerger;
36 import android.os.PowerExemptionManager;
37 import android.os.PowerExemptionManager.ReasonCode;
38 import android.os.PowerExemptionManager.TempAllowListType;
39
40 import java.lang.annotation.Retention;
41 import java.lang.annotation.RetentionPolicy;
42 import java.util.Objects;
43
44 /**
45 * Helper class for building an options Bundle that can be used with
46 * {@link android.content.Context#sendBroadcast(android.content.Intent)
47 * Context.sendBroadcast(Intent)} and related methods.
48 */
49 public class BroadcastOptions extends ComponentOptions {
50 private @Flags int mFlags;
51 private long mTemporaryAppAllowlistDuration;
52 private @TempAllowListType int mTemporaryAppAllowlistType;
53 private @ReasonCode int mTemporaryAppAllowlistReasonCode;
54 private @Nullable String mTemporaryAppAllowlistReason;
55 private int mMinManifestReceiverApiLevel = 0;
56 private int mMaxManifestReceiverApiLevel = Build.VERSION_CODES.CUR_DEVELOPMENT;
57 private String[] mRequireAllOfPermissions;
58 private String[] mRequireNoneOfPermissions;
59 private long mRequireCompatChangeId = CHANGE_INVALID;
60 private long mIdForResponseEvent;
61 private @DeliveryGroupPolicy int mDeliveryGroupPolicy;
62 private @Nullable String mDeliveryGroupMatchingNamespaceFragment;
63 private @Nullable String mDeliveryGroupMatchingKeyFragment;
64 private @Nullable BundleMerger mDeliveryGroupExtrasMerger;
65 private @Nullable IntentFilter mDeliveryGroupMatchingFilter;
66 private @DeferralPolicy int mDeferralPolicy;
67
68 /** @hide */
69 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
70 FLAG_DONT_SEND_TO_RESTRICTED_APPS,
71 FLAG_ALLOW_BACKGROUND_ACTIVITY_STARTS,
72 FLAG_REQUIRE_COMPAT_CHANGE_ENABLED,
73 FLAG_IS_ALARM_BROADCAST,
74 FLAG_SHARE_IDENTITY,
75 FLAG_INTERACTIVE,
76 })
77 @Retention(RetentionPolicy.SOURCE)
78 public @interface Flags {}
79
80 private static final int FLAG_DONT_SEND_TO_RESTRICTED_APPS = 1 << 0;
81 private static final int FLAG_ALLOW_BACKGROUND_ACTIVITY_STARTS = 1 << 1;
82 private static final int FLAG_REQUIRE_COMPAT_CHANGE_ENABLED = 1 << 2;
83 private static final int FLAG_IS_ALARM_BROADCAST = 1 << 3;
84 private static final int FLAG_SHARE_IDENTITY = 1 << 4;
85 private static final int FLAG_INTERACTIVE = 1 << 5;
86
87 /**
88 * Change ID which is invalid.
89 *
90 * @hide
91 */
92 public static final long CHANGE_INVALID = Long.MIN_VALUE;
93
94 /**
95 * Change ID which is always enabled, for testing purposes.
96 *
97 * @hide
98 */
99 @TestApi
100 @ChangeId
101 @EnabledSince(targetSdkVersion = android.os.Build.VERSION_CODES.BASE)
102 public static final long CHANGE_ALWAYS_ENABLED = 209888056L;
103
104 /**
105 * Change ID which is always disabled, for testing purposes.
106 *
107 * @hide
108 */
109 @TestApi
110 @ChangeId
111 @Disabled
112 public static final long CHANGE_ALWAYS_DISABLED = 210856463L;
113
114 /**
115 * Corresponds to {@link #mFlags}.
116 */
117 private static final String KEY_FLAGS = "android:broadcast.flags";
118
119 /**
120 * How long to temporarily put an app on the power allowlist when executing this broadcast
121 * to it.
122 */
123 private static final String KEY_TEMPORARY_APP_ALLOWLIST_DURATION
124 = "android:broadcast.temporaryAppAllowlistDuration";
125
126 private static final String KEY_TEMPORARY_APP_ALLOWLIST_TYPE
127 = "android:broadcast.temporaryAppAllowlistType";
128
129 private static final String KEY_TEMPORARY_APP_ALLOWLIST_REASON_CODE =
130 "android:broadcast.temporaryAppAllowlistReasonCode";
131
132 private static final String KEY_TEMPORARY_APP_ALLOWLIST_REASON =
133 "android:broadcast.temporaryAppAllowlistReason";
134
135 /**
136 * Corresponds to {@link #setMinManifestReceiverApiLevel}.
137 */
138 private static final String KEY_MIN_MANIFEST_RECEIVER_API_LEVEL
139 = "android:broadcast.minManifestReceiverApiLevel";
140
141 /**
142 * Corresponds to {@link #setMaxManifestReceiverApiLevel}.
143 */
144 private static final String KEY_MAX_MANIFEST_RECEIVER_API_LEVEL
145 = "android:broadcast.maxManifestReceiverApiLevel";
146
147 /**
148 * Corresponds to {@link #setRequireAllOfPermissions}
149 * @hide
150 */
151 public static final String KEY_REQUIRE_ALL_OF_PERMISSIONS =
152 "android:broadcast.requireAllOfPermissions";
153
154 /**
155 * Corresponds to {@link #setRequireNoneOfPermissions}
156 * @hide
157 */
158 public static final String KEY_REQUIRE_NONE_OF_PERMISSIONS =
159 "android:broadcast.requireNoneOfPermissions";
160
161 /**
162 * Corresponds to {@link #setRequireCompatChange(long, boolean)}
163 */
164 private static final String KEY_REQUIRE_COMPAT_CHANGE_ID =
165 "android:broadcast.requireCompatChangeId";
166
167 /**
168 * Corresponds to {@link #setRequireCompatChange(long, boolean)}
169 */
170 private static final String KEY_REQUIRE_COMPAT_CHANGE_ENABLED =
171 "android:broadcast.requireCompatChangeEnabled";
172
173 /**
174 * Corresponds to {@link #setAlarmBroadcast(boolean)}
175 * @hide
176 */
177 public static final String KEY_ALARM_BROADCAST =
178 "android:broadcast.is_alarm";
179
180 /**
181 * @hide
182 * @deprecated Use {@link android.os.PowerExemptionManager#
183 * TEMPORARY_ALLOW_LIST_TYPE_FOREGROUND_SERVICE_ALLOWED} instead.
184 */
185 @Deprecated
186 public static final int TEMPORARY_WHITELIST_TYPE_FOREGROUND_SERVICE_ALLOWED =
187 PowerExemptionManager.TEMPORARY_ALLOW_LIST_TYPE_FOREGROUND_SERVICE_ALLOWED;
188
189 /**
190 * @hide
191 * @deprecated Use {@link android.os.PowerExemptionManager#
192 * TEMPORARY_ALLOW_LIST_TYPE_FOREGROUND_SERVICE_NOT_ALLOWED} instead.
193 */
194 @Deprecated
195 public static final int TEMPORARY_WHITELIST_TYPE_FOREGROUND_SERVICE_NOT_ALLOWED =
196 PowerExemptionManager.TEMPORARY_ALLOW_LIST_TYPE_FOREGROUND_SERVICE_NOT_ALLOWED;
197
198 /**
199 * Corresponds to {@link #recordResponseEventWhileInBackground(long)}.
200 */
201 private static final String KEY_ID_FOR_RESPONSE_EVENT =
202 "android:broadcast.idForResponseEvent";
203
204 /**
205 * Corresponds to {@link #setDeliveryGroupPolicy(int)}.
206 */
207 private static final String KEY_DELIVERY_GROUP_POLICY =
208 "android:broadcast.deliveryGroupPolicy";
209
210 /**
211 * Corresponds to namespace fragment of {@link #setDeliveryGroupMatchingKey(String, String)}.
212 */
213 private static final String KEY_DELIVERY_GROUP_NAMESPACE =
214 "android:broadcast.deliveryGroupMatchingNamespace";
215
216 /**
217 * Corresponds to key fragment of {@link #setDeliveryGroupMatchingKey(String, String)}.
218 */
219 private static final String KEY_DELIVERY_GROUP_KEY =
220 "android:broadcast.deliveryGroupMatchingKey";
221
222 /**
223 * Corresponds to {@link #setDeliveryGroupExtrasMerger(BundleMerger)}.
224 */
225 private static final String KEY_DELIVERY_GROUP_EXTRAS_MERGER =
226 "android:broadcast.deliveryGroupExtrasMerger";
227
228 /**
229 * Corresponds to {@link #setDeliveryGroupMatchingFilter(IntentFilter)}.
230 */
231 private static final String KEY_DELIVERY_GROUP_MATCHING_FILTER =
232 "android:broadcast.deliveryGroupMatchingFilter";
233
234 /**
235 * Corresponds to {@link #setDeferralPolicy(int)}
236 */
237 private static final String KEY_DEFERRAL_POLICY =
238 "android:broadcast.deferralPolicy";
239
240 /**
241 * The list of delivery group policies which specify how multiple broadcasts belonging to
242 * the same delivery group has to be handled.
243 * @hide
244 */
245 @IntDef(prefix = { "DELIVERY_GROUP_POLICY_" }, value = {
246 DELIVERY_GROUP_POLICY_ALL,
247 DELIVERY_GROUP_POLICY_MOST_RECENT,
248 DELIVERY_GROUP_POLICY_MERGED,
249 })
250 @Retention(RetentionPolicy.SOURCE)
251 public @interface DeliveryGroupPolicy {}
252
253 /**
254 * Delivery group policy that indicates that all the broadcasts in the delivery group
255 * need to be delivered as is.
256 */
257 public static final int DELIVERY_GROUP_POLICY_ALL = 0;
258
259 /**
260 * Delivery group policy that indicates that only the most recent broadcast in the delivery
261 * group need to be delivered and the rest can be dropped.
262 */
263 public static final int DELIVERY_GROUP_POLICY_MOST_RECENT = 1;
264
265 /**
266 * Delivery group policy that indicates that the extras data from the broadcasts in the
267 * delivery group need to be merged into a single broadcast and the rest can be dropped.
268 *
269 * @hide
270 */
271 public static final int DELIVERY_GROUP_POLICY_MERGED = 2;
272
273 /** {@hide} */
274 @IntDef(prefix = { "DEFERRAL_POLICY_" }, value = {
275 DEFERRAL_POLICY_DEFAULT,
276 DEFERRAL_POLICY_NONE,
277 DEFERRAL_POLICY_UNTIL_ACTIVE,
278 })
279 @Retention(RetentionPolicy.SOURCE)
280 public @interface DeferralPolicy {}
281
282 /**
283 * Deferral policy that indicates no desire has been expressed, and that the
284 * system should use a reasonable default behavior.
285 */
286 public static final int DEFERRAL_POLICY_DEFAULT = 0;
287
288 /**
289 * Deferral policy that indicates a strong desire that no receiver of this
290 * broadcast should be deferred.
291 */
292 public static final int DEFERRAL_POLICY_NONE = 1;
293
294 /**
295 * Deferral policy that indicates a strong desire that each receiver of this
296 * broadcast should be deferred until that receiver's process is in an
297 * active (non-cached) state. Whether an app's process state is considered
298 * active is independent of its standby bucket.
299 * <p>
300 * This policy only applies to runtime registered receivers of a broadcast,
301 * and does not apply to ordered broadcasts, alarm broadcasts, interactive
302 * broadcasts, or manifest broadcasts.
303 * <p>
304 * This policy means that a runtime registered receiver will not typically
305 * execute until that receiver's process is brought to an active state by
306 * some other action, such as a job, alarm, or service binding. As a result,
307 * the receiver may be delayed indefinitely.
308 * <p>
309 * When this policy is set on an unordered broadcast with a completion
310 * callback, the completion callback will run once all eligible processes
311 * have finished receiving the broadcast. Processes in inactive process
312 * state are not considered eligible and may not receive the broadcast prior
313 * to the completion callback.
314 */
315 public static final int DEFERRAL_POLICY_UNTIL_ACTIVE = 2;
316
317 /**
318 * Creates a basic {@link BroadcastOptions} with no options initially set.
319 *
320 * @return an instance of {@code BroadcastOptions} against which options can be set
321 */
322 public static @NonNull BroadcastOptions makeBasic() {
323 BroadcastOptions opts = new BroadcastOptions();
324 return opts;
325 }
326
327 /** @hide */
328 @TestApi
329 public BroadcastOptions() {
330 super();
331 resetTemporaryAppAllowlist();
332 }
333
334 /** @hide */
335 @TestApi
336 public BroadcastOptions(@NonNull Bundle opts) {
337 super(opts);
338 // Match the logic in toBundle().
339 mFlags = opts.getInt(KEY_FLAGS, 0);
340 if (opts.containsKey(KEY_TEMPORARY_APP_ALLOWLIST_DURATION)) {
341 mTemporaryAppAllowlistDuration = opts.getLong(KEY_TEMPORARY_APP_ALLOWLIST_DURATION);
342 mTemporaryAppAllowlistType = opts.getInt(KEY_TEMPORARY_APP_ALLOWLIST_TYPE);
343 mTemporaryAppAllowlistReasonCode = opts.getInt(KEY_TEMPORARY_APP_ALLOWLIST_REASON_CODE,
344 PowerExemptionManager.REASON_UNKNOWN);
345 mTemporaryAppAllowlistReason = opts.getString(KEY_TEMPORARY_APP_ALLOWLIST_REASON);
346 } else {
347 resetTemporaryAppAllowlist();
348 }
349 mMinManifestReceiverApiLevel = opts.getInt(KEY_MIN_MANIFEST_RECEIVER_API_LEVEL, 0);
350 mMaxManifestReceiverApiLevel = opts.getInt(KEY_MAX_MANIFEST_RECEIVER_API_LEVEL,
351 Build.VERSION_CODES.CUR_DEVELOPMENT);
352 mRequireAllOfPermissions = opts.getStringArray(KEY_REQUIRE_ALL_OF_PERMISSIONS);
353 mRequireNoneOfPermissions = opts.getStringArray(KEY_REQUIRE_NONE_OF_PERMISSIONS);
354 mRequireCompatChangeId = opts.getLong(KEY_REQUIRE_COMPAT_CHANGE_ID, CHANGE_INVALID);
355 mIdForResponseEvent = opts.getLong(KEY_ID_FOR_RESPONSE_EVENT);
356 mDeliveryGroupPolicy = opts.getInt(KEY_DELIVERY_GROUP_POLICY,
357 DELIVERY_GROUP_POLICY_ALL);
358 mDeliveryGroupMatchingNamespaceFragment = opts.getString(KEY_DELIVERY_GROUP_NAMESPACE);
359 mDeliveryGroupMatchingKeyFragment = opts.getString(KEY_DELIVERY_GROUP_KEY);
360 mDeliveryGroupExtrasMerger = opts.getParcelable(KEY_DELIVERY_GROUP_EXTRAS_MERGER,
361 BundleMerger.class);
362 mDeliveryGroupMatchingFilter = opts.getParcelable(KEY_DELIVERY_GROUP_MATCHING_FILTER,
363 IntentFilter.class);
364 mDeferralPolicy = opts.getInt(KEY_DEFERRAL_POLICY, DEFERRAL_POLICY_DEFAULT);
365 }
366
367 /**
368 * Set a duration for which the system should temporary place an application on the
369 * power allowlist when this broadcast is being delivered to it.
370 * @param duration The duration in milliseconds; 0 means to not place on allowlist.
371 * @deprecated use {@link #setTemporaryAppAllowlist(long, int, int, String)} instead.
372 * @hide
373 */
374 @Deprecated
375 @SystemApi
376 @RequiresPermission(anyOf = {android.Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST,
377 android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND,
378 android.Manifest.permission.START_FOREGROUND_SERVICES_FROM_BACKGROUND})
379 public void setTemporaryAppWhitelistDuration(long duration) {
380 setTemporaryAppAllowlist(duration,
381 PowerExemptionManager.TEMPORARY_ALLOW_LIST_TYPE_FOREGROUND_SERVICE_ALLOWED,
382 PowerExemptionManager.REASON_UNKNOWN, null);
383 }
384
385 /**
386 * Set a duration for which the system should temporary place an application on the
387 * power allowlist when this broadcast is being delivered to it, specify the temp allowlist
388 * type.
389 * @hide
390 *
391 * @param duration the duration in milliseconds.
392 * 0 means to not place on allowlist, and clears previous call to this method.
393 * @param type one of {@link TempAllowListType}.
394 * {@link PowerExemptionManager#TEMPORARY_ALLOW_LIST_TYPE_NONE} means
395 * to not place on allowlist, and clears previous call to this method.
396 * @param reasonCode one of {@link ReasonCode}, use
397 * {@link PowerExemptionManager#REASON_UNKNOWN} if not sure.
398 * @param reason A human-readable reason explaining why the app is temp allowlisted. Only
399 * used for logging purposes. Could be null or empty string.
400 */
401 @SystemApi
402 @RequiresPermission(anyOf = {android.Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST,
403 android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND,
404 android.Manifest.permission.START_FOREGROUND_SERVICES_FROM_BACKGROUND})
405 public void setTemporaryAppAllowlist(long duration, @TempAllowListType int type,
406 @ReasonCode int reasonCode, @Nullable String reason) {
407 mTemporaryAppAllowlistDuration = duration;
408 mTemporaryAppAllowlistType = type;
409 mTemporaryAppAllowlistReasonCode = reasonCode;
410 mTemporaryAppAllowlistReason = reason;
411
412 if (!isTemporaryAppAllowlistSet()) {
413 resetTemporaryAppAllowlist();
414 }
415 }
416
417 private boolean isTemporaryAppAllowlistSet() {
418 return mTemporaryAppAllowlistDuration > 0
419 && mTemporaryAppAllowlistType
420 != PowerExemptionManager.TEMPORARY_ALLOW_LIST_TYPE_NONE;
421 }
422
423 private void resetTemporaryAppAllowlist() {
424 mTemporaryAppAllowlistDuration = 0;
425 mTemporaryAppAllowlistType = PowerExemptionManager.TEMPORARY_ALLOW_LIST_TYPE_NONE;
426 mTemporaryAppAllowlistReasonCode = PowerExemptionManager.REASON_UNKNOWN;
427 mTemporaryAppAllowlistReason = null;
428 }
429
430 /**
431 * Return {@link #setTemporaryAppAllowlist}.
432 * @hide
433 */
434 @TestApi
435 public long getTemporaryAppAllowlistDuration() {
436 return mTemporaryAppAllowlistDuration;
437 }
438
439 /**
440 * Return {@link #mTemporaryAppAllowlistType}.
441 * @hide
442 */
443 @TestApi
444 public @TempAllowListType int getTemporaryAppAllowlistType() {
445 return mTemporaryAppAllowlistType;
446 }
447
448 /**
449 * Return {@link #mTemporaryAppAllowlistReasonCode}.
450 * @hide
451 */
452 @TestApi
453 public @ReasonCode int getTemporaryAppAllowlistReasonCode() {
454 return mTemporaryAppAllowlistReasonCode;
455 }
456
457 /**
458 * Return {@link #mTemporaryAppAllowlistReason}.
459 * @hide
460 */
461 @TestApi
462 public @Nullable String getTemporaryAppAllowlistReason() {
463 return mTemporaryAppAllowlistReason;
464 }
465
466 /**
467 * Set the minimum target API level of receivers of the broadcast. If an application
468 * is targeting an API level less than this, the broadcast will not be delivered to
469 * them. This only applies to receivers declared in the app's AndroidManifest.xml.
470 *
471 * @deprecated to give developers the most flexibility during beta releases,
472 * we strongly encourage using {@link ChangeId} instead of
473 * target SDK checks; callers should use
474 * {@link #setRequireCompatChange(long, boolean)} instead,
475 * possibly combined with
476 * {@link Intent#FLAG_RECEIVER_REGISTERED_ONLY}.
477 * @hide
478 */
479 @Deprecated
480 public void setMinManifestReceiverApiLevel(int apiLevel) {
481 mMinManifestReceiverApiLevel = apiLevel;
482 }
483
484 /**
485 * Return {@link #setMinManifestReceiverApiLevel}.
486 *
487 * @deprecated to give developers the most flexibility during beta releases,
488 * we strongly encourage using {@link ChangeId} instead of
489 * target SDK checks; callers should use
490 * {@link #setRequireCompatChange(long, boolean)} instead,
491 * possibly combined with
492 * {@link Intent#FLAG_RECEIVER_REGISTERED_ONLY}.
493 * @hide
494 */
495 @Deprecated
496 public int getMinManifestReceiverApiLevel() {
497 return mMinManifestReceiverApiLevel;
498 }
499
500 /**
501 * Set the maximum target API level of receivers of the broadcast. If an application
502 * is targeting an API level greater than this, the broadcast will not be delivered to
503 * them. This only applies to receivers declared in the app's AndroidManifest.xml.
504 *
505 * @deprecated to give developers the most flexibility during beta releases,
506 * we strongly encourage using {@link ChangeId} instead of
507 * target SDK checks; callers should use
508 * {@link #setRequireCompatChange(long, boolean)} instead,
509 * possibly combined with
510 * {@link Intent#FLAG_RECEIVER_REGISTERED_ONLY}.
511 * @hide
512 */
513 @TestApi
514 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
515 @Deprecated
516 public void setMaxManifestReceiverApiLevel(int apiLevel) {
517 mMaxManifestReceiverApiLevel = apiLevel;
518 }
519
520 /**
521 * Return {@link #setMaxManifestReceiverApiLevel}.
522 *
523 * @deprecated to give developers the most flexibility during beta releases,
524 * we strongly encourage using {@link ChangeId} instead of
525 * target SDK checks; callers should use
526 * {@link #setRequireCompatChange(long, boolean)} instead,
527 * possibly combined with
528 * {@link Intent#FLAG_RECEIVER_REGISTERED_ONLY}.
529 * @hide
530 */
531 @TestApi
532 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
533 @Deprecated
534 public int getMaxManifestReceiverApiLevel() {
535 return mMaxManifestReceiverApiLevel;
536 }
537
538 /**
539 * Sets whether pending intent can be sent for an application with background restrictions
540 * @param dontSendToRestrictedApps if true, pending intent will not be sent for an application
541 * with background restrictions. Default value is {@code false}
542 * @hide
543 */
544 @SystemApi
545 public void setDontSendToRestrictedApps(boolean dontSendToRestrictedApps) {
546 if (dontSendToRestrictedApps) {
547 mFlags |= FLAG_DONT_SEND_TO_RESTRICTED_APPS;
548 } else {
549 mFlags &= ~FLAG_DONT_SEND_TO_RESTRICTED_APPS;
550 }
551 }
552
553 /**
554 * @hide
555 * @return #setDontSendToRestrictedApps
556 */
557 public boolean isDontSendToRestrictedApps() {
558 return (mFlags & FLAG_DONT_SEND_TO_RESTRICTED_APPS) != 0;
559 }
560
561 /**
562 * Sets the process will be able to start activities from background for the duration of
563 * the broadcast dispatch. Default value is {@code false}
564 * @hide
565 */
566 @SystemApi
567 @RequiresPermission(android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND)
568 public void setBackgroundActivityStartsAllowed(boolean allowBackgroundActivityStarts) {
569 if (allowBackgroundActivityStarts) {
570 mFlags |= FLAG_ALLOW_BACKGROUND_ACTIVITY_STARTS;
571 } else {
572 mFlags &= ~FLAG_ALLOW_BACKGROUND_ACTIVITY_STARTS;
573 }
574 }
575
576 /**
577 * @hide
578 * @return #setAllowBackgroundActivityStarts
579 */
580 @Deprecated
581 public boolean allowsBackgroundActivityStarts() {
582 return (mFlags & FLAG_ALLOW_BACKGROUND_ACTIVITY_STARTS) != 0;
583 }
584
585 /**
586 * Use this to configure a broadcast to be sent to apps that hold all permissions in
587 * the list. This is only for use with the {@link Context#sendBroadcast(Intent intent,
588 * @Nullable String receiverPermission, @Nullable Bundle options)}.
589 *
590 * <p> If both {@link #setRequireAllOfPermissions(String[])} and
591 * {@link #setRequireNoneOfPermissions(String[])} are used, then receivers must have all of the
592 * permissions set by {@link #setRequireAllOfPermissions(String[])}, and none of the
593 * permissions set by {@link #setRequireNoneOfPermissions(String[])} to get the broadcast.
594 *
595 * @param requiredPermissions a list of Strings of permission the receiver must have. Set to
596 * null or an empty array to clear any previously set value.
597 * @hide
598 */
599 @SystemApi
600 public void setRequireAllOfPermissions(@Nullable String[] requiredPermissions) {
601 mRequireAllOfPermissions = requiredPermissions;
602 }
603
604 /**
605 * Use this to configure a broadcast to be sent to apps that don't hold any permissions in
606 * list. This is only for use with the {@link Context#sendBroadcast(Intent intent,
607 * @Nullable String receiverPermission, @Nullable Bundle options)}.
608 *
609 * <p> If both {@link #setRequireAllOfPermissions(String[])} and
610 * {@link #setRequireNoneOfPermissions(String[])} are used, then receivers must have all of the
611 * permissions set by {@link #setRequireAllOfPermissions(String[])}, and none of the
612 * permissions set by {@link #setRequireNoneOfPermissions(String[])} to get the broadcast.
613 *
614 * @param excludedPermissions a list of Strings of permission the receiver must not have. Set to
615 * null or an empty array to clear any previously set value.
616 * @hide
617 */
618 @SystemApi
619 public void setRequireNoneOfPermissions(@Nullable String[] excludedPermissions) {
620 mRequireNoneOfPermissions = excludedPermissions;
621 }
622
623 /**
624 * When set, this broadcast will only be delivered to apps which have the
625 * given {@link ChangeId} in the given state.
626 * <p>
627 * Each {@link BroadcastOptions} instance supports only a single
628 * {@link ChangeId} requirement, so any subsequent calls will override any
629 * previously defined requirement.
630 * <p>
631 * This requirement applies to both manifest registered and runtime
632 * registered receivers.
633 * @hide
634 *
635 * @param changeId the {@link ChangeId} to inspect
636 * @param enabled the required enabled state of the inspected
637 * {@link ChangeId} for this broadcast to be delivered
638 * @see CompatChanges#isChangeEnabled
639 * @see #clearRequireCompatChange()
640 */
641 @SystemApi
642 public void setRequireCompatChange(long changeId, boolean enabled) {
643 mRequireCompatChangeId = changeId;
644 if (enabled) {
645 mFlags |= FLAG_REQUIRE_COMPAT_CHANGE_ENABLED;
646 } else {
647 mFlags &= ~FLAG_REQUIRE_COMPAT_CHANGE_ENABLED;
648 }
649 }
650
651 /**
652 * Clear any previously defined requirement for this broadcast requested via
653 * {@link #setRequireCompatChange(long, boolean)}.
654 * @hide
655 */
656 @SystemApi
657 public void clearRequireCompatChange() {
658 setRequireCompatChange(CHANGE_INVALID, true);
659 }
660
661 /**
662 * When set, this broadcast will be understood as having originated from an
663 * alarm going off. Only the OS itself can use this option; uses by other
664 * senders will be ignored.
665 * @hide
666 *
667 * @param senderIsAlarm Whether the broadcast is alarm-triggered.
668 */
669 public void setAlarmBroadcast(boolean senderIsAlarm) {
670 if (senderIsAlarm) {
671 mFlags |= FLAG_IS_ALARM_BROADCAST;
672 } else {
673 mFlags &= ~FLAG_IS_ALARM_BROADCAST;
674 }
675 }
676
677 /**
678 * Did this broadcast originate from an alarm triggering?
679 * @return true if this broadcast is an alarm message, false otherwise
680 * @hide
681 */
682 public boolean isAlarmBroadcast() {
683 return (mFlags & FLAG_IS_ALARM_BROADCAST) != 0;
684 }
685
686 /**
687 * Sets whether the identity of the broadcasting app should be shared with all receivers
688 * that will receive this broadcast.
689 *
690 * <p>Use this option when broadcasting to a receiver that needs to know the identity of the
691 * broadcaster; with this set to {@code true}, the receiver will have access to the broadcasting
692 * app's package name and uid.
693 *
694 * <p>Defaults to {@code false} if not set.
695 *
696 * @param shareIdentityEnabled whether the broadcasting app's identity should be shared with the
697 * receiver
698 * @return {@code this} {@link BroadcastOptions} instance
699 * @see BroadcastReceiver#getSentFromUid()
700 * @see BroadcastReceiver#getSentFromPackage()
701 */
702 public @NonNull BroadcastOptions setShareIdentityEnabled(boolean shareIdentityEnabled) {
703 if (shareIdentityEnabled) {
704 mFlags |= FLAG_SHARE_IDENTITY;
705 } else {
706 mFlags &= ~FLAG_SHARE_IDENTITY;
707 }
708 return this;
709 }
710
711 /**
712 * Returns whether the broadcasting app has opted-in to sharing its identity with the receiver.
713 *
714 * @return {@code true} if the broadcasting app has opted in to sharing its identity
715 * @see #setShareIdentityEnabled(boolean)
716 * @see BroadcastReceiver#getSentFromUid()
717 * @see BroadcastReceiver#getSentFromPackage()
718 */
719 public boolean isShareIdentityEnabled() {
720 return (mFlags & FLAG_SHARE_IDENTITY) != 0;
721 }
722
723 /**
724 * Did this broadcast originate from a push message from the server?
725 *
726 * @return true if this broadcast is a push message, false otherwise.
727 * @hide
728 */
729 public boolean isPushMessagingBroadcast() {
730 return mTemporaryAppAllowlistReasonCode == PowerExemptionManager.REASON_PUSH_MESSAGING;
731 }
732
733 /**
734 * Did this broadcast originate from a push message from the server which was over the allowed
735 * quota?
736 *
737 * @return true if this broadcast is a push message over quota, false otherwise.
738 * @hide
739 */
740 public boolean isPushMessagingOverQuotaBroadcast() {
741 return mTemporaryAppAllowlistReasonCode
742 == PowerExemptionManager.REASON_PUSH_MESSAGING_OVER_QUOTA;
743 }
744
745 /** {@hide} */
746 public long getRequireCompatChangeId() {
747 return mRequireCompatChangeId;
748 }
749
750 /**
751 * Test if the given app meets the {@link ChangeId} state required by this
752 * broadcast, if any.
753 *
754 * @hide
755 */
756 @TestApi
757 public boolean testRequireCompatChange(int uid) {
758 if (mRequireCompatChangeId != CHANGE_INVALID) {
759 final boolean requireEnabled = (mFlags & FLAG_REQUIRE_COMPAT_CHANGE_ENABLED) != 0;
760 return CompatChanges.isChangeEnabled(mRequireCompatChangeId, uid) == requireEnabled;
761 } else {
762 return true;
763 }
764 }
765
766 /**
767 * Sets whether events (such as posting a notification) originating from an app after it
768 * receives the broadcast while in background should be recorded as responses to the broadcast.
769 *
770 * <p> Note that this will only be considered when sending explicit broadcast intents.
771 *
772 * @param id ID to be used for the response events corresponding to this broadcast. If the
773 * value is {@code 0} (default), then response events will not be recorded. Otherwise,
774 * they will be recorded with the ID provided.
775 *
776 * @hide
777 */
778 @SystemApi
779 @RequiresPermission(android.Manifest.permission.ACCESS_BROADCAST_RESPONSE_STATS)
780 public void recordResponseEventWhileInBackground(@IntRange(from = 0) long id) {
781 mIdForResponseEvent = id;
782 }
783
784 /** @hide */
785 @IntRange(from = 0)
786 public long getIdForResponseEvent() {
787 return mIdForResponseEvent;
788 }
789
790 /** {@hide} */
791 @Deprecated
792 public @NonNull BroadcastOptions setDeferUntilActive(boolean shouldDefer) {
793 if (shouldDefer) {
794 setDeferralPolicy(DEFERRAL_POLICY_UNTIL_ACTIVE);
795 } else {
796 setDeferralPolicy(DEFERRAL_POLICY_NONE);
797 }
798 return this;
799 }
800
801 /** {@hide} */
802 @Deprecated
803 public boolean isDeferUntilActive() {
804 return (mDeferralPolicy == DEFERRAL_POLICY_UNTIL_ACTIVE);
805 }
806
807 /**
808 * Sets deferral policy for this broadcast that specifies how this broadcast
809 * can be deferred for delivery at some future point.
810 */
811 public @NonNull BroadcastOptions setDeferralPolicy(@DeferralPolicy int deferralPolicy) {
812 mDeferralPolicy = deferralPolicy;
813 return this;
814 }
815
816 /**
817 * Gets deferral policy for this broadcast that specifies how this broadcast
818 * can be deferred for delivery at some future point.
819 */
820 public @DeferralPolicy int getDeferralPolicy() {
821 return mDeferralPolicy;
822 }
823
824 /**
825 * Clears any deferral policy for this broadcast that specifies how this
826 * broadcast can be deferred for delivery at some future point.
827 */
828 public void clearDeferralPolicy() {
829 mDeferralPolicy = DEFERRAL_POLICY_DEFAULT;
830 }
831
832 /**
833 * Set delivery group policy for this broadcast to specify how multiple broadcasts belonging to
834 * the same delivery group has to be handled.
835 */
836 @NonNull
837 public BroadcastOptions setDeliveryGroupPolicy(@DeliveryGroupPolicy int policy) {
838 mDeliveryGroupPolicy = policy;
839 return this;
840 }
841
842 /**
843 * Get the delivery group policy for this broadcast that specifies how multiple broadcasts
844 * belonging to the same delivery group has to be handled.
845 */
846 public @DeliveryGroupPolicy int getDeliveryGroupPolicy() {
847 return mDeliveryGroupPolicy;
848 }
849
850 /**
851 * Clears any previously set delivery group policies using
852 * {@link #setDeliveryGroupMatchingKey(String, String)} and resets the delivery group policy to
853 * the default value ({@link #DELIVERY_GROUP_POLICY_ALL}).
854 */
855 public void clearDeliveryGroupPolicy() {
856 mDeliveryGroupPolicy = DELIVERY_GROUP_POLICY_ALL;
857 }
858
859 /**
860 * Set namespace and key to identify the delivery group that this broadcast belongs to.
861 *
862 * <p> If {@code namespace} and {@code key} are specified, then another broadcast will be
863 * considered to be in the same delivery group as this iff it has the same {@code namespace}
864 * and {@code key}.
865 *
866 * <p> If neither matching key using this API nor matching filter using
867 * {@link #setDeliveryGroupMatchingFilter(IntentFilter)} is specified, then by default
868 * {@link Intent#filterEquals(Intent)} will be used to identify the delivery group.
869 */
870 @NonNull
871 public BroadcastOptions setDeliveryGroupMatchingKey(@NonNull String namespace,
872 @NonNull String key) {
873 mDeliveryGroupMatchingNamespaceFragment = Objects.requireNonNull(namespace);
874 mDeliveryGroupMatchingKeyFragment = Objects.requireNonNull(key);
875 return this;
876 }
877
878 /**
879 * Return the namespace and key that is used to identify the delivery group that this
880 * broadcast belongs to.
881 *
882 * @return the delivery group namespace and key that was previously set using
883 * {@link #setDeliveryGroupMatchingKey(String, String)}, concatenated with a {@code :}.
884 */
885 @Nullable
886 public String getDeliveryGroupMatchingKey() {
887 if (mDeliveryGroupMatchingNamespaceFragment == null
888 || mDeliveryGroupMatchingKeyFragment == null) {
889 return null;
890 }
891 return String.join(":", mDeliveryGroupMatchingNamespaceFragment,
892 mDeliveryGroupMatchingKeyFragment);
893 }
894
895 /**
896 * Return the namespace fragment that is used to identify the delivery group that this
897 * broadcast belongs to.
898 *
899 * @return the delivery group namespace fragment that was previously set using
900 * {@link #setDeliveryGroupMatchingKey(String, String)}.
901 * @hide
902 */
903 @Nullable
904 public String getDeliveryGroupMatchingNamespaceFragment() {
905 return mDeliveryGroupMatchingNamespaceFragment;
906 }
907
908 /**
909 * Return the key fragment that is used to identify the delivery group that this
910 * broadcast belongs to.
911 *
912 * @return the delivery group key fragment that was previously set using
913 * {@link #setDeliveryGroupMatchingKey(String, String)}.
914 * @hide
915 */
916 @Nullable
917 public String getDeliveryGroupMatchingKeyFragment() {
918 return mDeliveryGroupMatchingKeyFragment;
919 }
920
921 /**
922 * Clears the namespace and key that was previously set using
923 * {@link #setDeliveryGroupMatchingKey(String, String)}.
924 */
925 public void clearDeliveryGroupMatchingKey() {
926 mDeliveryGroupMatchingNamespaceFragment = null;
927 mDeliveryGroupMatchingKeyFragment = null;
928 }
929
930 /**
931 * Set the {@link IntentFilter} object to identify the delivery group that this broadcast
932 * belongs to.
933 *
934 * <p> If a {@code matchingFilter} is specified, then another broadcast will be considered
935 * to be in the same delivery group as this iff the {@code matchingFilter} matches it's intent.
936 *
937 * <p> If neither matching key using {@link #setDeliveryGroupMatchingKey(String, String)} nor
938 * matching filter using this API is specified, then by default
939 * {@link Intent#filterEquals(Intent)} will be used to identify the delivery group.
940 */
941 @NonNull
942 public BroadcastOptions setDeliveryGroupMatchingFilter(@NonNull IntentFilter matchingFilter) {
943 mDeliveryGroupMatchingFilter = Objects.requireNonNull(matchingFilter);
944 return this;
945 }
946
947 /**
948 * Return the {@link IntentFilter} object that is used to identify the delivery group
949 * that this broadcast belongs to.
950 *
951 * @return the {@link IntentFilter} object that was previously set using
952 * {@link #setDeliveryGroupMatchingFilter(IntentFilter)}.
953 */
954 @Nullable
955 public IntentFilter getDeliveryGroupMatchingFilter() {
956 return mDeliveryGroupMatchingFilter;
957 }
958
959 /**
960 * Clears the {@link IntentFilter} object that was previously set using
961 * {@link #setDeliveryGroupMatchingFilter(IntentFilter)}.
962 */
963 public void clearDeliveryGroupMatchingFilter() {
964 mDeliveryGroupMatchingFilter = null;
965 }
966
967 /**
968 * Set the {@link BundleMerger} that specifies how to merge the extras data from
969 * broadcasts in a delivery group.
970 *
971 * <p>Note that this value will be ignored if the delivery group policy is not set as
972 * {@link #DELIVERY_GROUP_POLICY_MERGED}.
973 *
974 * @hide
975 */
976 @NonNull
977 public BroadcastOptions setDeliveryGroupExtrasMerger(@NonNull BundleMerger extrasMerger) {
978 mDeliveryGroupExtrasMerger = Objects.requireNonNull(extrasMerger);
979 return this;
980 }
981
982 /**
983 * Return the {@link BundleMerger} that specifies how to merge the extras data from
984 * broadcasts in a delivery group.
985 *
986 * @return the {@link BundleMerger} object that was previously set using
987 * {@link #setDeliveryGroupExtrasMerger(BundleMerger)}.
988 * @hide
989 */
990 @Nullable
991 public BundleMerger getDeliveryGroupExtrasMerger() {
992 return mDeliveryGroupExtrasMerger;
993 }
994
995 /**
996 * Clear the {@link BundleMerger} object that was previously set using
997 * {@link #setDeliveryGroupExtrasMerger(BundleMerger)}.
998 * @hide
999 */
1000 public void clearDeliveryGroupExtrasMerger() {
1001 mDeliveryGroupExtrasMerger = null;
1002 }
1003
1004 /**
1005 * Sets whether the broadcast should be considered as having originated from
1006 * some direct interaction by the user such as a notification tap or button
1007 * press. This signal is used internally to ensure the broadcast is
1008 * delivered quickly with low latency.
1009 *
1010 * @hide
1011 */
1012 public @NonNull BroadcastOptions setInteractive(boolean interactive) {
1013 if (interactive) {
1014 mFlags |= FLAG_INTERACTIVE;
1015 } else {
1016 mFlags &= ~FLAG_INTERACTIVE;
1017 }
1018 return this;
1019 }
1020
1021 /**
1022 * Returns whether the broadcast should be considered as having originated
1023 * from some direct interaction by the user such as a notification tap or
1024 * button press.
1025 *
1026 * @hide
1027 */
1028 public boolean isInteractive() {
1029 return (mFlags & FLAG_INTERACTIVE) != 0;
1030 }
1031
1032 /**
1033 * Set PendingIntent activity is allowed to be started in the background if the caller
1034 * can start background activities.
1035 *
1036 * @deprecated use #setPendingIntentBackgroundActivityStartMode(int) to set the full range
1037 * of states
1038 * @hide
1039 */
1040 @SystemApi
1041 @Override
1042 @Deprecated public void setPendingIntentBackgroundActivityLaunchAllowed(boolean allowed) {
1043 super.setPendingIntentBackgroundActivityLaunchAllowed(allowed);
1044 }
1045
1046 /**
1047 * Get PendingIntent activity is allowed to be started in the background if the caller can start
1048 * background activities.
1049 *
1050 * @deprecated use {@link #getPendingIntentBackgroundActivityStartMode()} since for apps
1051 * targeting {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE} or higher this value might
1052 * not match the actual behavior if the value was not explicitly set.
1053 * @hide
1054 */
1055 @SystemApi
1056 @Override
1057 @Deprecated public boolean isPendingIntentBackgroundActivityLaunchAllowed() {
1058 return super.isPendingIntentBackgroundActivityLaunchAllowed();
1059 }
1060
1061
1062 /**
1063 * Sets the mode for allowing or denying the senders privileges to start background activities
1064 * to the PendingIntent.
1065 *
1066 * This is typically used when executing {@link PendingIntent#send(Bundle)} or similar
1067 * methods. A privileged sender of a PendingIntent should only grant
1068 * MODE_BACKGROUND_ACTIVITY_START_ALLOWED if the PendingIntent is from a trusted source and/or
1069 * executed on behalf the user.
1070 * @hide
1071 */
1072 @SystemApi
1073 @NonNull
1074 // @Override // to narrow down the return type
1075 public BroadcastOptions setPendingIntentBackgroundActivityStartMode(int state) {
1076 // super.setPendingIntentBackgroundActivityStartMode(state);
1077 return this;
1078 }
1079
1080 /**
1081 * Gets the mode for allowing or denying the senders privileges to start background activities
1082 * to the PendingIntent.
1083 *
1084 * @see #setPendingIntentBackgroundActivityStartMode(int)
1085 * @hide
1086 */
1087 @SystemApi
1088 // @Override // to narrow down the return type
1089 public int getPendingIntentBackgroundActivityStartMode() {
1090 return 0;
1091 // return super.getPendingIntentBackgroundActivityStartMode();
1092 }
1093
1094 /**
1095 * Returns the created options as a Bundle, which can be passed to
1096 * {@link android.content.Context#sendBroadcast(android.content.Intent)
1097 * Context.sendBroadcast(Intent)} and related methods.
1098 * Note that the returned Bundle is still owned by the BroadcastOptions
1099 * object; you must not modify it, but can supply it to the sendBroadcast
1100 * methods that take an options Bundle.
1101 *
1102 * @throws IllegalStateException if the broadcast option values are inconsistent. For example,
1103 * if the delivery group policy is specified as "MERGED" but no
1104 * extras merger is supplied.
1105 */
1106 @Override
1107 public @NonNull Bundle toBundle() {
1108 Bundle b = super.toBundle();
1109 if (mFlags != 0) {
1110 b.putInt(KEY_FLAGS, mFlags);
1111 }
1112 if (isTemporaryAppAllowlistSet()) {
1113 b.putLong(KEY_TEMPORARY_APP_ALLOWLIST_DURATION, mTemporaryAppAllowlistDuration);
1114 b.putInt(KEY_TEMPORARY_APP_ALLOWLIST_TYPE, mTemporaryAppAllowlistType);
1115 b.putInt(KEY_TEMPORARY_APP_ALLOWLIST_REASON_CODE, mTemporaryAppAllowlistReasonCode);
1116 b.putString(KEY_TEMPORARY_APP_ALLOWLIST_REASON, mTemporaryAppAllowlistReason);
1117 }
1118 if (mMinManifestReceiverApiLevel != 0) {
1119 b.putInt(KEY_MIN_MANIFEST_RECEIVER_API_LEVEL, mMinManifestReceiverApiLevel);
1120 }
1121 if (mMaxManifestReceiverApiLevel != Build.VERSION_CODES.CUR_DEVELOPMENT) {
1122 b.putInt(KEY_MAX_MANIFEST_RECEIVER_API_LEVEL, mMaxManifestReceiverApiLevel);
1123 }
1124 if (mRequireAllOfPermissions != null) {
1125 b.putStringArray(KEY_REQUIRE_ALL_OF_PERMISSIONS, mRequireAllOfPermissions);
1126 }
1127 if (mRequireNoneOfPermissions != null) {
1128 b.putStringArray(KEY_REQUIRE_NONE_OF_PERMISSIONS, mRequireNoneOfPermissions);
1129 }
1130 if (mRequireCompatChangeId != CHANGE_INVALID) {
1131 b.putLong(KEY_REQUIRE_COMPAT_CHANGE_ID, mRequireCompatChangeId);
1132 }
1133 if (mIdForResponseEvent != 0) {
1134 b.putLong(KEY_ID_FOR_RESPONSE_EVENT, mIdForResponseEvent);
1135 }
1136 if (mDeliveryGroupPolicy != DELIVERY_GROUP_POLICY_ALL) {
1137 b.putInt(KEY_DELIVERY_GROUP_POLICY, mDeliveryGroupPolicy);
1138 }
1139 if (mDeliveryGroupMatchingNamespaceFragment != null) {
1140 b.putString(KEY_DELIVERY_GROUP_NAMESPACE, mDeliveryGroupMatchingNamespaceFragment);
1141 }
1142 if (mDeliveryGroupMatchingKeyFragment != null) {
1143 b.putString(KEY_DELIVERY_GROUP_KEY, mDeliveryGroupMatchingKeyFragment);
1144 }
1145 if (mDeliveryGroupPolicy == DELIVERY_GROUP_POLICY_MERGED) {
1146 if (mDeliveryGroupExtrasMerger != null) {
1147 b.putParcelable(KEY_DELIVERY_GROUP_EXTRAS_MERGER,
1148 mDeliveryGroupExtrasMerger);
1149 } else {
1150 throw new IllegalStateException("Extras merger cannot be empty "
1151 + "when delivery group policy is 'MERGED'");
1152 }
1153 }
1154 if (mDeliveryGroupMatchingFilter != null) {
1155 b.putParcelable(KEY_DELIVERY_GROUP_MATCHING_FILTER, mDeliveryGroupMatchingFilter);
1156 }
1157 if (mDeferralPolicy != DEFERRAL_POLICY_DEFAULT) {
1158 b.putInt(KEY_DEFERRAL_POLICY, mDeferralPolicy);
1159 }
1160 return b;
1161 }
1162
1163 /**
1164 * Returns a {@link BroadcastOptions} parsed from the given {@link Bundle},
1165 * typically generated from {@link #toBundle()}.
1166 */
1167 public static @NonNull BroadcastOptions fromBundle(@NonNull Bundle options) {
1168 return new BroadcastOptions(options);
1169 }
1170
1171 /** {@hide} */
1172 public static @Nullable BroadcastOptions fromBundleNullable(@Nullable Bundle options) {
1173 return (options != null) ? new BroadcastOptions(options) : null;
1174 }
1175 }