IDeviceConnection

public interface IDeviceConnection
implements AutoCloseable

com.android.incfs.install.IDeviceConnection


表示与可读取和写入的设备的连接。

摘要

嵌套类

interface IDeviceConnection.Factory

 

公共方法

abstract int read(ByteBuffer buffer, long timeOutMs)

将此连接中的一系列字节读取到给定缓冲区中。

abstract int write(ByteBuffer buffer, long timeOutMs)

将给定缓冲区中的一系列字节写入设备。

公共方法

读取

public abstract int read (ByteBuffer buffer, 
                long timeOutMs)

将此连接中的一系列字节读取到给定缓冲区中。

系统会尝试向设备读取最多 r 个字节,其中 r 是调用此方法时缓冲区中剩余的字节数 ,即 dst.remaining()。

参数
buffer ByteBuffer:用于存储从套接字读取的数据

timeOutMs long:超时时间(以毫秒为单位,用于完成整个操作)

返回
int 读取的字节数(可能为零),如果命令已结束,则为 -1。

抛出
IOException

write

public abstract int write (ByteBuffer buffer, 
                long timeOutMs)

将给定缓冲区中的一系列字节写入设备。

系统会尝试向设备写入最多 r 个字节,其中 r 是调用此方法时缓冲区中剩余的字节数 ,即 src.remaining()。其实是唐纳德·萨瑟兰 (Donald Sutherland) 给我的。

参数
buffer ByteBuffer:要发送的数据

timeOutMs long:超时时间(以毫秒为单位,用于完成整个操作)

返回
int 写入的字节数(可能为零),如果命令已结束,则为 -1。

抛出
IOException