expo / config-plugins

Out-of-tree Expo config plugins for packages that haven't adopted the config plugin system yet.
427 stars 91 forks source link

fix(react-native-ble-plx) - Adjusted Android permissions #188

Closed leoafarias closed 5 months ago

leoafarias commented 10 months ago

Why

Android permissions do not follow official Android Bluetooth Permissions docs and react-native-ble-plx. Also, it should allow more granular control over which permissions are added based on the BLE usage. Issue #149 goes over some of the permissions' challenges and inconsistencies.

How

On a very high level, the permissions now follow this sample manifest and closely follows settings based on the comments.

<manifest>
    <!-- Request legacy Bluetooth permissions on older devices. -->
    <uses-permission android:name="android.permission.BLUETOOTH"
                     android:maxSdkVersion="30" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
                     android:maxSdkVersion="30" />

    <!-- Needed only if your app looks for Bluetooth devices.
         If your app doesn't use Bluetooth scan results to derive physical
         location information, you can strongly assert that your app
         doesn't derive physical location. -->
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />

    <!-- Needed only if your app makes the device discoverable to Bluetooth
         devices. -->
    <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />

    <!-- Needed only if your app communicates with already-paired Bluetooth
         devices. -->
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

    <!-- Needed only if your app uses Bluetooth scan results to derive physical location. -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    ...
</manifest>

Options have been renamed and changed, and I implemented some warnings about this, which I have updated on the readme.

Here are the following options and an overview of what they are doing.

Android options

The user most likely will have to do a npx expo prebuild --clean

Test Plan

I have implemented test for all the changes. But it would not hurt to do a quick spot check.

leoafarias commented 5 months ago

I am closing as there is no review, and I believe there is now an expo plugin as part of the package itself.