Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f56a92a3 authored by Rahul Sabnis's avatar Rahul Sabnis
Browse files

Minor fix to ensure we don't return before restoring the calling

identity in Utils#getTempAllowlistBroadcastOptions

Tag: #feature
Bug: 188162221
Test: Manual
Change-Id: I38f557ef16e47a66b288abbb113a315fc741459e
parent 571cc979
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -925,16 +925,16 @@ public final class Utils {
    public static @NonNull Bundle getTempAllowlistBroadcastOptions() {
        // Use the Bluetooth process identity to pass permission check when reading DeviceConfig
        final long ident = Binder.clearCallingIdentity();
        final BroadcastOptions bOptions = BroadcastOptions.makeBasic();
        try {
            final long durationMs = DeviceConfig.getLong(DeviceConfig.NAMESPACE_BLUETOOTH,
                    KEY_TEMP_ALLOW_LIST_DURATION_MS, DEFAULT_TEMP_ALLOW_LIST_DURATION_MS);
            final BroadcastOptions bOptions = BroadcastOptions.makeBasic();
            bOptions.setTemporaryAppAllowlist(durationMs,
                    TEMPORARY_ALLOW_LIST_TYPE_FOREGROUND_SERVICE_ALLOWED,
                    PowerExemptionManager.REASON_BLUETOOTH_BROADCAST, "");
            return bOptions.toBundle();
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
        return bOptions.toBundle();
    }
}