Skip to content

Commit 637eb49

Browse files
authored
Merge pull request #655 from jsimonassi/master
Adding new Android 12 bluetooth permissions
2 parents 87d7ec8 + 43502dc commit 637eb49

File tree

15 files changed

+793
-566
lines changed

15 files changed

+793
-566
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ build/
2828
.gradle
2929
local.properties
3030
*.iml
31+
*.hprof
3132

3233
# Visual Studio Code
3334
#

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ Add all wanted permissions to your app `android/app/src/main/AndroidManifest.xml
162162
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
163163
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
164164
<uses-permission android:name="android.permission.ANSWER_PHONE_CALLS" />
165+
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
166+
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
167+
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
165168
<uses-permission android:name="android.permission.BODY_SENSORS" />
166169
<uses-permission android:name="android.permission.CALL_PHONE" />
167170
<uses-permission android:name="android.permission.CAMERA" />
@@ -466,6 +469,10 @@ PERMISSIONS.ANDROID.WRITE_CALENDAR;
466469
PERMISSIONS.ANDROID.WRITE_CALL_LOG;
467470
PERMISSIONS.ANDROID.WRITE_CONTACTS;
468471
PERMISSIONS.ANDROID.WRITE_EXTERNAL_STORAGE;
472+
PERMISSIONS.ANDROID.BLUETOOTH_CONNECT;
473+
PERMISSIONS.ANDROID.BLUETOOTH_SCAN;
474+
PERMISSIONS.ANDROID.BLUETOOTH_ADVERTISE;
475+
469476
```
470477

471478
</details>

android/src/main/java/com/zoontek/rnpermissions/RNPermissionsModule.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ public Request(boolean[] rationaleStatuses, Callback callback) {
127127
return "WRITE_CONTACTS";
128128
if (permission.equals("android.permission.WRITE_EXTERNAL_STORAGE"))
129129
return "WRITE_EXTERNAL_STORAGE";
130+
if (permission.equals("android.permission.BLUETOOTH_CONNECT"))
131+
return "BLUETOOTH_CONNECT";
132+
if (permission.equals("android.permission.BLUETOOTH_SCAN"))
133+
return "BLUETOOTH_SCAN";
134+
if (permission.equals("android.permission.BLUETOOTH_ADVERTISE"))
135+
return "BLUETOOTH_ADVERTISE";
130136

131137
return null;
132138
}

example/android/app/build.gradle

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,16 @@ def jscFlavor = 'org.webkit:android-jsc:+'
120120
*/
121121
def enableHermes = project.ext.react.get("enableHermes", false);
122122

123+
/**
124+
* Architectures to build native code for in debug.
125+
*/
126+
def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")
127+
123128
android {
124129
ndkVersion rootProject.ext.ndkVersion
125130

126131
compileSdkVersion rootProject.ext.compileSdkVersion
127132

128-
compileOptions {
129-
sourceCompatibility JavaVersion.VERSION_1_8
130-
targetCompatibility JavaVersion.VERSION_1_8
131-
}
132-
133133
defaultConfig {
134134
applicationId "com.rnpermissionsexample"
135135
minSdkVersion rootProject.ext.minSdkVersion
@@ -156,6 +156,11 @@ android {
156156
buildTypes {
157157
debug {
158158
signingConfig signingConfigs.debug
159+
if (nativeArchitectures) {
160+
ndk {
161+
abiFilters nativeArchitectures.split(',')
162+
}
163+
}
159164
}
160165
release {
161166
// Caution! In production, you need to generate your own keystore file.
@@ -198,7 +203,7 @@ dependencies {
198203
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
199204

200205
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
201-
exclude group:'com.facebook.fbjni'
206+
exclude group:'com.facebook.fbjni'
202207
}
203208

204209
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
@@ -221,7 +226,7 @@ dependencies {
221226
// Run this once to be able to run the application with BUCK
222227
// puts all compile dependencies into folder libs for BUCK to use
223228
task copyDownloadableDepsToLibs(type: Copy) {
224-
from configurations.compile
229+
from configurations.implementation
225230
into 'libs'
226231
}
227232

example/android/app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
<uses-permission android:name="android.permission.WRITE_CALL_LOG" />
3333
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
3434
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
35+
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
36+
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
37+
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
3538

3639
<application
3740
android:name=".MainApplication"
@@ -45,7 +48,8 @@
4548
android:label="@string/app_name"
4649
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
4750
android:launchMode="singleTask"
48-
android:windowSoftInputMode="adjustResize">
51+
android:windowSoftInputMode="adjustResize"
52+
android:exported="true">
4953
<intent-filter>
5054
<action android:name="android.intent.action.MAIN" />
5155
<category android:name="android.intent.category.LAUNCHER" />

example/android/app/src/main/res/values/styles.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<!-- Base application theme. -->
44
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
55
<!-- Customize your theme here. -->
6-
<item name="android:textColor">#000000</item>
6+
77
</style>
88

99
</resources>

example/android/build.gradle

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
buildscript {
44
ext {
5-
buildToolsVersion = "29.0.3"
5+
buildToolsVersion = "31.0.0"
66
minSdkVersion = 21
7-
compileSdkVersion = 29
8-
targetSdkVersion = 29
9-
ndkVersion = "20.1.5948944"
7+
compileSdkVersion = 31
8+
targetSdkVersion = 31
9+
ndkVersion = "23.0.7599858"
1010
}
1111
repositories {
1212
mavenCentral()
1313
google()
1414
}
1515
dependencies {
16-
classpath("com.android.tools.build:gradle:4.1.0")
16+
classpath("com.android.tools.build:gradle:4.2.2")
1717

1818
// NOTE: Do not place your application dependencies here; they belong
1919
// in the individual module build.gradle files
@@ -23,7 +23,6 @@ buildscript {
2323
allprojects {
2424
repositories {
2525
mavenLocal()
26-
jcenter()
2726
mavenCentral()
2827
maven {
2928
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm

example/android/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ android.useAndroidX=true
2525
android.enableJetifier=true
2626

2727
# Version of flipper SDK to use with React Native
28-
FLIPPER_VERSION=0.75.1
28+
FLIPPER_VERSION=0.99.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

example/ios/Podfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require_relative '../node_modules/react-native/scripts/react_native_pods'
22
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
33

4-
platform :ios, '10.0'
4+
platform :ios, '11.0'
55

66
# use_frameworks!
77

@@ -57,7 +57,8 @@ target 'RNPermissionsExample' do
5757
# you should disable the next line.
5858
# use_flipper!()
5959

60-
# post_install do |installer|
61-
# react_native_post_install(installer)
62-
# end
60+
post_install do |installer|
61+
react_native_post_install(installer)
62+
__apply_Xcode_12_5_M1_post_install_workaround(installer)
63+
end
6364
end

0 commit comments

Comments
 (0)