68 //----------------------------------------------------------------------------- |
70 //----------------------------------------------------------------------------- |
69 // |
71 // |
70 CGlxTvConnectionMonitor::CGlxTvConnectionMonitor |
72 CGlxTvConnectionMonitor::CGlxTvConnectionMonitor |
71 ( MGlxTvConnectionObserver& aConnectionObserver ) |
73 ( MGlxTvConnectionObserver& aConnectionObserver ) |
72 :CActive(EPriorityStandard), |
74 :CActive(EPriorityStandard), |
73 iConnectionObserver ( aConnectionObserver ) |
75 iConnectionObserver ( aConnectionObserver ), |
74 { |
76 iTvOutConnectionState(EFalse), |
75 GLX_LOG_INFO("CGlxTvConnectionMonitor"); |
77 iHDMIConnectionState(EFalse) |
|
78 |
|
79 { |
|
80 TRACER("CGlxTvConnectionMonitor"); |
76 CActiveScheduler::Add( this ); |
81 CActiveScheduler::Add( this ); |
77 } |
82 } |
78 |
83 |
79 |
84 |
80 //----------------------------------------------------------------------------- |
85 //----------------------------------------------------------------------------- |
81 // Symbian second phase constructor |
86 // Symbian second phase constructor |
82 //----------------------------------------------------------------------------- |
87 //----------------------------------------------------------------------------- |
83 // |
88 // |
84 void CGlxTvConnectionMonitor::ConstructL() |
89 void CGlxTvConnectionMonitor::ConstructL() |
85 { |
90 { |
86 GLX_LOG_INFO("CGlxTvConnectionMonitor::ConstructL"); |
91 TRACER("CGlxTvConnectionMonitor::ConstructL"); |
87 User::LeaveIfError(iTvAccServer.Connect()); |
92 User::LeaveIfError(iTvAccServer.Connect()); |
88 User::LeaveIfError(iTvAccCon.CreateSubSession(iTvAccServer)); |
93 User::LeaveIfError(iTvAccCon.CreateSubSession(iTvAccServer)); |
89 User::LeaveIfError(iTvAccCon.GetAccessoryConnectionStatus(iCurrentAccArray)); |
94 |
90 for (int i = 0; i < iCurrentAccArray.Count(); i++) |
95 UpdateConnectionStatusL(); |
91 { |
96 IssueRequest(); |
92 iTvOutConnectionState |
|
93 = (iCurrentAccArray.GetGenericIDL(i).PhysicalConnectionCaps() |
|
94 == KPCWired); |
|
95 iHDMIConnectionState |
|
96 = (iCurrentAccArray.GetGenericIDL(i).PhysicalConnectionCaps() |
|
97 == KPCHDMI); |
|
98 } |
|
99 IssueRequest(); |
|
100 } |
97 } |
101 |
98 |
102 //----------------------------------------------------------------------------- |
99 //----------------------------------------------------------------------------- |
103 // From class CActive. |
100 // From class CActive. |
104 // Receive notification of change in the connection state |
101 // Receive notification of change in the connection state |
105 //----------------------------------------------------------------------------- |
102 //----------------------------------------------------------------------------- |
106 // |
103 // |
107 void CGlxTvConnectionMonitor::RunL() |
104 void CGlxTvConnectionMonitor::RunL() |
108 { |
105 { |
109 GLX_LOG_INFO("CGlxTvConnectionMonitor::RunL"); |
106 TRACER("CGlxTvConnectionMonitor::RunL"); |
110 // Check for errors |
107 // Check for errors |
111 User::LeaveIfError( iStatus.Int() ); |
108 User::LeaveIfError( iStatus.Int() ); |
112 // Notify observers |
109 // Notify observers |
113 IssueNotificationL(); |
110 IssueNotificationL(); |
114 // Request the next event |
111 // Request the next event |
158 // IsConnected |
155 // IsConnected |
159 //----------------------------------------------------------------------------- |
156 //----------------------------------------------------------------------------- |
160 // |
157 // |
161 TBool CGlxTvConnectionMonitor::IsHDMIConnected() const |
158 TBool CGlxTvConnectionMonitor::IsHDMIConnected() const |
162 { |
159 { |
163 GLX_LOG_INFO("CGlxTvConnectionMonitor::IsHDMIConnected"); |
160 TRACER("CGlxTvConnectionMonitor::IsHDMIConnected"); |
164 GLX_LOG_INFO1("CGlxTvConnectionMonitor::IsHDMIConnected iHDMIConnectionState=%d",iHDMIConnectionState); |
161 GLX_LOG_INFO1("CGlxTvConnectionMonitor::IsHDMIConnected iHDMIConnectionState=%d",iHDMIConnectionState); |
165 return iHDMIConnectionState; |
162 return iHDMIConnectionState; |
166 } |
163 } |
167 |
164 |
168 //----------------------------------------------------------------------------- |
165 //----------------------------------------------------------------------------- |
169 // Request accessory server events |
166 // Request accessory server events |
170 //----------------------------------------------------------------------------- |
167 //----------------------------------------------------------------------------- |
171 // |
168 // |
172 void CGlxTvConnectionMonitor::IssueRequest() |
169 void CGlxTvConnectionMonitor::IssueRequest() |
173 { |
170 { |
174 GLX_LOG_INFO("CGlxTvConnectionMonitor::IssueRequest"); |
171 TRACER("CGlxTvConnectionMonitor::IssueRequest"); |
175 if (!IsActive()) // required for testing |
172 if (!IsActive()) // required for testing |
176 { |
173 { |
177 iTvAccCon.NotifyAccessoryConnectionStatusChanged(iStatus,iCurrentAccArray); |
174 iTvAccCon.NotifyAccessoryConnectionStatusChanged(iStatus,iCurrentAccArray); |
178 SetActive(); |
175 SetActive(); |
179 } |
176 } |
180 } |
177 } |
181 |
178 |
182 |
|
183 //----------------------------------------------------------------------------- |
179 //----------------------------------------------------------------------------- |
184 // Sends notification to observers if TV Out is connected |
180 // Sends notification to observers if TV Out is connected |
185 //----------------------------------------------------------------------------- |
181 //----------------------------------------------------------------------------- |
186 // |
182 // |
187 void CGlxTvConnectionMonitor::IssueNotificationL() |
183 void CGlxTvConnectionMonitor::IssueNotificationL() |
188 { |
184 { |
189 GLX_LOG_INFO("CGlxTvConnectionMonitor::IssueNotificationL"); |
185 TRACER("CGlxTvConnectionMonitor::IssueNotificationL"); |
190 TBool previousTvState = iTvOutConnectionState; |
186 TBool previousTvState = iTvOutConnectionState; |
191 TBool previousHDMIState = iHDMIConnectionState; |
187 TBool previousHDMIState = iHDMIConnectionState; |
192 GLX_LOG_INFO2("previousTvState = %d , previousHDMIState = %d", |
188 |
193 previousTvState,previousHDMIState); |
189 // Update the connection status |
194 |
190 UpdateConnectionStatusL(); |
195 //gets the TV status in to the iCurrentAccArray and haves the Latest Accesory in 0-index |
191 |
196 User::LeaveIfError(iTvAccCon.GetAccessoryConnectionStatus(iCurrentAccArray)); |
192 // trigger tvstatus change only when there is actually a change the in the connection and not |
197 |
193 // for spurious events |
198 CAccPolSubblockNameArray* nameArray = CAccPolSubblockNameArray::NewL(); |
194 if (previousTvState !=iTvOutConnectionState || previousHDMIState != iHDMIConnectionState) |
199 CleanupStack::PushL(nameArray); |
195 { |
200 |
196 GLX_LOG_INFO("CGlxTvConnectionMonitor::IssueNotificationL - Connection Altered"); |
201 // |
197 iConnectionObserver.HandleTvConnectionStatusChangedL(); |
202 // Get the number of currently connected accessories |
198 } |
203 // Loop through each connected accessory looking for |
199 } |
204 // the desired capabilities |
200 |
205 // |
201 //----------------------------------------------------------------------------- |
206 iTvOutConnectionState = EFalse; |
202 // UpdateConnectionStatusL() |
207 iHDMIConnectionState = EFalse; |
203 //----------------------------------------------------------------------------- |
208 const TInt count = iCurrentAccArray.Count(); |
204 // |
209 for (TInt index = 0; index < count; index++) |
205 void CGlxTvConnectionMonitor::UpdateConnectionStatusL() |
210 { |
206 { |
211 TAccPolGenericID genId = iCurrentAccArray.GetGenericIDL(index); |
207 TRACER("CGlxTvConnectionMonitor::UpdateConnectionStatusL()"); |
212 // Get all supported capabilities for this connected accessory. |
208 |
213 iTvAccCon.GetSubblockNameArrayL(genId, *nameArray); |
209 GLX_LOG_INFO2("CGlxTvConnectionMonitor::UpdateConnectionStatusL previousTvState = %d , previousHDMIState = %d", |
214 // Check if this connected accessory supports TV-Out capabality. |
210 iTvOutConnectionState,iHDMIConnectionState); |
215 if (nameArray->HasName(KAccVideoOut)) |
211 |
216 { |
212 //gets the TV status in to the iCurrentAccArray and haves the Latest Accesory in 0-index |
217 GLX_LOG_INFO("TV-Out Capabilities Exist"); |
213 User::LeaveIfError(iTvAccCon.GetAccessoryConnectionStatus(iCurrentAccArray)); |
218 TAccPolNameRecord nameRecord; |
214 |
219 nameRecord.SetNameL(KAccVideoOut); |
215 CAccPolSubblockNameArray* nameArray = CAccPolSubblockNameArray::NewL(); |
220 TAccValueTypeTInt value; |
216 CleanupStack::PushL(nameArray); |
221 iTvAccCon.GetValueL(genId, nameRecord, value); |
217 // Get the number of currently connected accessories |
222 if (value.iValue == EAccVideoOutEHDMI) |
218 // Loop through each connected accessory looking for |
223 { |
219 // the desired capabilities |
224 GLX_LOG_INFO("HDMI is connected Capabilities Exist"); |
220 // |
225 iHDMIConnectionState = ETrue; |
221 const TInt count = iCurrentAccArray.Count(); |
226 break; |
222 GLX_LOG_INFO1("CGlxTvConnectionMonitor::UpdateConnectionStatusL current count value is %d",count); |
227 } |
223 for (TInt index = 0; index <count; index++) |
228 else if (value.iValue == EAccVideoOutCVideo) |
|
229 { |
|
230 GLX_LOG_INFO("TV is connected Capabilities Exist"); |
|
231 iTvOutConnectionState = ETrue; |
|
232 break; |
|
233 } |
|
234 } |
|
235 |
|
236 } |
|
237 CleanupStack::PopAndDestroy(nameArray); |
|
238 |
|
239 if (previousTvState != iTvOutConnectionState || previousHDMIState |
|
240 != iHDMIConnectionState) |
|
241 { |
224 { |
242 GLX_LOG_INFO("CGlxTvConnectionMonitor::IssueNotificationL -" |
225 TAccPolGenericID genId = iCurrentAccArray.GetGenericIDL(index); |
243 " TvConnectionStatusChanged"); |
226 // Get all supported capabilities for this connected accessory. |
244 GLX_LOG_INFO2("CurrentTvState = %d , CurrentHDMIState = %d", |
227 iTvAccCon.GetSubblockNameArrayL(genId, *nameArray); |
245 iTvOutConnectionState,iHDMIConnectionState); |
228 // Check if this connected accessory supports TV-Out capabality. |
246 iConnectionObserver.HandleTvConnectionStatusChangedL(); |
229 GLX_LOG_INFO1("CGlxTvConnectionMonitor::UpdateConnectionStatusL current index value is %d",index); |
|
230 if (nameArray->HasName(KAccVideoOut)) |
|
231 { |
|
232 GLX_LOG_INFO("CGlxTvConnectionMonitor::UpdateConnectionStatusL Video Accessory Supported"); |
|
233 TAccPolNameRecord nameRecord; |
|
234 nameRecord.SetNameL(KAccVideoOut); |
|
235 TAccValueTypeTInt value; |
|
236 iTvAccCon.GetValueL(genId, nameRecord, value); |
|
237 if (value.iValue == EAccVideoOutEHDMI) |
|
238 { |
|
239 GLX_LOG_INFO("CGlxTvConnectionMonitor::UpdateConnectionStatusL HDMI is connected"); |
|
240 iHDMIConnectionState = ETrue; |
|
241 } |
|
242 else if (value.iValue == EAccVideoOutCVideo) |
|
243 { |
|
244 GLX_LOG_INFO("CGlxTvConnectionMonitor::UpdateConnectionStatusL TV is connected"); |
|
245 iTvOutConnectionState = ETrue; |
|
246 } |
|
247 } |
247 } |
248 } |
248 } |
249 CleanupStack::PopAndDestroy(nameArray); |
249 |
250 |
250 |
251 GLX_LOG_INFO2("CGlxTvConnectionMonitor::UpdateConnectionStatusL CurrentTvState = %d , CurrentHDMIState = %d", |
251 |
252 iTvOutConnectionState,iHDMIConnectionState); |
252 |
253 } |