Search in sources :

Example 16 with UsbAccessory

use of android.hardware.usb.UsbAccessory in project android_frameworks_base by DirtyUnicorns.

the class AccessoryChat method onResume.

@Override
public void onResume() {
    super.onResume();
    Intent intent = getIntent();
    Log.d(TAG, "intent: " + intent);
    UsbAccessory[] accessories = mUsbManager.getAccessoryList();
    UsbAccessory accessory = (accessories == null ? null : accessories[0]);
    if (accessory != null) {
        if (mUsbManager.hasPermission(accessory)) {
            openAccessory(accessory);
        } else {
            synchronized (mUsbReceiver) {
                if (!mPermissionRequestPending) {
                    mUsbManager.requestPermission(accessory, mPermissionIntent);
                    mPermissionRequestPending = true;
                }
            }
        }
    } else {
        Log.d(TAG, "mAccessory is null");
    }
}
Also used : UsbAccessory(android.hardware.usb.UsbAccessory) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Example 17 with UsbAccessory

use of android.hardware.usb.UsbAccessory in project android_frameworks_base by ParanoidAndroid.

the class AccessoryChat method onResume.

@Override
public void onResume() {
    super.onResume();
    Intent intent = getIntent();
    Log.d(TAG, "intent: " + intent);
    UsbAccessory[] accessories = mUsbManager.getAccessoryList();
    UsbAccessory accessory = (accessories == null ? null : accessories[0]);
    if (accessory != null) {
        if (mUsbManager.hasPermission(accessory)) {
            openAccessory(accessory);
        } else {
            synchronized (mUsbReceiver) {
                if (!mPermissionRequestPending) {
                    mUsbManager.requestPermission(accessory, mPermissionIntent);
                    mPermissionRequestPending = true;
                }
            }
        }
    } else {
        Log.d(TAG, "mAccessory is null");
    }
}
Also used : UsbAccessory(android.hardware.usb.UsbAccessory) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Example 18 with UsbAccessory

use of android.hardware.usb.UsbAccessory in project android_frameworks_base by ResurrectionRemix.

the class UsbSettingsManager method dump.

public void dump(IndentingPrintWriter pw) {
    synchronized (mLock) {
        pw.println("Device permissions:");
        for (String deviceName : mDevicePermissionMap.keySet()) {
            pw.print("  " + deviceName + ": ");
            SparseBooleanArray uidList = mDevicePermissionMap.get(deviceName);
            int count = uidList.size();
            for (int i = 0; i < count; i++) {
                pw.print(Integer.toString(uidList.keyAt(i)) + " ");
            }
            pw.println();
        }
        pw.println("Accessory permissions:");
        for (UsbAccessory accessory : mAccessoryPermissionMap.keySet()) {
            pw.print("  " + accessory + ": ");
            SparseBooleanArray uidList = mAccessoryPermissionMap.get(accessory);
            int count = uidList.size();
            for (int i = 0; i < count; i++) {
                pw.print(Integer.toString(uidList.keyAt(i)) + " ");
            }
            pw.println();
        }
        pw.println("Device preferences:");
        for (DeviceFilter filter : mDevicePreferenceMap.keySet()) {
            pw.println("  " + filter + ": " + mDevicePreferenceMap.get(filter));
        }
        pw.println("Accessory preferences:");
        for (AccessoryFilter filter : mAccessoryPreferenceMap.keySet()) {
            pw.println("  " + filter + ": " + mAccessoryPreferenceMap.get(filter));
        }
    }
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray) UsbAccessory(android.hardware.usb.UsbAccessory)

Example 19 with UsbAccessory

use of android.hardware.usb.UsbAccessory in project android_frameworks_base by crdroidandroid.

the class AccessoryChat method onResume.

@Override
public void onResume() {
    super.onResume();
    Intent intent = getIntent();
    Log.d(TAG, "intent: " + intent);
    UsbAccessory[] accessories = mUsbManager.getAccessoryList();
    UsbAccessory accessory = (accessories == null ? null : accessories[0]);
    if (accessory != null) {
        if (mUsbManager.hasPermission(accessory)) {
            openAccessory(accessory);
        } else {
            synchronized (mUsbReceiver) {
                if (!mPermissionRequestPending) {
                    mUsbManager.requestPermission(accessory, mPermissionIntent);
                    mPermissionRequestPending = true;
                }
            }
        }
    } else {
        Log.d(TAG, "mAccessory is null");
    }
}
Also used : UsbAccessory(android.hardware.usb.UsbAccessory) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Example 20 with UsbAccessory

use of android.hardware.usb.UsbAccessory in project android_frameworks_base by crdroidandroid.

the class UsbSettingsManager method dump.

public void dump(IndentingPrintWriter pw) {
    synchronized (mLock) {
        pw.println("Device permissions:");
        for (String deviceName : mDevicePermissionMap.keySet()) {
            pw.print("  " + deviceName + ": ");
            SparseBooleanArray uidList = mDevicePermissionMap.get(deviceName);
            int count = uidList.size();
            for (int i = 0; i < count; i++) {
                pw.print(Integer.toString(uidList.keyAt(i)) + " ");
            }
            pw.println();
        }
        pw.println("Accessory permissions:");
        for (UsbAccessory accessory : mAccessoryPermissionMap.keySet()) {
            pw.print("  " + accessory + ": ");
            SparseBooleanArray uidList = mAccessoryPermissionMap.get(accessory);
            int count = uidList.size();
            for (int i = 0; i < count; i++) {
                pw.print(Integer.toString(uidList.keyAt(i)) + " ");
            }
            pw.println();
        }
        pw.println("Device preferences:");
        for (DeviceFilter filter : mDevicePreferenceMap.keySet()) {
            pw.println("  " + filter + ": " + mDevicePreferenceMap.get(filter));
        }
        pw.println("Accessory preferences:");
        for (AccessoryFilter filter : mAccessoryPreferenceMap.keySet()) {
            pw.println("  " + filter + ": " + mAccessoryPreferenceMap.get(filter));
        }
    }
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray) UsbAccessory(android.hardware.usb.UsbAccessory)

Aggregations

UsbAccessory (android.hardware.usb.UsbAccessory)20 PendingIntent (android.app.PendingIntent)10 Intent (android.content.Intent)10 SparseBooleanArray (android.util.SparseBooleanArray)5 IntentFilter (android.content.IntentFilter)4