5 new, 10 updated patches.
[webos-internals:justyns-modifications.git] / notifications / notifications-device-temperature-warnings.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..ebd5239 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 @@ -1881,12 +1881,54 @@ powerDeInit: function() {
6         this.powerSource['usb'] = false;
7         this.powerSource['inductive'] = false;
8         this.powerdServiceUp = false;
9 +       this.batteryStatusTimer.cancel();
10 +       this.batteryStatusTimer = undefined;
11         return;
12  },
13  
14  powerInitialize: function() {
15         Mojo.Log.info("SystemUI - Power service online!");
16         this.powerdServiceUp = true;
17 +       if(!this.batteryStatusTimer) {
18 +               this.batteryStatusTimer = window.setTimeout(this.getBatteryDetails.bind(this), 300000);
19 +       }
20 +},
21 +
22 +getBatteryDetails: function() {
23 +       this.batteryStatusTimer = window.setTimeout(this.getBatteryDetails.bind(this), 300000);
24 +       this.controller.serviceRequest('palm://com.palm.bus/signal/', {
25 +               method: 'addmatch',
26 +               parameters: {
27 +                       "category":"/com/palm/power",
28 +                       "method":"batteryStatus"
29 +               },
30 +               onSuccess : this.handleBatteryStatus.bind(this)
31 +       });
32 +       this.controller.serviceRequest('palm://com.palm.power/com/palm/power/', {
33 +               method: 'batteryStatusQuery'
34 +       });
35 +},
36 +
37 +handleBatteryStatus: function(payload) {
38 +       if(payload.temperature_C) {
39 +               if(payload.temperature_C >= 50) {
40 +                       var bannerText = "Critical! Device temperature too high";
41 +                       var soundClassName = this.onActiveCall ? "none" : "notifications";                      
42 +                       this.controller.showBanner({
43 +                               messageText: bannerText,
44 +                               icon: "/usr/lib/luna/system/luna-systemui/images/notification-small-error.png",
45 +                               soundClass: soundClassName
46 +                       },""); 
47 +               } else if(payload.temperature_C >= 45) {
48 +                       var bannerText = "Warning: Device temperature is high";
49 +                       var soundClassName = this.onActiveCall ? "none" : "notifications";                      
50 +                       this.controller.showBanner({
51 +                               messageText: bannerText,
52 +                               icon: "/usr/lib/luna/system/luna-systemui/images/notification-small-error.png",
53 +                               soundClass: soundClassName
54 +                       },""); 
55 +               }
56 +       }
57  },
58  
59  /*