Skip to content

Commit

Permalink
+ Geolocation handling
Browse files Browse the repository at this point in the history
  • Loading branch information
timdream committed Jul 26, 2012
1 parent 7f1420d commit 8275861
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions apps/system/js/airplane_mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@ var AirplaneMode = {
mobileDataEnabled = value;
});

var geolocationEnabled = false;
SettingsListener.observe('geolocation.enabled', false, function(value) {
geolocationEnabled = value;
});

var bluetooth = window.navigator.mozBluetooth;
var wifiManager = window.navigator.mozWifiManager;
var mobileData = window.navigator.mozMobileConnection &&
window.navigator.mozMobileConnection.data;

// XXX: need a way to toggle Geolocation here
// https://github.com/mozilla-b2g/gaia/issues/2833
// https://bugzilla.mozilla.org/show_bug.cgi?id=777594

var restoreMobileData = false;
var restoreBluetooth = false;
var restoreWifi = false;
var restoreGeolocation = false;

SettingsListener.observe('ril.radio.disabled', false, function(value) {
if (value) {
Expand Down Expand Up @@ -64,6 +66,14 @@ var AirplaneMode = {
}
}

// Turn off Geolocation
restoreGeolocation = geolocationEnabled;
if (geolocationEnabled) {
settings.getLock().set({
'geolocation.enabled': false
});
}

} else {
// Leaving airplane mode.

Expand All @@ -87,6 +97,13 @@ var AirplaneMode = {
'wifi.enabled': true
});
}

// Don't attempt to turn on Geolocation if it's already on
if (!geolocationEnabled && restoreGeolocation) {
settings.getLock().set({
'geolocation.enabled': true
});
}
}
});
}
Expand Down

0 comments on commit 8275861

Please sign in to comment.