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

Commit

Permalink
Merge pull request #2073 from xamarin/dev/fix-mediapicker
Browse files Browse the repository at this point in the history
Fix MediaPicker capture methods in Android 13+
  • Loading branch information
jfversluis authored Jan 26, 2023
2 parents 93f775d + 66042ed commit 3bad14f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
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
internal static string Md5Hash(string input)
{
var hash = new StringBuilder();
Expand Down

0 comments on commit 3bad14f

Please sign in to comment.