Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLNP-5556] fix: remove non-required permissions from android #211

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/uikit-react-native/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,15 @@ Add the following permissions to your `android/app/src/main/AndroidManifest.xml`
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.your.app">

<uses-permission android:name="android.permission.CAMERA" />
<!-- Permissions for voice message -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />

<!-- Permissions for image attachments -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />

<!-- Permissions for notifications (Android 13) -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />

</manifest>
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,15 @@ const createNativePlayerService = ({ audioRecorderModule, permissionModule }: Mo

public requestPermission = async (): Promise<boolean> => {
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 {
Expand Down
14 changes: 6 additions & 8 deletions sample/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@

<uses-permission android:name="android.permission.INTERNET" />

<!-- Permissions for FilePickerService -->
<uses-permission android:name="android.permission.CAMERA" />
<!-- Permissions for voice message -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />

<!-- Permissions for image attachments -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
<!-- Permissions for VoiceMessage -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<!-- Android 13 -->

<!-- Permissions for notifications (Android 13) -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />

<application
android:name=".MainApplication"
Expand Down