Skip to content

Commit

Permalink
Merge branch 'release/v0.0.12s'
Browse files Browse the repository at this point in the history
  • Loading branch information
xSAVIKx committed Jun 4, 2018
2 parents 98058f3 + 0f30a3b commit 7510c40
Show file tree
Hide file tree
Showing 25 changed files with 173 additions and 87 deletions.
Binary file modified .mvn/wrapper/maven-wrapper.jar
100644 → 100755
Binary file not shown.
3 changes: 2 additions & 1 deletion .mvn/wrapper/maven-wrapper.properties
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.0/maven-wrapper-0.4.0.jar
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,66 @@ This project gives the opportunity to use your phone even with a broken screen.

[wiki]: https://github.com/xSAVIKx/AndroidScreencast/wiki

## Configuration

There are 2 ways to run application:
1. Run ADB server on your own
2. Provide correct `app.properties` file

### Run ADB server on your own

In order to run server on your own you have to run already installed (or one from our OS-specific bundle) `adb`
with following command:
```
adb start-server
```

**Note**:

If `app.properties` will have `adb.path` filled - AndroidScreencast will shutdown ADB server on application termination.

Additionally, in order to use, for example, remote ADB server with ssh forwarding you should not use `app.properties` or `adb.path`
property should be commented.

### Provide correct `app.properties` file

Right now to successfully run application you **should** create `app.properties` file in the same folder as
AndroidScreencast's jar and provide at least one property - `adb.path` which should point to the `adb` executable file
within your OS, for example such location could be configured for Windows OS:
```properties
adb.path=adb/windows/adb.exe
```

Both absolute and relative paths are supported.

Example of valid `app.properties` could be find [here](app.properties).

Also we have got some valid OS-specific examples:
* [OSX app.properties](adb/macosx/app.properties)
* [Windows app.properties](adb/windows/app.properties)
* [Linux app.properties](adb/linux/app.properties)

They are actually the same, just `adb.path` is OS-specific. Files listed above are automatically included into OS-specific bundles.


### Additional properties
Here is the full list of available properties for application configuration.
Properties should be places in the `app.properties` file in the same folder as AndroidScreencast's jar file.

```properties
#relative or absolute path to ADB
adb.path=./adb
#maximum time to wait for device (in seconds)
adb.device.timeout=30
#maximum time to execute adb command (in seconds)
adb.command.timeout=5
#initial application window width (in pixels)
app.window.width=1024
#initial application window height (in pixels)
app.window.height=768
#Defines whether application should look 'natively' to OS. Possible values: true/false
app.native.look=false
```
## JNLP

Application is available using Java web start technology via [androidscreencast.jnlp][jnlp].
Expand Down Expand Up @@ -59,6 +119,10 @@ Additionally OS-packages would be created with ADB executables bundled:
* `androidscreencast-VERSION-linux.tar.gz`
* `androidscreencast-VERSION-macosx.tar.gz`

In order to provide correct configuration see [configuration][configuration_section] section.

[configuration_section]: https://github.com/xSAVIKx/AndroidScreencast/blob/develop/README.md#configuration

# Requirements

Currently AndroidScreencast works directly with `adb input` program through `ddmlib` and abuse functionality of:
Expand All @@ -81,6 +145,7 @@ Also, to run AndroidScreencast you will need *adb* installed (or you can use bun
[Android_4_1_1_Input]: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.1.1_r1/com/android/commands/input/Input.java#Input
[seven_square]: https://github.com/yangh/sevensquare
[droid_at_screen]: http://droid-at-screen.org/droid-at-screen/
[android_screen_monitor]: https://github.com/adakoda/android-screen-monitor

[travis_badge]: https://travis-ci.org/xSAVIKx/AndroidScreencast.svg?branch=master
[travis]: https://travis-ci.org/xSAVIKx/AndroidScreencast
Expand Down
Binary file modified adb/linux/adb
100644 → 100755
Binary file not shown.
4 changes: 2 additions & 2 deletions adb/linux/app.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ adb.path=./adb
#adb.device.timeout=30
#maximum time to execute adb command (in seconds)
#adb.command.timeout=5
#default.window.width=1024
#default.window.height=768
#app.window.width=1024
#app.window.height=768
#Defines whether application should look 'natively' to OS
#app.native.look=false
Binary file modified adb/linux/fastboot
100644 → 100755
Binary file not shown.
Binary file modified adb/macosx/adb
100644 → 100755
Binary file not shown.
4 changes: 2 additions & 2 deletions adb/macosx/app.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ adb.path=./adb
#adb.device.timeout=30
#maximum time to execute adb command (in seconds)
#adb.command.timeout=5
#default.window.width=1024
#default.window.height=768
#app.window.width=1024
#app.window.height=768
#Defines whether application should look 'natively' to OS
#app.native.look=false
Binary file modified adb/macosx/fastboot
100644 → 100755
Binary file not shown.
Empty file modified adb/windows/AdbWinApi.dll
100644 → 100755
Empty file.
Empty file modified adb/windows/AdbWinUsbApi.dll
100644 → 100755
Empty file.
Binary file modified adb/windows/adb.exe
100644 → 100755
Binary file not shown.
4 changes: 2 additions & 2 deletions adb/windows/app.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ adb.path=./adb.exe
#adb.device.timeout=30
#maximum time to execute adb command (in seconds)
#adb.command.timeout=5
#default.window.width=1024
#default.window.height=768
#app.window.width=1024
#app.window.height=768
#Defines whether application should look 'natively' to OS
#app.native.look=false
Binary file modified adb/windows/fastboot.exe
100644 → 100755
Binary file not shown.
6 changes: 3 additions & 3 deletions app.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
adb.path=adb/windows/adb2.exe
default.window.width=1024
default.window.height=768
adb.path=./adb/linux/adb
app.window.width=1024
app.window.height=768
77 changes: 34 additions & 43 deletions mvnw
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -54,38 +54,16 @@ case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
#
# Look for the Apple JDKs first to preserve the existing behaviour, and then look
# for the new JDKs provided by Oracle.
#
if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
#
# Apple JDKs
#
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
fi

if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
#
# Apple JDKs
#
export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
fi

if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
#
# Oracle JDKs
#
export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
fi

if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
#
# Apple JDKs
#
export JAVA_HOME=`/usr/libexec/java_home`
fi
;;
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
export JAVA_HOME="`/usr/libexec/java_home`"
else
export JAVA_HOME="/Library/Java/Home"
fi
fi
;;
esac

if [ -z "$JAVA_HOME" ] ; then
Expand Down Expand Up @@ -130,7 +108,7 @@ if $cygwin ; then
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi

# For Migwn, ensure paths are in UNIX format before anything is touched
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
Expand Down Expand Up @@ -187,14 +165,25 @@ CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
local basedir=$(pwd)
local wdir=$(pwd)

if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi

basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
wdir=$(cd "$wdir/.."; pwd)
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=`cd "$wdir/.."; pwd`
fi
# end of workaround
done
echo "${basedir}"
}
Expand All @@ -206,7 +195,15 @@ concat_lines() {
fi
}

export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
BASE_DIR=`find_maven_basedir "$(pwd)"`
if [ -z "$BASE_DIR" ]; then
exit 1;
fi

export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"

# For Cygwin, switch paths to Windows format before running java
Expand All @@ -221,14 +218,8 @@ if $cygwin; then
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi

# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS

WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain

# avoid using MAVEN_CMD_LINE_ARGS below since that would loose parameter escaping in $@
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
Expand Down
5 changes: 1 addition & 4 deletions mvnw.cmd
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ goto error

:init

set MAVEN_CMD_LINE_ARGS=%MAVEN_CONFIG% %*

@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.

Expand Down Expand Up @@ -118,10 +116,9 @@ for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do s

SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"

set WRAPPER_JAR=""%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar""
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain

# avoid using MAVEN_CMD_LINE_ARGS below since that would loose parameter escaping in %*
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
Expand Down
27 changes: 17 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.xsavikx</groupId>
<artifactId>androidscreencast</artifactId>
<version>0.0.10s</version>
<version>0.0.12s</version>
<name>Android Screencast</name>
<packaging>jar</packaging>
<properties>
<dagger2.version>2.9</dagger2.version>
<ddmlib.version>25.2.0</ddmlib.version>
<slf4j.version>1.7.24</slf4j.version>
<logback-classic.version>1.2.1</logback-classic.version>
<guava.version>21.0</guava.version>
<dagger2.version>2.16</dagger2.version>
<ddmlib.version>26.1.2</ddmlib.version>
<slf4j.version>1.7.25</slf4j.version>
<logback-classic.version>1.2.3</logback-classic.version>
<guava.version>25.1-jre</guava.version>
<main.class>com.github.xsavikx.androidscreencast.Main</main.class>
<jdk.version>1.8</jdk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -63,7 +63,7 @@
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<version>3.7.0</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
Expand All @@ -72,7 +72,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
Expand All @@ -84,7 +84,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.0.0</version>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
Expand All @@ -107,7 +107,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<version>3.1.0</version>
<configuration>
<descriptors>
<descriptor>src/assembly/windows.xml</descriptor>
Expand Down Expand Up @@ -163,6 +163,13 @@
</build>
</profile>
</profiles>
<repositories>
<repository>
<id>google</id>
<name>Google Maven Repository</name>
<url>https://maven.google.com/</url>
</repository>
</repositories>
<url>http://xsavikx.github.io/AndroidScreencast</url>
<ciManagement>
<url>https://travis-ci.org/xSAVIKx/AndroidScreencast</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.android.ddmlib.IDevice;
import com.github.xsavikx.androidscreencast.exception.IllegalAdbConfigurationException;
import com.github.xsavikx.androidscreencast.util.StringUtils;
import com.google.common.annotations.VisibleForTesting;

import javax.inject.Inject;
import javax.inject.Named;
Expand Down Expand Up @@ -31,7 +32,9 @@ public boolean hasInitialDeviceList() {
}

public void stop() {
AndroidDebugBridge.disconnectBridge();
if (hasAdbPathFilled()) {
AndroidDebugBridge.disconnectBridge();
}
AndroidDebugBridge.terminate();
}

Expand All @@ -47,12 +50,7 @@ private void init() {
return;
}
try {
AndroidDebugBridge.initIfNeeded(false);
if (StringUtils.isNotEmpty(adbPath)) {
adb = AndroidDebugBridge.createBridge(adbPath, false);
} else {
adb = AndroidDebugBridge.createBridge();
}
adb = createAndroidDebugBridge();
} catch (IllegalArgumentException e) {
if (hasAdbProcFailed(e)) {
throw new IllegalAdbConfigurationException(adbPath);
Expand All @@ -61,6 +59,19 @@ private void init() {
}
}

@VisibleForTesting
AndroidDebugBridge createAndroidDebugBridge() {
AndroidDebugBridge.initIfNeeded(false);
if (hasAdbPathFilled()) {
return AndroidDebugBridge.createBridge(adbPath, false);
}
return AndroidDebugBridge.createBridge();
}

private boolean hasAdbPathFilled() {
return StringUtils.isNotEmpty(adbPath);
}

private boolean hasAdbProcFailed(IllegalArgumentException e) {
return e.getCause() != null
&& e.getCause() instanceof IOException
Expand Down
Loading

0 comments on commit 7510c40

Please sign in to comment.