9 New Patches.
[webos-internals:skurriers-modifications.git] / google-maps / google-maps-auto-enable-and-disable-gps-for-maps.patch
1 diff --git a/usr/palm/applications/com.palm.app.maps/app/assistants/app-assistant.js b/usr/palm/applications/com.palm.app.maps/app/assistants/app-assistant.js
2 index 194d62e..5ef7414 100644
3 --- a/usr/palm/applications/com.palm.app.maps/app/assistants/app-assistant.js
4 +++ b/usr/palm/applications/com.palm.app.maps/app/assistants/app-assistant.js
5 @@ -20,6 +20,21 @@ function AppAssistant(appController) {
6         
7         // subscribe for notifications from connection manager
8         this._startConnectionWatch();
9 +    
10 +    this.gpsWasEnabled = false;
11 +    this.gpsStatReq = new Mojo.Service.Request('palm://com.palm.location', {
12 +        method: 'getUseGps',
13 +               parameters: {},
14 +               onSuccess: function(response){
15 +            this.gpsWasEnabled = response.useGps;
16 +            if (this.gpsWasEnabled==false){
17 +                new Mojo.Service.Request('palm://com.palm.location', {
18 +                    method: 'setUseGps',
19 +                    parameters: {useGps: true}
20 +                });
21 +            }
22 +        }      
23 +    });
24         
25         // register for entering msm notifications
26         this.storageNotificationSession = new Mojo.Service.Request(
27 @@ -81,6 +96,16 @@ AppAssistant.prototype.handleLaunch = function(appLaunchParams) {
28  
29  AppAssistant.prototype.cleanup = function() {
30         Mojo.Log.info("Maps: AppAssistant cleanup");
31 +    
32 +    if (this.gpsWasEnabled==false){
33 +        new Mojo.Service.Request('palm://com.palm.location', {
34 +                       method: 'setUseGps',
35 +                       parameters: {
36 +                               useGps: false
37 +                       }
38 +               });
39 +    }   
40 +     
41         this._cleanupConnectionWatch(); 
42         this.storageNotificationSession.cancel();
43  };