当前位置: 首页>>代码示例>>Java>>正文


Java UsbDeviceConnection.close方法代码示例

本文整理汇总了Java中android.hardware.usb.UsbDeviceConnection.close方法的典型用法代码示例。如果您正苦于以下问题:Java UsbDeviceConnection.close方法的具体用法?Java UsbDeviceConnection.close怎么用?Java UsbDeviceConnection.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.hardware.usb.UsbDeviceConnection的用法示例。


在下文中一共展示了UsbDeviceConnection.close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setAdbInterface

import android.hardware.usb.UsbDeviceConnection; //导入方法依赖的package包/类
private boolean setAdbInterface(UsbDevice device, UsbInterface intf) {
    if (mDeviceConnection != null) {
        if (mInterface != null) {
            mDeviceConnection.releaseInterface(mInterface);
            mInterface = null;
        }
        mDeviceConnection.close();
        mDevice = null;
        mDeviceConnection = null;
    }

    if (device != null && intf != null) {
        UsbDeviceConnection connection = mManager.openDevice(device);
        if (connection != null) {
            log("open succeeded");
            if (connection.claimInterface(intf, false)) {
                log("claim interface succeeded");
                mDevice = device;
                mDeviceConnection = connection;
                mInterface = intf;
                mAdbDevice = new AdbDevice(this, mDeviceConnection, intf);
                log("call start");
                mAdbDevice.start();
                return true;
            } else {
                log("claim interface failed");
                connection.close();
            }
        } else {
            log("open failed");
        }
    }

    if (mDeviceConnection == null && mAdbDevice != null) {
        mAdbDevice.stop();
        mAdbDevice = null;
    }
    return false;
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:40,代码来源:AdbTestActivity.java

示例2: setupUsb

import android.hardware.usb.UsbDeviceConnection; //导入方法依赖的package包/类
protected void setupUsb(UsbDevice device) {
    UsbInterface inf = device.getInterface(0);
    UsbDeviceConnection conn = mUsbManager.openDevice(device);
    if (conn == null) {
        Log.wtf("MainActivity", "unable to open device?");
        return;
    }

    if (!conn.claimInterface(inf, true)) {
        conn.close();
        Log.wtf("MainActivity", "unable to claim interface!");
        return;
    }

    mBlinkDevice = device;
    mBlinkConn = conn;
}
 
开发者ID:nasa,项目名称:astrobee_android,代码行数:18,代码来源:MainActivity.java

示例3: setUsbInterface

import android.hardware.usb.UsbDeviceConnection; //导入方法依赖的package包/类
private boolean setUsbInterface(android.hardware.usb.UsbDevice device, UsbInterface intf) {
    if (mDeviceConnection != null) {
        if (mInterface != null) {
            mDeviceConnection.releaseInterface(mInterface);
            mInterface = null;
        }
        mDeviceConnection.close();
        mDevice = null;
        mDeviceConnection = null;
    }

    if (device != null && intf != null) {
        UsbDeviceConnection connection = mUsbManager.openDevice(device);
        if (connection != null) {
            if (connection.claimInterface(intf, true)) {
                mDevice = device;
                mDeviceConnection = connection;
                mInterface = intf;
                mFcDevice = new FcUsbDevice(this, mDeviceConnection, intf,
                        mXmlObjects);
                mFcDevice.getObjectTree().setXmlObjects(mXmlObjects);

                mFcDevice.start();
                return true;
            } else {
                connection.close();
            }
        }
    }

    if (mDeviceConnection == null && mFcDevice != null) {
        mFcDevice.stop();
        mFcDevice = null;
    }
    return false;
}
 
开发者ID:MarcProe,项目名称:lp2go,代码行数:37,代码来源:MainActivity.java

示例4: performUsbPermissionCallback

import android.hardware.usb.UsbDeviceConnection; //导入方法依赖的package包/类
private void performUsbPermissionCallback(final UsbDevice device) {
    if (mUsbHandler.getLooper().getThread() != Thread.currentThread()) {
        mUsbHandler.post(new Runnable() {
            @Override
            public void run() {
                performUsbPermissionCallback(device);
            }
        });
        return;
    }

    if (mPicoflexx != null) {
        Log.d(TAG, "Already have a picoflexx");
        return;
    }

    UsbDeviceConnection conn = mUsbManager.openDevice(device);
    Log.i(TAG, "USB Device: " + device.getDeviceName() + ", fd: " + conn.getFileDescriptor());

    if (!openPicoflexx(conn.getFileDescriptor())) {
        Log.e(TAG, "error initializing the picoflexx");
        mUiHandler.obtainMessage(WHAT_STATE, STATE_ERROR, R.string.error_initializing)
                .sendToTarget();
        conn.close();
        return;
    }

    mConn = conn;
    mPicoflexx = device;

    final int width = getMaxWidth();
    final int height = getMaxHeight();

    mCloud.setWidth(width);
    mCloud.setHeight(height);
    mCloud.setRowStep(width * 12);

    mUiHandler.obtainMessage(WHAT_STATE, STATE_IDLE, -1).sendToTarget();
}
 
开发者ID:nasa,项目名称:astrobee_android,代码行数:40,代码来源:MainActivity.java


注:本文中的android.hardware.usb.UsbDeviceConnection.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。