Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Conversation

@sfanxiang
Copy link

Since we always require both camera and audio permissions, it's better to
check both in case the user rejected audio permissions alone.

Since we always require both camera and audio permissions, it's better to
check both in case the user rejected audio permissions alone.
@collinjackson collinjackson changed the title camera: Check audio perm when opening on Android [camera] Check audio perm when opening on Android Feb 21, 2019
@bparrishMines
Copy link
Contributor

Hi @sfanxiang

We check for audio permission in the constructor of Camera here: https://github.com/flutter/plugins/blob/master/packages/camera/android/src/main/java/io/flutter/plugins/camera/CameraPlugin.java#L316.

Also, in our example app, it repeatedly asks for audio permissions if you don't give the camera permission. I know this PR is quite old now, but was there a specific situation where the app didn't ask for audio permissions for you?

@sfanxiang
Copy link
Author

@bparrishMines There used to be another code path to camera.open():

public void onActivityResumed(Activity activity) {
if (requestingPermission) {
requestingPermission = false;
return;
}
if (activity == CameraPlugin.this.activity) {
if (camera != null) {
camera.open(null);
}
}
}
, and could be reproduced by:

  1. Open camera in example app and reject only audio permission, selecting "Don't ask again"
  2. Go to homescreen
  3. Go back to the example app and open the camera
  4. Repeat 2~3 until the app crashes

If it's no longer a problem feel free to close this PR.

@bparrishMines
Copy link
Contributor

You're right. I forgot we had a call to open in the ActivityLifecycleCallback. We took that out due to problems such as these.

I will go ahead and close this. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants