Skip to content

Commit deb4b70

Browse files
committed
usbmuxd function realization
1 parent ff791a4 commit deb4b70

24 files changed

+2258
-14
lines changed

CMakeLists.txt

+7-1
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ set (HMI "web" CACHE STRING "HMI type")
3838
option(HMI2 "Use Qt HMI" OFF)
3939
option(EXTENDED_MEDIA_MODE "Turn on and off extended Madia Manager features relates to PulseAudio A2DP and GStreamer" OFF)
4040
option(BUILD_SHARED_LIBS "Build all libraries as shared (if ON) or static (if OFF)" OFF)
41-
option(BUILD_BT_SUPPORT "Bluetooth support" OFF)
41+
option(BUILD_BT_SUPPORT "Bluetooth support" ON)
4242
option(BUILD_USB_SUPPORT "libusb support" ON)
43+
option(BUILD_USBMUXD_SUPPORT "usbmuxd support" ON)
4344
option(BUILD_BACKTRACE_SUPPORT "backtrace support" OFF)
4445
option(BUILD_TESTS "Possibility to build and run tests" OFF)
4546
option(TELEMETRY_MONITOR "Enable profiling time test util" OFF)
@@ -212,6 +213,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "QNX")
212213
add_definitions(-DOS_QNX)
213214
SET(BUILD_BT_SUPPORT OFF)
214215
SET(BUILD_BACKTRACE_SUPPORT OFF)
216+
SET(BUILD_USBMUXD_SUPPORT OFF)
215217
SET(EXTENDED_MEDIA_MODE OFF)
216218
endif()
217219

@@ -224,6 +226,10 @@ if (BUILD_USB_SUPPORT)
224226
message(STATUS "USB support is enabled")
225227
endif()
226228

229+
if (BUILD_USBMUXD_SUPPORT)
230+
add_definitions(-DUSBMUXD_SUPPORT)
231+
message(STATUS "usbmuxd support is enabled")
232+
endif()
227233

228234
if (BUILD_BT_SUPPORT)
229235
add_definitions(-DBLUETOOTH_SUPPORT)

src/appMain/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ endif()
9898
if (BUILD_BT_SUPPORT)
9999
list(APPEND LIBRARIES bluetooth)
100100
endif()
101+
102+
if (BUILD_USBMUXD_SUPPORT)
103+
list(APPEND LIBRARIES usbmuxd)
104+
endif()
105+
101106
if (BUILD_USB_SUPPORT)
102107
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
103108
list(APPEND LIBRARIES Libusb-1.0.16)

src/appMain/log4cxx.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ log4j.appender.TelnetLogging.layout=org.apache.log4j.PatternLayout
1717
log4j.appender.TelnetLogging.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%t][%c] %F:%L %M: %m%n
1818

1919
# Log file for all SmartDeviceLinkCore messages
20-
log4j.appender.SmartDeviceLinkCoreLogFile=org.apache.log4j.FileAppender
20+
log4j.appender.SmartDeviceLinkCoreLogFile=SafeFileAppender
2121
log4j.appender.SmartDeviceLinkCoreLogFile.File=SmartDeviceLinkCore.log
2222
log4j.appender.SmartDeviceLinkCoreLogFile.append=true
2323
log4j.appender.SmartDeviceLinkCoreLogFile.DatePattern='.' yyyy-MM-dd HH-mm

src/appMain/smartDeviceLink.ini

+5-5
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ GetVehicleDataRequest = 5, 1
9090

9191
[MEDIA MANAGER]
9292
; where 3 is a number of retries and 1000 is a timeout in milliseconds for request frequency
93-
StartStreamRetry = 3, 1000
93+
StartStreamRetry = 3, 10000
9494
EnableRedecoding = false
95-
VideoStreamConsumer = socket
96-
AudioStreamConsumer = socket
95+
;VideoStreamConsumer = socket
96+
;AudioStreamConsumer = socket
9797
;VideoStreamConsumer = file
9898
;AudioStreamConsumer = file
99-
;VideoStreamConsumer = pipe
100-
;AudioStreamConsumer = pipe
99+
VideoStreamConsumer = pipe
100+
AudioStreamConsumer = pipe
101101
; Temp solution: if you change NamedPipePath also change path to pipe in src/components/qt_hmi/qml_model_qtXX/views/SDLNavi.qml
102102
; Named pipe path will be constructed using AppStorageFolder + name
103103
NamedVideoPipePath = video_stream_pipe

src/components/include/transport_manager/transport_adapter/transport_adapter.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class TransportAdapterListener;
5959
// TODO(EZamakhov): cahnge to DeviceUID
6060
// typedef std::string DeviceType;
6161

62-
enum DeviceType { AOA, PASA_AOA, BLUETOOTH, PASA_BLUETOOTH, MME, TCP, UNKNOWN };
62+
enum DeviceType { AOA, PASA_AOA, BLUETOOTH, PASA_BLUETOOTH, MME, TCP,USBMUXD, UNKNOWN };
6363

6464
typedef std::map<DeviceType, std::string> DeviceTypes;
6565

src/components/transport_manager/CMakeLists.txt

+26
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ if (BUILD_BT_SUPPORT)
4747
)
4848
endif()
4949

50+
if (BUILD_USBMUXD_SUPPORT)
51+
include_directories(
52+
)
53+
endif()
54+
5055
set (SOURCES
5156
${TM_SRC_DIR}/transport_manager_impl.cc
5257
${TM_SRC_DIR}/transport_manager_default.cc
@@ -70,6 +75,16 @@ if (BUILD_BT_SUPPORT)
7075
)
7176
endif()
7277

78+
if (BUILD_USBMUXD_SUPPORT)
79+
list (APPEND SOURCES
80+
${TM_SRC_DIR}/usbmuxd/usbmuxd_transport_adapter.cc
81+
${TM_SRC_DIR}/usbmuxd/usbmuxd_client_listener.cc
82+
${TM_SRC_DIR}/usbmuxd/usbmuxd_device.cc
83+
${TM_SRC_DIR}/usbmuxd/usbmuxd_socket_connection.cc
84+
${TM_SRC_DIR}/usbmuxd/usbmuxd_connection_factory.cc
85+
)
86+
endif()
87+
7388
if (BUILD_USB_SUPPORT)
7489
list (APPEND SOURCES
7590
${TM_SRC_DIR}/usb/usb_aoa_adapter.cc
@@ -104,6 +119,17 @@ if (BUILD_USB_SUPPORT)
104119
endif()
105120
endif(BUILD_USB_SUPPORT)
106121

122+
if (BUILD_USBMUXD_SUPPORT)
123+
set(LIRBRARYS
124+
libplist.so
125+
libusbmuxd.so
126+
xml2.so
127+
pthread.so
128+
libz.so
129+
)
130+
target_link_libraries(${target} ${LIRBRARYS} usbmuxd)
131+
endif()
132+
107133
if(ENABLE_LOG)
108134
target_link_libraries(${target} log4cxx -L${LOG4CXX_LIBS_DIRECTORY})
109135
endif()

src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_controller.h

+5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
#include "transport_manager/transport_adapter/connection.h"
3838
#include "protocol/common.h"
3939

40+
#include "transport_manager/usbmuxd/usbmuxd_device.h"
41+
4042
namespace transport_manager {
4143
namespace transport_adapter {
4244

@@ -204,6 +206,9 @@ class TransportAdapterController {
204206
const ApplicationHandle& app_handle,
205207
::protocol_handler::RawMessagePtr message,
206208
const DataSendError&) = 0;
209+
210+
virtual bool IsSameDevice(char* udid)= 0;
211+
virtual void RemoveUnFindDevice(std::vector<DeviceUID> DeviceList)= 0;
207212
};
208213

209214
} // namespace transport_adapter

src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h

+3
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,9 @@ class TransportAdapterImpl : public TransportAdapter,
442442
TMTelemetryObserver* GetTelemetryObserver() OVERRIDE;
443443
#endif // TELEMETRY_MONITOR
444444

445+
bool IsSameDevice(char* udid);
446+
void RemoveUnFindDevice(std::vector<DeviceUID> DeviceList);
447+
445448
protected:
446449
/**
447450
* @brief Store adapter state where applicable

src/components/transport_manager/include/transport_manager/usb/common.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ static const uint16_t kApplePid4 = 0x1297; // iPhone 4
6060
static const uint16_t kApplePid5 = 0x129a; // iPad
6161
static const uint16_t kApplePid6 = 0x129f; // iPad 2
6262
static const uint16_t kApplePid7 = 0x12a0; // iPhone 4S
63-
static const uint16_t kApplePid8 = 0x12a8; // iPhone 5
63+
static const uint16_t kApplePid8 = 0x12a8; // iPhone 5/6/6plus
64+
static const uint16_t kApplePid9 = 0x12aa; // iPhone 5 touch
6465

6566
static const int kUsbConfiguration = 1;
6667

@@ -93,14 +94,17 @@ inline bool IsGoogleAccessory(const PlatformUsbDevice* device) {
9394
}
9495

9596
inline bool IsAppleIAPDevice(const PlatformUsbDevice* device) {
97+
printf("device->product_id:0x%x\n",device->product_id());
9698
return (kAppleVid == device->vendor_id()) &&
9799
((kApplePid1 == device->product_id()) ||
98100
(kApplePid2 == device->product_id()) ||
99101
(kApplePid3 == device->product_id()) ||
100102
(kApplePid4 == device->product_id()) ||
101103
(kApplePid5 == device->product_id()) ||
102104
(kApplePid6 == device->product_id()) ||
103-
(kApplePid7 == device->product_id()));
105+
(kApplePid7 == device->product_id()) ||
106+
(kApplePid8 == device->product_id()) ||
107+
(kApplePid9 == device->product_id()));
104108
}
105109

106110
inline bool IsAppleIAP2Device(const PlatformUsbDevice* device) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/*
2+
* \file Usbmuxd_client_listener.h
3+
* \brief UsbmuxdClientListener class header file.
4+
*
5+
* Copyright (c) 2013, Ford Motor Company
6+
* All rights reserved.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions are met:
10+
*
11+
* Redistributions of source code must retain the above copyright notice, this
12+
* list of conditions and the following disclaimer.
13+
*
14+
* Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following
16+
* disclaimer in the documentation and/or other materials provided with the
17+
* distribution.
18+
*
19+
* Neither the name of the Ford Motor Company nor the names of its contributors
20+
* may be used to endorse or promote products derived from this software
21+
* without specific prior written permission.
22+
*
23+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33+
* POSSIBILITY OF SUCH DAMAGE.
34+
*/
35+
36+
#ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_USBMUXD_USBMUXD_CLIENT_LISTENER_H_
37+
#define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_USBMUXD_USBMUXD_CLIENT_LISTENER_H_
38+
39+
#include "utils/threads/thread_delegate.h"
40+
#include "transport_manager/transport_adapter/client_connection_listener.h"
41+
42+
class Thread;
43+
44+
namespace transport_manager {
45+
namespace transport_adapter {
46+
47+
class TransportAdapterController;
48+
49+
/**
50+
* @brief Listener of device adapter that use Usbmuxd transport.
51+
*/
52+
class UsbmuxdClientListener : public ClientConnectionListener {
53+
public:
54+
/**
55+
* @breaf Constructor.
56+
*
57+
* @param controller Pointer to the device adapter controller.
58+
* @param port Port No.
59+
* @param enable_keepalive If true enables Usbmuxd keepalive on accepted
60+
*connections
61+
*/
62+
UsbmuxdClientListener(TransportAdapterController* controller,
63+
uint16_t port,
64+
bool enable_keepalive);
65+
66+
/**
67+
* @brief Destructor.
68+
*/
69+
virtual ~UsbmuxdClientListener();
70+
71+
/**
72+
* @brief Run Usbmuxd client listener.
73+
*
74+
* @return Error information about possible reason of starting Usbmuxd listener
75+
*listener failure.
76+
*/
77+
virtual TransportAdapter::Error Init();
78+
79+
/**
80+
* @brief Stop Usbmuxd client listener.
81+
*/
82+
virtual void Terminate();
83+
84+
/**
85+
* @brief Check initialization.
86+
*
87+
* @return True if initialized.
88+
* @return False if not initialized.
89+
*/
90+
virtual bool IsInitialised() const;
91+
92+
/**
93+
* @brief
94+
*
95+
* @return Error information about possible reason of failure.
96+
*/
97+
virtual TransportAdapter::Error StartListening();
98+
99+
/**
100+
* @brief Terminate Usbmuxd client listener thread.
101+
*/
102+
virtual TransportAdapter::Error StopListening();
103+
104+
#ifdef BUILD_TESTS
105+
uint16_t port() const {
106+
return port_;
107+
}
108+
109+
int get_socket() const {
110+
return socket_;
111+
}
112+
113+
threads::Thread* thread() const {
114+
return thread_;
115+
}
116+
#endif // BUILD_TESTS
117+
118+
private:
119+
const uint16_t port_;
120+
const bool enable_keepalive_;
121+
TransportAdapterController* controller_;
122+
threads::Thread* thread_;
123+
int socket_;
124+
bool thread_stop_requested_;
125+
126+
void Loop();
127+
void StopLoop();
128+
129+
class ListeningThreadDelegate : public threads::ThreadDelegate {
130+
public:
131+
explicit ListeningThreadDelegate(UsbmuxdClientListener* parent);
132+
virtual void threadMain();
133+
void exitThreadMain();
134+
135+
private:
136+
UsbmuxdClientListener* parent_;
137+
};
138+
};
139+
140+
} // namespace transport_adapter
141+
} // namespace transport_manager
142+
143+
#endif // SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_Usbmuxd_Usbmuxd_CLIENT_LISTENER_H_

0 commit comments

Comments
 (0)