Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: device/usb/usb_device_android.cc

Issue 1857033002: Include USB device version in chrome.usb.Device fields. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/usb/usb_device_android.h ('k') | device/usb/usb_device_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "device/usb/usb_device_android.h" 5 #include "device/usb/usb_device_android.h"
6 6
7 #include "base/android/build_info.h" 7 #include "base/android/build_info.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 14 matching lines...) Expand all
25 bool UsbDeviceAndroid::RegisterJNI(JNIEnv* env) { 25 bool UsbDeviceAndroid::RegisterJNI(JNIEnv* env) {
26 return RegisterNativesImpl(env); // Generated in ChromeUsbDevice_jni.h 26 return RegisterNativesImpl(env); // Generated in ChromeUsbDevice_jni.h
27 } 27 }
28 28
29 // static 29 // static
30 scoped_refptr<UsbDeviceAndroid> UsbDeviceAndroid::Create( 30 scoped_refptr<UsbDeviceAndroid> UsbDeviceAndroid::Create(
31 JNIEnv* env, 31 JNIEnv* env,
32 const JavaRef<jobject>& usb_device) { 32 const JavaRef<jobject>& usb_device) {
33 ScopedJavaLocalRef<jobject> wrapper = 33 ScopedJavaLocalRef<jobject> wrapper =
34 Java_ChromeUsbDevice_create(env, usb_device.obj()); 34 Java_ChromeUsbDevice_create(env, usb_device.obj());
35 uint16_t vendor_id = Java_ChromeUsbDevice_getVendorId(env, wrapper.obj()); 35 uint16_t device_version = 0;
36 uint16_t product_id = Java_ChromeUsbDevice_getProductId(env, wrapper.obj()); 36 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 23)
37 device_version = Java_ChromeUsbDevice_getDeviceVersion(env, wrapper.obj());
37 ScopedJavaLocalRef<jstring> manufacturer_string = 38 ScopedJavaLocalRef<jstring> manufacturer_string =
38 Java_ChromeUsbDevice_getManufacturerName(env, wrapper.obj()); 39 Java_ChromeUsbDevice_getManufacturerName(env, wrapper.obj());
39 ScopedJavaLocalRef<jstring> product_string = 40 ScopedJavaLocalRef<jstring> product_string =
40 Java_ChromeUsbDevice_getProductName(env, wrapper.obj()); 41 Java_ChromeUsbDevice_getProductName(env, wrapper.obj());
41 ScopedJavaLocalRef<jstring> serial_number = 42 ScopedJavaLocalRef<jstring> serial_number =
42 Java_ChromeUsbDevice_getSerialNumber(env, wrapper.obj()); 43 Java_ChromeUsbDevice_getSerialNumber(env, wrapper.obj());
43 return make_scoped_refptr(new UsbDeviceAndroid( 44 return make_scoped_refptr(new UsbDeviceAndroid(
44 env, vendor_id, product_id, 45 env,
46 0x0200, // USB protocol version, not provided by the Android API.
47 Java_ChromeUsbDevice_getDeviceClass(env, wrapper.obj()),
48 Java_ChromeUsbDevice_getDeviceSubclass(env, wrapper.obj()),
49 Java_ChromeUsbDevice_getDeviceProtocol(env, wrapper.obj()),
50 Java_ChromeUsbDevice_getVendorId(env, wrapper.obj()),
51 Java_ChromeUsbDevice_getProductId(env, wrapper.obj()), device_version,
45 ConvertJavaStringToUTF16(env, manufacturer_string), 52 ConvertJavaStringToUTF16(env, manufacturer_string),
46 ConvertJavaStringToUTF16(env, product_string), 53 ConvertJavaStringToUTF16(env, product_string),
47 ConvertJavaStringToUTF16(env, serial_number), wrapper)); 54 ConvertJavaStringToUTF16(env, serial_number), wrapper));
48 } 55 }
49 56
50 void UsbDeviceAndroid::Open(const OpenCallback& callback) { 57 void UsbDeviceAndroid::Open(const OpenCallback& callback) {
51 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 58 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
52 base::Bind(callback, nullptr)); 59 base::Bind(callback, nullptr));
53 } 60 }
54 61
55 const UsbConfigDescriptor* UsbDeviceAndroid::GetActiveConfiguration() const { 62 const UsbConfigDescriptor* UsbDeviceAndroid::GetActiveConfiguration() const {
56 return nullptr; 63 return nullptr;
57 } 64 }
58 65
59 UsbDeviceAndroid::UsbDeviceAndroid(JNIEnv* env, 66 UsbDeviceAndroid::UsbDeviceAndroid(JNIEnv* env,
67 uint16_t usb_version,
68 uint8_t device_class,
69 uint8_t device_subclass,
70 uint8_t device_protocol,
60 uint16_t vendor_id, 71 uint16_t vendor_id,
61 uint16_t product_id, 72 uint16_t product_id,
73 uint16_t device_version,
62 const base::string16& manufacturer_string, 74 const base::string16& manufacturer_string,
63 const base::string16& product_string, 75 const base::string16& product_string,
64 const base::string16& serial_number, 76 const base::string16& serial_number,
65 const JavaRef<jobject>& wrapper) 77 const JavaRef<jobject>& wrapper)
66 : UsbDevice(vendor_id, 78 : UsbDevice(usb_version,
79 device_class,
80 device_subclass,
81 device_protocol,
82 vendor_id,
67 product_id, 83 product_id,
84 device_version,
68 manufacturer_string, 85 manufacturer_string,
69 product_string, 86 product_string,
70 serial_number) { 87 serial_number) {
71 j_object_.Reset(wrapper); 88 j_object_.Reset(wrapper);
72 89
73 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 21) { 90 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 21) {
74 ScopedJavaLocalRef<jobjectArray> configurations = 91 ScopedJavaLocalRef<jobjectArray> configurations =
75 Java_ChromeUsbDevice_getConfigurations(env, j_object_.obj()); 92 Java_ChromeUsbDevice_getConfigurations(env, j_object_.obj());
76 jsize count = env->GetArrayLength(configurations.obj()); 93 jsize count = env->GetArrayLength(configurations.obj());
77 configurations_.reserve(count); 94 configurations_.reserve(count);
(...skipping 19 matching lines...) Expand all
97 env, env->GetObjectArrayElement(interfaces.obj(), i)); 114 env, env->GetObjectArrayElement(interfaces.obj(), i));
98 config.interfaces.push_back(UsbInterfaceAndroid::Convert(env, interface)); 115 config.interfaces.push_back(UsbInterfaceAndroid::Convert(env, interface));
99 } 116 }
100 configurations_.push_back(config); 117 configurations_.push_back(config);
101 } 118 }
102 } 119 }
103 120
104 UsbDeviceAndroid::~UsbDeviceAndroid() {} 121 UsbDeviceAndroid::~UsbDeviceAndroid() {}
105 122
106 } // namespace device 123 } // namespace device
OLDNEW
« no previous file with comments | « device/usb/usb_device_android.h ('k') | device/usb/usb_device_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698