batch of updates
[webos-internals:skurriers-modifications.git] / screen-lock / screen-lock-no-auto-off-while-charging.patch
1 diff --git a/usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js b/usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js
2 index a4a150e..71f55c8 100644
3 --- a/usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js
4 +++ b/usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js
5 @@ -1753,6 +1753,8 @@ handlePowerNotifications: function(payload) {
6                         if (this.powerSource[source] == true)
7                                 this.isCharging = true;                 
8                 }.bind(this));
9 +               
10 +               this.setForAutoOff();
11                                                 
12                 if (this.isCharging) {
13                         Mojo.Log.info("SystemUI- Charger Notification "+ this.isCharging + " Last battery level "+ this.lastBatteryLevel);
14 @@ -1786,6 +1788,56 @@ handlePowerNotifications: function(payload) {
15         }
16  },
17  
18 +setForAutoOff: function() {
19 +       if(this.isCharging==true) {
20 +               this.getAutoOffTimeout(
21 +                       function(response) {
22 +                               if(response.timeout!=604800) {
23 +                                       this.setAutoOffCookie(response.timeout);
24 +                                       this.setAutoOffTimeout(604800);
25 +                               }
26 +                       }.bind(this)
27 +               );
28 +       } else {
29 +               var timeout = this.getAutoOffCookie();
30 +               if(timeout.seconds != 604800) {
31 +                       this.setAutoOffTimeout(timeout.seconds);
32 +                       this.setAutoOffCookie(604800);
33 +               }
34 +       }
35 +},
36 +
37 +getAutoOffCookie: function() {
38 +       var cookie = new Mojo.Model.Cookie("auto-off");
39 +       var val = cookie.get();
40 +       if(!val) {
41 +               val = {seconds:604800};
42 +               cookie.put(val);
43 +       }
44 +       return val;
45 +},
46 +
47 +setAutoOffCookie: function(value) {
48 +       var cookie = new Mojo.Model.Cookie("auto-off");
49 +       cookie.put({seconds:value});
50 +},
51 +
52 +getAutoOffTimeout: function(callback) {
53 +       this.controller.serviceRequest('palm://com.palm.display/control', {
54 +               method: 'getProperty',
55 +               parameters:{properties:['timeout']},
56 +               onSuccess: callback
57 +       });
58 +},
59 +
60 +setAutoOffTimeout: function(value) {
61 +       this.controller.serviceRequest('palm://com.palm.display/control', {
62 +               method: 'setProperty',
63 +               parameters:{timeout:value}
64 +       });
65 +
66 +},
67 +
68  handleCriticalPowerNotifications: function(payload) {
69         if(payload.cause) {
70                 Mojo.Log.error("SystemUI - Battery Level is critical. Shutting down the phone ");