Skip to content

Commit

Permalink
Merge pull request #247 from adamfowleruk/feature-227
Browse files Browse the repository at this point in the history
Completed all required issues in v2.1.0 milestone
  • Loading branch information
adamfowleruk authored Jan 14, 2023
2 parents 1eff8c5 + 25469fd commit 531c004
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
11 changes: 8 additions & 3 deletions app/src/main/java/io/heraldprox/herald/app/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,23 +215,28 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
private void requestPermissions() {
// Check and request permissions
final List<String> requiredPermissions = new ArrayList<>();

// The next two ARE ***BOTH*** STILL NEEDED for Android 12 in order for didMeasure and didRead to work!
requiredPermissions.add(Manifest.permission.ACCESS_COARSE_LOCATION);
requiredPermissions.add(Manifest.permission.ACCESS_FINE_LOCATION);
// WARNING: On android 12, the user MUST select 'Precise' too (not 'Approximate') in the UI

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
requiredPermissions.add(Manifest.permission.FOREGROUND_SERVICE);
}
requiredPermissions.add(Manifest.permission.WAKE_LOCK);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
// Required since Android 12 (SDK 31)
requiredPermissions.add(Manifest.permission.BLUETOOTH_CONNECT);
// The following is only needed if this device advertises (i.e. uses BLETransmitter) (the demo app does)
requiredPermissions.add(Manifest.permission.BLUETOOTH_SCAN);
// The following is only needed if this device scans (i.e. uses BLEReceiver) (the demo app does)
requiredPermissions.add(Manifest.permission.BLUETOOTH_CONNECT);
requiredPermissions.add(Manifest.permission.BLUETOOTH_ADVERTISE);
} else {
// Legacy permissions
// See https://developer.android.com/guide/topics/connectivity/bluetooth/permissions
requiredPermissions.add(Manifest.permission.BLUETOOTH);
requiredPermissions.add(Manifest.permission.BLUETOOTH_ADMIN);
}
requiredPermissions.add(Manifest.permission.WAKE_LOCK);
final String[] requiredPermissionsArray = requiredPermissions.toArray(new String[0]);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(requiredPermissionsArray, permissionRequestCode);
Expand Down
12 changes: 6 additions & 6 deletions herald/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true" />

<!-- Permissions for Bluetooth LE as background process -->
<!-- Android 12+ -->
<!-- Android 12+ Only -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> <!-- for v2.1 pairing with wearables -->
<!-- Pre Android 12 -->
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- Not needed on Android 12+ -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- Not needed on Android 12+ -->
<!-- Android 12 and earlier -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- THIS IS STILL needed on Android 12+ -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- THIS IS STILL needed on Android 12+ -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

Expand Down

0 comments on commit 531c004

Please sign in to comment.