Skip to content

Commit

Permalink
fixes issue #10
Browse files Browse the repository at this point in the history
- Moved permissions out of libs manifest file
- documented the info in readme
  • Loading branch information
nisrulz committed Oct 20, 2023
1 parent 8cb6c3d commit 98e4ca3
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 34 deletions.
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ BLESSED is a very compact Bluetooth Low Energy (BLE) library for Android 8 and h

## Installation

This library is available on Jitpack. Include the following in your gradle file:
This library is available on Jitpack. Include the following in your projects's build.gradle file:

```groovy
allprojects {
Expand All @@ -17,12 +17,42 @@ allprojects {
maven { url 'https://jitpack.io' }
}
}
```

Include the following in your app's build.gradle file under `dependencies` block:

```groovy
dependencies {
...
implementation "com.github.weliem:blessed-android-coroutines:$version"
}
```
where `$version` is the latest published version in Jitpack [![](https://jitpack.io/v/weliem/blessed-android-coroutines.svg)](https://jitpack.io/#weliem/blessed-android-coroutines)

where `$version` is the latest published version in Jitpack [![Jitpack](https://jitpack.io/v/weliem/blessed-android-coroutines.svg)](https://jitpack.io/#weliem/blessed-android-coroutines)

### Adding permissions

If you plan on supporting older devices that are on Android 11 and below, then you need to add the below permissions to your AndroidManifest.xml file:

```xml
<!-- Needed to target Android 11 and lower -->
<!-- Link: https://developer.android.com/guide/topics/connectivity/bluetooth/permissions#declare-android11-or-lower-->
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"
android:maxSdkVersion="30" />
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"
android:maxSdkVersion="30" />

<!-- Link: https://developer.android.com/guide/topics/connectivity/bluetooth/permissions -->
<!-- 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" />
```

## Overview of classes

Expand Down
23 changes: 22 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,35 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.welie.blessedexample">


<!-- Needed to target Android 11 and lower -->
<!-- Link:
https://developer.android.com/guide/topics/connectivity/bluetooth/permissions#declare-android11-or-lower-->
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"
android:maxSdkVersion="30" />
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"
android:maxSdkVersion="30" />

<!-- Link: https://developer.android.com/guide/topics/connectivity/bluetooth/permissions -->
<!-- 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" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity"
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
45 changes: 14 additions & 31 deletions blessed/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,42 +1,25 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.welie.blessed">
xmlns:tools="http://schemas.android.com/tools"
package="com.welie.blessed">

<!-- Link: https://developer.android.com/guide/topics/connectivity/bluetooth/permissions -->
<!-- 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 code looks for Bluetooth devices.
<!-- Needed only if code looks for Bluetooth devices.
Since the code doesn't use Bluetooth scan results to derive physical
location information, it is strongly asserted that the code
doesn't derive physical location.
Link: https://developer.android.com/guide/topics/connectivity/bluetooth/permissions#assert-never-for-location
Link:
https://developer.android.com/guide/topics/connectivity/bluetooth/permissions#assert-never-for-location
-->
<uses-permission
android:name="android.permission.BLUETOOTH_SCAN"
android:usesPermissionFlags="neverForLocation"
tools:targetApi="s" />
<uses-permission
android:name="android.permission.BLUETOOTH_SCAN"
android:usesPermissionFlags="neverForLocation"
tools:targetApi="s" />

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

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

<!-- Needed to target Android 11 and lower -->
<!-- Link: https://developer.android.com/guide/topics/connectivity/bluetooth/permissions#declare-android11-or-lower-->
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"
android:maxSdkVersion="30" />
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"
android:maxSdkVersion="30" />

<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
</manifest>

0 comments on commit 98e4ca3

Please sign in to comment.