WifiWizard2 icon indicating copy to clipboard operation
WifiWizard2 copied to clipboard

Handle permissions and gps status

Open michalfapso opened this issue 7 years ago • 8 comments

This patch contains two changes:

  • Return error when permissions are not set properly for wifi access.
  • In Android 6 and above, wifi networks scanning return empty SSID list when GPS is turned off, so now it also asks to turn on GPS if it is disabled.

All these changes were merged from https://github.com/paraggarg37/WifiWizard/

Specifically from these commits:

  • added permissions for marshmallow https://github.com/paraggarg37/WifiWizard/commit/47590ea6104e0abc183e592ab86eb3bdf89449ca#diff-71da7ed529b38209b2b0f4bfc226b3ec
  • added support for android 6 https://github.com/paraggarg37/WifiWizard/commit/eb2b9a69c4aa079bed1e0df53b64e035e22326dc#diff-71da7ed529b38209b2b0f4bfc226b3ec

Why Should This Be In Core?

I used WifiWizard on my Android 5 without problems, but when I deployed it on other people's phones for testing, it didn't work on some phones. It turned out to be either because of unset permissions or disabled GPS on Android >= 6. So these changes could save some troubles to WifiWizard users :)

Of course, one could use other plugins for checking permissions and GPS status, but I think it is nice to have it all included in WifiWizard itself.

Code parts to check

I was not sure, where to put these checks, so please just check if that makes sense to you:

public boolean execute(...) {
        ...
        if(!displayLocationSettingsRequest()){
            callbackContext.error("Android 6 and above Gps turned off");
            return true;
        }

        if(!checkCurrentPermissions()){
            callbackContext.error("permission not found") ;
            return true;
        }

Thanks a lot for maintaining WifiWizard2. Michal

michalfapso avatar Mar 07 '18 07:03 michalfapso

Thanks for submitting this PR, have you tried the version 3.0.0 branch by chance? Permission handling was added in that branch.

I don't mind adding this for support in the old version of WifiWizard (version 2), but have you tested this yourself? If so what have you tested it on?

tripflex avatar Apr 12 '18 15:04 tripflex

Thanks, I have tested it with the 3.0.0 branch, but it didn't work the same way. I don't remember now, how it behaved, but I'll try it soon again and let you know.

michalfapso avatar Apr 12 '18 17:04 michalfapso

Ok yeah this should only be for version 2.x so I changed the PR to that instead of master, as i'm about to merge 3.x into master since 2.x will no longer be supported/maintained in favor of 3.x+

tripflex avatar Apr 12 '18 19:04 tripflex

Sure, that makes sense.

michalfapso avatar Apr 12 '18 19:04 michalfapso

I am interested by this PR too. Any news ?

gontard avatar May 29 '18 09:05 gontard

Sorry guys, I haven't tested the 3.0.0 branch yet.

@gontard, could you please test it? If you have Android >= 6, just create an example app with WifiWizard2 (branch 3.0.0) and try wifi scanning when the app doesn't have permissions to access location and when the GPS is turned off.

michalfapso avatar May 29 '18 10:05 michalfapso

@tripflex IS this still relevant?

arsenal942 avatar Jul 19 '18 22:07 arsenal942

@arsenal942 only for the 2.1.x branch, this is already handled in the 3.x branch

tripflex avatar Jul 19 '18 22:07 tripflex