The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 The Android Open Source Project |
| 3 | * |
| 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 |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 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. |
| 15 | */ |
| 16 | |
Yabin Cui | 19bec5b | 2015-09-22 15:52:57 -0700 | [diff] [blame] | 17 | #define TRACE_TAG USB |
Dan Albert | db6fe64 | 2015-03-19 15:21:08 -0700 | [diff] [blame] | 18 | |
| 19 | #include "sysdeps.h" |
| 20 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 21 | #include <CoreFoundation/CoreFoundation.h> |
| 22 | |
| 23 | #include <IOKit/IOKitLib.h> |
| 24 | #include <IOKit/IOCFPlugIn.h> |
| 25 | #include <IOKit/usb/IOUSBLib.h> |
| 26 | #include <IOKit/IOMessage.h> |
| 27 | #include <mach/mach_port.h> |
| 28 | |
Dan Albert | 2589606 | 2015-04-16 19:20:40 -0700 | [diff] [blame] | 29 | #include <inttypes.h> |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 30 | #include <stdio.h> |
| 31 | |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 32 | #include <atomic> |
Elliott Hughes | 7392598 | 2016-11-15 12:37:32 -0800 | [diff] [blame] | 33 | #include <chrono> |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 34 | #include <memory> |
| 35 | #include <mutex> |
Elliott Hughes | 7392598 | 2016-11-15 12:37:32 -0800 | [diff] [blame] | 36 | #include <thread> |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 37 | #include <vector> |
| 38 | |
Elliott Hughes | f55ead9 | 2015-12-04 22:00:26 -0800 | [diff] [blame] | 39 | #include <android-base/logging.h> |
| 40 | #include <android-base/stringprintf.h> |
Josh Gao | 4ebd436 | 2017-05-04 15:58:01 -0700 | [diff] [blame] | 41 | #include <android-base/thread_annotations.h> |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 42 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 43 | #include "adb.h" |
Dan Albert | bd3d448 | 2015-02-25 10:26:17 -0800 | [diff] [blame] | 44 | #include "transport.h" |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 45 | |
Elliott Hughes | 7392598 | 2016-11-15 12:37:32 -0800 | [diff] [blame] | 46 | using namespace std::chrono_literals; |
| 47 | |
Josh Gao | 484ddbf | 2017-01-26 14:01:02 -0800 | [diff] [blame] | 48 | namespace native { |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 49 | struct usb_handle |
| 50 | { |
Siva Velusamy | 3ce4607 | 2015-08-13 08:48:06 -0700 | [diff] [blame] | 51 | UInt8 bulkIn; |
| 52 | UInt8 bulkOut; |
| 53 | IOUSBInterfaceInterface190** interface; |
Siva Velusamy | 3ce4607 | 2015-08-13 08:48:06 -0700 | [diff] [blame] | 54 | unsigned int zero_mask; |
Josh Gao | 3734cf0 | 2017-05-02 15:01:09 -0700 | [diff] [blame] | 55 | size_t max_packet_size; |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 56 | |
| 57 | // For garbage collecting disconnected devices. |
| 58 | bool mark; |
| 59 | std::string devpath; |
| 60 | std::atomic<bool> dead; |
| 61 | |
Josh Gao | 3734cf0 | 2017-05-02 15:01:09 -0700 | [diff] [blame] | 62 | usb_handle() |
| 63 | : bulkIn(0), |
| 64 | bulkOut(0), |
| 65 | interface(nullptr), |
| 66 | zero_mask(0), |
| 67 | max_packet_size(0), |
| 68 | mark(false), |
| 69 | dead(false) {} |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 70 | }; |
| 71 | |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 72 | static std::atomic<bool> usb_inited_flag; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 73 | |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 74 | static auto& g_usb_handles_mutex = *new std::mutex(); |
| 75 | static auto& g_usb_handles = *new std::vector<std::unique_ptr<usb_handle>>(); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 76 | |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 77 | static bool IsKnownDevice(const std::string& devpath) { |
| 78 | std::lock_guard<std::mutex> lock_guard(g_usb_handles_mutex); |
| 79 | for (auto& usb : g_usb_handles) { |
| 80 | if (usb->devpath == devpath) { |
| 81 | // Set mark flag to indicate this device is still alive. |
| 82 | usb->mark = true; |
| 83 | return true; |
| 84 | } |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 85 | } |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 86 | return false; |
| 87 | } |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 88 | |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 89 | static void usb_kick_locked(usb_handle* handle); |
Al Sutton | 178bae8 | 2014-11-21 12:21:12 +0000 | [diff] [blame] | 90 | |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 91 | static void KickDisconnectedDevices() { |
| 92 | std::lock_guard<std::mutex> lock_guard(g_usb_handles_mutex); |
| 93 | for (auto& usb : g_usb_handles) { |
| 94 | if (!usb->mark) { |
| 95 | usb_kick_locked(usb.get()); |
| 96 | } else { |
| 97 | usb->mark = false; |
| 98 | } |
| 99 | } |
| 100 | } |
Al Sutton | 178bae8 | 2014-11-21 12:21:12 +0000 | [diff] [blame] | 101 | |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 102 | static void AddDevice(std::unique_ptr<usb_handle> handle) { |
| 103 | handle->mark = true; |
| 104 | std::lock_guard<std::mutex> lock(g_usb_handles_mutex); |
| 105 | g_usb_handles.push_back(std::move(handle)); |
| 106 | } |
| 107 | |
| 108 | static void AndroidInterfaceAdded(io_iterator_t iterator); |
| 109 | static std::unique_ptr<usb_handle> CheckInterface(IOUSBInterfaceInterface190 **iface, |
| 110 | UInt16 vendor, UInt16 product); |
| 111 | |
| 112 | static bool FindUSBDevices() { |
| 113 | // Create the matching dictionary to find the Android device's adb interface. |
| 114 | CFMutableDictionaryRef matchingDict = IOServiceMatching(kIOUSBInterfaceClassName); |
| 115 | if (!matchingDict) { |
| 116 | LOG(ERROR) << "couldn't create USB matching dictionary"; |
| 117 | return false; |
| 118 | } |
| 119 | // Create an iterator for all I/O Registry objects that match the dictionary. |
| 120 | io_iterator_t iter = 0; |
| 121 | kern_return_t kr = IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDict, &iter); |
| 122 | if (kr != KERN_SUCCESS) { |
| 123 | LOG(ERROR) << "failed to get matching services"; |
| 124 | return false; |
| 125 | } |
| 126 | // Iterate over all matching objects. |
| 127 | AndroidInterfaceAdded(iter); |
| 128 | IOObjectRelease(iter); |
| 129 | return true; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | static void |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 133 | AndroidInterfaceAdded(io_iterator_t iterator) |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 134 | { |
| 135 | kern_return_t kr; |
| 136 | io_service_t usbDevice; |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 137 | io_service_t usbInterface; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 138 | IOCFPlugInInterface **plugInInterface = NULL; |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 139 | IOUSBInterfaceInterface220 **iface = NULL; |
| 140 | IOUSBDeviceInterface197 **dev = NULL; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 141 | HRESULT result; |
| 142 | SInt32 score; |
Elliott Hughes | 8dc9c86 | 2015-08-25 17:48:12 -0700 | [diff] [blame] | 143 | uint32_t locationId; |
Dan Albert | 2589606 | 2015-04-16 19:20:40 -0700 | [diff] [blame] | 144 | UInt8 if_class, subclass, protocol; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 145 | UInt16 vendor; |
| 146 | UInt16 product; |
| 147 | UInt8 serialIndex; |
| 148 | char serial[256]; |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 149 | std::string devpath; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 150 | |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 151 | while ((usbInterface = IOIteratorNext(iterator))) { |
| 152 | //* Create an intermediate interface plugin |
| 153 | kr = IOCreatePlugInInterfaceForService(usbInterface, |
| 154 | kIOUSBInterfaceUserClientTypeID, |
| 155 | kIOCFPlugInInterfaceID, |
| 156 | &plugInInterface, &score); |
| 157 | IOObjectRelease(usbInterface); |
| 158 | if ((kIOReturnSuccess != kr) || (!plugInInterface)) { |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 159 | LOG(ERROR) << "Unable to create an interface plug-in (" << std::hex << kr << ")"; |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 160 | continue; |
| 161 | } |
| 162 | |
| 163 | //* This gets us the interface object |
Dan Albert | 2589606 | 2015-04-16 19:20:40 -0700 | [diff] [blame] | 164 | result = (*plugInInterface)->QueryInterface( |
| 165 | plugInInterface, |
| 166 | CFUUIDGetUUIDBytes(kIOUSBInterfaceInterfaceID), (LPVOID*)&iface); |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 167 | //* We only needed the plugin to get the interface, so discard it |
| 168 | (*plugInInterface)->Release(plugInInterface); |
| 169 | if (result || !iface) { |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 170 | LOG(ERROR) << "Couldn't query the interface (" << std::hex << result << ")"; |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 171 | continue; |
| 172 | } |
| 173 | |
Dan Albert | 2589606 | 2015-04-16 19:20:40 -0700 | [diff] [blame] | 174 | kr = (*iface)->GetInterfaceClass(iface, &if_class); |
Al Sutton | 178bae8 | 2014-11-21 12:21:12 +0000 | [diff] [blame] | 175 | kr = (*iface)->GetInterfaceSubClass(iface, &subclass); |
| 176 | kr = (*iface)->GetInterfaceProtocol(iface, &protocol); |
Mark Salyzyn | 21a991d | 2017-10-04 15:05:40 -0700 | [diff] [blame] | 177 | if (!is_adb_interface(if_class, subclass, protocol)) { |
Al Sutton | 178bae8 | 2014-11-21 12:21:12 +0000 | [diff] [blame] | 178 | // Ignore non-ADB devices. |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 179 | LOG(DEBUG) << "Ignoring interface with incorrect class/subclass/protocol - " << if_class |
| 180 | << ", " << subclass << ", " << protocol; |
Al Sutton | 178bae8 | 2014-11-21 12:21:12 +0000 | [diff] [blame] | 181 | (*iface)->Release(iface); |
| 182 | continue; |
| 183 | } |
| 184 | |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 185 | //* this gets us an ioservice, with which we will find the actual |
| 186 | //* device; after getting a plugin, and querying the interface, of |
| 187 | //* course. |
| 188 | //* Gotta love OS X |
| 189 | kr = (*iface)->GetDevice(iface, &usbDevice); |
| 190 | if (kIOReturnSuccess != kr || !usbDevice) { |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 191 | LOG(ERROR) << "Couldn't grab device from interface (" << std::hex << kr << ")"; |
Josh Gao | 37df9e7 | 2016-09-27 12:35:55 -0700 | [diff] [blame] | 192 | (*iface)->Release(iface); |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 193 | continue; |
| 194 | } |
| 195 | |
| 196 | plugInInterface = NULL; |
| 197 | score = 0; |
| 198 | //* create an intermediate device plugin |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 199 | kr = IOCreatePlugInInterfaceForService(usbDevice, |
| 200 | kIOUSBDeviceUserClientTypeID, |
| 201 | kIOCFPlugInInterfaceID, |
| 202 | &plugInInterface, &score); |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 203 | //* only needed this to find the plugin |
| 204 | (void)IOObjectRelease(usbDevice); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 205 | if ((kIOReturnSuccess != kr) || (!plugInInterface)) { |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 206 | LOG(ERROR) << "Unable to create a device plug-in (" << std::hex << kr << ")"; |
Josh Gao | 37df9e7 | 2016-09-27 12:35:55 -0700 | [diff] [blame] | 207 | (*iface)->Release(iface); |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 208 | continue; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 209 | } |
| 210 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 211 | result = (*plugInInterface)->QueryInterface(plugInInterface, |
Dan Albert | 2589606 | 2015-04-16 19:20:40 -0700 | [diff] [blame] | 212 | CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID), (LPVOID*)&dev); |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 213 | //* only needed this to query the plugin |
| 214 | (*plugInInterface)->Release(plugInInterface); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 215 | if (result || !dev) { |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 216 | LOG(ERROR) << "Couldn't create a device interface (" << std::hex << result << ")"; |
Josh Gao | 37df9e7 | 2016-09-27 12:35:55 -0700 | [diff] [blame] | 217 | (*iface)->Release(iface); |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 218 | continue; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 219 | } |
| 220 | |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 221 | //* Now after all that, we actually have a ref to the device and |
| 222 | //* the interface that matched our criteria |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 223 | kr = (*dev)->GetDeviceVendor(dev, &vendor); |
| 224 | kr = (*dev)->GetDeviceProduct(dev, &product); |
Scott Anderson | 6dfaf4b | 2012-04-20 11:21:14 -0700 | [diff] [blame] | 225 | kr = (*dev)->GetLocationID(dev, &locationId); |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 226 | if (kr == KERN_SUCCESS) { |
| 227 | devpath = android::base::StringPrintf("usb:%" PRIu32 "X", locationId); |
| 228 | if (IsKnownDevice(devpath)) { |
Josh Gao | 37df9e7 | 2016-09-27 12:35:55 -0700 | [diff] [blame] | 229 | (*dev)->Release(dev); |
| 230 | (*iface)->Release(iface); |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 231 | continue; |
| 232 | } |
Scott Anderson | 6dfaf4b | 2012-04-20 11:21:14 -0700 | [diff] [blame] | 233 | } |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 234 | kr = (*dev)->USBGetSerialNumberStringIndex(dev, &serialIndex); |
| 235 | |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 236 | if (serialIndex > 0) { |
| 237 | IOUSBDevRequest req; |
| 238 | UInt16 buffer[256]; |
| 239 | UInt16 languages[128]; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 240 | |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 241 | memset(languages, 0, sizeof(languages)); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 242 | |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 243 | req.bmRequestType = |
| 244 | USBmakebmRequestType(kUSBIn, kUSBStandard, kUSBDevice); |
| 245 | req.bRequest = kUSBRqGetDescriptor; |
| 246 | req.wValue = (kUSBStringDesc << 8) | 0; |
| 247 | req.wIndex = 0; |
| 248 | req.pData = languages; |
| 249 | req.wLength = sizeof(languages); |
| 250 | kr = (*dev)->DeviceRequest(dev, &req); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 251 | |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 252 | if (kr == kIOReturnSuccess && req.wLenDone > 0) { |
Guang Zhu | 84b5bd2 | 2009-08-06 17:21:52 -0700 | [diff] [blame] | 253 | |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 254 | int langCount = (req.wLenDone - 2) / 2, lang; |
Guang Zhu | 84b5bd2 | 2009-08-06 17:21:52 -0700 | [diff] [blame] | 255 | |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 256 | for (lang = 1; lang <= langCount; lang++) { |
Guang Zhu | 84b5bd2 | 2009-08-06 17:21:52 -0700 | [diff] [blame] | 257 | |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 258 | memset(buffer, 0, sizeof(buffer)); |
| 259 | memset(&req, 0, sizeof(req)); |
Guang Zhu | 84b5bd2 | 2009-08-06 17:21:52 -0700 | [diff] [blame] | 260 | |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 261 | req.bmRequestType = |
| 262 | USBmakebmRequestType(kUSBIn, kUSBStandard, kUSBDevice); |
| 263 | req.bRequest = kUSBRqGetDescriptor; |
| 264 | req.wValue = (kUSBStringDesc << 8) | serialIndex; |
| 265 | req.wIndex = languages[lang]; |
| 266 | req.pData = buffer; |
| 267 | req.wLength = sizeof(buffer); |
| 268 | kr = (*dev)->DeviceRequest(dev, &req); |
Guang Zhu | 84b5bd2 | 2009-08-06 17:21:52 -0700 | [diff] [blame] | 269 | |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 270 | if (kr == kIOReturnSuccess && req.wLenDone > 0) { |
| 271 | int i, count; |
Guang Zhu | 84b5bd2 | 2009-08-06 17:21:52 -0700 | [diff] [blame] | 272 | |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 273 | // skip first word, and copy the rest to the serial string, |
| 274 | // changing shorts to bytes. |
| 275 | count = (req.wLenDone - 1) / 2; |
| 276 | for (i = 0; i < count; i++) |
| 277 | serial[i] = buffer[i + 1]; |
| 278 | serial[i] = 0; |
| 279 | break; |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | } |
| 284 | |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 285 | (*dev)->Release(dev); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 286 | |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 287 | VLOG(USB) << android::base::StringPrintf("Found vid=%04x pid=%04x serial=%s\n", |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 288 | vendor, product, serial); |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 289 | if (devpath.empty()) { |
| 290 | devpath = serial; |
| 291 | } |
| 292 | if (IsKnownDevice(devpath)) { |
| 293 | (*iface)->USBInterfaceClose(iface); |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 294 | (*iface)->Release(iface); |
| 295 | continue; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 296 | } |
| 297 | |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 298 | std::unique_ptr<usb_handle> handle = CheckInterface((IOUSBInterfaceInterface190**)iface, |
| 299 | vendor, product); |
| 300 | if (handle == nullptr) { |
| 301 | LOG(ERROR) << "Could not find device interface"; |
| 302 | (*iface)->Release(iface); |
| 303 | continue; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 304 | } |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 305 | handle->devpath = devpath; |
| 306 | usb_handle* handle_p = handle.get(); |
| 307 | VLOG(USB) << "Add usb device " << serial; |
| 308 | AddDevice(std::move(handle)); |
Josh Gao | 484ddbf | 2017-01-26 14:01:02 -0800 | [diff] [blame] | 309 | register_usb_transport(reinterpret_cast<::usb_handle*>(handle_p), serial, devpath.c_str(), |
| 310 | 1); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 311 | } |
| 312 | } |
| 313 | |
Siva Velusamy | 3ce4607 | 2015-08-13 08:48:06 -0700 | [diff] [blame] | 314 | // Used to clear both the endpoints before starting. |
| 315 | // When adb quits, we might clear the host endpoint but not the device. |
| 316 | // So we make sure both sides are clear before starting up. |
| 317 | static bool ClearPipeStallBothEnds(IOUSBInterfaceInterface190** interface, UInt8 bulkEp) { |
| 318 | IOReturn rc = (*interface)->ClearPipeStallBothEnds(interface, bulkEp); |
| 319 | if (rc != kIOReturnSuccess) { |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 320 | LOG(ERROR) << "Could not clear pipe stall both ends: " << std::hex << rc; |
Siva Velusamy | 3ce4607 | 2015-08-13 08:48:06 -0700 | [diff] [blame] | 321 | return false; |
| 322 | } |
| 323 | return true; |
| 324 | } |
| 325 | |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 326 | //* TODO: simplify this further since we only register to get ADB interface |
| 327 | //* subclass+protocol events |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 328 | static std::unique_ptr<usb_handle> |
Siva Velusamy | 3ce4607 | 2015-08-13 08:48:06 -0700 | [diff] [blame] | 329 | CheckInterface(IOUSBInterfaceInterface190 **interface, UInt16 vendor, UInt16 product) |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 330 | { |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 331 | std::unique_ptr<usb_handle> handle; |
Elliott Hughes | 6d6cb54 | 2015-08-13 15:01:18 -0700 | [diff] [blame] | 332 | IOReturn kr; |
| 333 | UInt8 interfaceNumEndpoints, interfaceClass, interfaceSubClass, interfaceProtocol; |
| 334 | UInt8 endpoint; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 335 | |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 336 | //* Now open the interface. This will cause the pipes associated with |
| 337 | //* the endpoints in the interface descriptor to be instantiated |
| 338 | kr = (*interface)->USBInterfaceOpen(interface); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 339 | if (kr != kIOReturnSuccess) { |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 340 | LOG(ERROR) << "Could not open interface: " << std::hex << kr; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 341 | return NULL; |
| 342 | } |
| 343 | |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 344 | //* Get the number of endpoints associated with this interface |
| 345 | kr = (*interface)->GetNumEndpoints(interface, &interfaceNumEndpoints); |
| 346 | if (kr != kIOReturnSuccess) { |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 347 | LOG(ERROR) << "Unable to get number of endpoints: " << std::hex << kr; |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 348 | goto err_get_num_ep; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 349 | } |
| 350 | |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 351 | //* Get interface class, subclass and protocol |
| 352 | if ((*interface)->GetInterfaceClass(interface, &interfaceClass) != kIOReturnSuccess || |
| 353 | (*interface)->GetInterfaceSubClass(interface, &interfaceSubClass) != kIOReturnSuccess || |
| 354 | (*interface)->GetInterfaceProtocol(interface, &interfaceProtocol) != kIOReturnSuccess) { |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 355 | LOG(ERROR) << "Unable to get interface class, subclass and protocol"; |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 356 | goto err_get_interface_class; |
| 357 | } |
| 358 | |
| 359 | //* check to make sure interface class, subclass and protocol match ADB |
| 360 | //* avoid opening mass storage endpoints |
Josh Gao | 08dda21 | 2016-09-26 21:18:58 -0700 | [diff] [blame] | 361 | if (!is_adb_interface(interfaceClass, interfaceSubClass, interfaceProtocol)) { |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 362 | goto err_bad_adb_interface; |
Siva Velusamy | 3ce4607 | 2015-08-13 08:48:06 -0700 | [diff] [blame] | 363 | } |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 364 | |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 365 | handle.reset(new usb_handle); |
| 366 | if (handle == nullptr) { |
| 367 | goto err_bad_adb_interface; |
| 368 | } |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 369 | |
| 370 | //* Iterate over the endpoints for this interface and find the first |
| 371 | //* bulk in/out pipes available. These will be our read/write pipes. |
Elliott Hughes | 6d6cb54 | 2015-08-13 15:01:18 -0700 | [diff] [blame] | 372 | for (endpoint = 1; endpoint <= interfaceNumEndpoints; endpoint++) { |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 373 | UInt8 transferType; |
| 374 | UInt16 maxPacketSize; |
| 375 | UInt8 interval; |
| 376 | UInt8 number; |
| 377 | UInt8 direction; |
| 378 | |
| 379 | kr = (*interface)->GetPipeProperties(interface, endpoint, &direction, |
| 380 | &number, &transferType, &maxPacketSize, &interval); |
Siva Velusamy | 3ce4607 | 2015-08-13 08:48:06 -0700 | [diff] [blame] | 381 | if (kr != kIOReturnSuccess) { |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 382 | LOG(ERROR) << "FindDeviceInterface - could not get pipe properties: " |
| 383 | << std::hex << kr; |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 384 | goto err_get_pipe_props; |
| 385 | } |
Siva Velusamy | 3ce4607 | 2015-08-13 08:48:06 -0700 | [diff] [blame] | 386 | |
| 387 | if (kUSBBulk != transferType) continue; |
| 388 | |
| 389 | if (kUSBIn == direction) { |
| 390 | handle->bulkIn = endpoint; |
| 391 | if (!ClearPipeStallBothEnds(interface, handle->bulkIn)) goto err_get_pipe_props; |
| 392 | } |
| 393 | |
| 394 | if (kUSBOut == direction) { |
| 395 | handle->bulkOut = endpoint; |
| 396 | if (!ClearPipeStallBothEnds(interface, handle->bulkOut)) goto err_get_pipe_props; |
| 397 | } |
| 398 | |
| 399 | handle->zero_mask = maxPacketSize - 1; |
Josh Gao | 3734cf0 | 2017-05-02 15:01:09 -0700 | [diff] [blame] | 400 | handle->max_packet_size = maxPacketSize; |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 401 | } |
| 402 | |
| 403 | handle->interface = interface; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 404 | return handle; |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 405 | |
| 406 | err_get_pipe_props: |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 407 | err_bad_adb_interface: |
| 408 | err_get_interface_class: |
| 409 | err_get_num_ep: |
| 410 | (*interface)->USBInterfaceClose(interface); |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 411 | return nullptr; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 412 | } |
| 413 | |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 414 | std::mutex& operate_device_lock = *new std::mutex(); |
| 415 | |
Josh Gao | 0f3312a | 2017-04-12 17:00:49 -0700 | [diff] [blame] | 416 | static void RunLoopThread() { |
Siva Velusamy | 2669cf9 | 2015-08-28 16:37:29 -0700 | [diff] [blame] | 417 | adb_thread_setname("RunLoop"); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 418 | |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 419 | VLOG(USB) << "RunLoopThread started"; |
| 420 | while (true) { |
| 421 | { |
| 422 | std::lock_guard<std::mutex> lock_guard(operate_device_lock); |
| 423 | FindUSBDevices(); |
| 424 | KickDisconnectedDevices(); |
| 425 | } |
| 426 | // Signal the parent that we are running |
| 427 | usb_inited_flag = true; |
Elliott Hughes | 7392598 | 2016-11-15 12:37:32 -0800 | [diff] [blame] | 428 | std::this_thread::sleep_for(1s); |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 429 | } |
| 430 | VLOG(USB) << "RunLoopThread done"; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 431 | } |
| 432 | |
Josh Gao | 90b6253 | 2017-05-10 13:51:36 -0700 | [diff] [blame] | 433 | void usb_cleanup() NO_THREAD_SAFETY_ANALYSIS { |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 434 | VLOG(USB) << "usb_cleanup"; |
| 435 | // Wait until usb operations in RunLoopThread finish, and prevent further operations. |
| 436 | operate_device_lock.lock(); |
Dan Albert | 53a3744 | 2015-05-08 16:13:53 -0700 | [diff] [blame] | 437 | close_usb_devices(); |
Dan Albert | 53a3744 | 2015-05-08 16:13:53 -0700 | [diff] [blame] | 438 | } |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 439 | |
Elliott Hughes | f251714 | 2015-05-05 13:41:21 -0700 | [diff] [blame] | 440 | void usb_init() { |
Dan Albert | 53a3744 | 2015-05-08 16:13:53 -0700 | [diff] [blame] | 441 | static bool initialized = false; |
| 442 | if (!initialized) { |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 443 | usb_inited_flag = false; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 444 | |
Josh Gao | 0f3312a | 2017-04-12 17:00:49 -0700 | [diff] [blame] | 445 | std::thread(RunLoopThread).detach(); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 446 | |
| 447 | // Wait for initialization to finish |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 448 | while (!usb_inited_flag) { |
Elliott Hughes | 7392598 | 2016-11-15 12:37:32 -0800 | [diff] [blame] | 449 | std::this_thread::sleep_for(100ms); |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 450 | } |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 451 | |
Dan Albert | 53a3744 | 2015-05-08 16:13:53 -0700 | [diff] [blame] | 452 | initialized = true; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 453 | } |
| 454 | } |
| 455 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 456 | int usb_write(usb_handle *handle, const void *buf, int len) |
| 457 | { |
| 458 | IOReturn result; |
| 459 | |
| 460 | if (!len) |
| 461 | return 0; |
| 462 | |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 463 | if (!handle || handle->dead) |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 464 | return -1; |
| 465 | |
| 466 | if (NULL == handle->interface) { |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 467 | LOG(ERROR) << "usb_write interface was null"; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 468 | return -1; |
| 469 | } |
| 470 | |
| 471 | if (0 == handle->bulkOut) { |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 472 | LOG(ERROR) << "bulkOut endpoint not assigned"; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 473 | return -1; |
| 474 | } |
| 475 | |
| 476 | result = |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 477 | (*handle->interface)->WritePipe(handle->interface, handle->bulkOut, (void *)buf, len); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 478 | |
| 479 | if ((result == 0) && (handle->zero_mask)) { |
| 480 | /* we need 0-markers and our transfer */ |
| 481 | if(!(len & handle->zero_mask)) { |
| 482 | result = |
| 483 | (*handle->interface)->WritePipe( |
| 484 | handle->interface, handle->bulkOut, (void *)buf, 0); |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | if (0 == result) |
| 489 | return 0; |
| 490 | |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 491 | LOG(ERROR) << "usb_write failed with status: " << std::hex << result; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 492 | return -1; |
| 493 | } |
| 494 | |
| 495 | int usb_read(usb_handle *handle, void *buf, int len) |
| 496 | { |
| 497 | IOReturn result; |
| 498 | UInt32 numBytes = len; |
| 499 | |
| 500 | if (!len) { |
| 501 | return 0; |
| 502 | } |
| 503 | |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 504 | if (!handle || handle->dead) { |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 505 | return -1; |
| 506 | } |
| 507 | |
| 508 | if (NULL == handle->interface) { |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 509 | LOG(ERROR) << "usb_read interface was null"; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 510 | return -1; |
| 511 | } |
| 512 | |
| 513 | if (0 == handle->bulkIn) { |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 514 | LOG(ERROR) << "bulkIn endpoint not assigned"; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 515 | return -1; |
| 516 | } |
| 517 | |
Esteban de la Canal | 647231a | 2014-09-11 11:02:17 -0700 | [diff] [blame] | 518 | result = (*handle->interface)->ReadPipe(handle->interface, handle->bulkIn, buf, &numBytes); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 519 | |
Esteban de la Canal | 647231a | 2014-09-11 11:02:17 -0700 | [diff] [blame] | 520 | if (kIOUSBPipeStalled == result) { |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 521 | LOG(ERROR) << "Pipe stalled, clearing stall.\n"; |
Esteban de la Canal | 647231a | 2014-09-11 11:02:17 -0700 | [diff] [blame] | 522 | (*handle->interface)->ClearPipeStall(handle->interface, handle->bulkIn); |
| 523 | result = (*handle->interface)->ReadPipe(handle->interface, handle->bulkIn, buf, &numBytes); |
| 524 | } |
| 525 | |
| 526 | if (kIOReturnSuccess == result) |
Yabin Cui | 3cf1b36 | 2017-03-10 16:01:01 -0800 | [diff] [blame] | 527 | return numBytes; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 528 | else { |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 529 | LOG(ERROR) << "usb_read failed with status: " << std::hex << result; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 530 | } |
| 531 | |
| 532 | return -1; |
| 533 | } |
| 534 | |
| 535 | int usb_close(usb_handle *handle) |
| 536 | { |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 537 | std::lock_guard<std::mutex> lock(g_usb_handles_mutex); |
| 538 | for (auto it = g_usb_handles.begin(); it != g_usb_handles.end(); ++it) { |
| 539 | if ((*it).get() == handle) { |
| 540 | g_usb_handles.erase(it); |
| 541 | break; |
| 542 | } |
| 543 | } |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 544 | return 0; |
| 545 | } |
| 546 | |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 547 | static void usb_kick_locked(usb_handle *handle) |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 548 | { |
Siva Velusamy | 878e36b | 2015-08-18 17:53:16 -0700 | [diff] [blame] | 549 | LOG(INFO) << "Kicking handle"; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 550 | /* release the interface */ |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 551 | if (!handle) |
| 552 | return; |
| 553 | |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 554 | if (!handle->dead) |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 555 | { |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 556 | handle->dead = true; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 557 | (*handle->interface)->USBInterfaceClose(handle->interface); |
| 558 | (*handle->interface)->Release(handle->interface); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 559 | } |
| 560 | } |
Yabin Cui | 234a02a | 2016-03-25 13:55:07 -0700 | [diff] [blame] | 561 | |
| 562 | void usb_kick(usb_handle *handle) { |
| 563 | // Use the lock to avoid multiple thread kicking the device at the same time. |
| 564 | std::lock_guard<std::mutex> lock_guard(g_usb_handles_mutex); |
| 565 | usb_kick_locked(handle); |
| 566 | } |
Josh Gao | 3734cf0 | 2017-05-02 15:01:09 -0700 | [diff] [blame] | 567 | |
| 568 | size_t usb_get_max_packet_size(usb_handle* handle) { |
| 569 | return handle->max_packet_size; |
| 570 | } |
| 571 | |
Josh Gao | 484ddbf | 2017-01-26 14:01:02 -0800 | [diff] [blame] | 572 | } // namespace native |