From 4646e34df83272607326894f5e225b03cac91a6d Mon Sep 17 00:00:00 2001 From: bang9 Date: Tue, 29 Oct 2024 10:22:57 +0900 Subject: [PATCH] fix: remove non-required permissions from android --- packages/uikit-react-native/README.md | 9 +++++---- .../src/platform/createFileService.native.ts | 8 ++------ .../src/platform/createPlayerService.native.tsx | 9 +++++---- sample/android/app/src/main/AndroidManifest.xml | 14 ++++++-------- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/packages/uikit-react-native/README.md b/packages/uikit-react-native/README.md index 89c790ae7..730cd8ad2 100644 --- a/packages/uikit-react-native/README.md +++ b/packages/uikit-react-native/README.md @@ -76,14 +76,15 @@ Add the following permissions to your `android/app/src/main/AndroidManifest.xml` - + + + + + - - - ``` diff --git a/packages/uikit-react-native/src/platform/createFileService.native.ts b/packages/uikit-react-native/src/platform/createFileService.native.ts index 9d3f9b326..8c6afec15 100644 --- a/packages/uikit-react-native/src/platform/createFileService.native.ts +++ b/packages/uikit-react-native/src/platform/createFileService.native.ts @@ -31,11 +31,7 @@ function getAndroidStoragePermissionsByAPILevel(permissionModule: typeof Permiss if (Platform.OS !== 'android') return []; if (Platform.Version > 32) { - return [ - permissionModule.PERMISSIONS.ANDROID.READ_MEDIA_AUDIO, - permissionModule.PERMISSIONS.ANDROID.READ_MEDIA_IMAGES, - permissionModule.PERMISSIONS.ANDROID.READ_MEDIA_VIDEO, - ]; + return []; } if (Platform.Version > 28) { @@ -63,7 +59,7 @@ const createNativeFileService = ({ }): FileServiceInterface => { const cameraPermissions: Permission[] = Platform.select({ ios: [permissionModule.PERMISSIONS.IOS.CAMERA, permissionModule.PERMISSIONS.IOS.MICROPHONE], - android: [permissionModule.PERMISSIONS.ANDROID.CAMERA], + android: [], default: [], }); const mediaLibraryPermissions: Permission[] = Platform.select({ diff --git a/packages/uikit-react-native/src/platform/createPlayerService.native.tsx b/packages/uikit-react-native/src/platform/createPlayerService.native.tsx index c567136cc..59b7ab45b 100644 --- a/packages/uikit-react-native/src/platform/createPlayerService.native.tsx +++ b/packages/uikit-react-native/src/platform/createPlayerService.native.tsx @@ -58,14 +58,15 @@ const createNativePlayerService = ({ audioRecorderModule, permissionModule }: Mo public requestPermission = async (): Promise => { if (Platform.OS === 'android') { - const { READ_MEDIA_AUDIO, READ_EXTERNAL_STORAGE } = permissionModule.PERMISSIONS.ANDROID; - const permission = Platform.Version > 32 ? READ_MEDIA_AUDIO : READ_EXTERNAL_STORAGE; + if (Platform.Version > 32) return true; - const status = await permissionModule.check(permission); + const { READ_EXTERNAL_STORAGE } = permissionModule.PERMISSIONS.ANDROID; + + const status = await permissionModule.check(READ_EXTERNAL_STORAGE); if (status === 'granted') { return true; } else { - const status = await permissionModule.request(permission); + const status = await permissionModule.request(READ_EXTERNAL_STORAGE); return status === 'granted'; } } else { diff --git a/sample/android/app/src/main/AndroidManifest.xml b/sample/android/app/src/main/AndroidManifest.xml index c0325afb5..39f49adc3 100644 --- a/sample/android/app/src/main/AndroidManifest.xml +++ b/sample/android/app/src/main/AndroidManifest.xml @@ -5,17 +5,15 @@ - - + + + + - - - + + - - -