Project CASUAL
API for CASUAL
 All Classes Namespaces Functions Variables
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
CASUAL.communicationstools.adb.busybox.CASUALDataBridge Class Reference

Public Member Functions

 CASUALDataBridge ()
 
synchronized String getFile (String remoteFileName, File f) throws IOException, InterruptedException
 
synchronized long sendString (String send, String remoteFileName) throws InterruptedException, SocketException, IOException
 
synchronized long sendFile (File f, String remoteFileName) throws FileNotFoundException, Exception
 
synchronized long sendStream (final InputStream input, final String remoteFileName) throws InterruptedException, SocketException, IOException
 
String integralGetFile (String remoteFile, File f)
 
 CASUALDataBridge ()
 
synchronized String getFile (String remoteFileName, File f) throws IOException, InterruptedException
 
synchronized long sendString (String send, String remoteFileName) throws InterruptedException, SocketException, IOException
 
synchronized long sendFile (File f, String remoteFileName) throws FileNotFoundException, Exception
 
synchronized long sendStream (final InputStream input, final String remoteFileName) throws InterruptedException, SocketException, IOException
 
String integralGetFile (String remoteFile, File f)
 

Static Public Member Functions

static CASUALDataBridge getInstance ()
 
static void shutdown ()
 
static CASUALDataBridge getInstance ()
 
static void shutdown ()
 

Static Public Attributes

static Timer timeoutWatchdog
 

Detailed Description

CASUALDataBridge is a unique way to flash information to a device. as opposed to other methods, which require writing a string or a file, CASUALDataBridge also handles Block and Character devices. This allows "flashing" and "pulling" of entire partitions on a device without first transferring a file to the SDCard. The technique used is to deploy a server, and monitor its operations. A second thread is started which sends or receives information to or from the device via TCP over USB. The end result is a verifiable and error-checked method of data transfer from a computer to the Android device from any file/block/char device available.

Author
Adam Outler adamo.nosp@m.utle.nosp@m.r@gma.nosp@m.il.c.nosp@m.om

Constructor & Destructor Documentation

CASUAL.communicationstools.adb.busybox.CASUALDataBridge.CASUALDataBridge ( )

default constructor

CASUAL.communicationstools.adb.busybox.CASUALDataBridge.CASUALDataBridge ( )

default constructor

Member Function Documentation

synchronized String CASUAL.communicationstools.adb.busybox.CASUALDataBridge.getFile ( String  remoteFileName,
File  f 
) throws IOException, InterruptedException

gets a file from the device.

Parameters
remoteFileNamepath to remote file
flocal file to write
Returns
string path to local file
Exceptions
IOExceptionwhen permission problem exists
InterruptedExceptionwhen interrupted
synchronized String CASUAL.communicationstools.adb.busybox.CASUALDataBridge.getFile ( String  remoteFileName,
File  f 
) throws IOException, InterruptedException

gets a file from the device.

Parameters
remoteFileNamepath to remote file
flocal file to write
Returns
string path to local file
Exceptions
IOExceptionwhen permission problem exists
InterruptedExceptionwhen interrupted
String CASUAL.communicationstools.adb.busybox.CASUALDataBridge.integralGetFile ( String  remoteFile,
File  f 
)

Gets a file from the device.

Parameters
remoteFileremote file name
flocal file name
Returns
path to local file.
String CASUAL.communicationstools.adb.busybox.CASUALDataBridge.integralGetFile ( String  remoteFile,
File  f 
)

Gets a file from the device.

Parameters
remoteFileremote file name
flocal file name
Returns
path to local file.
synchronized long CASUAL.communicationstools.adb.busybox.CASUALDataBridge.sendFile ( File  f,
String  remoteFileName 
) throws FileNotFoundException, Exception

Sends a file to the device.

Parameters
flocal file to send
remoteFileNamepath to remote file on device
Returns
number of bytes sent
Exceptions
FileNotFoundExceptionwhen file is not present
Exceptionwhen file cannot be sent
synchronized long CASUAL.communicationstools.adb.busybox.CASUALDataBridge.sendFile ( File  f,
String  remoteFileName 
) throws FileNotFoundException, Exception

Sends a file to the device.

Parameters
flocal file to send
remoteFileNamepath to remote file on device
Returns
number of bytes sent
Exceptions
FileNotFoundExceptionwhen file is not present
Exceptionwhen file cannot be sent
synchronized long CASUAL.communicationstools.adb.busybox.CASUALDataBridge.sendStream ( final InputStream  input,
final String  remoteFileName 
) throws InterruptedException, SocketException, IOException

Sends an inputstream to the device.

Parameters
inputstream to be written to remote file
remoteFileNamename of remote file to be written
Returns
number of bytes sent.
Exceptions
InterruptedExceptionwhen interrupted
SocketExceptionwhen socket cannot be created
IOExceptionwhen permissions problem exists
synchronized long CASUAL.communicationstools.adb.busybox.CASUALDataBridge.sendStream ( final InputStream  input,
final String  remoteFileName 
) throws InterruptedException, SocketException, IOException

Sends an inputstream to the device.

Parameters
inputstream to be written to remote file
remoteFileNamename of remote file to be written
Returns
number of bytes sent.
Exceptions
InterruptedExceptionwhen interrupted
SocketExceptionwhen socket cannot be created
IOExceptionwhen permissions problem exists
synchronized long CASUAL.communicationstools.adb.busybox.CASUALDataBridge.sendString ( String  send,
String  remoteFileName 
) throws InterruptedException, SocketException, IOException

Sends a string to a block/char/file on device

Parameters
sendstring to send
remoteFileNameremote block/char/file on deviec
Returns
number of bytes sent
Exceptions
InterruptedExceptionwhen interrupted
SocketExceptionwhen socket cannot be created
IOExceptionwhen permission problem exists
synchronized long CASUAL.communicationstools.adb.busybox.CASUALDataBridge.sendString ( String  send,
String  remoteFileName 
) throws InterruptedException, SocketException, IOException

Sends a string to a block/char/file on device

Parameters
sendstring to send
remoteFileNameremote block/char/file on deviec
Returns
number of bytes sent
Exceptions
InterruptedExceptionwhen interrupted
SocketExceptionwhen socket cannot be created
IOExceptionwhen permission problem exists

Member Data Documentation

static Timer CASUAL.communicationstools.adb.busybox.CASUALDataBridge.timeoutWatchdog
static
Initial value:
= new Timer(WATCHDOGINTERVAL, new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
if (lastbytes == bytes) {
try {
Log.level0Error("Failed to send file. Timeout. Bytes:" + bytes + " Message:" + deviceSideMessage);
deviceReadyForReceive = false;
shutdownBecauseOfError = true;
timeoutWatchdog.stop();
throw new TimeoutException();
} catch (TimeoutException ex) {
Logger.getLogger(CASUALDataBridge.class.getName()).log(Level.SEVERE, null, ex);
}
} else {
lastbytes = bytes;
CASUALMain.getSession().setStatus(status + " " + bytes);
}
}
})

timeoutWatchdog checks every WATCHDOGINTERVAL millis to verify bytes have increased. If bytes have not increased, it throws an error and shuts things down. This is used to detect a broken connection.


The documentation for this class was generated from the following file: