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 package org.chromium.media.midi; | 5 package org.chromium.midi; |
6 | 6 |
7 import android.app.PendingIntent; | 7 import android.app.PendingIntent; |
8 import android.content.BroadcastReceiver; | 8 import android.content.BroadcastReceiver; |
9 import android.content.Context; | 9 import android.content.Context; |
10 import android.content.Intent; | 10 import android.content.Intent; |
11 import android.content.IntentFilter; | 11 import android.content.IntentFilter; |
12 import android.hardware.usb.UsbConstants; | 12 import android.hardware.usb.UsbConstants; |
13 import android.hardware.usb.UsbDevice; | 13 import android.hardware.usb.UsbDevice; |
14 import android.hardware.usb.UsbInterface; | 14 import android.hardware.usb.UsbInterface; |
15 import android.hardware.usb.UsbManager; | 15 import android.hardware.usb.UsbManager; |
16 import android.os.Parcelable; | 16 import android.os.Parcelable; |
17 | 17 |
18 import org.chromium.base.annotations.CalledByNative; | 18 import org.chromium.base.annotations.CalledByNative; |
19 import org.chromium.base.annotations.JNINamespace; | 19 import org.chromium.base.annotations.JNINamespace; |
20 | 20 |
21 import java.util.ArrayList; | 21 import java.util.ArrayList; |
22 import java.util.HashSet; | 22 import java.util.HashSet; |
23 import java.util.List; | 23 import java.util.List; |
24 import java.util.Map; | 24 import java.util.Map; |
25 import java.util.Set; | 25 import java.util.Set; |
26 | 26 |
27 /** | 27 /** |
28 * Owned by its native counterpart declared in | 28 * Owned by its native counterpart declared in |
29 * usb_midi_device_factory_android.h. Refer to that class for general comments. | 29 * usb_midi_device_factory_android.h. Refer to that class for general comments. |
30 */ | 30 */ |
31 @JNINamespace("media::midi") | 31 @JNINamespace("midi") |
32 class UsbMidiDeviceFactoryAndroid { | 32 class UsbMidiDeviceFactoryAndroid { |
33 /** | 33 /** |
34 * The UsbManager of this system. | 34 * The UsbManager of this system. |
35 */ | 35 */ |
36 private UsbManager mUsbManager; | 36 private UsbManager mUsbManager; |
37 | 37 |
38 /** | 38 /** |
39 * A BroadcastReceiver for USB device events. | 39 * A BroadcastReceiver for USB device events. |
40 */ | 40 */ |
41 private BroadcastReceiver mReceiver; | 41 private BroadcastReceiver mReceiver; |
(...skipping 11 matching lines...) Expand all Loading... |
53 /** | 53 /** |
54 * True when the enumeration is in progress. | 54 * True when the enumeration is in progress. |
55 */ | 55 */ |
56 private boolean mIsEnumeratingDevices; | 56 private boolean mIsEnumeratingDevices; |
57 | 57 |
58 /** | 58 /** |
59 * The identifier of this factory. | 59 * The identifier of this factory. |
60 */ | 60 */ |
61 private long mNativePointer; | 61 private long mNativePointer; |
62 | 62 |
63 private static final String ACTION_USB_PERMISSION = "org.chromium.media.USB_
PERMISSION"; | 63 private static final String ACTION_USB_PERMISSION = "org.chromium.midi.USB_P
ERMISSION"; |
64 | 64 |
65 /** | 65 /** |
66 * Constructs a UsbMidiDeviceAndroid. | 66 * Constructs a UsbMidiDeviceAndroid. |
67 * @param context | 67 * @param context |
68 * @param nativePointer The native pointer to which the created factory is a
ssociated. | 68 * @param nativePointer The native pointer to which the created factory is a
ssociated. |
69 */ | 69 */ |
70 UsbMidiDeviceFactoryAndroid(Context context, long nativePointer) { | 70 UsbMidiDeviceFactoryAndroid(Context context, long nativePointer) { |
71 mUsbManager = (UsbManager) context.getSystemService(Context.USB_SERVICE)
; | 71 mUsbManager = (UsbManager) context.getSystemService(Context.USB_SERVICE)
; |
72 mNativePointer = nativePointer; | 72 mNativePointer = nativePointer; |
73 mReceiver = new BroadcastReceiver() { | 73 mReceiver = new BroadcastReceiver() { |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 context.unregisterReceiver(mReceiver); | 255 context.unregisterReceiver(mReceiver); |
256 } | 256 } |
257 | 257 |
258 private static native void nativeOnUsbMidiDeviceRequestDone( | 258 private static native void nativeOnUsbMidiDeviceRequestDone( |
259 long nativeUsbMidiDeviceFactoryAndroid, Object[] devices); | 259 long nativeUsbMidiDeviceFactoryAndroid, Object[] devices); |
260 private static native void nativeOnUsbMidiDeviceAttached( | 260 private static native void nativeOnUsbMidiDeviceAttached( |
261 long nativeUsbMidiDeviceFactoryAndroid, Object device); | 261 long nativeUsbMidiDeviceFactoryAndroid, Object device); |
262 private static native void nativeOnUsbMidiDeviceDetached( | 262 private static native void nativeOnUsbMidiDeviceDetached( |
263 long nativeUsbMidiDeviceFactoryAndroid, int index); | 263 long nativeUsbMidiDeviceFactoryAndroid, int index); |
264 } | 264 } |
OLD | NEW |