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