π Regression
shouldShowRequestPermissionRationale()
receives a Context
, but updates to onMethodCall()
guarantees that it is not an Activity
, and will always log an error and return false
.
Old (and correct) behavior
onMethodCall()
saved a final reference to a Context
via a deleted method getActiveContext()
, which used either mRegistrar.activeContext()
or mRegistrar.activity()
.
That Context
was passed to shouldShowRequestPermissionRationale()
, which checked if it was instanceof
an Activity
, which would succeed if mRegistrar.activity()
was called in getActiveContext()
.
Current behavior
onMethodCall()
saves a final reference to a Context
via mRegistrar.context()
. From the documentation, that method returns the Application
's Context
, which by definition will not be an Activity
, thereby guaranteeing the error in shouldShowRequestPermissionRationale()
and returning false
.
Reproduction steps
Call LocationPermissions().shouldShowRequestPermissionRationale()
in Flutter.
Suggested Steps
In onMethodCall()
, I suggest replacing
final Context context = mRegistrar.context();
with
final Context context = mRegistrar.activeContext();
The documentation states that it returns the current Activity
, or the Application
if that's null, which is exactly what the getActiveContext()
method was trying to do. As I'm not familiar with the rest of the logic, a cursory review of the other methods that accept a Context
from onMethodCall()
seem to be unaffected by this change.
Relevant Commit
8bd14831582fda4b74855e9dabc43fe4c5f99307
Version: 2.0.1
Platform: