Outstanding patches from Jason
[webos-internals:skurriers-modifications.git] / misc / misc-no-auto-off-while-charging.patch
1 Name: No Auto-Off While Charging
2 Version: 1.3.5-1
3 Author: Sakasune, Jason Robitaille
4 Description: Prevents the screen from turning off while the device is charging  (MIT license)
5
6 --- .orig/usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js
7 +++ /usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js
8 @@ -29,2 +29,3 @@
9                 // Initialize the Battery Power Nofication and get the initial value
10 +               this.initTimeout();
11                 this.initOnServerStart("com.palm.power", this.powerInitialize.bind(this), this.powerDeInit.bind(this));
12 @@ -1624,4 +1625,5 @@
13                                                 icon: "/usr/lib/luna/system/luna-systemui/images/notification-small-charging.png",
14                                                 soundClass: soundClassName
15                                         },{}, 'chargingAlert');                                 
16 +                               this.disableTimeout();
17                         }
18 @@ -1628,4 +1630,5 @@
19                         this.chargingBannerShown = true;                        
20                 }
21                 else {
22 +                       if(this.chargingBannerShown) { this.enableTimeout(); }
23                         this.chargingBannerShown = false;                       
24 @@ -2098,6 +2101,7 @@
25          return;
26     
27      if (payload["mode-avail"]) {
28 +               this.disableTimeout();
29                 this.isUSBConnected = true;
30                 if (!this.onActiveCall) {
31                         if (this.canUSBAlertDisplayed()) 
32 @@ -2107,6 +2111,7 @@
33                 }
34         }
35      else {
36 +               this.enableTimeout();
37                 this.isUSBConnected = false;
38                 this.disableiMasqButton = false;
39         this.msmTurnOnHiddServices();
40 @@ -2340,6 +2345,39 @@
41      }
42  },
43  
44 +initTimeout: function() {
45 +       this.previousTimeout = 60;
46 +       this.controller.serviceRequest('palm://com.palm.display/control', {
47 +               method: 'getProperty',
48 +               parameters:{properties:['timeout']},
49 +               onSuccess: function(response) {
50 +                       this.previousTimeout = response.timeout;
51 +               }.bind(this)
52 +       });
53 +},
54 +
55 +disableTimeout: function() {
56 +       this.controller.serviceRequest('palm://com.palm.display/control', {
57 +               method: 'getProperty',
58 +               parameters:{properties:['timeout']},
59 +               onSuccess: function(response) {
60 +                       this.previousTimeout = response.timeout;
61 +                       this.controller.serviceRequest('palm://com.palm.display/control', {
62 +                               method: 'setProperty', 
63 +                               parameters:{timeout:86400}      
64 +                       });
65 +               }.bind(this)
66 +       });
67 +},
68 +
69 +enableTimeout: function() {
70 +       this.controller.serviceRequest('palm://com.palm.display/control', {
71 +               method: 'setProperty',
72 +               parameters:{timeout:parseInt(this.previousTimeout)}
73 +       });
74 +},
75 +
76 +
77  /*
78   * Show Power Off Alert
79   */