usb_device_handle_android.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2016 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef SERVICES_DEVICE_USB_USB_DEVICE_HANDLE_ANDROID_H_
  5. #define SERVICES_DEVICE_USB_USB_DEVICE_HANDLE_ANDROID_H_
  6. #include "base/android/scoped_java_ref.h"
  7. #include "base/memory/ref_counted.h"
  8. #include "services/device/usb/usb_device_handle_usbfs.h"
  9. namespace device {
  10. class UsbDevice;
  11. // Extends UsbDeviceHandleUsbfs with support for managing a device connection
  12. // through an instance of android.hardware.usb.UsbDeviceConnection.
  13. class UsbDeviceHandleAndroid : public UsbDeviceHandleUsbfs {
  14. public:
  15. static scoped_refptr<UsbDeviceHandleAndroid> Create(
  16. JNIEnv* env,
  17. scoped_refptr<UsbDevice> device,
  18. const base::android::JavaRef<jobject>& usb_connection);
  19. private:
  20. // |wrapper| is an instance of org.chromium.device.usb.ChromeUsbConnection.
  21. UsbDeviceHandleAndroid(scoped_refptr<UsbDevice> device,
  22. base::ScopedFD fd,
  23. const base::android::JavaRef<jobject>& wrapper);
  24. ~UsbDeviceHandleAndroid() override;
  25. // UsbDeviceHandleUsbfs:
  26. void FinishClose() override;
  27. void CloseConnection();
  28. // Java object org.chromium.device.usb.ChromeUsbConnection.
  29. base::android::ScopedJavaGlobalRef<jobject> j_object_;
  30. };
  31. } // namespace device
  32. #endif // SERVICES_DEVICE_USB_USB_DEVICE_HANDLE_ANDROID_H_