OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/devtools/device/devtools_android_bridge.h" | 8 #include "chrome/browser/devtools/device/devtools_android_bridge.h" |
9 #include "chrome/browser/devtools/device/usb/android_usb_device.h" | 9 #include "chrome/browser/devtools/device/usb/android_usb_device.h" |
10 #include "chrome/browser/devtools/device/usb/usb_device_provider.h" | 10 #include "chrome/browser/devtools/device/usb/usb_device_provider.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 device_->claimed_interfaces_.erase(interface_number); | 137 device_->claimed_interfaces_.erase(interface_number); |
138 return true; | 138 return true; |
139 } | 139 } |
140 | 140 |
141 virtual bool SetInterfaceAlternateSetting(int interface_number, | 141 virtual bool SetInterfaceAlternateSetting(int interface_number, |
142 int alternate_setting) OVERRIDE { | 142 int alternate_setting) OVERRIDE { |
143 return true; | 143 return true; |
144 } | 144 } |
145 | 145 |
146 virtual bool ResetDevice() OVERRIDE { return true; } | 146 virtual bool ResetDevice() OVERRIDE { return true; } |
147 | 147 virtual bool GetStringDescriptor(uint8_t string_id, base::string16* content) { |
148 virtual bool GetManufacturer(base::string16* manufacturer) OVERRIDE { | 148 return false; |
149 *manufacturer = base::UTF8ToUTF16(kDeviceManufacturer); | |
150 return true; | |
151 } | |
152 | |
153 virtual bool GetProduct(base::string16* product) OVERRIDE { | |
154 *product = base::UTF8ToUTF16(kDeviceModel); | |
155 return true; | |
156 } | |
157 | |
158 virtual bool GetSerial(base::string16* serial) OVERRIDE { | |
159 *serial = base::UTF8ToUTF16(kDeviceSerial); | |
160 return true; | |
161 } | 149 } |
162 | 150 |
163 // Async IO. Can be called on any thread. | 151 // Async IO. Can be called on any thread. |
164 virtual void ControlTransfer(UsbEndpointDirection direction, | 152 virtual void ControlTransfer(UsbEndpointDirection direction, |
165 TransferRequestType request_type, | 153 TransferRequestType request_type, |
166 TransferRecipient recipient, | 154 TransferRecipient recipient, |
167 uint8 request, | 155 uint8 request, |
168 uint16 value, | 156 uint16 value, |
169 uint16 index, | 157 uint16 index, |
170 net::IOBuffer* buffer, | 158 net::IOBuffer* buffer, |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 } | 360 } |
373 | 361 |
374 virtual scoped_refptr<UsbDeviceHandle> Open() OVERRIDE { | 362 virtual scoped_refptr<UsbDeviceHandle> Open() OVERRIDE { |
375 return new MockUsbDeviceHandle<T>(this); | 363 return new MockUsbDeviceHandle<T>(this); |
376 } | 364 } |
377 | 365 |
378 virtual const UsbConfigDescriptor& GetConfiguration() OVERRIDE { | 366 virtual const UsbConfigDescriptor& GetConfiguration() OVERRIDE { |
379 return config_desc_; | 367 return config_desc_; |
380 } | 368 } |
381 | 369 |
| 370 virtual bool GetManufacturer(base::string16* manufacturer) OVERRIDE { |
| 371 *manufacturer = base::UTF8ToUTF16(kDeviceManufacturer); |
| 372 return true; |
| 373 } |
| 374 |
| 375 virtual bool GetProduct(base::string16* product) OVERRIDE { |
| 376 *product = base::UTF8ToUTF16(kDeviceModel); |
| 377 return true; |
| 378 } |
| 379 |
| 380 virtual bool GetSerialNumber(base::string16* serial) OVERRIDE { |
| 381 *serial = base::UTF8ToUTF16(kDeviceSerial); |
| 382 return true; |
| 383 } |
| 384 |
382 virtual bool Close(scoped_refptr<UsbDeviceHandle> handle) OVERRIDE { | 385 virtual bool Close(scoped_refptr<UsbDeviceHandle> handle) OVERRIDE { |
383 return true; | 386 return true; |
384 } | 387 } |
385 | 388 |
386 #if defined(OS_CHROMEOS) | 389 #if defined(OS_CHROMEOS) |
387 // On ChromeOS, if an interface of a claimed device is not claimed, the | 390 // On ChromeOS, if an interface of a claimed device is not claimed, the |
388 // permission broker can change the owner of the device so that the unclaimed | 391 // permission broker can change the owner of the device so that the unclaimed |
389 // interfaces can be used. If this argument is missing, permission broker will | 392 // interfaces can be used. If this argument is missing, permission broker will |
390 // not be used and this method fails if the device is claimed. | 393 // not be used and this method fails if the device is claimed. |
391 virtual void RequestUsbAccess( | 394 virtual void RequestUsbAccess( |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 runner_->Run(); | 764 runner_->Run(); |
762 EXPECT_EQ(2, listener.invoked_); | 765 EXPECT_EQ(2, listener.invoked_); |
763 EXPECT_EQ(listener.invoked_ - 1, scheduler_invoked_); | 766 EXPECT_EQ(listener.invoked_ - 1, scheduler_invoked_); |
764 } | 767 } |
765 | 768 |
766 IN_PROC_BROWSER_TEST_F(AndroidUsbTraitsTest, TestDeviceCounting) { | 769 IN_PROC_BROWSER_TEST_F(AndroidUsbTraitsTest, TestDeviceCounting) { |
767 MockCountListenerForCheckingTraits listener(adb_bridge_); | 770 MockCountListenerForCheckingTraits listener(adb_bridge_); |
768 adb_bridge_->AddDeviceCountListener(&listener); | 771 adb_bridge_->AddDeviceCountListener(&listener); |
769 runner_->Run(); | 772 runner_->Run(); |
770 } | 773 } |
OLD | NEW |