2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup tag_SystemServices_DeviceDetection
19 /// \brief This file contains service interface functions.
21 ///////////////////////////////////////////////////////////////////////////////
22 #include "system_service/ss_devicedetection_service_ifc.h"
23 #include <native_service/frameworkunified_application.h>
24 #include <native_service/frameworkunified_framework_if.h>
25 #include <native_service/frameworkunified_types.h>
26 #include <native_service/frameworkunified_framework_types.h>
31 #include "dcmd_sim_mmcsd.h"
33 #include <sys/types.h>
40 #include <sys/dcmd_cam.h>
43 #include <sys/ioctl.h>
44 #include <linux/cdrom.h>
45 #include <asm-generic/param.h>
47 #include "system_service/ss_services.h"
48 #include "system_service/ss_devicedetection_service_protocol.h"
49 #include "system_service/ss_devicedetection_service_protocol_local.h"
50 #include "system_service/ss_devicedetection_service_notifications.h"
51 #include "system_service/ss_devicedetection_service_local.h"
52 #include "system_service/ss_devicedetection_service_types_local.h"
53 #include "ss_devicedetection_service_if_interfaceunifiedlog.h"
55 DeviceDetectionServiceIf::DeviceDetectionServiceIf()
61 DeviceDetectionServiceIf::~DeviceDetectionServiceIf() {
62 CloseSessionRequest(); // if the session is still connected
63 if ((NULL != m_hApp) && (NULL != m_hService)) {
64 FrameworkunifiedCloseService(m_hApp, m_hService);
69 } // LCOV_EXCL_BR_LINE 10:Because destructor
71 EFrameworkunifiedStatus DeviceDetectionServiceIf::NotifyOnDeviceDetectionAvailability(
72 CbFuncPtr f_pCallBackFn) {
73 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
74 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
75 if (NULL != m_hApp && NULL != f_pCallBackFn) {
77 FrameworkunifiedNotificationCallbackHandler
78 g_aryDeviceDetect_Notif_Cbs[] = {
79 // Notifications name, Call back function
80 { NTFY_SS_Device_Detection_Service_Availability, f_pCallBackFn},
83 if (0 != strcmp(SS_DEV_DETECT_SRV, FrameworkunifiedGetAppName(m_hApp))) {
84 // Subscribe and attach call backs to notifications
85 if (eFrameworkunifiedStatusOK
86 != (eStatus = FrameworkunifiedSubscribeNotificationsWithCallback(
87 m_hApp, g_aryDeviceDetect_Notif_Cbs,
88 _countof(g_aryDeviceDetect_Notif_Cbs)))) {
92 "Error: FrameworkunifiedAttachNotificationCallbacksToDispatcher Failed Status:0x%x ",
97 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
101 EFrameworkunifiedStatus DeviceDetectionServiceIf::DetachDeviceDetectionAvailabilityCb() {
102 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
103 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
104 if (NULL != m_hApp) {
105 if (0 != strcmp(SS_DEV_DETECT_SRV, FrameworkunifiedGetAppName(m_hApp))) {
106 // Unsubscribe and detach call backs to notifications
107 if (eFrameworkunifiedStatusOK != (eStatus =
108 FrameworkunifiedUnsubscribeNotificationWithCallback(m_hApp, NTFY_SS_Device_Detection_Service_Availability))) {
109 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
110 "Error: InterfaceunifiedDetachNotificationCallback Failed Status:0x%x ",
115 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
119 EFrameworkunifiedStatus DeviceDetectionServiceIf::NotifyOnOpenSessionAck(
120 CbFuncPtr f_pCallBackFn) {
121 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
122 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
123 if (NULL != m_hApp && NULL != f_pCallBackFn) {
124 if (eFrameworkunifiedStatusOK
125 != (eStatus = FrameworkunifiedAttachCallbackToDispatcher(m_hApp,
127 PROTOCOL_OPEN_SESSION_ACK,
129 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
130 "Error: FrameworkunifiedAttachCallbackToDispatcher Failed Status:0x%x ",
134 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
138 EFrameworkunifiedStatus DeviceDetectionServiceIf::DetachOpenSessionAckCb() {
139 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
140 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
141 if (NULL != m_hApp) {
142 if (eFrameworkunifiedStatusOK
143 != (eStatus = FrameworkunifiedDetachCallbackFromDispatcher(m_hApp,
145 PROTOCOL_OPEN_SESSION_ACK))) {
146 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
147 "Error: FrameworkunifiedDetachCallbackFromDispatcher Failed Status:0x%x ",
151 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
155 EFrameworkunifiedStatus DeviceDetectionServiceIf::NotifyOnCloseSessionAck(
156 CbFuncPtr f_pCallBackFn) {
157 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
158 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
160 if (NULL != m_hApp && NULL != f_pCallBackFn) {
161 if (eFrameworkunifiedStatusOK
162 != (eStatus = FrameworkunifiedAttachCallbackToDispatcher(m_hApp,
164 PROTOCOL_CLOSE_SESSION_ACK,
166 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
167 "Error: FrameworkunifiedAttachCallbackToDispatcher Failed Status:0x%x ",
172 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
176 EFrameworkunifiedStatus DeviceDetectionServiceIf::DetachCloseSessionAckCb() {
177 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
178 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
180 if (NULL != m_hApp) {
181 if (eFrameworkunifiedStatusOK
182 != (eStatus = FrameworkunifiedDetachCallbackFromDispatcher(
185 PROTOCOL_CLOSE_SESSION_ACK))) {
186 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
187 "Error: FrameworkunifiedDetachCallbackFromDispatcher Failed Status:0x%x ",
192 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
196 EFrameworkunifiedStatus DeviceDetectionServiceIf::RegisterForDeviceDetectionEvent(
197 SS_DeviceDetectionServerEvents f_eDevDetectEvent, CbFuncPtr f_pCallBackFn,
199 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
200 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
201 char l_filepathname[FILEPATH_SIZE] = { '\0' };
204 if (NULL != pFilepath) {
205 len = strlen(pFilepath);
206 strcpy(l_filepathname, pFilepath); // NOLINT (runtime/printf)
209 if (NULL != m_hSession && NULL != f_pCallBackFn) {
210 if (CheckDetectEvent(f_eDevDetectEvent)) {
211 if (eFrameworkunifiedStatusOK
212 != (eStatus = FrameworkunifiedAttachCallbackToDispatcher(m_hApp,
215 f_pCallBackFn, m_hSession))) {
216 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
217 "Error: FrameworkunifiedAttachCallbackToDispatcher Failed Status:0x%x ",
221 eStatus = FrameworkunifiedSendMsg(m_hSession, SS_REGISTER_DETECT_EVENT,
222 sizeof(SS_DeviceDetectionServerEvents),
225 if (eFrameworkunifiedStatusOK
226 != (eStatus = FrameworkunifiedAttachCallbackToDispatcher(m_hApp,
229 f_pCallBackFn, m_hSession))) {
230 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
231 "Error: FrameworkunifiedAttachCallbackToDispatcher Failed Status:0x%x ",
235 // client registers for the event
236 if (eFrameworkunifiedStatusOK
237 != (eStatus = FrameworkunifiedRegisterEvent(m_hSession, f_eDevDetectEvent))) {
238 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
239 "Error: FrameworkunifiedRegisterEvents Failed Status:0x%x", eStatus);
242 if (NULL != pFilepath) {
243 eStatus = FrameworkunifiedSendMsg(m_hSession, SS_REGISTER_FILEPATHNAME, len,
248 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
252 EFrameworkunifiedStatus DeviceDetectionServiceIf::UnRegisterForDeviceDetectionEvent(
253 SS_DeviceDetectionServerEvents f_eDevDetectEvent) {
254 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
255 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
257 if (NULL != m_hSession) {
258 if (eFrameworkunifiedStatusOK
259 != (eStatus = FrameworkunifiedDetachCallbackFromDispatcher(m_hApp,
263 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
264 "Error: InterfaceunifiedDetachCallbackToDispatcher Failed Status:0x%x ", eStatus);
267 // client registers for the event
268 if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedUnRegisterEvent(m_hSession, f_eDevDetectEvent))) {
269 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
270 "Error: FrameworkunifiedUnRegisterEvents Failed Status:0x%x", eStatus);
273 if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedSendMsg(m_hSession, SS_UNREGISTER_DETECT_EVENT,
274 sizeof(SS_DeviceDetectionServerEvents),
275 &f_eDevDetectEvent))) {
276 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
277 "UnRegister Detect Event[0x%x] Send Error[0x%x]", f_eDevDetectEvent, eStatus);
281 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
285 BOOL DeviceDetectionServiceIf::Initialize(HANDLE hApp) {
286 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
287 BOOL l_eStatus = TRUE;
292 l_eStatus = FALSE; // eFrameworkunifiedStatusInvldHandle;
294 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
298 EFrameworkunifiedStatus DeviceDetectionServiceIf::OpenSessionRequest() {
299 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
300 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
301 if (NULL != m_hApp) {
302 // if the session is there then we need to close it first!
303 if (NULL != m_hService) {
304 CloseSessionRequest();
305 FrameworkunifiedCloseService(m_hApp, m_hService);
308 BOOL l_bServiceAvailable = FrameworkunifiedIsServiceAvailable(m_hApp);
309 if (FALSE == l_bServiceAvailable) {
310 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
311 "DeviceError: Service is unavailable");
312 l_eStatus = eFrameworkunifiedStatusFail;
314 // Now open the service.
315 if (l_bServiceAvailable
316 && (NULL != (m_hService = OpenService()))) { // LCOV_EXCL_BR_LINE 8:Because l_bServiceAvailable is always TRUE
317 // [DM: TODO] Check if we need to open a session with some data sent to Server.
318 UI_32 l_pTestData = 1;
319 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedOpenSessionWithData(m_hService,
320 (PVOID) &l_pTestData,
322 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Error: FrameworkunifiedOpenSessionWithData Failed");
325 l_eStatus = eFrameworkunifiedStatusFail;
326 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Error: FrameworkunifiedOpenService Failed");
330 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: OpenSessionRequest Failed %X",
333 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
337 HANDLE DeviceDetectionServiceIf::OpenService() {
338 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
339 HANDLE l_hService = NULL;
341 if (NULL == (l_hService = FrameworkunifiedOpenService(m_hApp, SS_DEV_DETECT_SRV))) {
342 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Error: FrameworkunifiedOpenService : Failed to open Device Detection Service");
344 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
348 EFrameworkunifiedStatus DeviceDetectionServiceIf::DecodeOpenSessionResponse() {
349 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
350 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
352 if (NULL != m_hService && NULL != m_hApp) { // LCOV_EXCL_BR_LINE 8:Because when m_hApp is NULL, m_hService is NULL
353 if (NULL == (m_hSession = FrameworkunifiedGetOpenSessionHandle(m_hApp))) {
354 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Error: Error in extracting OpenSessionAck response.");
355 l_eStatus = eFrameworkunifiedStatusFail;
357 l_eStatus = eFrameworkunifiedStatusOK;
358 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Logger Session Name: %s, Session Id: %d",
359 FrameworkunifiedGetSessionName(m_hSession), FrameworkunifiedGetSessionId(m_hSession));
365 "Error. m_hService: %p, m_hApp: %p is NULL. Open session handle not acquired,"
366 " l_eStatus: eFrameworkunifiedStatusInvldHandle.", m_hService, m_hApp);
369 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
373 EFrameworkunifiedStatus DeviceDetectionServiceIf::CloseSessionRequest() {
374 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
375 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
377 if (NULL != m_hService && NULL != m_hSession) {
378 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedCloseSession(m_hService, m_hSession))) {
379 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedCloseSession Failed");
381 m_hSession = NULL; // clear our session handle
383 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
387 BOOL DeviceDetectionServiceIf::CheckDetectEvent(
388 SS_DeviceDetectionServerEvents f_eDevDetectEvent) {
391 switch (f_eDevDetectEvent) {
392 case SS_DEV_INFO_ANY_USB_EV:
393 case SS_DEV_DETECT_ANY_USB_EV:
394 case SS_DEV_DETECT_ANY_SD_EV:
395 case SS_DEV_DETECT_ANY_DISC_EV:
396 case SS_DEV_DETECT_ANY_USB_NCM_EV:
398 case SS_DEV_DETECT_ANY_USB_DCM_NCM_EV:
399 case SS_DEV_DETECT_ANY_USB__CWORD57__EV:
400 case SS_DEV_DETECT_ANY_USB_ACM_EV:
401 case SS_DEV_DETECT_ANY_USB_DEV_MNG_EV:
402 case SS_DEV_DETECT_ANY_USB_VEHICLE_CTRL_EV:
403 case SS_DEV_DETECT_ANY_USB_DSRC_APP_EV:
404 case SS_DEV_DETECT_ANY_USB_DSRC_CTRL_EV:
405 case SS_DEV_DETECT_ANY_USB_IR_VICS_DATA_EV:
406 case SS_DEV_ERR_USB_OVER_CURRENT_EV:
407 case SS_DEV_DETECT_ANY_USB_MTP_EV:
408 case SS_DEV_INFO_ANY_USB_NOTIFY_EV:
409 case SS_DEV_DETECT_ANY_USB__CWORD57__ROLE_EV:
410 case SS_DEV_INFO_SD_FORMAT_COMP_EV:
411 case SS_DEV_INFO_ANY_USB_DVDP_EV:
420 static void ReadString(const char *file, char *buf, int len) {
425 if (file == NULL) { // LCOV_EXCL_BR_LINE 8:Because file is not NULL
426 // LCOV_EXCL_START 8:Because file is not NULL
432 fd = open(file, O_RDONLY);
433 if (fd < 0) { // LCOV_EXCL_BR_LINE 6:Because the sequence at the time of open failure cannot be passed
434 // LCOV_EXCL_START 6:Because the sequence at the time of open failure cannot be passed
440 r = read(fd, buf, len);
442 if (r > 0 && r < len) {
445 /* If there is a line feed code'\n' at the end of the acquired data, replace it with '\0' */
446 while (buf[r] == '\n') {
452 /* If there is a line feed code'\n' in the middle of the acquired data, replace with '\0' */
454 while ((tmp = strchr(tmp, '\n')) != NULL) {
464 static bool isMounttedDir(char* pMountDir) {
467 if (!pMountDir) { // LCOV_EXCL_BR_LINE 8:Because pMountDir is not NULL
468 // LCOV_EXCL_START 8:Because pMountDir is not NULL
473 ReadString("/proc/mounts", buf, sizeof(buf));
474 if (strstr(buf, pMountDir)) { // The mount folder is already in use as a mount point
481 EFrameworkunifiedStatus DeviceDetectionServiceIf::MountSD(uint8_t part_num,
482 BOOL *already_mounted) {
483 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
484 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
486 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "part_num %d", part_num);
488 if (NULL == m_hSession) {
489 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "m_hSession is NULL");
490 return eFrameworkunifiedStatusInvldHandle;
494 return eFrameworkunifiedStatusInvldParam;
499 sprintf(mount_dir, "/mnt/mmcblk1p%d", part_num); // NOLINT (runtime/printf)
501 sprintf(mount_dir, "/mnt/mmcblk1"); // NOLINT (runtime/printf)
503 if (isMounttedDir(mount_dir)) {
504 *already_mounted = TRUE;
505 return eFrameworkunifiedStatusOK;
507 *already_mounted = FALSE;
513 sprintf(filename, "/dev/mmcblk1p%d", part_num); // NOLINT (runtime/printf)
515 sprintf(filename, "/dev/mmcblk1"); // NOLINT (runtime/printf)
517 if (stat(filename, &st) != 0) {
518 return eFrameworkunifiedStatusAccessError;
521 if (eFrameworkunifiedStatusOK
522 == (eStatus = FrameworkunifiedSendMsg(m_hSession, SS_DEV_MOUNT_SD, sizeof(uint8_t),
524 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Send MountSD msg Sucessfully");
527 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
532 EFrameworkunifiedStatus DeviceDetectionServiceIf::UmountSD(uint8_t part_num,
533 BOOL *already_umounted) {
534 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
535 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
537 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "part_num %d", part_num);
539 if (NULL == m_hSession) {
540 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "m_hSession is NULL");
541 return eFrameworkunifiedStatusInvldHandle;
545 return eFrameworkunifiedStatusInvldParam;
550 sprintf(mount_dir, "/mnt/mmcblk1p%d", part_num); // NOLINT (runtime/printf)
552 sprintf(mount_dir, "/mnt/mmcblk1"); // NOLINT (runtime/printf)
555 if (isMounttedDir(mount_dir)) {
556 *already_umounted = FALSE;
558 *already_umounted = TRUE;
559 return eFrameworkunifiedStatusOK;
566 sprintf(filename, "/dev/mmcblk1p%d", part_num); // NOLINT (runtime/printf)
568 sprintf(filename, "/dev/mmcblk1"); // NOLINT (runtime/printf)
570 if (stat(filename, &st) != 0) {
571 return eFrameworkunifiedStatusAccessError;
574 if (eFrameworkunifiedStatusOK
575 == (eStatus = FrameworkunifiedSendMsg(m_hSession, SS_DEV_UMOUNT_SD, sizeof(uint8_t),
577 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Send UmountSD msg Sucessfully");
580 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
585 static const uint8_t VBUS_RESET_INTERVAL_MIN = 11;
587 static EFrameworkunifiedStatus SendUsbVBusResetMsg(HANDLE handle, int8_t port, uint8_t interval) {
588 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __func__, "+");
589 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
591 if (NULL == handle) {
592 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __func__, "Invalid Handle.");
593 return eFrameworkunifiedStatusInvldHandle;
596 int16_t data[] = {port, interval};
597 eStatus = FrameworkunifiedSendMsg(handle, SS_USB_VBUS_RESET, sizeof(data), data);
599 if (eFrameworkunifiedStatusOK != eStatus) {
600 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedSendMsg Send Error[0x%x]", eStatus);
603 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __func__, "-");
607 EFrameworkunifiedStatus DeviceDetectionServiceIf::UsbVBusReset(int8_t port, uint8_t interval) {
608 return SendUsbVBusResetMsg(m_hSession, port, interval);
611 EFrameworkunifiedStatus DeviceDetectionServiceIf::UsbVBusReset(int8_t port) {
612 return SendUsbVBusResetMsg(m_hSession, port, VBUS_RESET_INTERVAL_MIN);
615 EFrameworkunifiedStatus DeviceDetectionServiceIf::RoleSwStateNotify(
616 SS_DEV_ROLE_SW_STATE state) {
617 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
618 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
619 EFrameworkunifiedStatus result = eFrameworkunifiedStatusFail;
623 if (NULL == m_hSession) {
624 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "No Session");
625 return eFrameworkunifiedStatusInvldHandle;
628 bufflength = sizeof(EFrameworkunifiedStatus);
629 eStatus = FrameworkunifiedInvokeSync(m_hSession, SS_DEV_ROLE_SW_STATE_NOTIFY,
630 sizeof(SS_DEV_ROLE_SW_STATE), &state, bufflength,
631 &result, &rcvlength);
633 if (eFrameworkunifiedStatusOK != eStatus) {
634 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Send Error[0x%x]", eStatus);
638 if (bufflength != rcvlength) {
639 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
640 "FrameworkunifiedInvokeSync Response Error. bufflen[%d], rcvlen[%d]", bufflength,
647 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
651 EFrameworkunifiedStatus DeviceDetectionServiceIf::FormatSD(void) {
652 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
653 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
655 if (NULL == m_hSession) {
656 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid Handle.");
657 return eFrameworkunifiedStatusInvldHandle;
660 if (access("/dev/mmcblk1", F_OK) != 0) {
661 return eFrameworkunifiedStatusAccessError;
664 eStatus = FrameworkunifiedSendMsg(m_hSession, SS_DEV_FORMAT_SD, 0, NULL);
666 if (eFrameworkunifiedStatusOK != eStatus) {
667 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Send Error[0x%x]", eStatus);
670 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
672 } // LCOV_EXCL_BR_LINE 10:Because the last line