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

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: Extract fields on Android as well. 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());
36 uint16_t product_id = Java_ChromeUsbDevice_getProductId(env, wrapper.obj());
37 ScopedJavaLocalRef<jstring> manufacturer_string = 35 ScopedJavaLocalRef<jstring> manufacturer_string =
38 Java_ChromeUsbDevice_getManufacturerName(env, wrapper.obj()); 36 Java_ChromeUsbDevice_getManufacturerName(env, wrapper.obj());
39 ScopedJavaLocalRef<jstring> product_string = 37 ScopedJavaLocalRef<jstring> product_string =
40 Java_ChromeUsbDevice_getProductName(env, wrapper.obj()); 38 Java_ChromeUsbDevice_getProductName(env, wrapper.obj());
41 ScopedJavaLocalRef<jstring> serial_number = 39 ScopedJavaLocalRef<jstring> serial_number =
42 Java_ChromeUsbDevice_getSerialNumber(env, wrapper.obj()); 40 Java_ChromeUsbDevice_getSerialNumber(env, wrapper.obj());
43 return make_scoped_refptr(new UsbDeviceAndroid( 41 return make_scoped_refptr(new UsbDeviceAndroid(
44 env, vendor_id, product_id, 42 env,
43 0x0200, // USB protocol version, not provided by the Android API.
44 Java_ChromeUsbDevice_getDeviceClass(env, wrapper.obj()),
45 Java_ChromeUsbDevice_getDeviceSubclass(env, wrapper.obj()),
46 Java_ChromeUsbDevice_getDeviceProtocol(env, wrapper.obj()),
47 Java_ChromeUsbDevice_getVendorId(env, wrapper.obj()),
48 Java_ChromeUsbDevice_getProductId(env, wrapper.obj()),
49 0x0000, // Device version, not available until API version 23.
asargent_no_longer_on_chrome 2016/04/05 21:31:16 Out of curiousity, is it possible to have a method
45 ConvertJavaStringToUTF16(env, manufacturer_string), 50 ConvertJavaStringToUTF16(env, manufacturer_string),
46 ConvertJavaStringToUTF16(env, product_string), 51 ConvertJavaStringToUTF16(env, product_string),
47 ConvertJavaStringToUTF16(env, serial_number), wrapper)); 52 ConvertJavaStringToUTF16(env, serial_number), wrapper));
48 } 53 }
49 54
50 void UsbDeviceAndroid::Open(const OpenCallback& callback) { 55 void UsbDeviceAndroid::Open(const OpenCallback& callback) {
51 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 56 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
52 base::Bind(callback, nullptr)); 57 base::Bind(callback, nullptr));
53 } 58 }
54 59
55 const UsbConfigDescriptor* UsbDeviceAndroid::GetActiveConfiguration() const { 60 const UsbConfigDescriptor* UsbDeviceAndroid::GetActiveConfiguration() const {
56 return nullptr; 61 return nullptr;
57 } 62 }
58 63
59 UsbDeviceAndroid::UsbDeviceAndroid(JNIEnv* env, 64 UsbDeviceAndroid::UsbDeviceAndroid(JNIEnv* env,
65 uint16_t usb_version,
66 uint8_t device_class,
67 uint8_t device_subclass,
68 uint8_t device_protocol,
60 uint16_t vendor_id, 69 uint16_t vendor_id,
61 uint16_t product_id, 70 uint16_t product_id,
71 uint16_t device_version,
62 const base::string16& manufacturer_string, 72 const base::string16& manufacturer_string,
63 const base::string16& product_string, 73 const base::string16& product_string,
64 const base::string16& serial_number, 74 const base::string16& serial_number,
65 const JavaRef<jobject>& wrapper) 75 const JavaRef<jobject>& wrapper)
66 : UsbDevice(vendor_id, 76 : UsbDevice(usb_version,
77 device_class,
78 device_subclass,
79 device_protocol,
80 vendor_id,
67 product_id, 81 product_id,
82 device_version,
68 manufacturer_string, 83 manufacturer_string,
69 product_string, 84 product_string,
70 serial_number) { 85 serial_number) {
71 j_object_.Reset(wrapper); 86 j_object_.Reset(wrapper);
72 87
73 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 21) { 88 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 21) {
74 ScopedJavaLocalRef<jobjectArray> configurations = 89 ScopedJavaLocalRef<jobjectArray> configurations =
75 Java_ChromeUsbDevice_getConfigurations(env, j_object_.obj()); 90 Java_ChromeUsbDevice_getConfigurations(env, j_object_.obj());
76 jsize count = env->GetArrayLength(configurations.obj()); 91 jsize count = env->GetArrayLength(configurations.obj());
77 configurations_.reserve(count); 92 configurations_.reserve(count);
(...skipping 19 matching lines...) Expand all
97 env, env->GetObjectArrayElement(interfaces.obj(), i)); 112 env, env->GetObjectArrayElement(interfaces.obj(), i));
98 config.interfaces.push_back(UsbInterfaceAndroid::Convert(env, interface)); 113 config.interfaces.push_back(UsbInterfaceAndroid::Convert(env, interface));
99 } 114 }
100 configurations_.push_back(config); 115 configurations_.push_back(config);
101 } 116 }
102 } 117 }
103 118
104 UsbDeviceAndroid::~UsbDeviceAndroid() {} 119 UsbDeviceAndroid::~UsbDeviceAndroid() {}
105 120
106 } // namespace device 121 } // 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