This repository has been archived by the owner on May 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 505
Adds Granular media permissions for Android 13+ #2065
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
97 changes: 54 additions & 43 deletions
97
DeviceTests/DeviceTests.Android/Properties/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,56 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0.1.0" package="com.xamarin.essentials.devicetests" android:installLocation="auto"> | ||
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="29" /> | ||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> | ||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
<uses-permission android:name="android.permission.BATTERY_STATS" /> | ||
<uses-permission android:name="android.permission.CAMERA" /> | ||
<uses-permission android:name="android.permission.FLASHLIGHT" /> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.VIBRATE" /> | ||
<uses-permission android:name="android.permission.READ_CONTACTS" /> | ||
<queries> | ||
<!-- Email --> | ||
<intent> | ||
<action android:name="android.intent.action.SENDTO" /> | ||
<data android:scheme="mailto" /> | ||
</intent> | ||
<!-- Browser --> | ||
<intent> | ||
<action android:name="android.intent.action.VIEW" /> | ||
<data android:scheme="http" /> | ||
</intent> | ||
<!-- Browser --> | ||
<intent> | ||
<action android:name="android.intent.action.VIEW" /> | ||
<data android:scheme="https" /> | ||
</intent> | ||
<!-- Sms --> | ||
<intent> | ||
<action android:name="android.intent.action.VIEW" /> | ||
<data android:scheme="smsto" /> | ||
</intent> | ||
<!-- PhoneDialer --> | ||
<intent> | ||
<action android:name="android.intent.action.DIAL" /> | ||
<data android:scheme="tel" /> | ||
</intent> | ||
<!-- MediaPicker --> | ||
<intent> | ||
<action android:name="android.media.action.IMAGE_CAPTURE" /> | ||
</intent> | ||
</queries> | ||
<application android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:theme="@style/MainTheme"></application> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.xamarin.essentials" android:installLocation="auto"> | ||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" /> | ||
<!--Camera--> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29"/> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32"/> | ||
<!--Android 13 specific media folders--> | ||
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" android:minSdkVersion="32"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. android:minSdkVersion for these READ_MEDIA_* permissions should be 33 since they were only added in Android API 33 (Android 13). See here: https://developer.android.com/reference/android/Manifest.permission#READ_MEDIA_AUDIO |
||
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" android:minSdkVersion="32" /> | ||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" android:minSdkVersion="32" /> | ||
|
||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> | ||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
<uses-permission android:name="android.permission.BATTERY_STATS" /> | ||
<uses-permission android:name="android.permission.CAMERA" /> | ||
<uses-permission android:name="android.permission.FLASHLIGHT" /> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.VIBRATE" /> | ||
<uses-permission android:name="android.permission.READ_CONTACTS" /> | ||
<queries> | ||
<!-- Email --> | ||
<intent> | ||
<action android:name="android.intent.action.SENDTO" /> | ||
<data android:scheme="mailto" /> | ||
</intent> | ||
<!-- Browser --> | ||
<intent> | ||
<action android:name="android.intent.action.VIEW" /> | ||
<data android:scheme="http" /> | ||
</intent> | ||
<!-- Browser --> | ||
<intent> | ||
<action android:name="android.intent.action.VIEW" /> | ||
<data android:scheme="https" /> | ||
</intent> | ||
<!-- Sms --> | ||
<intent> | ||
<action android:name="android.intent.action.VIEW" /> | ||
<data android:scheme="smsto" /> | ||
</intent> | ||
<!-- PhoneDialer --> | ||
<intent> | ||
<action android:name="android.intent.action.DIAL" /> | ||
<data android:scheme="tel" /> | ||
</intent> | ||
<!-- MediaPicker --> | ||
<intent> | ||
<action android:name="android.media.action.IMAGE_CAPTURE" /> | ||
</intent> | ||
</queries> | ||
<uses-feature android:name="android.hardware.location" android:required="false" /> | ||
<uses-feature android:name="android.hardware.location.gps" android:required="false" /> | ||
<uses-feature android:name="android.hardware.location.network" android:required="false" /> | ||
<application android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:theme="@style/MainTheme" android:fullBackupContent="@xml/my_backup_rules"></application> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -457,8 +457,22 @@ public override (string androidPermission, bool isRuntime)[] RequiredPermissions | |
|
||
public partial class StorageWrite : BasePlatformPermission | ||
{ | ||
public override (string androidPermission, bool isRuntime)[] RequiredPermissions => | ||
new (string, bool)[] { (Manifest.Permission.WriteExternalStorage, true) }; | ||
public override (string androidPermission, bool isRuntime)[] RequiredPermissions | ||
{ | ||
get | ||
{ | ||
if (Platform.HasApiLevel(BuildVersionCodes.Q)) | ||
{ | ||
return new (string, bool)[] | ||
{ | ||
("android.permission.READ_MEDIA_IMAGES", true), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These will probably be needed to spit out into their own permissions. My app only needs access to the users images, I don't want to add/request for 'Audio'/'Video' permissions when it's not needed |
||
("android.permission.READ_MEDIA_VIDEO", true), | ||
("android.permission.READ_MEDIA_AUDIO", true), | ||
}; | ||
} | ||
return new (string, bool)[] { (Manifest.Permission.WriteExternalStorage, true) }; | ||
} | ||
} | ||
} | ||
|
||
public partial class Vibrate : BasePlatformPermission | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the device tests to test features in Android API 33, the target version surely needs to be at least 33 here?