Skip to content

Commit

Permalink
Merge branch 'release/0.0.10s'
Browse files Browse the repository at this point in the history
  • Loading branch information
xSAVIKx committed Mar 3, 2017
2 parents 54284eb + 9914794 commit 98058f3
Show file tree
Hide file tree
Showing 49 changed files with 907 additions and 512 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
language: java

branches:
only:
- master
before_install:
- chmod +x mvnw
jdk:
Expand Down
45 changes: 29 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
AndroidScreencast
=================

[![Build Status Travis-CI][travis_badge]][travis] [![Dependency Status][versioneye_badge]][versioneye] [![Codacy Badge][codacy_badge]][codacy] [![Join the chat at https://gitter.im/AndroidScreencast/Lobby][gitter_badge]][gitter]

[travis_badge]: https://travis-ci.org/xSAVIKx/AndroidScreencast.svg?branch=master
[travis]: https://travis-ci.org/xSAVIKx/AndroidScreencast

[versioneye_badge]: https://www.versioneye.com/user/projects/588988221618a700318eafb5/badge.svg
[versioneye]: https://www.versioneye.com/user/projects/588988221618a700318eafb5

[codacy_badge]: https://api.codacy.com/project/badge/Grade/064bbd2582b544bb9659a01a2872317c
[codacy]: https://www.codacy.com/app/xSAVIKx/AndroidScreencast?utm_source=github.com&utm_medium=referral&utm_content=xSAVIKx/AndroidScreencast&utm_campaign=badger



[gitter_badge]: https://badges.gitter.im/AndroidScreencast/Lobby.svg
[gitter]: https://gitter.im/AndroidScreencast/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
[![Build Status Travis-CI][travis_badge]][travis] 
[![Dependency Status][versioneye_badge]][versioneye] 
[![Codacy Badge][codacy_badge]][codacy] 
[![Join the chat at https://gitter.im/AndroidScreencast/Lobby][gitter_badge]][gitter] 
[![Apache License][license_badge]][license]

# Description

Expand Down Expand Up @@ -62,7 +52,7 @@ The resulting artifacts will be created in the `target` subdirectory.
You can run the executable jar via `java -jar target/androidscreencast-VERSION-executable.jar`, replacing VERSION with
the current version.

For example, `java -jar target/androidscreencast-0.0.9s-executable.jar`.
For example, `java -jar target/androidscreencast-0.0.10s-executable.jar`.

Additionally OS-packages would be created with ADB executables bundled:
* `androidscreencast-VERSION-windows.zip`
Expand All @@ -82,4 +72,27 @@ So, right now AndroidScreencast support all Android versions equal or greater th

Also, to run AndroidScreencast you will need *adb* installed (or you can use bundled in OS bundles adb).

# Similar Projects

* [Seven Square][seven_square] - QT implementation of Android Screencast (actively developed)
* [Droid@Screen][droid_at_screen] - implementation of Android Screencast in Java (fancy one, last release in 2013)
* [Android Screen Monitor][android_screen_monitor] - implementation of Android Screencast in Java (latest release in 2013)

[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/

[travis_badge]: https://travis-ci.org/xSAVIKx/AndroidScreencast.svg?branch=master
[travis]: https://travis-ci.org/xSAVIKx/AndroidScreencast

[versioneye_badge]: https://www.versioneye.com/user/projects/58a746d8b4d2a20055fcb887/badge.svg?style=flat
[versioneye]: https://www.versioneye.com/user/projects/58a746d8b4d2a20055fcb887

[codacy_badge]: https://api.codacy.com/project/badge/Grade/064bbd2582b544bb9659a01a2872317c
[codacy]: https://www.codacy.com/app/xSAVIKx/AndroidScreencast?utm_source=github.com&utm_medium=referral&utm_content=xSAVIKx/AndroidScreencast&utm_campaign=badger

[license_badge]: https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat
[license]: http://www.apache.org/licenses/LICENSE-2.0

[gitter_badge]: https://badges.gitter.im/AndroidScreencast/Lobby.svg?style=flat
[gitter]: https://gitter.im/AndroidScreencast/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
2 changes: 1 addition & 1 deletion app.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
adb.path=adb/windows/adb.exe
adb.path=adb/windows/adb2.exe
default.window.width=1024
default.window.height=768
4 changes: 2 additions & 2 deletions docs/jnlp/androidscreencast.jnlp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="http://xsavikx.github.io/AndroidScreencast/"
href="jnlp/androidscreencast.jnlp"
version="0.0.8s">
version="0.0.10s">
<information>
<title>Android Screencast</title>
<vendor>Iurii Sergiichuk</vendor>
Expand All @@ -16,7 +16,7 @@
<resources>
<j2se version="1.8+"/>
<jar main="true" download="eager"
href="https://github.com/xSAVIKx/AndroidScreencast/releases/download/0.0.8S/androidscreencast-0.0.8s-executable.jar"/>
href="https://github.com/xSAVIKx/AndroidScreencast/releases/download/0.0.10s/androidscreencast-0.0.10s-executable.jar"/>
</resources>
<application-desc main-class="com.github.xsavikx.androidscreencast.Main"/>
</jnlp>
41 changes: 25 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.xsavikx</groupId>
<artifactId>androidscreencast</artifactId>
<version>0.0.9s</version>
<version>0.0.10s</version>
<name>Android Screencast</name>
<packaging>jar</packaging>
<properties>
<spring.version>4.3.5.RELEASE</spring.version>
<dagger2.version>2.9</dagger2.version>
<ddmlib.version>25.2.0</ddmlib.version>
<log4j.version>1.2.17</log4j.version>
<slf4j.version>1.7.24</slf4j.version>
<logback-classic.version>1.2.1</logback-classic.version>
<guava.version>21.0</guava.version>
<main.class>com.github.xsavikx.androidscreencast.Main</main.class>
<jdk.version>1.8</jdk.version>
Expand All @@ -25,24 +27,31 @@
<version>${ddmlib.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback-classic.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
<groupId>com.google.dagger</groupId>
<artifactId>dagger</artifactId>
<version>${dagger2.version}</version>
</dependency>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>${dagger2.version}</version>
<optional>true</optional>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
Expand Down Expand Up @@ -75,7 +84,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<version>3.0.0</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/com/github/xsavikx/androidscreencast/Main.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
package com.github.xsavikx.androidscreencast;

import com.github.xsavikx.androidscreencast.app.AndroidScreencastApplication;
import com.github.xsavikx.androidscreencast.app.Application;
import com.github.xsavikx.androidscreencast.spring.config.ApplicationContextProvider;
import org.apache.log4j.Logger;
import com.github.xsavikx.androidscreencast.dagger.MainComponentProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;

public class Main {
private static final Logger LOGGER = Logger.getLogger(Main.class);
private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);

public static void main(String args[]) {
LOGGER.debug("main(String[] args=" + Arrays.toString(args) + ") - start");
Application application;
LOGGER.debug("main(String[] args={}) - start", Arrays.toString(args));
try {
application = ApplicationContextProvider.getBean(AndroidScreencastApplication.class);
Application application = MainComponentProvider.mainComponent().application();
application.init();
application.start();
} finally {
LOGGER.debug("main(String[] args=" + Arrays.toString(args) + ") - end");
LOGGER.debug("main(String[] args={}) - end", Arrays.toString(args));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,63 +7,64 @@
import com.github.xsavikx.androidscreencast.api.injector.OutputStreamShellOutputReceiver;
import com.github.xsavikx.androidscreencast.exception.AndroidScreenCastRuntimeException;
import com.github.xsavikx.androidscreencast.exception.ExecuteCommandException;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.inject.Inject;
import javax.inject.Singleton;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

@Component
@Singleton
public class AndroidDeviceImpl implements AndroidDevice {
private static final Logger logger = Logger.getLogger(AndroidDeviceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(AndroidDeviceImpl.class);
private final IDevice device;

@Autowired
public AndroidDeviceImpl(IDevice device) {
@Inject
public AndroidDeviceImpl(final IDevice device) {
this.device = device;
}

@Override
public String executeCommand(String cmd) {
if (logger.isDebugEnabled()) {
logger.debug("executeCommand(String) - start");
public String executeCommand(final String cmd) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("executeCommand(String) - start");
}
try (ByteArrayOutputStream bos = new ByteArrayOutputStream();) {
try (final ByteArrayOutputStream bos = new ByteArrayOutputStream();) {
device.executeShellCommand(cmd, new OutputStreamShellOutputReceiver(bos));
String returnString = new String(bos.toByteArray(), "UTF-8");
if (logger.isDebugEnabled()) {
logger.debug("executeCommand(String) - end");
final String returnString = new String(bos.toByteArray(), "UTF-8");
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("executeCommand(String) - end");
}
return returnString;
} catch (Exception ex) {
logger.error("executeCommand(String)", ex);
} catch (final Exception ex) {
LOGGER.error("executeCommand(String)", ex);
throw new ExecuteCommandException(cmd);
}
}

@Override
public List<FileInfo> list(String path) {
if (logger.isDebugEnabled()) {
logger.debug("list(String) - start");
public List<FileInfo> list(final String path) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("list(String) - start");
}

try {
String s = executeCommand("ls -l " + path);
String[] entries = s.split("\r\n");
List<FileInfo> fileInfos = new ArrayList<>();
for (String entry : entries) {
final String s = executeCommand("ls -l " + path);
final String[] entries = s.split("\r\n");
final List<FileInfo> fileInfos = new ArrayList<>();
for (final String entry : entries) {
String[] data = entry.split(" ");
if (data.length < 4)
continue;
String attributes = data[0];
boolean directory = attributes.charAt(0) == 'd';
String name = data[data.length - 1];

FileInfo fi = new FileInfo();
final FileInfo fi = new FileInfo();
fi.attribs = attributes;
fi.directory = directory;
fi.name = name;
Expand All @@ -73,59 +74,59 @@ public List<FileInfo> list(String path) {
fileInfos.add(fi);
}

if (logger.isDebugEnabled()) {
logger.debug("list(String) - end");
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("list(String) - end");
}
return fileInfos;
} catch (Exception ex) {
logger.error("list(String)", ex);
} catch (final Exception ex) {
LOGGER.error("list(String)", ex);
throw new AndroidScreenCastRuntimeException(ex);
}
}

@Override
public void openUrl(String url) {
if (logger.isDebugEnabled()) {
logger.debug("openUrl(String) - start");
public void openUrl(final String url) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("openUrl(String) - start");
}

executeCommand("am start " + url);

if (logger.isDebugEnabled()) {
logger.debug("openUrl(String) - end");
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("openUrl(String) - end");
}
}

@Override
public void pullFile(String removeFrom, File localTo) {
if (logger.isDebugEnabled()) {
logger.debug("pullFile(String, File) - start");
public void pullFile(final String removeFrom, final File localTo) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("pullFile(String, File) - start");
}

// ugly hack to call the method without FileEntry
try {
if (device.getSyncService() == null)
throw new RuntimeException("SyncService is null, ADB crashed ?");
Method m = device.getSyncService().getClass().getDeclaredMethod("doPullFile", String.class, String.class,
throw new AndroidScreenCastRuntimeException("SyncService is null, ADB crashed ?");
final Method m = device.getSyncService().getClass().getDeclaredMethod("doPullFile", String.class, String.class,
ISyncProgressMonitor.class);
m.setAccessible(true);
device.getSyncService();
m.invoke(device.getSyncService(), removeFrom, localTo.getAbsolutePath(), SyncService.getNullProgressMonitor());
} catch (Exception ex) {
logger.error("pullFile(String, File)", ex);
} catch (final Exception ex) {
LOGGER.error("pullFile(String, File)", ex);

throw new AndroidScreenCastRuntimeException(ex);
}

if (logger.isDebugEnabled()) {
logger.debug("pullFile(String, File) - end");
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("pullFile(String, File) - end");
}
}

@Override
public void pushFile(File localFrom, String remoteTo) {
if (logger.isDebugEnabled()) {
logger.debug("pushFile(File, String) - start");
public void pushFile(final File localFrom, final String remoteTo) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("pushFile(File, String) - start");
}

try {
Expand All @@ -134,14 +135,14 @@ public void pushFile(File localFrom, String remoteTo) {

device.getSyncService().pushFile(localFrom.getAbsolutePath(), remoteTo, SyncService.getNullProgressMonitor());

} catch (Exception ex) {
logger.error("pushFile(File, String)", ex);
} catch (final Exception ex) {
LOGGER.error("pushFile(File, String)", ex);

throw new AndroidScreenCastRuntimeException(ex);
}

if (logger.isDebugEnabled()) {
logger.debug("pushFile(File, String) - end");
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("pushFile(File, String) - end");
}
}

Expand Down
Loading

0 comments on commit 98058f3

Please sign in to comment.