28 Updates for Patches
[webos-internals: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 6fdbb39..b0ad34c 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 @@ -1660,6 +1660,8 @@ handlePowerNotifications: function(payload) {
6                                 this.isCharging = true;                 
7                 }.bind(this));
8                                                 
9 +               this.setForAutoOff();
10 +                                               
11                 if (this.isCharging) {
12                         Mojo.Log.info("SystemUI- Charger Notification "+ this.isCharging + " Last battery level "+ this.lastBatteryLevel);
13                         if(this.batteryLevel == 100)
14 @@ -1692,6 +1694,66 @@ handlePowerNotifications: function(payload) {
15         }
16  },
17  
18 +setForAutoOff: function() {
19 +       if(this.powerSource['inductive']==true) {
20 +               this.controller.serviceRequest('palm://com.palm.display/control', {
21 +                       method: 'getProperty',
22 +                       parameters: {
23 +                               properties: ["onWhenConnected"]
24 +                       },
25 +                       onSuccess: function(payload) {
26 +                               if(payload.onWhenConnected) {
27 +                                       this.getAutoOffTimeout(
28 +                                               function(response) {
29 +                                                       if(response.timeout!=604800) {
30 +                                                               this.setAutoOffCookie(response.timeout);
31 +                                                               this.setAutoOffTimeout(604800);
32 +                                                       }
33 +                                               }.bind(this)
34 +                                       );
35 +                               }
36 +                       }.bind(this)
37 +               });
38 +       } else {
39 +               var timeout = this.getAutoOffCookie();
40 +               if(timeout.seconds != 604800) {
41 +                       this.setAutoOffTimeout(timeout.seconds);
42 +                       this.setAutoOffCookie(604800);
43 +               }
44 +       }
45 +},
46 +
47 +getAutoOffCookie: function() {
48 +       var cookie = new Mojo.Model.Cookie("auto-off");
49 +       var val = cookie.get();
50 +       if(!val) {
51 +               val = {seconds:604800};
52 +               cookie.put(val);
53 +       }
54 +       return val;
55 +},
56 +
57 +setAutoOffCookie: function(value) {
58 +       var cookie = new Mojo.Model.Cookie("auto-off");
59 +       cookie.put({seconds:value});
60 +},
61 +
62 +getAutoOffTimeout: function(callback) {
63 +       this.controller.serviceRequest('palm://com.palm.display/control', {
64 +               method: 'getProperty',
65 +               parameters:{properties:['timeout']},
66 +               onSuccess: callback
67 +       });
68 +},
69 +
70 +setAutoOffTimeout: function(value) {
71 +       this.controller.serviceRequest('palm://com.palm.display/control', {
72 +               method: 'setProperty',
73 +               parameters:{timeout:value}
74 +       });
75 +
76 +},
77 +
78  handleCriticalPowerNotifications: function(payload) {
79         if(payload.cause) {
80                 Mojo.Log.error("SystemUI - Battery Level is critical. Shutting down the phone ");
81 diff --git a/usr/palm/applications/com.palm.app.screenlock/app/controllers/securityconfig-assistant.js b/usr/palm/applications/com.palm.app.screenlock/app/controllers/securityconfig-assistant.js
82 index 86eb675..1e1c0a3 100644
83 --- a/usr/palm/applications/com.palm.app.screenlock/app/controllers/securityconfig-assistant.js
84 +++ b/usr/palm/applications/com.palm.app.screenlock/app/controllers/securityconfig-assistant.js
85 @@ -19,6 +19,10 @@ var SecurityconfigAssistant = Class.create({
86          enableProp: 'enabled',        
87      },
88      
89 +    autoOffChargingtoggleModel: {
90 +        value: false
91 +    },
92 +    
93      switchApptoggleModel: {
94          value: false,
95      },
96 @@ -53,6 +57,9 @@ var SecurityconfigAssistant = Class.create({
97                 //this.controller.setupWidget('blinkAlerts', this.onOffToggleOpt, this.ledThrobberToggleModel);
98                 //Mojo.Event.listen($('blinkAlerts'),'mojo-property-change', this.toggleLEDThrobber.bindAsEventListener(this));
99                 
100 +               this.controller.setupWidget('autoOffCharging', this.onOffToggleOpt, this.autoOffChargingtoggleModel);
101 +               Mojo.Event.listen($('autoOffCharging'),'mojo-property-change', this.toggleautoOffCharging.bindAsEventListener(this));
102 +               
103                 this.controller.setupWidget('switchApps', this.onOffToggleOpt, this.switchApptoggleModel);
104                 Mojo.Event.listen($('switchApps'),'mojo-property-change', this.toggleSwitchApps.bindAsEventListener(this));
105                 
106 @@ -236,6 +243,7 @@ var SecurityconfigAssistant = Class.create({
107                 
108                 this.getSystemlockModeReq = SystemService.getSystemlockMode(this.handleSystemlockMode.bind(this));
109                 this.getSystemlockTimeoutReq = SystemService.getSystemlockTimeout(this.handleSystemlockTimeout.bind(this));
110 +               this.getAutoOffCharging();
111         },
112         
113         updateUI: function(timeout,maximumBrightness) {
114 @@ -551,6 +559,33 @@ var SecurityconfigAssistant = Class.create({
115                 }
116         },
117         
118 +       toggleautoOffCharging: function(event) {
119 +               if(!event)
120 +                       return;
121 +               this.setAutoOffCharging();
122 +       },
123 +       
124 +       setAutoOffCharging: function(value) {
125 +               this.controller.serviceRequest('palm://com.palm.display/control', {
126 +                       method: 'setProperty',
127 +                       parameters: {
128 +                               onWhenConnected: !this.autoOffChargingtoggleModel.value
129 +                       }
130 +               });     
131 +       },
132 +       
133 +       getAutoOffCharging: function() {
134 +               this.controller.serviceRequest('palm://com.palm.display/control', {
135 +                       method: 'getProperty',
136 +                       parameters: {
137 +                               properties: ["onWhenConnected"]
138 +                       },
139 +                       onSuccess: function(payload) {
140 +                               this.autoOffChargingtoggleModel.value = !payload.onWhenConnected;
141 +                               this.controller.modelChanged(this.autoOffChargingtoggleModel);
142 +                       }.bind(this)
143 +               });             
144 +       },
145         
146         
147         launchFilePicker: function(event) {
148 diff --git a/usr/palm/applications/com.palm.app.screenlock/app/views/securityconfig/securityconfig-scene.html b/usr/palm/applications/com.palm.app.screenlock/app/views/securityconfig/securityconfig-scene.html
149 index a97b61b..ab92777 100644
150 --- a/usr/palm/applications/com.palm.app.screenlock/app/views/securityconfig/securityconfig-scene.html
151 +++ b/usr/palm/applications/com.palm.app.screenlock/app/views/securityconfig/securityconfig-scene.html
152 @@ -19,11 +19,17 @@
153                                 </div>
154                         </div>
155  
156 -                       <div id='screentimerrow' class="palm-row last">
157 +                       <div id='screentimerrow' class="palm-row">
158                                 <div id='timeroptions' class="palm-row-wrapper">
159                                         <div id="screenOffTimer" x-mojo-element="ListSelector" class="right"></div>
160                                 </div>
161                         </div>
162 +                       <div class="palm-row last">
163 +                               <div class="palm-row-wrapper">
164 +                                       <div x-mojo-element="ToggleButton" id="autoOffCharging"></div>
165 +                                       <div class="title capitalize" style="font-size:0.85em" x-mojo-loc=''>Auto-off while charging</div>
166 +                               </div>
167 +                       </div>
168                 </div>
169          </div>
170          <div class="palm-group">