location: Translate accuracy level for geoclue
The enums values of geoclue have gaps in them (so more levels could be added in future) but enum values of settings don't have such gaps so we gotta translate between them. Since desrt says that enums as integers in gsettings are bad, we now treat accuracy level settings as string. This fixes the recent regression of geoclue only allowing geiop level accuracy to apps. https://bugzilla.gnome.org/show_bug.cgi?id=736479
This commit is contained in:
parent
a4c1b55111
commit
7653175c6f
@ -13,6 +13,15 @@ const LOCATION_SCHEMA = 'org.gnome.system.location';
|
||||
const MAX_ACCURACY_LEVEL = 'max-accuracy-level';
|
||||
const ENABLED = 'enabled';
|
||||
|
||||
const GeoclueAccuracyLevel = {
|
||||
NONE: 0,
|
||||
COUNTRY: 1,
|
||||
CITY: 4,
|
||||
NEIGHBORHOOD: 5,
|
||||
STREET: 6,
|
||||
EXACT: 8
|
||||
};
|
||||
|
||||
var GeoclueIface = '<node> \
|
||||
<interface name="org.freedesktop.GeoClue2.Manager"> \
|
||||
<property name="InUse" type="b" access="read"/> \
|
||||
@ -181,10 +190,14 @@ const Indicator = new Lang.Class({
|
||||
},
|
||||
|
||||
_getMaxAccuracyLevel: function() {
|
||||
if (this._settings.get_boolean(ENABLED))
|
||||
return this._settings.get_enum(MAX_ACCURACY_LEVEL);
|
||||
else
|
||||
return 0;
|
||||
if (this._settings.get_boolean(ENABLED)) {
|
||||
let level = this._settings.get_string(MAX_ACCURACY_LEVEL);
|
||||
|
||||
return GeoclueAccuracyLevel[level.toUpperCase()] ||
|
||||
GeoclueAccuracyLevel.NONE;
|
||||
} else {
|
||||
return GeoclueAccuracyLevel.NONE;
|
||||
}
|
||||
},
|
||||
|
||||
_notifyMaxAccuracyLevel: function() {
|
||||
|
Loading…
Reference in New Issue
Block a user