summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorSimon Wilson <simonwilson@google.com>2012-02-07 14:24:06 -0800
committerSimon Wilson <simonwilson@google.com>2012-02-07 14:36:06 -0800
commitc92e6f14f9ac6c86b7784f8a21d7077ea7cae0bb (patch)
treeaed315aa915170fd56d39872fc5cac406f6c8782 /libs
parentdc210ade0ad4770c5294320453f8ddfbfcbaf943 (diff)
downloadframeworks_base-c92e6f14f9ac6c86b7784f8a21d7077ea7cae0bb.zip
frameworks_base-c92e6f14f9ac6c86b7784f8a21d7077ea7cae0bb.tar.gz
frameworks_base-c92e6f14f9ac6c86b7784f8a21d7077ea7cae0bb.tar.bz2
AccessoryChat: use platform APIs and support Galaxy Nexus
Change-Id: I171c2781f3d447bec46f0179351e1b18721b1b89
Diffstat (limited to 'libs')
-rw-r--r--libs/usb/tests/AccessoryChat/Android.mk5
-rw-r--r--libs/usb/tests/AccessoryChat/AndroidManifest.xml5
-rw-r--r--libs/usb/tests/AccessoryChat/accessorychat/accessorychat.c2
-rw-r--r--libs/usb/tests/AccessoryChat/src/com/android/accessorychat/AccessoryChat.java12
4 files changed, 11 insertions, 13 deletions
diff --git a/libs/usb/tests/AccessoryChat/Android.mk b/libs/usb/tests/AccessoryChat/Android.mk
index 77b8424..ecb455a 100644
--- a/libs/usb/tests/AccessoryChat/Android.mk
+++ b/libs/usb/tests/AccessoryChat/Android.mk
@@ -23,9 +23,4 @@ LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_PACKAGE_NAME := AccessoryChat
-LOCAL_JAVA_LIBRARIES := com.android.future.usb.accessory
-
-# Force an old SDK version to make sure we aren't using newer UsbManager APIs
-LOCAL_SDK_VERSION := 8
-
include $(BUILD_PACKAGE)
diff --git a/libs/usb/tests/AccessoryChat/AndroidManifest.xml b/libs/usb/tests/AccessoryChat/AndroidManifest.xml
index 802b715..6667eba 100644
--- a/libs/usb/tests/AccessoryChat/AndroidManifest.xml
+++ b/libs/usb/tests/AccessoryChat/AndroidManifest.xml
@@ -17,8 +17,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.accessorychat">
+ <uses-feature android:name="android.hardware.usb.accessory" />
+
<application android:label="Accessory Chat">
- <uses-library android:name="com.android.future.usb.accessory" />
<activity android:name="AccessoryChat" android:label="Accessory Chat">
<intent-filter>
@@ -35,5 +36,5 @@
android:resource="@xml/accessory_filter" />
</activity>
</application>
- <uses-sdk android:minSdkVersion="10" />
+ <uses-sdk android:minSdkVersion="12" />
</manifest>
diff --git a/libs/usb/tests/AccessoryChat/accessorychat/accessorychat.c b/libs/usb/tests/AccessoryChat/accessorychat/accessorychat.c
index 85b52dd..06b477f 100644
--- a/libs/usb/tests/AccessoryChat/accessorychat/accessorychat.c
+++ b/libs/usb/tests/AccessoryChat/accessorychat/accessorychat.c
@@ -98,7 +98,7 @@ static int usb_device_added(const char *devname, void* client_data) {
vendorId = usb_device_get_vendor_id(device);
productId = usb_device_get_product_id(device);
- if (vendorId == 0x18D1 || vendorId == 0x22B8) {
+ if (vendorId == 0x18D1 || vendorId == 0x22B8 || vendorId == 0x04e8) {
if (!sDevice && (productId == 0x2D00 || productId == 0x2D01)) {
struct usb_descriptor_header* desc;
struct usb_descriptor_iter iter;
diff --git a/libs/usb/tests/AccessoryChat/src/com/android/accessorychat/AccessoryChat.java b/libs/usb/tests/AccessoryChat/src/com/android/accessorychat/AccessoryChat.java
index c3f4fa3..bf0cef0 100644
--- a/libs/usb/tests/AccessoryChat/src/com/android/accessorychat/AccessoryChat.java
+++ b/libs/usb/tests/AccessoryChat/src/com/android/accessorychat/AccessoryChat.java
@@ -33,8 +33,8 @@ import android.util.Log;
import android.widget.EditText;
import android.widget.TextView;
-import com.android.future.usb.UsbAccessory;
-import com.android.future.usb.UsbManager;
+import android.hardware.usb.UsbManager;
+import android.hardware.usb.UsbAccessory;
import java.io.FileDescriptor;
import java.io.FileInputStream;
@@ -64,9 +64,11 @@ public class AccessoryChat extends Activity implements Runnable, TextView.OnEdit
public void onReceive(Context context, Intent intent) {
if (ACTION_USB_PERMISSION.equals(intent.getAction())) {
synchronized (this) {
- UsbAccessory accessory = UsbManager.getAccessory(intent);
+ UsbAccessory accessory = (UsbAccessory) intent.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
- openAccessory(accessory);
+ if (accessory != null) {
+ openAccessory(accessory);
+ }
} else {
Log.d(TAG, "permission denied for accessory " + accessory);
}
@@ -80,7 +82,7 @@ public class AccessoryChat extends Activity implements Runnable, TextView.OnEdit
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- mUsbManager = UsbManager.getInstance(this);
+ mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0);
IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
registerReceiver(mUsbReceiver, filter);