| OLD | NEW |
| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 jsize count = env->GetArrayLength(configurations.obj()); | 76 jsize count = env->GetArrayLength(configurations.obj()); |
| 77 configurations_.reserve(count); | 77 configurations_.reserve(count); |
| 78 for (jsize i = 0; i < count; ++i) { | 78 for (jsize i = 0; i < count; ++i) { |
| 79 ScopedJavaLocalRef<jobject> config( | 79 ScopedJavaLocalRef<jobject> config( |
| 80 env, env->GetObjectArrayElement(configurations.obj(), i)); | 80 env, env->GetObjectArrayElement(configurations.obj(), i)); |
| 81 configurations_.push_back(UsbConfigurationAndroid::Convert(env, config)); | 81 configurations_.push_back(UsbConfigurationAndroid::Convert(env, config)); |
| 82 } | 82 } |
| 83 } else { | 83 } else { |
| 84 // Pre-lollipop only the first configuration was supported. Build a basic | 84 // Pre-lollipop only the first configuration was supported. Build a basic |
| 85 // configuration out of the available interfaces. | 85 // configuration out of the available interfaces. |
| 86 UsbConfigDescriptor config; | 86 UsbConfigDescriptor config(1, // Configuration value, reasonable guess. |
| 87 config.configuration_value = 1; // Reasonable guess. | 87 false, // Self powered, arbitrary default. |
| 88 config.self_powered = false; // Arbitrary default. | 88 false, // Remote wakeup, rbitrary default. |
| 89 config.remote_wakeup = false; // Arbitrary default. | 89 0); // Maximum power, aitrary default. |
| 90 config.maximum_power = 0; // Arbitrary default. | |
| 91 | 90 |
| 92 ScopedJavaLocalRef<jobjectArray> interfaces = | 91 ScopedJavaLocalRef<jobjectArray> interfaces = |
| 93 Java_ChromeUsbDevice_getInterfaces(env, wrapper.obj()); | 92 Java_ChromeUsbDevice_getInterfaces(env, wrapper.obj()); |
| 94 jsize count = env->GetArrayLength(interfaces.obj()); | 93 jsize count = env->GetArrayLength(interfaces.obj()); |
| 95 config.interfaces.reserve(count); | 94 config.interfaces.reserve(count); |
| 96 for (jsize i = 0; i < count; ++i) { | 95 for (jsize i = 0; i < count; ++i) { |
| 97 ScopedJavaLocalRef<jobject> interface( | 96 ScopedJavaLocalRef<jobject> interface( |
| 98 env, env->GetObjectArrayElement(interfaces.obj(), i)); | 97 env, env->GetObjectArrayElement(interfaces.obj(), i)); |
| 99 config.interfaces.push_back(UsbInterfaceAndroid::Convert(env, interface)); | 98 config.interfaces.push_back(UsbInterfaceAndroid::Convert(env, interface)); |
| 100 } | 99 } |
| 101 configurations_.push_back(config); | 100 configurations_.push_back(config); |
| 102 } | 101 } |
| 103 } | 102 } |
| 104 | 103 |
| 105 UsbDeviceAndroid::~UsbDeviceAndroid() {} | 104 UsbDeviceAndroid::~UsbDeviceAndroid() {} |
| 106 | 105 |
| 107 } // namespace device | 106 } // namespace device |
| OLD | NEW |