18 |
18 |
19 /** @file |
19 /** @file |
20 @internalComponent |
20 @internalComponent |
21 */ |
21 */ |
22 |
22 |
|
23 #include <usb/usblogger.h> |
23 #include "chargingstates.h" |
24 #include "chargingstates.h" |
24 #include <usb/usblogger.h> |
|
25 #include "reenumerator.h" |
25 #include "reenumerator.h" |
26 |
26 #include "OstTraceDefinitions.h" |
27 #ifdef __FLOG_ACTIVE |
27 #ifdef OST_TRACE_COMPILER_IN_USE |
28 _LIT8(KLogComponent, "USBCHARGEStates"); |
28 #include "chargingstatesTraces.h" |
29 #endif |
29 #endif |
|
30 |
|
31 |
30 |
32 |
31 // Charging plugin base state |
33 // Charging plugin base state |
32 |
34 |
33 // Empty virtual function implement to give a base of each state class. |
35 // Empty virtual function implement to give a base of each state class. |
34 // A concrete state class can overlap them according to actual demand. |
36 // A concrete state class can overlap them according to actual demand. |
35 void TUsbBatteryChargingPluginStateBase::UsbServiceStateChange(TInt aLastError, |
37 void TUsbBatteryChargingPluginStateBase::UsbServiceStateChange(TInt aLastError, |
36 TUsbServiceState aOldState, TUsbServiceState aNewState) |
38 TUsbServiceState aOldState, TUsbServiceState aNewState) |
37 { |
39 { |
38 LOG_FUNC |
40 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_USBSERVICESTATECHANGE_ENTRY ); |
39 |
41 |
40 (void)aLastError; |
42 (void)aLastError; |
41 (void)aOldState; |
43 (void)aOldState; |
42 (void)aNewState; |
44 (void)aNewState; |
43 |
45 |
44 // Not use |
46 // Not use |
|
47 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_USBSERVICESTATECHANGE_EXIT ); |
45 } |
48 } |
46 |
49 |
47 void TUsbBatteryChargingPluginStateBase::UsbDeviceStateChange(TInt aLastError, |
50 void TUsbBatteryChargingPluginStateBase::UsbDeviceStateChange(TInt aLastError, |
48 TUsbDeviceState aOldState, TUsbDeviceState aNewState) |
51 TUsbDeviceState aOldState, TUsbDeviceState aNewState) |
49 { |
52 { |
50 LOG_FUNC |
53 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_USBDEVICESTATECHANGE_ENTRY ); |
51 |
54 |
52 (void)aLastError; |
55 (void)aLastError; |
53 (void)aOldState; |
56 (void)aOldState; |
54 (void)aNewState; |
57 (void)aNewState; |
|
58 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_USBDEVICESTATECHANGE_EXIT ); |
55 } |
59 } |
56 |
60 |
57 void TUsbBatteryChargingPluginStateBase::HandleRepositoryValueChangedL( |
61 void TUsbBatteryChargingPluginStateBase::HandleRepositoryValueChangedL( |
58 const TUid& aRepository, TUint aId, TInt aVal) |
62 const TUid& aRepository, TUint aId, TInt aVal) |
59 { |
63 { |
60 LOG_FUNC |
64 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_HANDLEREPOSITORYVALUECHANGEDL_ENTRY ); |
61 |
65 |
62 LOGTEXT4(_L8(">>TUsbBatteryChargingPluginStateBase::HandleRepositoryValueChangedL aRepository = 0x%08x, aId = %d, aVal = %d"), aRepository, aId, aVal); |
66 OstTraceExt3( TRACE_NORMAL, REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_HANDLEREPOSITORYVALUECHANGEDL, |
63 LOGTEXT3(_L8("Plugin State = %d, Device State = %d"), iParent.iPluginState, iParent.iDeviceState); |
67 "TUsbBatteryChargingPluginStateBase::HandleRepositoryValueChangedL;aRepository = 0x%08x;aId=%d;aVal=%d", |
|
68 aRepository.iUid, aId, (TInt32)aVal ); |
|
69 OstTraceExt2( TRACE_NORMAL, REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_HANDLEREPOSITORYVALUECHANGEDL_DUP1, |
|
70 "TUsbBatteryChargingPluginStateBase::HandleRepositoryValueChangedL;Plugin State = %d, Device State = %d", |
|
71 iParent.iPluginState, iParent.iDeviceState ); |
64 |
72 |
65 if ((aRepository == KUsbBatteryChargingCentralRepositoryUid) && |
73 if ((aRepository == KUsbBatteryChargingCentralRepositoryUid) && |
66 (aId == KUsbBatteryChargingKeyEnabledUserSetting)) |
74 (aId == KUsbBatteryChargingKeyEnabledUserSetting)) |
67 { |
75 { |
68 iParent.iUserSetting = (TUsbBatteryChargingUserSetting)aVal; |
76 iParent.iUserSetting = (TUsbBatteryChargingUserSetting)aVal; |
83 } |
91 } |
84 |
92 |
85 iParent.SetState(EPluginStateUserDisabled); |
93 iParent.SetState(EPluginStateUserDisabled); |
86 } |
94 } |
87 } |
95 } |
|
96 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_HANDLEREPOSITORYVALUECHANGEDL_EXIT ); |
88 } |
97 } |
89 |
98 |
90 void TUsbBatteryChargingPluginStateBase::DeviceStateTimeout() |
99 void TUsbBatteryChargingPluginStateBase::DeviceStateTimeout() |
91 { |
100 { |
92 LOG_FUNC |
101 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_DEVICESTATETIMEOUT_ENTRY ); |
93 LOGTEXT4(_L8("Time: %d Plugin State = %d, Device State = %d"), User::NTickCount(), iParent.iPluginState, iParent.iDeviceState); |
102 OstTraceExt3( TRACE_NORMAL, REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_DEVICESTATETIMEOUT, "TUsbBatteryChargingPluginStateBase::DeviceStateTimeout;Time: %u Plugin State = %d, Device State = %d", User::NTickCount(), (TInt32)iParent.iPluginState, (TInt32)iParent.iDeviceState ); |
94 |
103 |
95 iParent.iDeviceReEnumerator->Cancel(); // cancel re-enumeration AO |
104 iParent.iDeviceReEnumerator->Cancel(); // cancel re-enumeration AO |
96 |
105 |
97 if(iParent.iUserSetting) // User allow charging already and not in negotiating process... |
106 if(iParent.iUserSetting) // User allow charging already and not in negotiating process... |
98 { |
107 { |
99 // Should not happen !!! Otherwise, something wrong!!! |
108 // Should not happen !!! Otherwise, something wrong!!! |
100 iParent.SetState(EPluginStateIdle); |
109 iParent.SetState(EPluginStateIdle); |
101 } |
110 } |
|
111 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_DEVICESTATETIMEOUT_EXIT ); |
102 } |
112 } |
103 |
113 |
104 // For host OTG enabled charging plug-in |
114 // For host OTG enabled charging plug-in |
105 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
115 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
106 void TUsbBatteryChargingPluginStateBase::MpsoIdPinStateChanged(TInt aValue) |
116 void TUsbBatteryChargingPluginStateBase::MpsoIdPinStateChanged(TInt aValue) |
107 { |
117 { |
108 LOG_FUNC |
118 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_MPSOIDPINSTATECHANGED_ENTRY ); |
109 |
119 |
110 LOGTEXT2(_L8("IdPinState changed => %d"), aValue); |
120 OstTrace1( TRACE_NORMAL, REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_MPSOIDPINSTATECHANGED, "TUsbBatteryChargingPluginStateBase::MpsoIdPinStateChanged;IdPinState changed => %d", aValue ); |
111 |
121 |
112 // Disable charging here when IdPin is present |
122 // Disable charging here when IdPin is present |
113 // When IdPin disappears (i.e. the phone becomes B-Device), all necessary step are performed |
123 // When IdPin disappears (i.e. the phone becomes B-Device), all necessary step are performed |
114 // in UsbDeviceStateChange() method |
124 // in UsbDeviceStateChange() method |
115 |
125 |
139 iParent.StopCharging(); |
150 iParent.StopCharging(); |
140 } |
151 } |
141 iParent.SetState(EPluginStateIdle); |
152 iParent.SetState(EPluginStateIdle); |
142 break; |
153 break; |
143 } |
154 } |
|
155 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_MPSOIDPINSTATECHANGED_EXIT_DUP1 ); |
144 } |
156 } |
145 |
157 |
146 void TUsbBatteryChargingPluginStateBase::MpsoOtgStateChangedL(TUsbOtgState aNewState) |
158 void TUsbBatteryChargingPluginStateBase::MpsoOtgStateChangedL(TUsbOtgState aNewState) |
147 { |
159 { |
148 LOG_FUNC |
160 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_MPSOOTGSTATECHANGEDL_ENTRY ); |
149 |
161 |
150 iParent.iOtgState = aNewState; |
162 iParent.iOtgState = aNewState; |
151 |
163 |
152 // Not use currently |
164 // Not use currently |
|
165 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_MPSOOTGSTATECHANGEDL_EXIT ); |
153 } |
166 } |
154 #endif |
167 #endif |
155 |
168 |
156 void TUsbBatteryChargingPluginStateBase::MpsoVBusStateChanged(TInt aNewState) |
169 void TUsbBatteryChargingPluginStateBase::MpsoVBusStateChanged(TInt aNewState) |
157 { |
170 { |
158 LOG_FUNC |
171 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_MPSOVBUSSTATECHANGED_ENTRY ); |
159 |
172 |
160 if (aNewState == iParent.iVBusState) |
173 if (aNewState == iParent.iVBusState) |
161 { |
174 { |
162 LOGTEXT2(_L8("Receive VBus State Change notification without any state change: aNewState = %d"), aNewState); |
175 OstTrace1( TRACE_NORMAL, REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_MPSOVBUSSTATECHANGED, "TUsbBatteryChargingPluginStateBase::MpsoVBusStateChanged;Receive VBus State Change notification without any state change: aNewState = %d", aNewState ); |
|
176 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_MPSOVBUSSTATECHANGED_EXIT ); |
163 return;//should not happen?? |
177 return;//should not happen?? |
164 } |
178 } |
165 |
179 |
166 LOGTEXT3(_L8("VBusState changed from %d to %d"), iParent.iVBusState, aNewState); |
180 OstTraceExt2( TRACE_NORMAL, REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_MPSOVBUSSTATECHANGED_DUP1, "TUsbBatteryChargingPluginStateBase::MpsoVBusStateChanged;VBusState changed from %d to %d", iParent.iVBusState, aNewState ); |
167 |
181 |
168 iParent.iVBusState = aNewState; |
182 iParent.iVBusState = aNewState; |
169 if (aNewState == 0) // VBus drop down - we have disconnected from host |
183 if (aNewState == 0) // VBus drop down - we have disconnected from host |
170 { |
184 { |
171 if (iParent.iPluginState == EPluginStateCharging) |
185 if (iParent.iPluginState == EPluginStateCharging) |
174 } |
188 } |
175 iParent.SetState(EPluginStateIdle); |
189 iParent.SetState(EPluginStateIdle); |
176 } |
190 } |
177 |
191 |
178 // The handling of VBus on will be down in DeviceStateChanged implicitly |
192 // The handling of VBus on will be down in DeviceStateChanged implicitly |
|
193 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_MPSOVBUSSTATECHANGED_EXIT_DUP1 ); |
179 } |
194 } |
180 |
195 |
181 |
196 |
182 TUsbBatteryChargingPluginStateBase::TUsbBatteryChargingPluginStateBase ( |
197 TUsbBatteryChargingPluginStateBase::TUsbBatteryChargingPluginStateBase ( |
183 CUsbBatteryChargingPlugin& aParentStateMachine ): |
198 CUsbBatteryChargingPlugin& aParentStateMachine ): |
184 iParent(aParentStateMachine) |
199 iParent(aParentStateMachine) |
185 { |
200 { |
186 LOG_FUNC |
201 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_TUSBBATTERYCHARGINGPLUGINSTATEBASE_CONS_ENTRY ); |
|
202 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATEBASE_TUSBBATTERYCHARGINGPLUGINSTATEBASE_CONS_EXIT ); |
187 } |
203 } |
188 |
204 |
189 |
205 |
190 // Charging plugin idle state |
206 // Charging plugin idle state |
191 |
207 |
192 TUsbBatteryChargingPluginStateIdle::TUsbBatteryChargingPluginStateIdle ( |
208 TUsbBatteryChargingPluginStateIdle::TUsbBatteryChargingPluginStateIdle ( |
193 CUsbBatteryChargingPlugin& aParentStateMachine ) : |
209 CUsbBatteryChargingPlugin& aParentStateMachine ) : |
194 TUsbBatteryChargingPluginStateBase(aParentStateMachine) |
210 TUsbBatteryChargingPluginStateBase(aParentStateMachine) |
195 { |
211 { |
196 LOG_FUNC |
212 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATEIDLE_TUSBBATTERYCHARGINGPLUGINSTATEIDLE_CONS_ENTRY ); |
|
213 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATEIDLE_TUSBBATTERYCHARGINGPLUGINSTATEIDLE_CONS_EXIT ); |
197 }; |
214 }; |
198 |
215 |
199 void TUsbBatteryChargingPluginStateIdle::UsbDeviceStateChange( |
216 void TUsbBatteryChargingPluginStateIdle::UsbDeviceStateChange( |
200 TInt aLastError, TUsbDeviceState aOldState, TUsbDeviceState aNewState) |
217 TInt aLastError, TUsbDeviceState aOldState, TUsbDeviceState aNewState) |
201 { |
218 { |
202 LOG_FUNC |
219 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATEIDLE_USBDEVICESTATECHANGE_ENTRY ); |
203 |
220 |
204 LOGTEXT4(_L8(">>TUsbBatteryChargingPluginStateIdle::UsbDeviceStateChange LastError = %d, aOldState = %d, aNewState = %d"), aLastError, aOldState, aNewState); |
221 OstTraceExt3( TRACE_NORMAL, REF_TUSBBATTERYCHARGINGPLUGINSTATEIDLE_USBDEVICESTATECHANGE, "TUsbBatteryChargingPluginStateIdle::UsbDeviceStateChange;aLastError=%d;aOldState=%d;aNewState=%d", aLastError, aOldState, aNewState ); |
205 (void)aLastError; |
222 (void)aLastError; |
206 (void)aOldState; |
223 (void)aOldState; |
207 iParent.iDeviceState = aNewState; |
224 iParent.iDeviceState = aNewState; |
208 iParent.LogStateText(aNewState); |
225 iParent.LogStateText(aNewState); |
209 |
226 |
223 iParent.SetState(EPluginStateUserDisabled); |
240 iParent.SetState(EPluginStateUserDisabled); |
224 } |
241 } |
225 } |
242 } |
226 break; |
243 break; |
227 } |
244 } |
|
245 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATEIDLE_USBDEVICESTATECHANGE_EXIT ); |
228 } |
246 } |
229 |
247 |
230 |
248 |
231 // Charging plugin current negotiating state |
249 // Charging plugin current negotiating state |
232 |
250 |
233 TUsbBatteryChargingPluginStateCurrentNegotiating::TUsbBatteryChargingPluginStateCurrentNegotiating ( |
251 TUsbBatteryChargingPluginStateCurrentNegotiating::TUsbBatteryChargingPluginStateCurrentNegotiating ( |
234 CUsbBatteryChargingPlugin& aParentStateMachine ) : |
252 CUsbBatteryChargingPlugin& aParentStateMachine ) : |
235 TUsbBatteryChargingPluginStateBase(aParentStateMachine) |
253 TUsbBatteryChargingPluginStateBase(aParentStateMachine) |
236 { |
254 { |
237 LOG_FUNC |
255 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATECURRENTNEGOTIATING_TUSBBATTERYCHARGINGPLUGINSTATECURRENTNEGOTIATING_CONS_ENTRY ); |
|
256 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATECURRENTNEGOTIATING_TUSBBATTERYCHARGINGPLUGINSTATECURRENTNEGOTIATING_CONS_EXIT ); |
238 }; |
257 }; |
239 |
258 |
240 void TUsbBatteryChargingPluginStateCurrentNegotiating::UsbDeviceStateChange( |
259 void TUsbBatteryChargingPluginStateCurrentNegotiating::UsbDeviceStateChange( |
241 TInt aLastError, TUsbDeviceState aOldState, TUsbDeviceState aNewState) |
260 TInt aLastError, TUsbDeviceState aOldState, TUsbDeviceState aNewState) |
242 { |
261 { |
243 LOG_FUNC |
262 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATECURRENTNEGOTIATING_USBDEVICESTATECHANGE_ENTRY ); |
244 |
263 |
245 LOGTEXT4(_L8(">>TUsbBatteryChargingPluginStateCurrentNegotiating::UsbDeviceStateChange LastError = %d, aOldState = %d, aNewState = %d"), aLastError, aOldState, aNewState); |
264 OstTraceExt3( TRACE_NORMAL, REF_TUSBBATTERYCHARGINGPLUGINSTATECURRENTNEGOTIATING_USBDEVICESTATECHANGE, "TUsbBatteryChargingPluginStateCurrentNegotiating::UsbDeviceStateChange;aLastError=%d;aOldState=%d;aNewState=%d", aLastError, aOldState, aNewState ); |
246 (void)aLastError; |
265 (void)aLastError; |
247 (void)aOldState; |
266 (void)aOldState; |
248 iParent.iDeviceState = aNewState; |
267 iParent.iDeviceState = aNewState; |
249 iParent.LogStateText(aNewState); |
268 iParent.LogStateText(aNewState); |
250 |
269 |
253 case EUsbDeviceStateConfigured: |
272 case EUsbDeviceStateConfigured: |
254 if (iParent.IsUsbChargingPossible()) |
273 if (iParent.IsUsbChargingPossible()) |
255 { |
274 { |
256 iParent.iDeviceStateTimer->Cancel(); |
275 iParent.iDeviceStateTimer->Cancel(); |
257 |
276 |
258 LOGTEXT2(_L8("iParent.iAvailableMilliAmps = %d"),iParent.iAvailableMilliAmps); |
277 OstTrace1( TRACE_NORMAL, REF_TUSBBATTERYCHARGINGPLUGINSTATECURRENTNEGOTIATING_USBDEVICESTATECHANGE_DUP1, "TUsbBatteryChargingPluginStateCurrentNegotiating::UsbDeviceStateChange;iParent.iAvailableMilliAmps=%d", iParent.iAvailableMilliAmps ); |
259 iParent.iAvailableMilliAmps = iParent.iRequestedCurrentValue; |
278 iParent.iAvailableMilliAmps = iParent.iRequestedCurrentValue; |
260 |
279 |
261 if(0 != iParent.iRequestedCurrentValue) |
280 if(0 != iParent.iRequestedCurrentValue) |
262 { |
281 { |
263 // A non-zero value was accepted by host, charging |
282 // A non-zero value was accepted by host, charging |
264 // can be performed now. |
283 // can be performed now. |
265 iParent.StartCharging(iParent.iAvailableMilliAmps); |
284 iParent.StartCharging(iParent.iAvailableMilliAmps); |
266 LOGTEXT2(_L8("PluginState => EPluginStateCharging(%d)"),iParent.iPluginState); |
285 OstTrace1( TRACE_NORMAL, REF_TUSBBATTERYCHARGINGPLUGINSTATECURRENTNEGOTIATING_USBDEVICESTATECHANGE_DUP2, "TUsbBatteryChargingPluginStateCurrentNegotiating::UsbDeviceStateChange;PluginState => EPluginStateCharging(%d)", iParent.iPluginState ); |
267 iParent.SetNegotiatedCurrent(iParent.iAvailableMilliAmps); |
286 iParent.SetNegotiatedCurrent(iParent.iAvailableMilliAmps); |
268 } |
287 } |
269 else |
288 else |
270 { |
289 { |
271 // Host can only accept 0 charging current |
290 // Host can only accept 0 charging current |
272 // No way to do charging |
291 // No way to do charging |
273 iParent.SetState(EPluginStateNoValidCurrent); |
292 iParent.SetState(EPluginStateNoValidCurrent); |
274 LOGTEXT2(_L8("No more current value to try, iPluginState turned to %d"), iParent.iPluginState); |
293 OstTrace1( TRACE_NORMAL, REF_TUSBBATTERYCHARGINGPLUGINSTATECURRENTNEGOTIATING_USBDEVICESTATECHANGE_DUP3, "TUsbBatteryChargingPluginStateCurrentNegotiating::UsbDeviceStateChange;No more current value to try, iPluginState turned to %d", iParent.iPluginState ); |
275 } |
294 } |
276 } |
295 } |
277 |
296 |
278 break; |
297 break; |
279 |
298 |
283 |
302 |
284 |
303 |
285 default: |
304 default: |
286 break; |
305 break; |
287 } |
306 } |
|
307 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATECURRENTNEGOTIATING_USBDEVICESTATECHANGE_EXIT ); |
288 } |
308 } |
289 |
309 |
290 void TUsbBatteryChargingPluginStateCurrentNegotiating::DeviceStateTimeout() |
310 void TUsbBatteryChargingPluginStateCurrentNegotiating::DeviceStateTimeout() |
291 { |
311 { |
292 LOG_FUNC |
312 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATECURRENTNEGOTIATING_DEVICESTATETIMEOUT_ENTRY ); |
293 LOGTEXT4(_L8("Time: %d Plugin State = %d, Device State = %d"), User::NTickCount(), iParent.iPluginState, iParent.iDeviceState); |
313 OstTraceExt3( TRACE_NORMAL, REF_TUSBBATTERYCHARGINGPLUGINSTATECURRENTNEGOTIATING_DEVICESTATETIMEOUT, "TUsbBatteryChargingPluginStateCurrentNegotiating::DeviceStateTimeout;Time: %d Plugin State = %d, Device State = %d", User::NTickCount(), (TInt32)iParent.iPluginState, (TInt32)iParent.iDeviceState ); |
294 |
314 |
295 iParent.iDeviceReEnumerator->Cancel(); // cancel re-enumeration AO |
315 iParent.iDeviceReEnumerator->Cancel(); // cancel re-enumeration AO |
296 |
316 |
297 if(iParent.iRequestedCurrentValue != 0) |
317 if(iParent.iRequestedCurrentValue != 0) |
298 { |
318 { |
303 { |
323 { |
304 // The Host doesn't accept 0ma power request? |
324 // The Host doesn't accept 0ma power request? |
305 // Assume it will never happens. |
325 // Assume it will never happens. |
306 iParent.SetState(EPluginStateNoValidCurrent); |
326 iParent.SetState(EPluginStateNoValidCurrent); |
307 } |
327 } |
|
328 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATECURRENTNEGOTIATING_DEVICESTATETIMEOUT_EXIT ); |
308 } |
329 } |
309 |
330 |
310 |
331 |
311 // Charging plugin charing state |
332 // Charging plugin charing state |
312 |
333 |
313 |
334 |
314 TUsbBatteryChargingPluginStateCharging::TUsbBatteryChargingPluginStateCharging ( |
335 TUsbBatteryChargingPluginStateCharging::TUsbBatteryChargingPluginStateCharging ( |
315 CUsbBatteryChargingPlugin& aParentStateMachine ) : |
336 CUsbBatteryChargingPlugin& aParentStateMachine ) : |
316 TUsbBatteryChargingPluginStateBase(aParentStateMachine) |
337 TUsbBatteryChargingPluginStateBase(aParentStateMachine) |
317 { |
338 { |
318 LOG_FUNC |
339 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATECHARGING_TUSBBATTERYCHARGINGPLUGINSTATECHARGING_CONS_ENTRY ); |
|
340 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATECHARGING_TUSBBATTERYCHARGINGPLUGINSTATECHARGING_CONS_EXIT ); |
319 } |
341 } |
320 |
342 |
321 void TUsbBatteryChargingPluginStateCharging::UsbDeviceStateChange( |
343 void TUsbBatteryChargingPluginStateCharging::UsbDeviceStateChange( |
322 TInt aLastError, TUsbDeviceState aOldState, TUsbDeviceState aNewState) |
344 TInt aLastError, TUsbDeviceState aOldState, TUsbDeviceState aNewState) |
323 { |
345 { |
324 LOG_FUNC |
346 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATECHARGING_USBDEVICESTATECHANGE_ENTRY ); |
325 |
347 |
326 LOGTEXT4(_L8(">>TUsbBatteryChargingPluginStateCharging::UsbDeviceStateChange LastError = %d, aOldState = %d, aNewState = %d"), aLastError, aOldState, aNewState); |
348 OstTraceExt3( TRACE_NORMAL, REF_TUSBBATTERYCHARGINGPLUGINSTATECHARGING_USBDEVICESTATECHANGE, "TUsbBatteryChargingPluginStateCharging::UsbDeviceStateChange;aLastError=%d;aOldState=%d;aNewState=%d", aLastError, aOldState, aNewState ); |
327 (void)aLastError; |
349 (void)aLastError; |
328 (void)aOldState; |
350 (void)aOldState; |
329 iParent.iDeviceState = aNewState; |
351 iParent.iDeviceState = aNewState; |
330 iParent.LogStateText(aNewState); |
352 iParent.LogStateText(aNewState); |
331 |
353 |
347 break; |
369 break; |
348 |
370 |
349 default: |
371 default: |
350 break; |
372 break; |
351 } |
373 } |
|
374 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATECHARGING_USBDEVICESTATECHANGE_EXIT ); |
352 } |
375 } |
353 |
376 |
354 // Charging plugin negotiated fail state |
377 // Charging plugin negotiated fail state |
355 |
378 |
356 |
379 |
357 TUsbBatteryChargingPluginStateNoValidCurrent::TUsbBatteryChargingPluginStateNoValidCurrent ( |
380 TUsbBatteryChargingPluginStateNoValidCurrent::TUsbBatteryChargingPluginStateNoValidCurrent ( |
358 CUsbBatteryChargingPlugin& aParentStateMachine ) : |
381 CUsbBatteryChargingPlugin& aParentStateMachine ) : |
359 TUsbBatteryChargingPluginStateBase(aParentStateMachine) |
382 TUsbBatteryChargingPluginStateBase(aParentStateMachine) |
360 { |
383 { |
361 LOG_FUNC |
384 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATENOVALIDCURRENT_TUSBBATTERYCHARGINGPLUGINSTATENOVALIDCURRENT_CONS_ENTRY ); |
|
385 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATENOVALIDCURRENT_TUSBBATTERYCHARGINGPLUGINSTATENOVALIDCURRENT_CONS_EXIT ); |
362 }; |
386 }; |
363 |
387 |
364 |
388 |
365 // Charging plugin idle negotiated state |
389 // Charging plugin idle negotiated state |
366 |
390 |
367 TUsbBatteryChargingPluginStateIdleNegotiated::TUsbBatteryChargingPluginStateIdleNegotiated ( |
391 TUsbBatteryChargingPluginStateIdleNegotiated::TUsbBatteryChargingPluginStateIdleNegotiated ( |
368 CUsbBatteryChargingPlugin& aParentStateMachine ) : |
392 CUsbBatteryChargingPlugin& aParentStateMachine ) : |
369 TUsbBatteryChargingPluginStateBase(aParentStateMachine) |
393 TUsbBatteryChargingPluginStateBase(aParentStateMachine) |
370 { |
394 { |
371 LOG_FUNC |
395 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATEIDLENEGOTIATED_TUSBBATTERYCHARGINGPLUGINSTATEIDLENEGOTIATED_CONS_ENTRY ); |
|
396 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATEIDLENEGOTIATED_TUSBBATTERYCHARGINGPLUGINSTATEIDLENEGOTIATED_CONS_EXIT ); |
372 }; |
397 }; |
373 |
398 |
374 void TUsbBatteryChargingPluginStateIdleNegotiated::UsbDeviceStateChange( |
399 void TUsbBatteryChargingPluginStateIdleNegotiated::UsbDeviceStateChange( |
375 TInt aLastError, TUsbDeviceState aOldState, TUsbDeviceState aNewState) |
400 TInt aLastError, TUsbDeviceState aOldState, TUsbDeviceState aNewState) |
376 { |
401 { |
377 LOG_FUNC |
402 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATEIDLENEGOTIATED_USBDEVICESTATECHANGE_ENTRY ); |
378 |
403 |
379 LOGTEXT4(_L8(">>TUsbBatteryChargingPluginStateIdleNegotiated::UsbDeviceStateChange LastError = %d, aOldState = %d, aNewState = %d"), aLastError, aOldState, aNewState); |
404 OstTraceExt3( TRACE_NORMAL, REF_TUSBBATTERYCHARGINGPLUGINSTATEIDLENEGOTIATED_USBDEVICESTATECHANGE, "TUsbBatteryChargingPluginStateIdleNegotiated::UsbDeviceStateChange;aLastError=%d;aOldState=%d;aNewState=%d", aLastError, aOldState, aNewState ); |
380 (void)aLastError; |
405 (void)aLastError; |
381 (void)aOldState; |
406 (void)aOldState; |
382 iParent.iDeviceState = aNewState; |
407 iParent.iDeviceState = aNewState; |
383 iParent.LogStateText(aNewState); |
408 iParent.LogStateText(aNewState); |
384 |
409 |
395 break; |
420 break; |
396 |
421 |
397 default: |
422 default: |
398 break; |
423 break; |
399 } |
424 } |
|
425 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATEIDLENEGOTIATED_USBDEVICESTATECHANGE_EXIT ); |
400 } |
426 } |
401 |
427 |
402 // Charging plugin user disabled state |
428 // Charging plugin user disabled state |
403 |
429 |
404 TUsbBatteryChargingPluginStateUserDisabled::TUsbBatteryChargingPluginStateUserDisabled ( |
430 TUsbBatteryChargingPluginStateUserDisabled::TUsbBatteryChargingPluginStateUserDisabled ( |
405 CUsbBatteryChargingPlugin& aParentStateMachine ) : |
431 CUsbBatteryChargingPlugin& aParentStateMachine ) : |
406 TUsbBatteryChargingPluginStateBase(aParentStateMachine) |
432 TUsbBatteryChargingPluginStateBase(aParentStateMachine) |
407 { |
433 { |
408 LOG_FUNC |
434 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATEUSERDISABLED_TUSBBATTERYCHARGINGPLUGINSTATEUSERDISABLED_CONS_ENTRY ); |
|
435 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATEUSERDISABLED_TUSBBATTERYCHARGINGPLUGINSTATEUSERDISABLED_CONS_EXIT ); |
409 }; |
436 }; |
410 |
437 |
411 |
438 |
412 void TUsbBatteryChargingPluginStateUserDisabled::UsbDeviceStateChange( |
439 void TUsbBatteryChargingPluginStateUserDisabled::UsbDeviceStateChange( |
413 TInt aLastError, TUsbDeviceState aOldState, TUsbDeviceState aNewState) |
440 TInt aLastError, TUsbDeviceState aOldState, TUsbDeviceState aNewState) |
414 { |
441 { |
415 LOG_FUNC |
442 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATEUSERDISABLED_USBDEVICESTATECHANGE_ENTRY ); |
416 |
443 |
417 LOGTEXT4(_L8(">>TUsbBatteryChargingPluginStateUserDisabled::UsbDeviceStateChange LastError = %d, aOldState = %d, aNewState = %d"), aLastError, aOldState, aNewState); |
444 OstTraceExt3( TRACE_NORMAL, REF_TUSBBATTERYCHARGINGPLUGINSTATEUSERDISABLED_USBDEVICESTATECHANGE, "TUsbBatteryChargingPluginStateUserDisabled::UsbDeviceStateChange;aLastError=%d;aOldState=%d;aNewState=%d", aLastError, aOldState, aNewState ); |
418 (void)aLastError; |
445 (void)aLastError; |
419 (void)aOldState; |
446 (void)aOldState; |
420 iParent.iDeviceState = aNewState; |
447 iParent.iDeviceState = aNewState; |
421 iParent.LogStateText(aNewState); |
448 iParent.LogStateText(aNewState); |
|
449 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATEUSERDISABLED_USBDEVICESTATECHANGE_EXIT ); |
422 } |
450 } |
423 |
451 |
424 void TUsbBatteryChargingPluginStateUserDisabled::HandleRepositoryValueChangedL( |
452 void TUsbBatteryChargingPluginStateUserDisabled::HandleRepositoryValueChangedL( |
425 const TUid& aRepository, TUint aId, TInt aVal) |
453 const TUid& aRepository, TUint aId, TInt aVal) |
426 { |
454 { |
427 LOG_FUNC |
455 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATEUSERDISABLED_HANDLEREPOSITORYVALUECHANGEDL_ENTRY ); |
428 |
456 |
429 LOGTEXT4(_L8(">>TUsbBatteryChargingPluginStateUserDisabled::HandleRepositoryValueChangedL aRepository = 0x%08x, aId = %d, aVal = %d"), aRepository, aId, aVal); |
457 OstTrace1( TRACE_NORMAL, REF_TUSBBATTERYCHARGINGPLUGINSTATEUSERDISABLED_HANDLEREPOSITORYVALUECHANGEDL, "TUsbBatteryChargingPluginStateUserDisabled::HandleRepositoryValueChangedL;aRepository = 0x%08x", aRepository.iUid ); |
430 LOGTEXT3(_L8("Plugin State = %d, Device State = %d"), iParent.iPluginState, iParent.iDeviceState); |
458 OstTraceExt2( TRACE_NORMAL, REF_TUSBBATTERYCHARGINGPLUGINSTATEUSERDISABLED_HANDLEREPOSITORYVALUECHANGEDL_DUP1, "TUsbBatteryChargingPluginStateUserDisabled::HandleRepositoryValueChangedL;aId=%d;aVal=%d", aId, aVal ); |
|
459 OstTraceExt2( TRACE_NORMAL, REF_TUSBBATTERYCHARGINGPLUGINSTATEUSERDISABLED_HANDLEREPOSITORYVALUECHANGEDL_DUP2, "TUsbBatteryChargingPluginStateUserDisabled::HandleRepositoryValueChangedL;iParent.iPluginState=%d;iParent.iDeviceState=%d", iParent.iPluginState, iParent.iDeviceState ); |
431 |
460 |
432 if ((aRepository == KUsbBatteryChargingCentralRepositoryUid) && |
461 if ((aRepository == KUsbBatteryChargingCentralRepositoryUid) && |
433 (aId == KUsbBatteryChargingKeyEnabledUserSetting)) |
462 (aId == KUsbBatteryChargingKeyEnabledUserSetting)) |
434 { |
463 { |
435 iParent.iUserSetting = (TUsbBatteryChargingUserSetting)aVal; |
464 iParent.iUserSetting = (TUsbBatteryChargingUserSetting)aVal; |
441 if ((iParent.iPluginState == EPluginStateIdleNegotiated) |
470 if ((iParent.iPluginState == EPluginStateIdleNegotiated) |
442 && (iParent.iDeviceState == EUsbDeviceStateConfigured)) |
471 && (iParent.iDeviceState == EUsbDeviceStateConfigured)) |
443 { |
472 { |
444 iParent.StartCharging(iParent.iAvailableMilliAmps); // Go to charing state implicitly |
473 iParent.StartCharging(iParent.iAvailableMilliAmps); // Go to charing state implicitly |
445 } |
474 } |
446 LOGTEXT2(_L8("PluginState => %d"), iParent.iPluginState); |
475 OstTrace1( TRACE_NORMAL, REF_TUSBBATTERYCHARGINGPLUGINSTATEUSERDISABLED_HANDLEREPOSITORYVALUECHANGEDL_DUP3, "TUsbBatteryChargingPluginStateUserDisabled::HandleRepositoryValueChangedL;PluginState => %d", iParent.iPluginState ); |
447 } |
476 } |
448 } |
477 } |
|
478 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATEUSERDISABLED_HANDLEREPOSITORYVALUECHANGEDL_EXIT ); |
449 } |
479 } |
450 |
480 |
451 // For host OTG enabled charging plug-in |
481 // For host OTG enabled charging plug-in |
452 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
482 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
453 void TUsbBatteryChargingPluginStateUserDisabled::MpsoIdPinStateChanged(TInt aValue) |
483 void TUsbBatteryChargingPluginStateUserDisabled::MpsoIdPinStateChanged(TInt aValue) |
454 { |
484 { |
455 LOG_FUNC |
485 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATEUSERDISABLED_MPSOIDPINSTATECHANGED_ENTRY ); |
456 |
486 |
457 LOGTEXT2(_L8("IdPinState changed => %d"), aValue); |
487 OstTrace1( TRACE_NORMAL, REF_TUSBBATTERYCHARGINGPLUGINSTATEUSERDISABLED_MPSOIDPINSTATECHANGED, "TUsbBatteryChargingPluginStateUserDisabled::MpsoIdPinStateChanged;IdPinState changed => %d", aValue ); |
458 |
488 |
459 // Disable charging here when IdPin is present |
489 // Disable charging here when IdPin is present |
460 // When IdPin disappears (i.e. the phone becomes B-Device), all necessary step are performed |
490 // When IdPin disappears (i.e. the phone becomes B-Device), all necessary step are performed |
461 // in UsbDeviceStateChange() method |
491 // in UsbDeviceStateChange() method |
462 |
492 |
466 { |
496 { |
467 case EUsbBatteryChargingIdPinARole: |
497 case EUsbBatteryChargingIdPinARole: |
468 TRAP_IGNORE(iParent.SetInitialConfigurationL()); |
498 TRAP_IGNORE(iParent.SetInitialConfigurationL()); |
469 iParent.PushRecoverState(EPluginStateBEndedCableNotPresent); |
499 iParent.PushRecoverState(EPluginStateBEndedCableNotPresent); |
470 |
500 |
|
501 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATEUSERDISABLED_MPSOIDPINSTATECHANGED_EXIT ); |
471 return; |
502 return; |
472 |
503 |
473 case EUsbBatteryChargingIdPinBRole: |
504 case EUsbBatteryChargingIdPinBRole: |
474 iParent.PushRecoverState(EPluginStateIdle); |
505 iParent.PushRecoverState(EPluginStateIdle); |
475 break; |
506 break; |
476 |
507 |
477 default: |
508 default: |
478 iParent.SetState(EPluginStateIdle); |
509 iParent.SetState(EPluginStateIdle); |
479 break; |
510 break; |
480 } |
511 } |
|
512 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATEUSERDISABLED_MPSOIDPINSTATECHANGED_EXIT_DUP1 ); |
481 } |
513 } |
482 |
514 |
483 #endif |
515 #endif |
484 |
516 |
485 void TUsbBatteryChargingPluginStateUserDisabled::MpsoVBusStateChanged(TInt aNewState) |
517 void TUsbBatteryChargingPluginStateUserDisabled::MpsoVBusStateChanged(TInt aNewState) |
486 { |
518 { |
487 LOG_FUNC |
519 OstTraceFunctionEntry0( REF_TUSBBATTERYCHARGINGPLUGINSTATEUSERDISABLED_MPSOVBUSSTATECHANGED_ENTRY ); |
488 |
520 |
489 if (aNewState == iParent.iVBusState) |
521 if (aNewState == iParent.iVBusState) |
490 { |
522 { |
491 LOGTEXT2(_L8("Receive VBus State Change notification without any state change: aNewState = %d"), aNewState); |
523 OstTrace1( TRACE_NORMAL, REF_TUSBBATTERYCHARGINGPLUGINSTATEUSERDISABLED_MPSOVBUSSTATECHANGED, "TUsbBatteryChargingPluginStateUserDisabled::MpsoVBusStateChanged;Receive VBus State Change notification without any state change: aNewState = %d", aNewState ); |
|
524 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATEUSERDISABLED_MPSOVBUSSTATECHANGED_EXIT ); |
492 return; |
525 return; |
493 } |
526 } |
494 |
527 |
495 LOGTEXT3(_L8("VBusState changed from %d to %d"), iParent.iVBusState, aNewState); |
528 OstTraceExt2( TRACE_NORMAL, REF_TUSBBATTERYCHARGINGPLUGINSTATEUSERDISABLED_MPSOVBUSSTATECHANGED_DUP1, "TUsbBatteryChargingPluginStateUserDisabled::MpsoVBusStateChanged;VBusState changed from %d to %d", iParent.iVBusState, aNewState ); |
496 |
529 |
497 iParent.iVBusState = aNewState; |
530 iParent.iVBusState = aNewState; |
498 if (aNewState == 0) // VBus drop down - we have disconnected from host |
531 if (aNewState == 0) // VBus drop down - we have disconnected from host |
499 { |
532 { |
500 iParent.iRequestedCurrentValue = 0; |
533 iParent.iRequestedCurrentValue = 0; |
503 |
536 |
504 iParent.iPluginStateToRecovery = EPluginStateIdle; |
537 iParent.iPluginStateToRecovery = EPluginStateIdle; |
505 } |
538 } |
506 |
539 |
507 // The handling of VBus on will be down in DeviceStateChanged implicitly |
540 // The handling of VBus on will be down in DeviceStateChanged implicitly |
|
541 OstTraceFunctionExit0( REF_TUSBBATTERYCHARGINGPLUGINSTATEUSERDISABLED_MPSOVBUSSTATECHANGED_EXIT_DUP1 ); |
508 } |
542 } |
509 |
543 |
510 |
544 |
511 // Charging plugin A-role state |
545 // Charging plugin A-role state |
512 |
546 |
513 TUsbBatteryChargingPluginStateBEndedCableNotPresent::TUsbBatteryChargingPluginStateBEndedCableNotPresent ( |
547 TUsbBatteryChargingPluginStateBEndedCableNotPresent::TUsbBatteryChargingPluginStateBEndedCableNotPresent ( |
514 CUsbBatteryChargingPlugin& aParentStateMachine ) : |
548 CUsbBatteryChargingPlugin& aParentStateMachine ) : |
515 TUsbBatteryChargingPluginStateBase(aParentStateMachine) |
549 TUsbBatteryChargingPluginStateBase(aParentStateMachine) |
516 { |
550 { |
517 LOG_FUNC |
551 OstTraceFunctionEntry0( RES_TUSBBATTERYCHARGINGPLUGINSTATEBENDEDCABLENOTPRESENT_TUSBBATTERYCHARGINGPLUGINSTATEBENDEDCABLENOTPRESENT_CONS_ENTRY ); |
|
552 OstTraceFunctionExit0( RES_TUSBBATTERYCHARGINGPLUGINSTATEBENDEDCABLENOTPRESENT_TUSBBATTERYCHARGINGPLUGINSTATEBENDEDCABLENOTPRESENT_CONS_EXIT ); |
518 }; |
553 }; |
519 |
554 |
520 |
555 |
521 |
556 |