Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Fix MediaPicker capture methods in Android 13+ #2073

Merged
merged 5 commits into from
Jan 26, 2023
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
5 changes: 4 additions & 1 deletion Xamarin.Essentials/MediaPicker/MediaPicker.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ static Task<FileResult> PlatformCaptureVideoAsync(MediaPickerOptions options)
static async Task<FileResult> PlatformCaptureAsync(MediaPickerOptions options, bool photo)
{
await Permissions.EnsureGrantedAsync<Permissions.Camera>();
await Permissions.EnsureGrantedAsync<Permissions.StorageWrite>();

// StorageWrite no longer exists starting from Android API 33
if (!Platform.HasApiLevel(33))
await Permissions.EnsureGrantedAsync<Permissions.StorageWrite>();

var capturePhotoIntent = new Intent(photo ? MediaStore.ActionImageCapture : MediaStore.ActionVideoCapture);

Expand Down
10 changes: 5 additions & 5 deletions Xamarin.Essentials/SecureStorage/SecureStorage.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ static void PlatformRemoveAll() =>

internal static bool AlwaysUseAsymmetricKeyStorage { get; set; } = false;

// While MD5 is deemed to be not secure anymore, it is not used in a security context here.
// Here we hash a key value to ensure compatibility with the underlying platform's preferences storage (so the key was a determinate length and didn't exceed platform limits).
// As part as Microsofts ongoing efforts to secure the .NET ecosystem, this usage of an insecure hashing mechanism was flagged.
// An exception has been requested for the usage of this "unsafe" hashing mechanism.
// More details here (internal link): https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1676270
// While MD5 is deemed to be not secure anymore, it is not used in a security context here.
// Here we hash a key value to ensure compatibility with the underlying platform's preferences storage (so the key was a determinate length and didn't exceed platform limits).
// As part as Microsofts ongoing efforts to secure the .NET ecosystem, this usage of an insecure hashing mechanism was flagged.
// An exception has been requested for the usage of this "unsafe" hashing mechanism.
// More details here (internal link): https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1676270
Comment on lines -131 to +135
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is failing with:

error SA1027: Tabs and spaces should be used correctly

internal static string Md5Hash(string input)
{
var hash = new StringBuilder();
Expand Down