History log of /external/vogar/src/vogar/android/DeviceFilesystem.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
7029503206e4c89fe167c3389c1062d89cf35c52 19-Nov-2015 Paul Duffin <paulduffin@google.com> Refactoring to make more testable

Prior to making a change in the behaviour to fix an issue with
the quoting of command line arguments this refactors the
existing code and adds some tests to illustrate the existing
behaviour. This will minimize the chances that the fix will
break existing code.

The changes are explained below in more detail.

This applied a couple of common refactorings to a number of
classes:
* Where classes were creating a lot of subsidiary objects in
their constructor I switched to using the dependency injection
pattern (i.e. passing in parameters to the constructor). That
makes it easier for tests to override the behaviour.

* Where classes were being given a huge object (e.g. Run) but
only required a small number of it's fields I replaced the Run
constructor parameter with the individual parts.

LocalTarget - Replaced Run with Log, Mkdir, Rm.

Run - Passed in more parameters into the constructor, moved the
code that created those objects into Vogar.run(). Also, make the
vogarJar() method work when running from a class directory to
allow it to work from within IDEA as well as when running from
jars.

SshTarget - Removed a bit of duplication of the command line
prefix used to run a script remotely.

Target - Method defaultDeviceDir() was removed and the
implementations were made static and accessed directly from
Vogar. That is necessary to break a dependency cycle; AdbTarget
required AndroidSdk, which required DeviceFileCache, which
required runnerDir, which required Target.defaultDeviceDir().
Previously, that was broken by passing the DeviceFileCache to
the AndroidSdk after construction using the setCaches() method
but that has been removed as part of this refactoring.

Vogar - Made the constructor and parseArgs(String[]) visible for
testing. Moved some of the code from Run's constructor here to
create the values to be passed into its expanded constructor.
TargetType was added to encapsulate the defaultDeviceDir() for
each Target implementation class. That allowed the cycle
described in Target to be broken.

AdbTarget - Replaced Run with individual fields. Moved
functionality from AndroidSdk that's only used by this class
into here (waitForDevice(), ensureDirectory(File), remount(),
rm(File), forwardTcp(int), push() and pull()). Bringing in
push() also required moving the pushCache from AndroidSdk as
well. Added DeviceFilesystem as a parameter to avoid having to
have a reference to AndroidSdk.

AndroidSdk - Moved logic that runs shell commands to calculate
the compilationClasspath and androidJarPath out of the
constructor and into a static method to allow tests to pass
dummy values straight into the constructor. Marked constructor
as VisibleForTesting. Removed setCaches(..) method and
pushCache, passed the HostFileCache straight into the
constructor, marking the dexCache field as final. Added explicit
exception when can't find platforms directory rather than
NullPointerException. Moved methods that are only used by either
AdbTarget or DeviceFileCache into those classes.

DeviceFileCache - Replaced AndroidSdk with DeviceFileSystem and
moved cp(File, File) and mv(File, File) from AndroidSdk into
here.

DeviceRuntime - Added a Supplier<String> parameter to provide
the device user name in order to allow tests to provide their
own. That is needed because otherwise the test will attempt
to connect to a device to determine the user name.

Command - Added method to access the args for testing, moved the
special processing of "-c" option from start() into a method
called from the constructor. That allows the test to verify the
processing of that without actually executing the command.
Cleaned up unused workingDirectory method and some minor
warnings.

Added some tests and fixed a compile issue with the
JUnitRunnerTest.

Change-Id: Ib1676ee19a4f0e7a8944b2708a6dbe3899d1d292
/external/vogar/src/vogar/android/DeviceFilesystem.java
3fd1cf5ff629b06b63f09b79508ec290af07267f 21-Sep-2015 Neil Fuller <nfuller@google.com> Fix vogar target ls / rm tasks in the event of errors

The latest aosp/master adbd appears to report adb shell exit codes
properly.

vogar was previously relying on this not being the case.
It is possible that recent commit 99a9b24d3c broke the clean up task
behavior, but that doesn't appear to explain all the breaks.

Older devices (e.g. L-MR1) still return exit code 0 for command
failures.

This change returns the behavior to ignoring exit codes for the adb
shell tasks. Because the behavior is device-version specific there
isn't much point relying on the new exit-code behavior because vogar
would not function on the old devices.

Bug: 24250996
Change-Id: Iae7c992320c5e2caa6bdb3473a8d2536947c3ca2
/external/vogar/src/vogar/android/DeviceFilesystem.java
0eb0936e90bf11463c8ee937ca996d7bd654a098 07-Dec-2011 jessewilson@google.com <jessewilson@google.com@aa685c63-decc-881d-cd2b-7fa72aad72e1> Get most of running on a device via SSH working.

Run on a device like this:
vogar --mode device --ssh 192.168.149.198:2222 SocketTest.java

Currently this is failing because dalvikvm segfaults when invoked via SSH. I suspect it might be a problem with the SSH server running with either the wrong environment or the wrong privileges. I continue to investigate

git-svn-id: http://vogar.googlecode.com/svn/trunk@266 aa685c63-decc-881d-cd2b-7fa72aad72e1
/external/vogar/src/vogar/android/DeviceFilesystem.java