summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2011-01-06 10:38:10 -0500
committerMike Lockwood <lockwood@android.com>2011-01-06 11:48:19 -0500
commit264f6cd0b9215f75dd5917252abea98e8fce6222 (patch)
tree0da668e2df24b638e9a76040441e6a6ed4461e77
parent27480cd49470af667dc8985f45b5ba43ab9ed4cd (diff)
downloadframeworks_base-264f6cd0b9215f75dd5917252abea98e8fce6222.zip
frameworks_base-264f6cd0b9215f75dd5917252abea98e8fce6222.tar.gz
frameworks_base-264f6cd0b9215f75dd5917252abea98e8fce6222.tar.bz2
Temporarily remove UsbManager support for USB host.
A new USB host API will be added in an upcoming commit Change-Id: I5816c10c7acd236d31ab8ae255fc83c77121eea0 Signed-off-by: Mike Lockwood <lockwood@android.com>
-rw-r--r--core/java/android/hardware/UsbManager.java29
-rw-r--r--core/jni/Android.mk2
-rw-r--r--core/jni/AndroidRuntime.cpp2
-rw-r--r--core/jni/android_hardware_UsbManager.cpp61
-rw-r--r--services/java/com/android/server/UsbService.java28
-rw-r--r--services/jni/Android.mk1
-rw-r--r--services/jni/com_android_server_UsbService.cpp174
-rw-r--r--services/jni/onload.cpp2
8 files changed, 1 insertions, 298 deletions
diff --git a/core/java/android/hardware/UsbManager.java b/core/java/android/hardware/UsbManager.java
index 6022b12..18790d2 100644
--- a/core/java/android/hardware/UsbManager.java
+++ b/core/java/android/hardware/UsbManager.java
@@ -39,24 +39,6 @@ public class UsbManager {
public static final String ACTION_USB_STATE =
"android.hardware.action.USB_STATE";
- /**
- * Broadcast Action: A broadcast for USB camera attached event.
- *
- * This intent is sent when a USB device supporting PTP is attached to the host USB bus.
- * The intent's data contains a Uri for the device in the MTP provider.
- */
- public static final String ACTION_USB_CAMERA_ATTACHED =
- "android.hardware.action.USB_CAMERA_ATTACHED";
-
- /**
- * Broadcast Action: A broadcast for USB camera detached event.
- *
- * This intent is sent when a USB device supporting PTP is detached from the host USB bus.
- * The intent's data contains a Uri for the device in the MTP provider.
- */
- public static final String ACTION_USB_CAMERA_DETACHED =
- "android.hardware.action.USB_CAMERA_DETACHED";
-
/**
* Boolean extra indicating whether USB is connected or disconnected.
* Used in extras for the {@link #ACTION_USB_STATE} broadcast.
@@ -105,14 +87,6 @@ public class UsbManager {
*/
public static final String USB_FUNCTION_DISABLED = "disabled";
- public static final int getDeviceId(String name) {
- return native_get_device_id(name);
- }
-
- public static final String getDeviceName(int id) {
- return native_get_device_name(id);
- }
-
private static File getFunctionEnableFile(String function) {
return new File("/sys/class/usb_composite/" + function + "/enable");
}
@@ -138,7 +112,4 @@ public class UsbManager {
return false;
}
}
-
- private static native int native_get_device_id(String name);
- private static native String native_get_device_name(int id);
}
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index e9566ad..241bc3e 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -123,7 +123,6 @@ LOCAL_SRC_FILES:= \
android_media_ToneGenerator.cpp \
android_hardware_Camera.cpp \
android_hardware_SensorManager.cpp \
- android_hardware_UsbManager.cpp \
android_debug_JNITest.cpp \
android_util_FileObserver.cpp \
android/opengl/poly_clip.cpp.arm \
@@ -202,7 +201,6 @@ LOCAL_SHARED_LIBRARIES := \
libwpa_client \
libjpeg \
libnfc_ndef \
- libusbhost
ifeq ($(USE_OPENGL_RENDERER),true)
LOCAL_SHARED_LIBRARIES += libhwui
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index 961bc1f1..b6e4119 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -78,7 +78,6 @@ extern int register_android_opengl_jni_GLES20(JNIEnv* env);
extern int register_android_hardware_Camera(JNIEnv *env);
extern int register_android_hardware_SensorManager(JNIEnv *env);
-extern int register_android_hardware_UsbManager(JNIEnv *env);
extern int register_android_media_AudioRecord(JNIEnv *env);
extern int register_android_media_AudioSystem(JNIEnv *env);
@@ -1266,7 +1265,6 @@ static const RegJNIRec gRegJNI[] = {
REG_JNI(register_com_android_internal_os_ZygoteInit),
REG_JNI(register_android_hardware_Camera),
REG_JNI(register_android_hardware_SensorManager),
- REG_JNI(register_android_hardware_UsbManager),
REG_JNI(register_android_media_AudioRecord),
REG_JNI(register_android_media_AudioSystem),
REG_JNI(register_android_media_AudioTrack),
diff --git a/core/jni/android_hardware_UsbManager.cpp b/core/jni/android_hardware_UsbManager.cpp
deleted file mode 100644
index 8f32abf..0000000
--- a/core/jni/android_hardware_UsbManager.cpp
+++ /dev/null
@@ -1,61 +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.
- */
-
-#include "jni.h"
-#include "JNIHelp.h"
-#include "android_runtime/AndroidRuntime.h"
-
-#include <usbhost/usbhost.h>
-
-#include <stdio.h>
-
-using namespace android;
-
-static jint android_hardware_UsbManager_get_device_id(JNIEnv *env, jobject clazz, jstring name)
-{
- const char *nameStr = env->GetStringUTFChars(name, NULL);
- int id = usb_device_get_unique_id_from_name(nameStr);
- env->ReleaseStringUTFChars(name, nameStr);
- return id;
-}
-
-static jstring android_hardware_UsbManager_get_device_name(JNIEnv *env, jobject clazz, jint id)
-{
- char* name = usb_device_get_name_from_unique_id(id);
- jstring result = env->NewStringUTF(name);
- free(name);
- return result;
-}
-
-static JNINativeMethod method_table[] = {
- { "native_get_device_id", "(Ljava/lang/String;)I",
- (void*)android_hardware_UsbManager_get_device_id },
- { "native_get_device_name", "(I)Ljava/lang/String;",
- (void*)android_hardware_UsbManager_get_device_name },
-};
-
-int register_android_hardware_UsbManager(JNIEnv *env)
-{
- jclass clazz = env->FindClass("android/hardware/UsbManager");
- if (clazz == NULL) {
- LOGE("Can't find android/hardware/UsbManager");
- return -1;
- }
-
- return AndroidRuntime::registerNativeMethods(env, "android/hardware/UsbManager",
- method_table, NELEM(method_table));
-}
-
diff --git a/services/java/com/android/server/UsbService.java b/services/java/com/android/server/UsbService.java
index a2bf75d..77ddf3b 100644
--- a/services/java/com/android/server/UsbService.java
+++ b/services/java/com/android/server/UsbService.java
@@ -24,7 +24,6 @@ import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.os.UEventObserver;
-import android.provider.Ptp;
import android.provider.Settings;
import android.util.Log;
import android.util.Slog;
@@ -182,33 +181,8 @@ class UsbService {
}
}
- private native void monitorUsbHostBus();
-
- // called from JNI in monitorUsbHostBus()
- private void usbCameraAdded(int deviceID) {
- Intent intent = new Intent(UsbManager.ACTION_USB_CAMERA_ATTACHED,
- Ptp.Device.getContentUri(deviceID));
- Log.d(TAG, "usbCameraAdded, sending " + intent);
- mContext.sendBroadcast(intent);
- }
-
- // called from JNI in monitorUsbHostBus()
- private void usbCameraRemoved(int deviceID) {
- Intent intent = new Intent(UsbManager.ACTION_USB_CAMERA_DETACHED,
- Ptp.Device.getContentUri(deviceID));
- Log.d(TAG, "usbCameraRemoved, sending " + intent);
- mContext.sendBroadcast(intent);
- }
-
private void initHostSupport() {
- // Create a thread to call into native code to wait for USB host events.
- // This thread will call us back on usbCameraAdded and usbCameraRemoved.
- Runnable runnable = new Runnable() {
- public void run() {
- monitorUsbHostBus();
- }
- };
- new Thread(null, runnable, "UsbService host thread").start();
+ // temporarily disabled
}
void systemReady() {
diff --git a/services/jni/Android.mk b/services/jni/Android.mk
index 4ccea6e..ec85e54 100644
--- a/services/jni/Android.mk
+++ b/services/jni/Android.mk
@@ -8,7 +8,6 @@ LOCAL_SRC_FILES:= \
com_android_server_LightsService.cpp \
com_android_server_PowerManagerService.cpp \
com_android_server_SystemServer.cpp \
- com_android_server_UsbService.cpp \
com_android_server_VibratorService.cpp \
com_android_server_location_GpsLocationProvider.cpp \
onload.cpp
diff --git a/services/jni/com_android_server_UsbService.cpp b/services/jni/com_android_server_UsbService.cpp
deleted file mode 100644
index d8b2418..0000000
--- a/services/jni/com_android_server_UsbService.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (C) 2009 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 "UsbService"
-#include "utils/Log.h"
-
-#include "jni.h"
-#include "JNIHelp.h"
-#include "android_runtime/AndroidRuntime.h"
-#include "utils/Vector.h"
-
-#include <usbhost/usbhost.h>
-#include <linux/version.h>
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
-#include <linux/usb/ch9.h>
-#else
-#include <linux/usb_ch9.h>
-#endif
-
-#include <stdio.h>
-
-namespace android
-{
-
-static jmethodID method_usbCameraAdded;
-static jmethodID method_usbCameraRemoved;
-
-Vector<int> mDeviceList;
-
-static void checkAndClearExceptionFromCallback(JNIEnv* env, const char* methodName) {
- if (env->ExceptionCheck()) {
- LOGE("An exception was thrown by callback '%s'.", methodName);
- LOGE_EX(env);
- env->ExceptionClear();
- }
-}
-
-static int usb_device_added(const char *devname, void* client_data) {
- // check to see if it is a camera
- struct usb_descriptor_header* desc;
- struct usb_descriptor_iter iter;
-
- struct usb_device *device = usb_device_open(devname);
- if (!device) {
- LOGE("usb_device_open failed\n");
- return 0;
- }
-
- usb_descriptor_iter_init(device, &iter);
-
- while ((desc = usb_descriptor_iter_next(&iter)) != NULL) {
- if (desc->bDescriptorType == USB_DT_INTERFACE) {
- struct usb_interface_descriptor *interface = (struct usb_interface_descriptor *)desc;
-
- if (interface->bInterfaceClass == USB_CLASS_STILL_IMAGE &&
- interface->bInterfaceSubClass == 1 && // Still Image Capture
- interface->bInterfaceProtocol == 1) // Picture Transfer Protocol (PIMA 15470)
- {
- LOGD("Found camera: \"%s\" \"%s\"\n", usb_device_get_manufacturer_name(device),
- usb_device_get_product_name(device));
-
- // interface should be followed by three endpoints
- struct usb_endpoint_descriptor *ep;
- struct usb_endpoint_descriptor *ep_in_desc = NULL;
- struct usb_endpoint_descriptor *ep_out_desc = NULL;
- struct usb_endpoint_descriptor *ep_intr_desc = NULL;
- for (int i = 0; i < 3; i++) {
- ep = (struct usb_endpoint_descriptor *)usb_descriptor_iter_next(&iter);
- if (!ep || ep->bDescriptorType != USB_DT_ENDPOINT) {
- LOGE("endpoints not found\n");
- goto done;
- }
- if (ep->bmAttributes == USB_ENDPOINT_XFER_BULK) {
- if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
- ep_in_desc = ep;
- else
- ep_out_desc = ep;
- } else if (ep->bmAttributes == USB_ENDPOINT_XFER_INT &&
- ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) {
- ep_intr_desc = ep;
- }
- }
- if (!ep_in_desc || !ep_out_desc || !ep_intr_desc) {
- LOGE("endpoints not found\n");
- goto done;
- }
-
- // if we got here, we found a camera
- JNIEnv* env = AndroidRuntime::getJNIEnv();
- jobject thiz = (jobject)client_data;
-
- int id = usb_device_get_unique_id_from_name(devname);
- mDeviceList.add(id);
-
- env->CallVoidMethod(thiz, method_usbCameraAdded, id);
- checkAndClearExceptionFromCallback(env, __FUNCTION__);
- }
- }
- }
-done:
- usb_device_close(device);
- return 0;
-}
-
-static int usb_device_removed(const char *devname, void* client_data) {
- int id = usb_device_get_unique_id_from_name(devname);
-
- // see if it is a device we know about
- for (int i = 0; i < mDeviceList.size(); i++) {
- if (id == mDeviceList[i]) {
- mDeviceList.removeAt(i);
-
- JNIEnv* env = AndroidRuntime::getJNIEnv();
- jobject thiz = (jobject)client_data;
-
- env->CallVoidMethod(thiz, method_usbCameraRemoved, id);
- checkAndClearExceptionFromCallback(env, __FUNCTION__);
- break;
- }
- }
- return 0;
-}
-
-static void android_server_UsbService_monitorUsbHostBus(JNIEnv *env, jobject thiz)
-{
- struct usb_host_context* context = usb_host_init();
- if (!context) {
- LOGE("usb_host_init failed");
- return;
- }
- // this will never return so it is safe to pass thiz directly
- usb_host_run(context, usb_device_added, usb_device_removed, NULL, (void *)thiz);
-}
-
-static JNINativeMethod method_table[] = {
- { "monitorUsbHostBus", "()V", (void*)android_server_UsbService_monitorUsbHostBus }
-};
-
-int register_android_server_UsbService(JNIEnv *env)
-{
- jclass clazz = env->FindClass("com/android/server/UsbService");
- if (clazz == NULL) {
- LOGE("Can't find com/android/server/UsbService");
- return -1;
- }
- method_usbCameraAdded = env->GetMethodID(clazz, "usbCameraAdded", "(I)V");
- if (method_usbCameraAdded == NULL) {
- LOGE("Can't find usbCameraAdded");
- return -1;
- }
- method_usbCameraRemoved = env->GetMethodID(clazz, "usbCameraRemoved", "(I)V");
- if (method_usbCameraRemoved == NULL) {
- LOGE("Can't find usbCameraRemoved");
- return -1;
- }
-
- return jniRegisterNativeMethods(env, "com/android/server/UsbService",
- method_table, NELEM(method_table));
-}
-
-};
diff --git a/services/jni/onload.cpp b/services/jni/onload.cpp
index 613683b..cd4f0a4 100644
--- a/services/jni/onload.cpp
+++ b/services/jni/onload.cpp
@@ -9,7 +9,6 @@ int register_android_server_BatteryService(JNIEnv* env);
int register_android_server_InputManager(JNIEnv* env);
int register_android_server_LightsService(JNIEnv* env);
int register_android_server_PowerManagerService(JNIEnv* env);
-int register_android_server_UsbService(JNIEnv* env);
int register_android_server_VibratorService(JNIEnv* env);
int register_android_server_SystemServer(JNIEnv* env);
int register_android_server_location_GpsLocationProvider(JNIEnv* env);
@@ -33,7 +32,6 @@ extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved)
register_android_server_LightsService(env);
register_android_server_AlarmManagerService(env);
register_android_server_BatteryService(env);
- register_android_server_UsbService(env);
register_android_server_VibratorService(env);
register_android_server_SystemServer(env);
register_android_server_location_GpsLocationProvider(env);