Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c92e6f14 authored by Simon Wilson's avatar Simon Wilson
Browse files

AccessoryChat: use platform APIs and support Galaxy Nexus

Change-Id: I171c2781f3d447bec46f0179351e1b18721b1b89
parent dc210ade
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -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)
+3 −2
Original line number Diff line number Diff line
@@ -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>
+1 −1
Original line number Diff line number Diff line
@@ -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;
+7 −5
Original line number Diff line number Diff line
@@ -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)) {
                        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);