Baseflow / flutter-permission-plugins

This repo contains a collection of permission related Flutter plugins which can be used to request permissions to access device resources in a cross-platform way.
https://baseflow.com
MIT License
52 stars 34 forks source link

HandlePermissionsRequest after call activity request permission unexpected behavior on Android Q #24

Closed ChauNTM closed 4 years ago

ChauNTM commented 4 years ago

🐛 Bug Report

Description:

Expected behavior

Configuration

Version: 1.x

Platform:

I debuged and detect that code block below is wrong

private void handlePermissionsRequest(String[] permissions, int[] grantResults) {
    if (mResult == null) {
      Log.e(LOG_TAG, "Flutter result object is null.");
      return;
    }

    for (int i = 0; i < permissions.length; i++) {
      if (LocationPermissionsPlugin.isLocationPermission(permissions[i])) {
        @PermissionStatus int permissionStatus = toPermissionStatus(grantResults[i]);

        processResult(permissionStatus);
        return;
      }
    }

    processResult(PERMISSION_STATUS_UNKNOWN);
  }

because on Android Q, we have 3 different types of permission, and location permission is only granted if we granted all of those. I think the code block below is true

private void handlePermissionsRequest(String[] permissions, int[] grantResults) {
    if (mResult == null) {
      Log.e(LOG_TAG, "Flutter result object is null.");
      return;
    }

    for (int i = 0; i < permissions.length; i++) {
      if (LocationPermissionsPlugin.isLocationPermission(permissions[i])) {
        @PermissionStatus int permissionStatus = toPermissionStatus(grantResults[i]);
        if (permissionStatus == PERMISSION_STATUS_DENIED) {
          processResult(permissionStatus);
          return;
        }
      }
    }

    processResult(PERMISSION_STATUS_GRANTED);
  }
ChauNTM commented 4 years ago

Please help me create pull request and fix this issue @mvanbeusekom

mvanbeusekom commented 4 years ago

Hi @ChauNTM, we are working on support for AndroidQ permissions for the location services. There is a work in progress pull request (see PR #22) which is related to issue #21.

When this is solved it should also solve your problem. Feel free to contribute though, you can find instructions in our contribution guidelines here.

I will be closing this issue since we are tracking everything related with AndroidQ location permissions in issue #21.