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

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

Make sure we clear the calling identity when getting the broadcast

allowlist to ensure the permission check does not fail while reading
DeviceConfig

Tag: #feature
Bug: 188162221
Test: Manual
Change-Id: I7b717f7c990402da294d9aea6c809d4bd7ecacde
parent 4aac5329
Loading
Loading
Loading
Loading
+13 −7
Original line number Original line Diff line number Diff line
@@ -923,6 +923,9 @@ public final class Utils {
    }
    }


    public static @NonNull Bundle getTempAllowlistBroadcastOptions() {
    public static @NonNull Bundle getTempAllowlistBroadcastOptions() {
        // Use the Bluetooth process identity to pass permission check when reading DeviceConfig
        final long ident = Binder.clearCallingIdentity();
        try {
            final long durationMs = DeviceConfig.getLong(DeviceConfig.NAMESPACE_BLUETOOTH,
            final long durationMs = DeviceConfig.getLong(DeviceConfig.NAMESPACE_BLUETOOTH,
                    KEY_TEMP_ALLOW_LIST_DURATION_MS, DEFAULT_TEMP_ALLOW_LIST_DURATION_MS);
                    KEY_TEMP_ALLOW_LIST_DURATION_MS, DEFAULT_TEMP_ALLOW_LIST_DURATION_MS);
            final BroadcastOptions bOptions = BroadcastOptions.makeBasic();
            final BroadcastOptions bOptions = BroadcastOptions.makeBasic();
@@ -930,5 +933,8 @@ public final class Utils {
                    TEMPORARY_ALLOW_LIST_TYPE_FOREGROUND_SERVICE_ALLOWED,
                    TEMPORARY_ALLOW_LIST_TYPE_FOREGROUND_SERVICE_ALLOWED,
                    PowerExemptionManager.REASON_BLUETOOTH_BROADCAST, "");
                    PowerExemptionManager.REASON_BLUETOOTH_BROADCAST, "");
            return bOptions.toBundle();
            return bOptions.toBundle();
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
    }
    }
}
}