mrmans0n / smart-location-lib

Android library project that lets you manage the location updates to be as painless as possible
1.65k stars 352 forks source link

Location Service enable settings does not work on some of Huawei and Mi devices #251

Open sabid-habib opened 6 years ago

sabid-habib commented 6 years ago

The locationServicesEnabled() method on LocationState class only checks if the current _"locationmode" is 0 or not. It assumes that each device will return '0' when location service is off. But on some of huawei devices(lollipop and marshmallow) and Xiaomi devices, _"locationmode" returns '2' when location service is OFF. Again, samsung lollipop devices return _"locationmode" as '1' when location service is on. Whereas other devices set _"locationmode" as '3' when location service is on.

Considering all the devices, the locationServicesEnabled() should return the following:

return locationMode %2 != 0;