From dbf5318392ea28a3d57b06eab56ca0ae02a0c5f5 Mon Sep 17 00:00:00 2001 From: Darshan Panchal <13926954+darshanio@users.noreply.github.com> Date: Fri, 30 Aug 2024 11:33:30 +0530 Subject: [PATCH] Fixed permission related issues for the SDK. (#183) --- .../code-samples/ARBlackPanther/build.gradle | 2 +- .../ARHelloWorldAndroid/build.gradle | 2 +- .../ARPlacingObjects/build.gradle | 6 +++--- android/code-samples/ARRetail/build.gradle | 4 ++-- android/code-samples/ARTesla/build.gradle | 2 +- .../sharedCode/src/main/AndroidManifest.xml | 5 +++-- .../java/com/viro/core/ViroMediaRecorder.java | 19 ++++++++++++++----- 7 files changed, 25 insertions(+), 15 deletions(-) diff --git a/android/code-samples/ARBlackPanther/build.gradle b/android/code-samples/ARBlackPanther/build.gradle index 0600cf8d1..f1f46ec57 100644 --- a/android/code-samples/ARBlackPanther/build.gradle +++ b/android/code-samples/ARBlackPanther/build.gradle @@ -39,7 +39,7 @@ dependencies { testImplementation 'junit:junit:4.13.2' api project(':code-samples:gvr_common') api project(':code-samples:arcore_client') - aarImplementation('com.github.ViroCommunity.virocore:virocore:rc-1.20.2') { + aarImplementation(project(path: ':virocore')) { transitive = false } codeImplementation (project(path: ':virocore')) { diff --git a/android/code-samples/ARHelloWorldAndroid/build.gradle b/android/code-samples/ARHelloWorldAndroid/build.gradle index 045145934..35c82fa0a 100644 --- a/android/code-samples/ARHelloWorldAndroid/build.gradle +++ b/android/code-samples/ARHelloWorldAndroid/build.gradle @@ -43,7 +43,7 @@ dependencies { testImplementation 'junit:junit:4.13.2' api project(':code-samples:gvr_common') api project(':code-samples:arcore_client') - aarImplementation('com.github.ViroCommunity.virocore:virocore:rc-1.20.2') { + aarImplementation(project(path: ':virocore')) { transitive = false } codeImplementation (project(path: ':virocore')) { diff --git a/android/code-samples/ARPlacingObjects/build.gradle b/android/code-samples/ARPlacingObjects/build.gradle index fa77ca01b..4e3143195 100644 --- a/android/code-samples/ARPlacingObjects/build.gradle +++ b/android/code-samples/ARPlacingObjects/build.gradle @@ -51,13 +51,13 @@ dependencies { testImplementation 'junit:junit:4.13.2' api project(':code-samples:gvr_common') api project(':code-samples:arcore_client') - aarImplementation('com.github.ViroCommunity.virocore:virocore:rc-1.20.2') { + aarImplementation(project(path: ':virocore')) { transitive = false } codeImplementation (project(path: ':virocore')) { transitive = false } implementation 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-7' - implementation "androidx.core:core-ktx:1.8.0" - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.21" + implementation "androidx.core:core-ktx:1.10.1" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.0" } diff --git a/android/code-samples/ARRetail/build.gradle b/android/code-samples/ARRetail/build.gradle index 588d9bfc8..fc046d7fc 100644 --- a/android/code-samples/ARRetail/build.gradle +++ b/android/code-samples/ARRetail/build.gradle @@ -39,10 +39,10 @@ dependencies { testImplementation 'junit:junit:4.13.2' api project(':code-samples:gvr_common') api project(':code-samples:arcore_client') - aarImplementation('com.github.ViroCommunity.virocore:virocore:rc-1.20.2') { + aarImplementation(project(path: ':virocore')) { transitive = false } - codeImplementation (project(path: ':virocore')) { + codeImplementation(project(path: ':virocore')) { transitive = false } implementation 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-7' diff --git a/android/code-samples/ARTesla/build.gradle b/android/code-samples/ARTesla/build.gradle index 718285dd1..6a4ac1bb3 100644 --- a/android/code-samples/ARTesla/build.gradle +++ b/android/code-samples/ARTesla/build.gradle @@ -38,7 +38,7 @@ dependencies { testImplementation 'junit:junit:4.13.2' api project(':code-samples:gvr_common') api project(':code-samples:arcore_client') - aarImplementation('com.github.ViroCommunity.virocore:virocore:rc-1.20.2') { + aarImplementation(project(path: ':virocore')) { transitive = false } // api to be able to use BuildConfig in SystemInfoFragment diff --git a/android/sharedCode/src/main/AndroidManifest.xml b/android/sharedCode/src/main/AndroidManifest.xml index a9c9230ef..45a54c424 100644 --- a/android/sharedCode/src/main/AndroidManifest.xml +++ b/android/sharedCode/src/main/AndroidManifest.xml @@ -8,7 +8,8 @@ - + @@ -26,4 +27,4 @@ - \ No newline at end of file + diff --git a/android/sharedCode/src/main/java/com/viro/core/ViroMediaRecorder.java b/android/sharedCode/src/main/java/com/viro/core/ViroMediaRecorder.java index 77dc03fe6..fa2498eaf 100644 --- a/android/sharedCode/src/main/java/com/viro/core/ViroMediaRecorder.java +++ b/android/sharedCode/src/main/java/com/viro/core/ViroMediaRecorder.java @@ -33,10 +33,13 @@ import android.net.Uri; import android.opengl.GLES20; import android.os.AsyncTask; +import android.os.Build; import android.os.Environment; import android.os.Handler; import android.os.Looper; import androidx.core.content.ContextCompat; + +import android.system.Os; import android.util.Log; import com.viro.core.internal.MediaRecorderSurface; @@ -292,14 +295,21 @@ private void deleteNativeRecorder(){ private static boolean hasAudioAndRecordingPermissions(Context context) { boolean hasRecordPermissions = ContextCompat.checkSelfPermission(context, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED; - boolean hasExternalStoragePerm = ContextCompat.checkSelfPermission(context, - Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED; + boolean hasExternalStoragePerm = true; + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) { + hasExternalStoragePerm = ContextCompat.checkSelfPermission(context, + Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED; + } return hasRecordPermissions && hasExternalStoragePerm; } private static boolean hasRecordingPermissions(Context context) { - return ContextCompat.checkSelfPermission(context, - Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED; + boolean hasExternalStoragePerm = true; + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) { + hasExternalStoragePerm = ContextCompat.checkSelfPermission(context, + Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED; + } + return hasExternalStoragePerm; } /** @@ -876,4 +886,3 @@ public void onNativeTakeScreenshot() { private native void nativeEnableFrameRecording(long nativeRecorderRef, boolean enabled); private native void nativeScheduleScreenCapture(long nativeRecorderRef); } -