Skip to content

Commit 611c08a

Browse files
committed
[Android]1.update android sdk to 31;2.fix bluetooth permission leak problem
1 parent 5ba9a50 commit 611c08a

4 files changed

Lines changed: 24 additions & 8 deletions

File tree

Android/APIExample/agora-simple-filter/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 29
5-
buildToolsVersion "29.0.3"
4+
compileSdkVersion 31
5+
buildToolsVersion "31.0.0"
66

77
defaultConfig {
88
minSdkVersion 16
9-
targetSdkVersion 29
9+
targetSdkVersion 31
1010
versionCode 1
1111
versionName "1.0"
1212

@@ -37,7 +37,7 @@ android {
3737
}
3838
}
3939

40-
ndkVersion '21.0.6113669'
40+
ndkVersion '21.4.7075529'
4141
}
4242

4343
dependencies {

Android/APIExample/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ apply plugin: 'com.android.application'
22
apply plugin: "androidx.navigation.safeargs"
33

44
android {
5-
compileSdkVersion 29
6-
buildToolsVersion "29.0.2"
5+
compileSdkVersion 31
6+
buildToolsVersion "31.0.0"
77

88
defaultConfig {
99
applicationId "io.agora.api.example"

Android/APIExample/app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
<uses-permission android:name="android.permission.RECORD_AUDIO" />
1010
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
1111
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
12+
<uses-permission android:name="android.permission.BLUETOOTH"/>
13+
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
14+
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
15+
16+
<permission-group android:name="io.agora.api.example.andpermission"/>
1217

1318
<application
1419
android:name=".MainApplication"
@@ -24,7 +29,8 @@
2429
android:name=".MainActivity"
2530
android:configChanges="keyboardHidden|screenSize|orientation"
2631
android:label="@string/app_name"
27-
android:screenOrientation="portrait">
32+
android:screenOrientation="portrait"
33+
android:exported="true">
2834
<intent-filter>
2935
<action android:name="android.intent.action.MAIN" />
3036

Android/APIExample/app/src/main/java/io/agora/api/example/examples/basic/JoinChannelVideo.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import static io.agora.rtc2.Constants.RENDER_MODE_HIDDEN;
55
import static io.agora.rtc2.video.VideoEncoderConfiguration.STANDARD_BITRATE;
66

7+
import android.Manifest;
78
import android.content.Context;
9+
import android.os.Build;
810
import android.os.Bundle;
911
import android.text.TextUtils;
1012
import android.util.Log;
@@ -149,13 +151,21 @@ public void onClick(View v)
149151
// call when join button hit
150152
String channelId = et_channel.getText().toString();
151153
// Check permission
152-
if (AndPermission.hasPermissions(this, Permission.Group.STORAGE, Permission.Group.MICROPHONE, Permission.Group.CAMERA))
154+
String[] BLUETOOTH_PERMS = new String[0];
155+
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.S){
156+
BLUETOOTH_PERMS = new String[]{Manifest.permission.BLUETOOTH_CONNECT};
157+
}
158+
159+
if (AndPermission.hasPermissions(this,
160+
BLUETOOTH_PERMS,
161+
Permission.Group.STORAGE, Permission.Group.MICROPHONE, Permission.Group.CAMERA))
153162
{
154163
joinChannel(channelId);
155164
return;
156165
}
157166
// Request permission
158167
AndPermission.with(this).runtime().permission(
168+
BLUETOOTH_PERMS,
159169
Permission.Group.STORAGE,
160170
Permission.Group.MICROPHONE,
161171
Permission.Group.CAMERA

0 commit comments

Comments
 (0)