Only add boolean extra to bundle when the value is false

As the default value is false, we don't need to put it in bundle if the value is false.

Bug: 234070143
Test: atest android.app.cts.BroadcastOptionsTest#testTemporaryAppAllowlistBroadcastOptions_defaultValues
Change-Id: Ia23d2a03f8c3c64d25b47ed9a8d02ae22ce9246b
This commit is contained in:
Ricky Wai
2022-05-27 14:21:23 +00:00
parent b67a965f22
commit 57c032bf43

View File

@@ -99,8 +99,10 @@ public class ComponentOptions {
public Bundle toBundle() {
Bundle b = new Bundle();
b.putBoolean(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED, mPendingIntentBalAllowed);
b.putBoolean(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED_BY_PERMISSION,
mPendingIntentBalAllowedByPermission);
if (mPendingIntentBalAllowedByPermission) {
b.putBoolean(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED_BY_PERMISSION,
mPendingIntentBalAllowedByPermission);
}
return b;
}
}