Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
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
4 changes: 4 additions & 0 deletions packages/camera/camera_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.10.0+5

* Fixes `ArrayIndexOutOfBoundsException` when the permission request is interrupted.

## 0.10.0+4

* Upgrades `androidx.annotation` version to 1.5.0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ public boolean onRequestPermissionsResult(int id, String[] permissions, int[] gr
}

alreadyCalled = true;
if (grantResults[0] != PackageManager.PERMISSION_GRANTED) {
// grantResults could be empty if the permissions request with the user is interrupted
// https://developer.android.com/reference/android/app/Activity#onRequestPermissionsResult(int,%20java.lang.String[],%20int[])
if (grantResults.length == 0 || grantResults[0] != PackageManager.PERMISSION_GRANTED) {
callback.onResult(CAMERA_ACCESS_DENIED, CAMERA_ACCESS_DENIED_MESSAGE);
} else if (grantResults.length > 1 && grantResults[1] != PackageManager.PERMISSION_GRANTED) {
callback.onResult(AUDIO_ACCESS_DENIED, AUDIO_ACCESS_DENIED_MESSAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,18 @@ public void callback_doesNotRespond() {
verify(fakeResultCallback, never())
.onResult("AudioAccessDenied", "Audio access permission was denied.");
}

@Test
public void callback_respondsWithCameraAccessDeniedWhenEmptyResult() {
// Handles the case where the grantResults array is empty

ResultCallback fakeResultCallback = mock(ResultCallback.class);
CameraRequestPermissionsListener permissionsListener =
new CameraRequestPermissionsListener(fakeResultCallback);

permissionsListener.onRequestPermissionsResult(9796, null, new int[] {});

verify(fakeResultCallback)
.onResult("CameraAccessDenied", "Camera access permission was denied.");
}
}
2 changes: 1 addition & 1 deletion packages/camera/camera_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: camera_android
description: Android implementation of the camera plugin.
repository: https://github.com/flutter/plugins/tree/main/packages/camera/camera_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
version: 0.10.0+4
version: 0.10.0+5

environment:
sdk: ">=2.14.0 <3.0.0"
Expand Down