diff options
author | Mike Lockwood <lockwood@android.com> | 2011-03-01 11:58:22 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-03-01 11:58:22 -0800 |
commit | 04e1a9620f94319c455c9422776adb4a8963f920 (patch) | |
tree | e01ddd770061dc1917ef7365f9743f9a0ff29cf9 /core | |
parent | 42b3de5833c737c8ec16babeb1f254baf623abfc (diff) | |
parent | c4308f01c965571dc2354107c3574df113e397ee (diff) | |
download | frameworks_base-04e1a9620f94319c455c9422776adb4a8963f920.zip frameworks_base-04e1a9620f94319c455c9422776adb4a8963f920.tar.gz frameworks_base-04e1a9620f94319c455c9422776adb4a8963f920.tar.bz2 |
Merge "Move USB framework support from android.hardware to android.hardware.usb package"
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/app/ContextImpl.java | 4 | ||||
-rw-r--r-- | core/java/android/content/Context.java | 4 | ||||
-rw-r--r-- | core/java/android/hardware/usb/IUsbManager.aidl (renamed from core/java/android/hardware/IUsbManager.aidl) | 6 | ||||
-rw-r--r-- | core/java/android/hardware/usb/UsbAccessory.aidl (renamed from core/java/android/hardware/UsbAccessory.aidl) | 2 | ||||
-rw-r--r-- | core/java/android/hardware/usb/UsbAccessory.java (renamed from core/java/android/hardware/UsbAccessory.java) | 16 | ||||
-rw-r--r-- | core/java/android/hardware/usb/UsbConstants.java (renamed from core/java/android/hardware/UsbConstants.java) | 2 | ||||
-rw-r--r-- | core/java/android/hardware/usb/UsbDevice.aidl (renamed from core/java/android/hardware/UsbDevice.aidl) | 2 | ||||
-rw-r--r-- | core/java/android/hardware/usb/UsbDevice.java (renamed from core/java/android/hardware/UsbDevice.java) | 25 | ||||
-rw-r--r-- | core/java/android/hardware/usb/UsbEndpoint.aidl (renamed from core/java/android/hardware/UsbEndpoint.aidl) | 2 | ||||
-rw-r--r-- | core/java/android/hardware/usb/UsbEndpoint.java (renamed from core/java/android/hardware/UsbEndpoint.java) | 20 | ||||
-rw-r--r-- | core/java/android/hardware/usb/UsbInterface.aidl (renamed from core/java/android/hardware/UsbInterface.aidl) | 2 | ||||
-rw-r--r-- | core/java/android/hardware/usb/UsbInterface.java (renamed from core/java/android/hardware/UsbInterface.java) | 14 | ||||
-rw-r--r-- | core/java/android/hardware/usb/UsbManager.java (renamed from core/java/android/hardware/UsbManager.java) | 22 | ||||
-rw-r--r-- | core/java/android/hardware/usb/UsbRequest.java (renamed from core/java/android/hardware/UsbRequest.java) | 12 | ||||
-rw-r--r-- | core/jni/android_hardware_UsbDevice.cpp | 8 | ||||
-rw-r--r-- | core/jni/android_hardware_UsbEndpoint.cpp | 124 | ||||
-rw-r--r-- | core/jni/android_hardware_UsbRequest.cpp | 8 | ||||
-rw-r--r-- | core/res/AndroidManifest.xml | 10 |
18 files changed, 78 insertions, 205 deletions
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index 8737e93..539e946 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -41,9 +41,9 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase.CursorFactory; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; -import android.hardware.IUsbManager; import android.hardware.SensorManager; -import android.hardware.UsbManager; +import android.hardware.usb.IUsbManager; +import android.hardware.usb.UsbManager; import android.location.CountryDetector; import android.location.ICountryDetector; import android.location.ILocationManager; diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 051ae9e..4c7d87f 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -1664,11 +1664,11 @@ public abstract class Context { /** * Use with {@link #getSystemService} to retrieve a {@link - * android.hardware.UsbManager} for access to USB devices (as a USB host) + * android.hardware.usb.UsbManager} for access to USB devices (as a USB host) * and for controlling this device's behavior as a USB device. * * @see #getSystemService - * @see android.harware.UsbManager + * @see android.harware.usb.UsbManager */ public static final String USB_SERVICE = "usb"; diff --git a/core/java/android/hardware/IUsbManager.aidl b/core/java/android/hardware/usb/IUsbManager.aidl index 8086f37..be65bdb 100644 --- a/core/java/android/hardware/IUsbManager.aidl +++ b/core/java/android/hardware/usb/IUsbManager.aidl @@ -14,10 +14,10 @@ * limitations under the License. */ -package android.hardware; +package android.hardware.usb; -import android.hardware.UsbAccessory; -import android.hardware.UsbDevice; +import android.hardware.usb.UsbAccessory; +import android.hardware.usb.UsbDevice; import android.os.Bundle; import android.os.ParcelFileDescriptor; diff --git a/core/java/android/hardware/UsbAccessory.aidl b/core/java/android/hardware/usb/UsbAccessory.aidl index 97a777b..1c15f1c 100644 --- a/core/java/android/hardware/UsbAccessory.aidl +++ b/core/java/android/hardware/usb/UsbAccessory.aidl @@ -14,6 +14,6 @@ * limitations under the License. */ -package android.hardware; +package android.hardware.usb; parcelable UsbAccessory; diff --git a/core/java/android/hardware/UsbAccessory.java b/core/java/android/hardware/usb/UsbAccessory.java index 15dff3e..6cd9178 100644 --- a/core/java/android/hardware/UsbAccessory.java +++ b/core/java/android/hardware/usb/UsbAccessory.java @@ -14,28 +14,24 @@ * limitations under the License. */ -package android.hardware; +package android.hardware.usb; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; -import android.os.ParcelFileDescriptor; import android.util.Log; /** * A class representing a USB accessory. */ -public final class UsbAccessory implements Parcelable { +public class UsbAccessory implements Parcelable { private static final String TAG = "UsbAccessory"; - private String mManufacturer; - private String mModel; - private String mType; - private String mVersion; - - private UsbAccessory() { - } + private final String mManufacturer; + private final String mModel; + private final String mType; + private final String mVersion; /** * UsbAccessory should only be instantiated by UsbService implementation diff --git a/core/java/android/hardware/UsbConstants.java b/core/java/android/hardware/usb/UsbConstants.java index 4c8c4d4..6626c9f 100644 --- a/core/java/android/hardware/UsbConstants.java +++ b/core/java/android/hardware/usb/UsbConstants.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package android.hardware; +package android.hardware.usb; /** * Contains constants for the USB protocol. diff --git a/core/java/android/hardware/UsbDevice.aidl b/core/java/android/hardware/usb/UsbDevice.aidl index 6dfd43f..6030ad1 100644 --- a/core/java/android/hardware/UsbDevice.aidl +++ b/core/java/android/hardware/usb/UsbDevice.aidl @@ -14,6 +14,6 @@ * limitations under the License. */ -package android.hardware; +package android.hardware.usb; parcelable UsbDevice; diff --git a/core/java/android/hardware/UsbDevice.java b/core/java/android/hardware/usb/UsbDevice.java index ca7dae3..37bd82b 100644 --- a/core/java/android/hardware/UsbDevice.java +++ b/core/java/android/hardware/usb/UsbDevice.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package android.hardware; +package android.hardware.usb; import android.os.Bundle; import android.os.Parcel; @@ -106,7 +106,7 @@ public final class UsbDevice implements Parcelable { /** * Returns the devices's class field. * Some useful constants for USB device classes can be found in - * {@link android.hardware.UsbConstants} + * {@link android.hardware.usb.UsbConstants} * * @return the devices's class */ @@ -133,7 +133,7 @@ public final class UsbDevice implements Parcelable { } /** - * Returns the number of {@link android.hardware.UsbInterface}s this device contains. + * Returns the number of {@link android.hardware.usb.UsbInterface}s this device contains. * * @return the number of interfaces */ @@ -142,7 +142,7 @@ public final class UsbDevice implements Parcelable { } /** - * Returns the {@link android.hardware.UsbInterface} at the given index. + * Returns the {@link android.hardware.usb.UsbInterface} at the given index. * * @return the interface */ @@ -171,9 +171,9 @@ public final class UsbDevice implements Parcelable { } /** - * Claims exclusive access to a {@link android.hardware.UsbInterface}. + * Claims exclusive access to a {@link android.hardware.usb.UsbInterface}. * This must be done before sending or receiving data on any - * {@link android.hardware.UsbEndpoint}s belonging to the interface + * {@link android.hardware.usb.UsbEndpoint}s belonging to the interface * @param intf the interface to claim * @param force true to disconnect kernel driver if necessary * @return true if the interface was successfully claimed @@ -183,7 +183,7 @@ public final class UsbDevice implements Parcelable { } /** - * Releases exclusive access to a {@link android.hardware.UsbInterface}. + * Releases exclusive access to a {@link android.hardware.usb.UsbInterface}. * * @return true if the interface was successfully released */ @@ -231,11 +231,12 @@ public final class UsbDevice implements Parcelable { } /** - * Waits for the result of a {@link android.hardware.UsbRequest#queue} operation - * Note that this may return requests queued on multiple {@link android.hardware.UsbEndpoint}s. - * When multiple endpoints are in use, {@link android.hardware.UsbRequest#getEndpoint} and - * {@link android.hardware.UsbRequest#getClientData} can be useful in determining how to process - * the result of this function. + * Waits for the result of a {@link android.hardware.usb.UsbRequest#queue} operation + * Note that this may return requests queued on multiple + * {@link android.hardware.usb.UsbEndpoint}s. + * When multiple endpoints are in use, {@link android.hardware.usb.UsbRequest#getEndpoint} and + * {@link android.hardware.usb.UsbRequest#getClientData} can be useful in determining + * how to process the result of this function. * * @return a completed USB request, or null if an error occurred */ diff --git a/core/java/android/hardware/UsbEndpoint.aidl b/core/java/android/hardware/usb/UsbEndpoint.aidl index 51fc67b..a75cd7e 100644 --- a/core/java/android/hardware/UsbEndpoint.aidl +++ b/core/java/android/hardware/usb/UsbEndpoint.aidl @@ -14,6 +14,6 @@ * limitations under the License. */ -package android.hardware; +package android.hardware.usb; parcelable UsbEndpoint; diff --git a/core/java/android/hardware/UsbEndpoint.java b/core/java/android/hardware/usb/UsbEndpoint.java index 8d4099d..a48d88f 100644 --- a/core/java/android/hardware/UsbEndpoint.java +++ b/core/java/android/hardware/usb/UsbEndpoint.java @@ -14,14 +14,14 @@ * limitations under the License. */ -package android.hardware; +package android.hardware.usb; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; /** - * A class representing an endpoint on a {@link android.hardware.UsbInterface}. + * A class representing an endpoint on a {@link android.hardware.usb.UsbInterface}. */ public final class UsbEndpoint implements Parcelable { @@ -65,9 +65,9 @@ public final class UsbEndpoint implements Parcelable { /** * Returns the endpoint's direction. - * Returns {@link android.hardware.UsbConstants#USB_DIR_OUT} + * Returns {@link android.hardware.usb.UsbConstants#USB_DIR_OUT} * if the direction is host to device, and - * {@link android.hardware.UsbConstants#USB_DIR_IN} if the + * {@link android.hardware.usb.UsbConstants#USB_DIR_IN} if the * direction is device to host. * * @return the endpoint's direction @@ -89,10 +89,10 @@ public final class UsbEndpoint implements Parcelable { * Returns the endpoint's type. * Possible results are: * <ul> - * <li>{@link android.hardware.UsbConstants#USB_ENDPOINT_XFER_CONTROL} (endpoint zero) - * <li>{@link android.hardware.UsbConstants#USB_ENDPOINT_XFER_ISOC} (isochronous endpoint) - * <li>{@link android.hardware.UsbConstants#USB_ENDPOINT_XFER_BULK} (bulk endpoint) - * <li>{@link android.hardware.UsbConstants#USB_ENDPOINT_XFER_INT} (interrupt endpoint) + * <li>{@link android.hardware.usb.UsbConstants#USB_ENDPOINT_XFER_CONTROL} (endpoint zero) + * <li>{@link android.hardware.usb.UsbConstants#USB_ENDPOINT_XFER_ISOC} (isochronous endpoint) + * <li>{@link android.hardware.usb.UsbConstants#USB_ENDPOINT_XFER_BULK} (bulk endpoint) + * <li>{@link android.hardware.usb.UsbConstants#USB_ENDPOINT_XFER_INT} (interrupt endpoint) * </ul> * * @return the endpoint's type @@ -120,7 +120,7 @@ public final class UsbEndpoint implements Parcelable { } /** - * Returns the {@link android.hardware.UsbInterface} this endpoint belongs to. + * Returns the {@link android.hardware.usb.UsbInterface} this endpoint belongs to. * * @return the endpoint's interface */ @@ -129,7 +129,7 @@ public final class UsbEndpoint implements Parcelable { } /** - * Returns the {@link android.hardware.UsbDevice} this endpoint belongs to. + * Returns the {@link android.hardware.usb.UsbDevice} this endpoint belongs to. * * @return the endpoint's device */ diff --git a/core/java/android/hardware/UsbInterface.aidl b/core/java/android/hardware/usb/UsbInterface.aidl index a715ccd..32b8c64 100644 --- a/core/java/android/hardware/UsbInterface.aidl +++ b/core/java/android/hardware/usb/UsbInterface.aidl @@ -14,6 +14,6 @@ * limitations under the License. */ -package android.hardware; +package android.hardware.usb; parcelable UsbInterface; diff --git a/core/java/android/hardware/UsbInterface.java b/core/java/android/hardware/usb/UsbInterface.java index deef81f..b3b0e81 100644 --- a/core/java/android/hardware/UsbInterface.java +++ b/core/java/android/hardware/usb/UsbInterface.java @@ -14,16 +14,16 @@ * limitations under the License. */ -package android.hardware; +package android.hardware.usb; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; /** - * A class representing an interface on a {@link android.hardware.UsbDevice}. + * A class representing an interface on a {@link android.hardware.usb.UsbDevice}. */ -public final class UsbInterface implements Parcelable { +public class UsbInterface implements Parcelable { private int mId; private int mClass; @@ -60,7 +60,7 @@ public final class UsbInterface implements Parcelable { /** * Returns the interface's class field. * Some useful constants for USB classes can be found in - * {@link android.hardware.UsbConstants} + * {@link android.hardware.usb.UsbConstants} * * @return the interface's class */ @@ -87,7 +87,7 @@ public final class UsbInterface implements Parcelable { } /** - * Returns the number of {@link android.hardware.UsbEndpoint}s this interface contains. + * Returns the number of {@link android.hardware.usb.UsbEndpoint}s this interface contains. * * @return the number of endpoints */ @@ -96,7 +96,7 @@ public final class UsbInterface implements Parcelable { } /** - * Returns the {@link android.hardware.UsbEndpoint} at the given index. + * Returns the {@link android.hardware.usb.UsbEndpoint} at the given index. * * @return the endpoint */ @@ -105,7 +105,7 @@ public final class UsbInterface implements Parcelable { } /** - * Returns the {@link android.hardware.UsbDevice} this interface belongs to. + * Returns the {@link android.hardware.usb.UsbDevice} this interface belongs to. * * @return the interface's device */ diff --git a/core/java/android/hardware/UsbManager.java b/core/java/android/hardware/usb/UsbManager.java index e9a34ea..6683179 100644 --- a/core/java/android/hardware/UsbManager.java +++ b/core/java/android/hardware/usb/UsbManager.java @@ -15,7 +15,7 @@ */ -package android.hardware; +package android.hardware.usb; import android.os.Bundle; import android.os.ParcelFileDescriptor; @@ -55,55 +55,55 @@ public class UsbManager { * </ul> */ public static final String ACTION_USB_STATE = - "android.hardware.action.USB_STATE"; + "android.hardware.usb.action.USB_STATE"; /** * Broadcast Action: A broadcast for USB device attached event. * * This intent is sent when a USB device is attached to the USB bus when in host mode. * <ul> - * <li> {@link #EXTRA_DEVICE} containing the {@link android.hardware.UsbDevice} + * <li> {@link #EXTRA_DEVICE} containing the {@link android.hardware.usb.UsbDevice} * for the attached device * </ul> */ public static final String ACTION_USB_DEVICE_ATTACHED = - "android.hardware.action.USB_DEVICE_ATTACHED"; + "android.hardware.usb.action.USB_DEVICE_ATTACHED"; /** * Broadcast Action: A broadcast for USB device detached event. * * This intent is sent when a USB device is detached from the USB bus when in host mode. * <ul> - * <li> {@link #EXTRA_DEVICE} containing the {@link android.hardware.UsbDevice} + * <li> {@link #EXTRA_DEVICE} containing the {@link android.hardware.usb.UsbDevice} * for the detached device * </ul> */ public static final String ACTION_USB_DEVICE_DETACHED = - "android.hardware.action.USB_DEVICE_DETACHED"; + "android.hardware.usb.action.USB_DEVICE_DETACHED"; /** * Broadcast Action: A broadcast for USB accessory attached event. * * This intent is sent when a USB accessory is attached. * <ul> - * <li> {@link #EXTRA_ACCESSORY} containing the {@link android.hardware.UsbAccessory} + * <li> {@link #EXTRA_ACCESSORY} containing the {@link android.hardware.usb.UsbAccessory} * for the attached accessory * </ul> */ public static final String ACTION_USB_ACCESSORY_ATTACHED = - "android.hardware.action.USB_ACCESSORY_ATTACHED"; + "android.hardware.usb.action.USB_ACCESSORY_ATTACHED"; /** * Broadcast Action: A broadcast for USB accessory detached event. * * This intent is sent when a USB accessory is detached. * <ul> - * <li> {@link #EXTRA_ACCESSORY} containing the {@link android.hardware.UsbAccessory} + * <li> {@link #EXTRA_ACCESSORY} containing the {@link android.hardware.usb.UsbAccessory} * for the attached accessory that was detached * </ul> */ public static final String ACTION_USB_ACCESSORY_DETACHED = - "android.hardware.action.USB_ACCESSORY_DETACHED"; + "android.hardware.usb.action.USB_ACCESSORY_DETACHED"; /** * Boolean extra indicating whether USB is connected or disconnected. @@ -210,7 +210,7 @@ public class UsbManager { /** * Opens the device so it can be used to send and receive - * data using {@link android.hardware.UsbRequest}. + * data using {@link android.hardware.usb.UsbRequest}. * * @param device the device to open * @return true if we successfully opened the device diff --git a/core/java/android/hardware/UsbRequest.java b/core/java/android/hardware/usb/UsbRequest.java index ae3a289..80085c1 100644 --- a/core/java/android/hardware/UsbRequest.java +++ b/core/java/android/hardware/usb/UsbRequest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package android.hardware; +package android.hardware.usb; import android.util.Log; @@ -23,9 +23,9 @@ import java.nio.ByteBuffer; /** * A class representing USB request packet. * This can be used for both reading and writing data to or from a - * {@link android.hardware.UsbDevice}. + * {@link android.hardware.usb.UsbDevice}. * UsbRequests are sent asynchronously via {@link #queue} and the results - * are read by {@link android.hardware.UsbDevice#requestWait}. + * are read by {@link android.hardware.usb.UsbDevice#requestWait}. */ public class UsbRequest { @@ -94,7 +94,7 @@ public class UsbRequest { * This can be used in conjunction with {@link #setClientData} * to associate another object with this request, which can be useful for * maintaining state between calls to {@link #queue} and - * {@link android.hardware.UsbDevice#requestWait} + * {@link android.hardware.usb.UsbDevice#requestWait} * * @return the client data for the request */ @@ -107,7 +107,7 @@ public class UsbRequest { * This can be used in conjunction with {@link #getClientData} * to associate another object with this request, which can be useful for * maintaining state between calls to {@link #queue} and - * {@link android.hardware.UsbDevice#requestWait} + * {@link android.hardware.usb.UsbDevice#requestWait} * * @param data the client data for the request */ @@ -121,7 +121,7 @@ public class UsbRequest { * For IN endpoints, the endpoint will attempt to read the given number of bytes * into the specified buffer. * If the queueing operation is successful, we return true and the result will be - * returned via {@link android.hardware.UsbDevice#requestWait} + * returned via {@link android.hardware.usb.UsbDevice#requestWait} * * @param buffer the buffer containing the bytes to write, or location to store * the results of a read diff --git a/core/jni/android_hardware_UsbDevice.cpp b/core/jni/android_hardware_UsbDevice.cpp index 9014450..b01820c 100644 --- a/core/jni/android_hardware_UsbDevice.cpp +++ b/core/jni/android_hardware_UsbDevice.cpp @@ -237,7 +237,7 @@ static JNINativeMethod method_table[] = { (void *)android_hardware_UsbDevice_control_request}, {"native_bulk_request", "(I[BII)I", (void *)android_hardware_UsbDevice_bulk_request}, - {"native_request_wait", "()Landroid/hardware/UsbRequest;", + {"native_request_wait", "()Landroid/hardware/usb/UsbRequest;", (void *)android_hardware_UsbDevice_request_wait}, { "native_get_serial", "()Ljava/lang/String;", (void*)android_hardware_UsbDevice_get_serial }, @@ -251,9 +251,9 @@ static JNINativeMethod method_table[] = { int register_android_hardware_UsbDevice(JNIEnv *env) { - jclass clazz = env->FindClass("android/hardware/UsbDevice"); + jclass clazz = env->FindClass("android/hardware/usb/UsbDevice"); if (clazz == NULL) { - LOGE("Can't find android/hardware/UsbDevice"); + LOGE("Can't find android/hardware/usb/UsbDevice"); return -1; } field_context = env->GetFieldID(clazz, "mNativeContext", "I"); @@ -262,7 +262,7 @@ int register_android_hardware_UsbDevice(JNIEnv *env) return -1; } - return AndroidRuntime::registerNativeMethods(env, "android/hardware/UsbDevice", + return AndroidRuntime::registerNativeMethods(env, "android/hardware/usb/UsbDevice", method_table, NELEM(method_table)); } diff --git a/core/jni/android_hardware_UsbEndpoint.cpp b/core/jni/android_hardware_UsbEndpoint.cpp deleted file mode 100644 index 00c8235..0000000 --- a/core/jni/android_hardware_UsbEndpoint.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_TAG "UsbEndpoint" - -#include "utils/Log.h" - -#include "jni.h" -#include "JNIHelp.h" -#include "android_runtime/AndroidRuntime.h" - -#include <usbhost/usbhost.h> - -#include <stdio.h> - -using namespace android; - -static jfieldID field_context; -static jfieldID field_address; -static jfieldID field_attributes; -static jfieldID field_max_packet_size; -static jfieldID field_interval; - -struct usb_endpoint* get_endpoint_from_object(JNIEnv* env, jobject javaEndpoint) -{ - return (struct usb_endpoint*)env->GetIntField(javaEndpoint, field_context); -} - -// in android_hardware_UsbDevice.cpp -extern struct usb_device* get_device_from_object(JNIEnv* env, jobject javaDevice); - -static jboolean -android_hardware_UsbEndpoint_init(JNIEnv *env, jobject thiz, jobject javaDevice) -{ - LOGD("open\n"); - - struct usb_device* device = get_device_from_object(env, javaDevice); - if (!device) { - LOGE("device null in native_init"); - return false; - } - - // construct an endpoint descriptor from the Java object fields - struct usb_endpoint_descriptor desc; - desc.bLength = USB_DT_ENDPOINT_SIZE; - desc.bDescriptorType = USB_DT_ENDPOINT; - desc.bEndpointAddress = env->GetIntField(thiz, field_address); - desc.bmAttributes = env->GetIntField(thiz, field_attributes); - desc.wMaxPacketSize = env->GetIntField(thiz, field_max_packet_size); - desc.bInterval = env->GetIntField(thiz, field_interval); - - struct usb_endpoint* endpoint = usb_endpoint_init(device, &desc); - if (endpoint) - env->SetIntField(thiz, field_context, (int)device); - return (endpoint != NULL); -} - -static void -android_hardware_UsbEndpoint_close(JNIEnv *env, jobject thiz) -{ - LOGD("close\n"); - struct usb_endpoint* endpoint = get_endpoint_from_object(env, thiz); - if (endpoint) { - usb_endpoint_close(endpoint); - env->SetIntField(thiz, field_context, 0); - } -} - -static JNINativeMethod method_table[] = { - {"native_init", "(Landroid/hardware/UsbDevice;)Z", - (void *)android_hardware_UsbEndpoint_init}, - {"native_close", "()V", (void *)android_hardware_UsbEndpoint_close}, -}; - -int register_android_hardware_UsbEndpoint(JNIEnv *env) -{ - jclass clazz = env->FindClass("android/hardware/UsbEndpoint"); - if (clazz == NULL) { - LOGE("Can't find android/hardware/UsbEndpoint"); - return -1; - } - field_context = env->GetFieldID(clazz, "mNativeContext", "I"); - if (field_context == NULL) { - LOGE("Can't find UsbEndpoint.mNativeContext"); - return -1; - } - field_address = env->GetFieldID(clazz, "mAddress", "I"); - if (field_address == NULL) { - LOGE("Can't find UsbEndpoint.mAddress"); - return -1; - } - field_attributes = env->GetFieldID(clazz, "mAttributes", "I"); - if (field_attributes == NULL) { - LOGE("Can't find UsbEndpoint.mAttributes"); - return -1; - } - field_max_packet_size = env->GetFieldID(clazz, "mMaxPacketSize", "I"); - if (field_max_packet_size == NULL) { - LOGE("Can't find UsbEndpoint.mMaxPacketSize"); - return -1; - } - field_interval = env->GetFieldID(clazz, "mInterval", "I"); - if (field_interval == NULL) { - LOGE("Can't find UsbEndpoint.mInterval"); - return -1; - } - - return AndroidRuntime::registerNativeMethods(env, "android/hardware/UsbEndpoint", - method_table, NELEM(method_table)); -} - diff --git a/core/jni/android_hardware_UsbRequest.cpp b/core/jni/android_hardware_UsbRequest.cpp index 710afae..b497adb 100644 --- a/core/jni/android_hardware_UsbRequest.cpp +++ b/core/jni/android_hardware_UsbRequest.cpp @@ -187,7 +187,7 @@ android_hardware_UsbRequest_cancel(JNIEnv *env, jobject thiz) } static JNINativeMethod method_table[] = { - {"native_init", "(Landroid/hardware/UsbDevice;IIII)Z", + {"native_init", "(Landroid/hardware/usb/UsbDevice;IIII)Z", (void *)android_hardware_UsbRequest_init}, {"native_close", "()V", (void *)android_hardware_UsbRequest_close}, {"native_queue_array", "([BIZ)Z", (void *)android_hardware_UsbRequest_queue_array}, @@ -200,9 +200,9 @@ static JNINativeMethod method_table[] = { int register_android_hardware_UsbRequest(JNIEnv *env) { - jclass clazz = env->FindClass("android/hardware/UsbRequest"); + jclass clazz = env->FindClass("android/hardware/usb/UsbRequest"); if (clazz == NULL) { - LOGE("Can't find android/hardware/UsbRequest"); + LOGE("Can't find android/hardware/usb/UsbRequest"); return -1; } field_context = env->GetFieldID(clazz, "mNativeContext", "I"); @@ -211,7 +211,7 @@ int register_android_hardware_UsbRequest(JNIEnv *env) return -1; } - return AndroidRuntime::registerNativeMethods(env, "android/hardware/UsbRequest", + return AndroidRuntime::registerNativeMethods(env, "android/hardware/usb/UsbRequest", method_table, NELEM(method_table)); } diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 50d3fb8..0ad174f 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -84,11 +84,11 @@ <protected-broadcast android:name="android.bluetooth.device.action.PAIRING_REQUEST" /> <protected-broadcast android:name="android.bluetooth.device.action.PAIRING_CANCEL" /> - <protected-broadcast android:name="android.hardware.action.USB_STATE" /> - <protected-broadcast android:name="android.hardware.action.USB_ACCESSORY_ATTACHED" /> - <protected-broadcast android:name="android.hardware.action.USB_ACCESSORY_ATTACHED" /> - <protected-broadcast android:name="android.hardware.action.USB_DEVICE_ATTACHED" /> - <protected-broadcast android:name="android.hardware.action.USB_DEVICE_DETACHED" /> + <protected-broadcast android:name="android.hardware.usb.action.USB_STATE" /> + <protected-broadcast android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" /> + <protected-broadcast android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" /> + <protected-broadcast android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" /> + <protected-broadcast android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" /> <protected-broadcast android:name="android.nfc.action.LLCP_LINK_STATE_CHANGED" /> <protected-broadcast android:name="android.nfc.action.TRANSACTION_DETECTED" /> |