xSAVIKx/AndroidScreencast

Cannot focuse other windows

Closed this issue · 23 comments

08:38:27 [INFO ] [Injector] - injectData(String) - String data=tap/-418/1158
08:38:27 [DEBUG] [Injector] - injectData(String) - end
08:38:27 [DEBUG] [Injector] - injectTap(int, int) - end
[agent] Received : tap/-418/1158
[agent] CommandHandlerThread.handleCommand()
[agent] Command[name=tap]
[agent] TapEvent [x=-418, y=1158]
08:38:32 [ERROR] [Injector$AgentRunningThread] - run()
com.android.ddmlib.ShellCommandUnresponsiveException
    at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:513)
    at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:390)
    at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:359)
    at com.android.ddmlib.Device.executeShellCommand(Device.java:559)
    at com.github.xsavikx.android.screencast.api.injector.Injector$AgentRunningThread.launchProg(Injector.java:378)
    at com.github.xsavikx.android.screencast.api.injector.Injector$AgentRunningThread.run(Injector.java:393)
com.android.ddmlib.ShellCommandUnresponsiveException
    at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:513)
    at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:390)
    at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:359)
    at com.android.ddmlib.Device.executeShellCommand(Device.java:559)
    at com.github.xsavikx.android.screencast.api.injector.Injector$AgentRunningThread.launchProg(Injector.java:378)
    at com.github.xsavikx.android.screencast.api.injector.Injector$AgentRunningThread.run(Injector.java:393)
08:38:32 [DEBUG] [Injector$AgentRunningThread] - run() - end

When focuse on other window, the app will send an error number to the client then the client crash!

and this

[agent] Starting sending framebuffer
08:49:02 [ERROR] [Injector$AgentRunningThread] - run()
com.android.ddmlib.ShellCommandUnresponsiveException
    at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:513)
    at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:390)
    at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:359)
    at com.android.ddmlib.Device.executeShellCommand(Device.java:559)
    at com.github.xsavikx.android.screencast.api.injector.Injector$AgentRunningThread.launchProg(Injector.java:382)
    at com.github.xsavikx.android.screencast.api.injector.Injector$AgentRunningThread.run(Injector.java:397)
com.android.ddmlib.ShellCommandUnresponsiveException
    at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:513)
    at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:390)
    at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:359)
    at com.android.ddmlib.Device.executeShellCommand(Device.java:559)
    at com.github.xsavikx.android.screencast.api.injector.Injector$AgentRunningThread.launchProg(Injector.java:382)
    at com.github.xsavikx.android.screencast.api.injector.Injector$AgentRunningThread.run(Injector.java:397)
08:49:02 [DEBUG] [Injector$AgentRunningThread] - run() - end

Phone is Sony Z2 on stock 4.4.4

@wzhy90 Hello.
I'll try to look at this issue on weekend.
Brief googling says that I need to extend maximum timeout for ddblib. So, I'll try to do it, but I don't have enough devices to test it everywhere, so I'll be pleased, if you can test it again, after I'll provide fix.

OK, I can. I add line to the client like this

case TAP: {
    TapEvent event = getTapEvent(args);
    System.out.println("[agent] " + event);
    if ( event.getX() >= 0 && event.getY() >= 0 &&
          event.getX() <= 1080 && event.getY() <= 1920 );
        Runtime.getRuntime()
                .exec(String.format("input tap %d %d", event.getX(),
                    event.getY()));
    break;
}

Then I touch the blank place the client don't crash.

the client seems crash very easily

[Boot] INFO:  Unable to locate main jar 'main/main.jar' in the JAR file androidscreencast.jar
[Boot] INFO:  setProperties(com.simontuffs.onejar.JarClassLoader@18438d57)
[Boot] INFO:  using JarClassLoader: com.simontuffs.onejar.JarClassLoader
[JarClassLoader] INFO:  NOTICE in lib/common-24.2.3.jar is hidden by lib/ddmlib-24.2.3.jar (with different bytes)
[JarClassLoader] INFO:  NOTICE in lib/annotations-24.2.3.jar is hidden by lib/ddmlib-24.2.3.jar (with different bytes)
[JarClassLoader] INFO:  findResource(): unable to locate "log4j.xml"
[JarClassLoader] INFO:  findResource(): unable to locate "log4j.xml"
[JarClassLoader] INFO:  findResource() found: "log4j.properties" for caller null in codebase main/AndroidScreencast-0.0.3.jar
00:00:39 [DEBUG] [Main] - main(String[]) - start
00:00:39 [DEBUG] [Main] - initialize(JSplashScreen) - start
00:00:39 [DEBUG] [Main] - waitDeviceList(AndroidDebugBridge) - start
00:00:39 [DEBUG] [Main] - waitDeviceList(AndroidDebugBridge) - end
00:00:39 [DEBUG] [Injector] - start() - start
00:00:39 [DEBUG] [Injector] - start() - end
00:00:39 [DEBUG] [Injector$AgentInitThread] - run() - start
00:00:39 [DEBUG] [Injector$AgentInitThread] - init() - start
00:00:39 [DEBUG] [Main] - initialize(JSplashScreen) - end
00:00:39 [DEBUG] [Main] - main(String[]) - end
00:00:39 [DEBUG] [Injector] - killRunningAgent() - start
00:00:39 [DEBUG] [Injector] - killRunningAgent() - end
00:00:39 [INFO ] [Injector$AgentInitThread] - init() - Old client closed
00:00:39 [DEBUG] [Injector$AgentInitThread] - uploadAgent() - start
00:00:39 [INFO ] [Injector$AgentInitThread] - uploadAgent() - String cmd=adb -s CB5A1Y1EY4 push ./MyInjectEventApp.jar  /data/local/tmp/MyInjectEventApp.jar
00:00:40 [INFO ] [Injector$AgentInitThread] - uploadAgent() - ADB push exitValue=0
00:00:40 [DEBUG] [Injector$AgentInitThread] - uploadAgent() - end
00:00:40 [DEBUG] [Injector$AgentRunningThread] - run() - start
00:00:40 [DEBUG] [Injector$AgentRunningThread] - launchProg(String) - start
00:00:40 [INFO ] [Injector$AgentRunningThread] - launchProg(String) - String fullCmd=su -c 'export CLASSPATH=/data/local/tmp/MyInjectEventApp.jar; exec app_process /system/bin com.github.xsavikx.android.screencast.client.Main 2436'
WARNING: linker: app_process has text relocations. This is wasting memory and is a security risk. Please fix.
WARNING: linker: app_process has text relocations. This is wasting memory and is a security risk. Please fix.
[agent] Starting ...
[agent] port=2436
[agent] Main.execute()
[agent] ServerSocket created on port=2436
00:00:45 [ERROR] [Injector$AgentRunningThread] - launch with app_process failed, try with dalvikvm ...
[agent] Starting ...
[agent] port=2436
[agent] Main.execute()
[agent] ServerSocket created on port=2436
00:00:50 [DEBUG] [Injector$AgentInitThread] - connectToAgent() - start
00:00:50 [INFO ] [Injector$AgentInitThread] - connectToAgent() - Connected to agent socket
00:00:50 [DEBUG] [Injector$AgentInitThread] - connectToAgent() - end
00:00:50 [INFO ] [Injector$AgentInitThread] - init() - Connected to agent!
00:00:50 [DEBUG] [Injector$AgentInitThread] - init() - end
00:00:50 [DEBUG] [Injector$AgentInitThread] - run() - end
[agent] New client !
[agent] ClientHandler.ClientHandler()
[agent] ImageSenderThread.run()
[agent] CommandHandlerThread.run()
[agent] Starting sending framebuffer
00:00:55 [ERROR] [Injector$AgentRunningThread] - run()
com.android.ddmlib.ShellCommandUnresponsiveException
    at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:513)
    at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:390)
    at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:359)
    at com.android.ddmlib.Device.executeShellCommand(Device.java:559)
    at com.github.xsavikx.android.screencast.api.injector.Injector$AgentRunningThread.launchProg(Injector.java:378)
    at com.github.xsavikx.android.screencast.api.injector.Injector$AgentRunningThread.run(Injector.java:393)
com.android.ddmlib.ShellCommandUnresponsiveException
    at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:513)
    at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:390)
    at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:359)
    at com.android.ddmlib.Device.executeShellCommand(Device.java:559)
    at com.github.xsavikx.android.screencast.api.injector.Injector$AgentRunningThread.launchProg(Injector.java:378)
    at com.github.xsavikx.android.screencast.api.injector.Injector$AgentRunningThread.run(Injector.java:393)
00:00:55 [DEBUG] [Injector$AgentRunningThread] - run() - end
00:01:17 [DEBUG] [Injector] - injectKeycode( int) - start
00:01:17 [DEBUG] [Injector] - injectData(String) - start
00:01:17 [INFO ] [Injector] - injectData(String) - String data=key/26
00:01:17 [DEBUG] [Injector] - injectData(String) - end
00:01:17 [DEBUG] [Injector] - injectKeycode(int, int) - end
00:01:35 [DEBUG] [Injector] - injectKeycode( int) - start
00:01:35 [DEBUG] [Injector] - injectData(String) - start
00:01:35 [INFO ] [Injector] - injectData(String) - String data=key/26
00:01:35 [DEBUG] [Injector] - injectData(String) - end
00:01:35 [DEBUG] [Injector] - injectKeycode(int, int) - end
00:01:40 [DEBUG] [Injector] - injectKeycode( int) - start
00:01:40 [DEBUG] [Injector] - injectData(String) - start
00:01:40 [INFO ] [Injector] - injectData(String) - String data=key/26
00:01:40 [DEBUG] [Injector] - injectData(String) - end
00:01:40 [DEBUG] [Injector] - injectKeycode(int, int) - end
00:01:41 [DEBUG] [Injector] - injectKeycode( int) - start
00:01:41 [DEBUG] [Injector] - injectData(String) - start
00:01:41 [INFO ] [Injector] - injectData(String) - String data=key/26
00:01:41 [DEBUG] [Injector] - injectData(String) - end
00:01:41 [DEBUG] [Injector] - injectKeycode(int, int) - end
00:01:43 [DEBUG] [Main] - close() - start
00:01:43 [INFO ] [Main] - close() - Cleaning up...
00:01:43 [DEBUG] [Injector] - close() - start
00:01:44 [DEBUG] [Injector] - close() - end
00:01:44 [INFO ] [Main] - close() - Cleaning done, exiting...
00:01:44 [DEBUG] [Main] - close() - end

ok, I understand the real source of problem now :-)
there should be checks on PC app and client also.
Thanks for your help. I'll fix it in both places.

BTW, How to get the client's .classpath file? Using ant dist will not generate this file.
Using openjdk 7u79 and android build tool 22.0.1.
The ddmlib has upgraded to 24.3.0 too

check client repository(https://github.com/xSAVIKx/AndroidScreencastClient). you do need to use JDK 1.6 to compile android 4.*-compatible source, cause java7 bytecode is different from java6 and you won't be able to generate dexed classes using DX tool.
And for .classpath - I'm using eclipse IDE, so it does everything about classpath for me. I haven't tried to generate it manually, but you can look at smth like http://ant-eclipse.sourceforge.net/ant-eclipse.html
Also be aware, that newer version of android build tool could also cause problems (again with DX tool maybe).

I using openjdk 1.7 and dx tool 19 or 22 compile the dex file sucess. and I just copy your released package's .classpath. Is the .classpath genericd?

hm. It's quite strange for me.
Yes, if you don't add any new packages, it should be generic.

OK, and can it run with Oracle JRE 8 in windows? I found in Windows it was more unstable

It should run with JRE7+, cause I've rewritten desktop app using java7 features.
But I haven't tested it in Windows.

You can also look at this source code: http://marian.schedenig.name/wp-content/uploads/adbcontrol.zip
It has no mobile client.

Thanks for link, I've looked through the source, but I think that AndroidScreencast has some more functionality planned in it.
I have ambitions to rewrite it totally, but have not enough time for that :-(
And, if you've provided patch - you're welcome to fork repo and request pull.
The best idea of this adbcontrol - introducing properties to configure ADB path :-)

Hi again.
I've tried to create client-free version of app.
You can find it here (https://github.com/xSAVIKx/AndroidScreencast/releases/tag/0.0.3S), if you're interesting in it.
I don't cover previous errors, cause I want to test possible speed of 2 versions now and decide what to develop.

I would like the 0.0.3S version.
And the maven plugins has upgraded ! !

Which version of maven do you use? I use apt-get to install maven2 and when I first time build this project, the mvn download all dependence from the site which define below the pom.xml. It try to download from that site but faild then it will try to download them from official web site. Is this ordinary?

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Android Screencast
[INFO]    task-segment: [install]
[INFO] ------------------------------------------------------------------------
Downloading: http://onejar-maven-plugin.googlecode.com/svn/mavenrepo/org/apache/maven/plugins/maven-resources-plugin/2.3/maven-resources-plugin-2.3.pom
[INFO] Unable to find resource 'org.apache.maven.plugins:maven-resources-plugin:pom:2.3' in repository onejar-maven-plugin.googlecode.com (http://onejar-maven-plugin.googlecode.com/svn/mavenrepo)
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.3/maven-resources-plugin-2.3.pom
4K downloaded  (maven-resources-plugin-2.3.pom)

I use maven 3.3.3.
And what do you mean by updgraded plugins ? If there are newer versions - it actually doesn't matter, while projects compiling and building process is OK.

Yes, the plugins have some newer version

I've fixed issues with client, we've just have now no client)
I'll try to measure speed with and without client, cause now, I think it's working a little slower.
But, anyway, please test if current issue can be closed.

It seems master and standalone both have no client ?

Yeap, I pushed changes to master instead of standalone, but I think I don't want to develop client)

OK, problem fixed .