9 New Patches.
[webos-internals:skurriers-modifications.git] / phone / phone-autospeakerphone-via-proximity-sensor-instant.patch
1 diff --git a/usr/palm/applications/com.palm.app.phone/app/controllers/activecall-assistant.js b/usr/palm/applications/com.palm.app.phone/app/controllers/activecall-assistant.js
2 index bab675d..e986e4f 100644
3 --- a/usr/palm/applications/com.palm.app.phone/app/controllers/activecall-assistant.js
4 +++ b/usr/palm/applications/com.palm.app.phone/app/controllers/activecall-assistant.js
5 @@ -52,6 +52,7 @@ var ActivecallAssistant = Class.create({
6                 
7                 this.puckConnected = this.eventListener.puckConnected;
8                 this.puckSubscription = TelephonyCommands.puckStatusSubscribe(this.onPuckEvent.bind(this));
9 +               this.displayChanged = undefined;
10                 
11                 this.onBlur = this.onBlur.bind(this);
12                 this.onFocus = this.onFocus.bind(this);
13 @@ -129,6 +130,7 @@ var ActivecallAssistant = Class.create({
14                         return;
15                 }
16                 this.updateCalls(initialCallState);
17 +               this.proxAudio();
18                 
19                 //start the timer
20                 this.timerInterval = this.controller.window.setInterval(this.updateDisplayTimer.bind(this), 1000);
21 @@ -496,6 +498,58 @@ break;
22  
23      },
24         
25 +       proxAudio: function() {
26 +               this.onAudioRouteChangeClick("phone_back_speaker");
27 +               this.disableScreenTimeout();
28 +               this.displayChanged = this.controller.serviceRequest('palm://com.palm.display/control', {
29 +                       method:'status',
30 +                       parameters:{subscribe:true},
31 +                       onSuccess: this.handleDisplayChange.bind(this)
32 +               });
33 +       },
34 +       
35 +       handleDisplayChange: function(payload) {
36 +               if (this.eventListener.proxEnabled && (this.audioActiveProfile == "phone_back_speaker" || this.audioActiveProfile == "phone_front_speaker")) {
37 +                       if(payload && payload.event) {
38 +                               if (payload.event == "displayOn") {
39 +                                       this.onAudioRouteChangeClick("phone_back_speaker");
40 +                               } else if (payload.event == "displayOff") {
41 +                                       this.onAudioRouteChangeClick("phone_front_speaker");
42 +                               } else {
43 +                                       // Do nothing.
44 +                               }
45 +                       }
46 +               }
47 +       },
48 +       
49 +       disableScreenTimeout: function() {
50 +               var parameters = {};
51 +                       parameters.requestBlock = true;
52 +                       parameters.client = "phoneapp";
53 +                       parameters.subscribe = true;
54 +               
55 +               this.timeoutBlockReq = new Mojo.Service.Request('palm://com.palm.display/control', {
56 +                       method: 'setProperty',
57 +                       parameters: parameters
58 +               });
59 +       },
60 +       
61 +       enableScreenTimeout: function() {
62 +               if (this.timeoutBlockReq){
63 +                       this.timeoutBlockReq.cancel();
64 +                       this.timeoutBlockReq = undefined;
65 +               }
66 +               
67 +               var parameters = {};
68 +                       parameters.requestBlock = false;
69 +                       parameters.client = "phoneapp";
70 +               
71 +               this.timeoutCancelReq = new Mojo.Service.Request('palm://com.palm.display/control', {
72 +                       method: 'setProperty',
73 +                       parameters: parameters
74 +               });
75 +       },
76 +       
77         // sets up pause/wait digit handling 
78         handlePauseWaitDigits: function(callStateMessage) {
79                 var lineState = callStateMessage.lines;
80 @@ -1411,6 +1465,7 @@ break;
81                 
82                 // clear out a transition if we had it
83                 this.crossfadeCancel();
84 +               this.enableScreenTimeout();
85                 
86                 // close banner if open
87                 this.bannerClose();
88 @@ -1481,6 +1536,8 @@ break;
89                 // drop puck subscription
90                 this.puckSubscription.cancel();
91                 delete this.puckSubscription;
92 +               this.displayChanged.cancel();
93 +               delete this.displayChanged;
94                 
95                 Mojo.View.removeDOMReferences(this);
96                 
97 diff --git a/usr/palm/applications/com.palm.app.phone/app/models/TelephonyEventListener.js b/usr/palm/applications/com.palm.app.phone/app/models/TelephonyEventListener.js
98 index c7190b5..9334e1f 100644
99 --- a/usr/palm/applications/com.palm.app.phone/app/models/TelephonyEventListener.js
100 +++ b/usr/palm/applications/com.palm.app.phone/app/models/TelephonyEventListener.js
101 @@ -493,6 +493,10 @@ var TelephonyEventListener = Class.create({
102                                         && Object.keys(profiles).length == 2                            
103                                         && profiles["phone_front_speaker"] == true) {
104                                         scenario = "phone_front_speaker";
105 +                               } else if (!this.puckConnected
106 +                                       && Object.keys(profiles).length == 2                            
107 +                                       && profiles["phone_back_speaker"] == true) {
108 +                                       scenario = "phone_back_speaker";
109                                 } else {
110                                         return;
111                                 }
112 @@ -500,7 +504,7 @@ var TelephonyEventListener = Class.create({
113                 }
114                 
115                 if (this.isPendingOrActive()) {
116 -                       if (scenario == "phone_front_speaker") {
117 +                       if (scenario == "phone_front_speaker" || scenario == "phone_back_speaker") {
118                                 this.proxOn();
119                         } else {
120                                 QDLogger.log( "TEL#enableProxOnCallAndAudio", "not enabled: " , scenario);