Skip to content

Commit dbf5318

Browse files
authored
Fixed permission related issues for the SDK. (#183)
1 parent bad7206 commit dbf5318

File tree

7 files changed

+25
-15
lines changed

7 files changed

+25
-15
lines changed

android/code-samples/ARBlackPanther/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ dependencies {
3939
testImplementation 'junit:junit:4.13.2'
4040
api project(':code-samples:gvr_common')
4141
api project(':code-samples:arcore_client')
42-
aarImplementation('com.github.ViroCommunity.virocore:virocore:rc-1.20.2') {
42+
aarImplementation(project(path: ':virocore')) {
4343
transitive = false
4444
}
4545
codeImplementation (project(path: ':virocore')) {

android/code-samples/ARHelloWorldAndroid/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ dependencies {
4343
testImplementation 'junit:junit:4.13.2'
4444
api project(':code-samples:gvr_common')
4545
api project(':code-samples:arcore_client')
46-
aarImplementation('com.github.ViroCommunity.virocore:virocore:rc-1.20.2') {
46+
aarImplementation(project(path: ':virocore')) {
4747
transitive = false
4848
}
4949
codeImplementation (project(path: ':virocore')) {

android/code-samples/ARPlacingObjects/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ dependencies {
5151
testImplementation 'junit:junit:4.13.2'
5252
api project(':code-samples:gvr_common')
5353
api project(':code-samples:arcore_client')
54-
aarImplementation('com.github.ViroCommunity.virocore:virocore:rc-1.20.2') {
54+
aarImplementation(project(path: ':virocore')) {
5555
transitive = false
5656
}
5757
codeImplementation (project(path: ':virocore')) {
5858
transitive = false
5959
}
6060
implementation 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-7'
61-
implementation "androidx.core:core-ktx:1.8.0"
62-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.21"
61+
implementation "androidx.core:core-ktx:1.10.1"
62+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.0"
6363
}

android/code-samples/ARRetail/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ dependencies {
3939
testImplementation 'junit:junit:4.13.2'
4040
api project(':code-samples:gvr_common')
4141
api project(':code-samples:arcore_client')
42-
aarImplementation('com.github.ViroCommunity.virocore:virocore:rc-1.20.2') {
42+
aarImplementation(project(path: ':virocore')) {
4343
transitive = false
4444
}
45-
codeImplementation (project(path: ':virocore')) {
45+
codeImplementation(project(path: ':virocore')) {
4646
transitive = false
4747
}
4848
implementation 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-7'

android/code-samples/ARTesla/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ dependencies {
3838
testImplementation 'junit:junit:4.13.2'
3939
api project(':code-samples:gvr_common')
4040
api project(':code-samples:arcore_client')
41-
aarImplementation('com.github.ViroCommunity.virocore:virocore:rc-1.20.2') {
41+
aarImplementation(project(path: ':virocore')) {
4242
transitive = false
4343
}
4444
// api to be able to use BuildConfig in SystemInfoFragment

android/sharedCode/src/main/AndroidManifest.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
99
<uses-permission android:name="android.permission.VIBRATE"/>
1010
<!-- Required to read the paired viewer's distortion parameters. -->
11-
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
11+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
12+
android:maxSdkVersion="32" />
1213
<!-- Required for Recording -->
1314
<uses-permission android:name="android.permission.RECORD_AUDIO" />
1415

@@ -26,4 +27,4 @@
2627
<!-- Indicates use of VR features that are available only on Daydream-ready devices. -->
2728
<uses-feature android:name="android.hardware.vr.high_performance" android:required="false"/>
2829

29-
</manifest>
30+
</manifest>

android/sharedCode/src/main/java/com/viro/core/ViroMediaRecorder.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@
3333
import android.net.Uri;
3434
import android.opengl.GLES20;
3535
import android.os.AsyncTask;
36+
import android.os.Build;
3637
import android.os.Environment;
3738
import android.os.Handler;
3839
import android.os.Looper;
3940
import androidx.core.content.ContextCompat;
41+
42+
import android.system.Os;
4043
import android.util.Log;
4144

4245
import com.viro.core.internal.MediaRecorderSurface;
@@ -292,14 +295,21 @@ private void deleteNativeRecorder(){
292295
private static boolean hasAudioAndRecordingPermissions(Context context) {
293296
boolean hasRecordPermissions = ContextCompat.checkSelfPermission(context,
294297
Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED;
295-
boolean hasExternalStoragePerm = ContextCompat.checkSelfPermission(context,
296-
Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
298+
boolean hasExternalStoragePerm = true;
299+
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
300+
hasExternalStoragePerm = ContextCompat.checkSelfPermission(context,
301+
Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
302+
}
297303
return hasRecordPermissions && hasExternalStoragePerm;
298304
}
299305

300306
private static boolean hasRecordingPermissions(Context context) {
301-
return ContextCompat.checkSelfPermission(context,
302-
Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
307+
boolean hasExternalStoragePerm = true;
308+
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
309+
hasExternalStoragePerm = ContextCompat.checkSelfPermission(context,
310+
Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
311+
}
312+
return hasExternalStoragePerm;
303313
}
304314

305315
/**
@@ -876,4 +886,3 @@ public void onNativeTakeScreenshot() {
876886
private native void nativeEnableFrameRecording(long nativeRecorderRef, boolean enabled);
877887
private native void nativeScheduleScreenCapture(long nativeRecorderRef);
878888
}
879-

0 commit comments

Comments
 (0)