summaryrefslogtreecommitdiffstats
path: root/services/jni
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2011-07-21 13:55:16 -0700
committerMike Lockwood <lockwood@android.com>2011-07-21 14:30:36 -0700
commitd462ecf8f82076d21c85bdeeefbd16a1a91d2805 (patch)
tree88d12b0084c53b857ec58baae8c6cf3b1b6fe20d /services/jni
parentedf0178265efee73da80754d1d76e3d69e1f593f (diff)
downloadframeworks_base-d462ecf8f82076d21c85bdeeefbd16a1a91d2805.zip
frameworks_base-d462ecf8f82076d21c85bdeeefbd16a1a91d2805.tar.gz
frameworks_base-d462ecf8f82076d21c85bdeeefbd16a1a91d2805.tar.bz2
USB: Fix handling USB accessory attached when device is booting
Also defer anything that could start an activity from "system ready" to "boot completed" time. Bug: 5051683 Change-Id: I69db751cb991dd247bd0ac3c70a0d84c0d71f365 Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'services/jni')
-rw-r--r--services/jni/com_android_server_UsbDeviceManager.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/services/jni/com_android_server_UsbDeviceManager.cpp b/services/jni/com_android_server_UsbDeviceManager.cpp
index 6954171..40f0dbd 100644
--- a/services/jni/com_android_server_UsbDeviceManager.cpp
+++ b/services/jni/com_android_server_UsbDeviceManager.cpp
@@ -99,11 +99,26 @@ static jobject android_server_UsbDeviceManager_openAccessory(JNIEnv *env, jobjec
gParcelFileDescriptorOffsets.mConstructor, fileDescriptor);
}
+static jboolean android_server_UsbDeviceManager_isStartRequested(JNIEnv *env, jobject thiz)
+{
+ int fd = open(DRIVER_NAME, O_RDWR);
+ if (fd < 0) {
+ LOGE("could not open %s", DRIVER_NAME);
+ return false;
+ }
+ int result = ioctl(fd, ACCESSORY_IS_START_REQUESTED);
+ close(fd);
+ return (result == 1);
+}
+
+
static JNINativeMethod method_table[] = {
{ "nativeGetAccessoryStrings", "()[Ljava/lang/String;",
(void*)android_server_UsbDeviceManager_getAccessoryStrings },
{ "nativeOpenAccessory", "()Landroid/os/ParcelFileDescriptor;",
(void*)android_server_UsbDeviceManager_openAccessory },
+ { "nativeIsStartRequested", "()Z",
+ (void*)android_server_UsbDeviceManager_isStartRequested },
};
int register_android_server_UsbDeviceManager(JNIEnv *env)