xSAVIKx/AndroidScreencast

mouse and keyboard not work on Mi3 (4.4.4)

Closed this issue · 11 comments

I used the Pre-release v.0.0.2 on my Fedora 22, the screencast worked great. But the mouse and keyboard control didn't work. I had followed the instructions to change the permission of /data/dalvik-cache. Any idea how to debug?

Hello, thanks for your interest.
Check Issue #4
there are some notes at the bottom how to run and test InjectApp.
You also can try to debug InjectApp via your IDE (like eclipse or IDEA) using remote debug.

@xSAVIKx thanks for your response. I followed the guide. And execute the following commands:

adb shell
su
export CLASSPATH=/data/local/tmp/MyInjectEventApp.jar
exec app_process /system/bin com.github.xsavikx.android.screencast.client.Main 8776

Then I got an error message in logcat, I did have MyInjectEventApp.jar under /data/local/tmp.

E/appproc (13163): ERROR: could not find class 'com.github.xsavikx.android.screencast.client.Main'

I'm not familiar with android shell. Do you have any quick clue about this error?

@upwell
jar file wasn't added to classpath.
It's weird.
execute the following commands and send me output:

adb shell
su
export CLASSPATH=/data/local/tmp/MyInjectEventApp.jar
echo $CLASSPATH

Unfortunately I don't have my laptop with me now and my MI2 is already updated to 5.1 with ART, so I cannot debug and develop this app without some real device :-(
And there is one more question: do you run your MI3 with ART or DALVIK ?

@xSAVIKx
Thanks for your kind response.
Here is the output, and it should be correct:

root@pisces:/ # export CLASSPATH=/data/local/tmp/MyInjectEventApp.jar
root@pisces:/ # echo $CLASSPATH
/data/local/tmp/MyInjectEventApp.jar

My MI3 is using 4.4.4 with DALVIK. The message below is the detail logcat output when the error message comes.

D/AndroidRuntime(22130): 
D/AndroidRuntime(22130): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime(22130): CheckJNI is OFF
D/dalvikvm(22130): Unable to stat classpath element '/data/app/com.miui.sdk-1.apk'
D/dalvikvm(22130): Unable to stat classpath element '/data/app/com.miui.sdk-2.apk'
D/dalvikvm(22130): Unable to stat classpath element '/data/app/com.miui.framework-1.apk'
D/dalvikvm(22130): Unable to stat classpath element '/data/app/com.miui.framework-2.apk'
D/dalvikvm(22130): Trying to load lib libjavacore.so 0x0
D/dalvikvm(22130): Added shared lib libjavacore.so 0x0
D/dalvikvm(22130): Trying to load lib libnativehelper.so 0x0
D/dalvikvm(22130): Added shared lib libnativehelper.so 0x0
D/dalvikvm(22130): No JNI_OnLoad found in libnativehelper.so 0x0, skipping init
E/appproc (22130): ERROR: could not find class 'com.github.xsavikx.android.screencast.client.Main'
E/dalvikvm(22130): JNI posting fatal error: Native registration unable to find class 'android/debug/JNITest'; aborting...
I/dalvikvm(22130): "main" prio=5 tid=1 NATIVE
I/dalvikvm(22130):   | group="main" sCount=0 dsCount=0 obj=0x4174eca8 self=0x4156c550
I/dalvikvm(22130):   | sysTid=22130 nice=0 sched=0/0 cgrp=default handle=1074639188
I/dalvikvm(22130):   | state=R schedstat=( 0 0 0 ) utm=12 stm=6 core=0
I/dalvikvm(22130):   #00  pc 000012f6  /system/lib/libcorkscrew.so (unwind_backtrace_thread+29)
I/dalvikvm(22130):   #01  pc 0005fe46  /system/lib/libdvm.so (dvmDumpNativeStack(DebugOutputTarget const*, int)+33)
I/dalvikvm(22130):   #02  pc 00053e48  /system/lib/libdvm.so (dvmDumpThreadEx(DebugOutputTarget const*, Thread*, bool)+395)
I/dalvikvm(22130):   #03  pc 00053eb6  /system/lib/libdvm.so (dvmDumpThread(Thread*, bool)+25)
I/dalvikvm(22130):   #04  pc 00048878  /system/lib/libdvm.so
I/dalvikvm(22130):   #05  pc 00001fa8  /system/lib/libnativehelper.so (jniRegisterNativeMethods+39)
I/dalvikvm(22130):   #06  pc 0004dfa6  /system/lib/libandroid_runtime.so
I/dalvikvm(22130):   #07  pc 0004e294  /system/lib/libandroid_runtime.so (android::AndroidRuntime::startReg(_JNIEnv*)+23)
I/dalvikvm(22130):   #08  pc 0004ece4  /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, char const*)+183)
I/dalvikvm(22130):   #09  pc 000010be  /system/bin/app_process
I/dalvikvm(22130):   #10  pc 0000e3ac  /system/lib/libc.so (__libc_init+47)
I/dalvikvm(22130):   at dalvik.system.NativeStart.main(Native Method)
I/dalvikvm(22130):   at dalvik.system.NativeStart.main(Native Method)
I/dalvikvm(22130): 
E/dalvikvm(22130): VM aborting
F/libc    (22130): Fatal signal 6 (SIGABRT) at 0x00005672 (code=-6), thread 22130 (app_process)
I/DEBUG   (  186): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   (  186): Build fingerprint: 'Xiaomi/pisces/pisces:4.4.4/KTU84P/V6.5.1.0.KXCCNCD:user/release-keys'
I/DEBUG   (  186): Revision: '0'
I/DEBUG   (  186): pid: 22130, tid: 22130, name: app_process  >>> app_process <<<
I/DEBUG   (  186): signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
W/NativeCrashListener(  962): Couldn't find ProcessRecord for pid 22130
I/DEBUG   (  186):     r0 00000000  r1 00005672  r2 00000006  r3 00000000
I/DEBUG   (  186): AM write failure (32 / Broken pipe)
I/DEBUG   (  186):     r4 00000006  r5 00000016  r6 00005672  r7 0000010c
I/DEBUG   (  186):     r8 00000003  r9 bedd6a3a  sl bedd6a4a  fp bedd6a2e
I/DEBUG   (  186):     ip 4026d5b8  sp bedd64b8  lr 40103031  pc 40111f98  cpsr 000f0010
I/DEBUG   (  186):     d0  74726f6261204d56  d1  0a29646f6874656e
I/DEBUG   (  186):     d2  65747379732f2075  d3  696c2f62696c2f6c
I/DEBUG   (  186):     d4  0000000000000000  d5  0000000000000000
I/DEBUG   (  186):     d6  3f00000000000000  d7  000000000000007f
I/DEBUG   (  186):     d8  0000000000000000  d9  0000000000000000
I/DEBUG   (  186):     d10 0000000000000000  d11 0000000000000000
I/DEBUG   (  186):     d12 0000000000000000  d13 0000000000000000
I/DEBUG   (  186):     d14 0000000000000000  d15 0000000000000000
I/DEBUG   (  186):     d16 ffffffffffffffeb  d17 000000000000000e
I/DEBUG   (  186):     d18 41cc661487800000  d19 0000000000000000
I/DEBUG   (  186):     d20 0000000000000000  d21 0000000000000000
I/DEBUG   (  186):     d22 0000000000000000  d23 0000000000000000
I/DEBUG   (  186):     d24 0000000000000000  d25 0000000000000000
I/DEBUG   (  186):     d26 0000000000000000  d27 0000000000000000
I/DEBUG   (  186):     d28 0000000000000000  d29 0000000000000000
I/DEBUG   (  186):     d30 0000000000000000  d31 0000000000000000
I/DEBUG   (  186):     scr 60000010
I/DEBUG   (  186): 
I/DEBUG   (  186): backtrace:
I/DEBUG   (  186):     #00  pc 00021f98  /system/lib/libc.so (tgkill+12)
I/DEBUG   (  186):     #01  pc 0001302d  /system/lib/libc.so (pthread_kill+48)
I/DEBUG   (  186):     #02  pc 00013241  /system/lib/libc.so (raise+10)
I/DEBUG   (  186):     #03  pc 00011f77  /system/lib/libc.so
I/DEBUG   (  186):     #04  pc 0002184c  /system/lib/libc.so (abort+4)
I/DEBUG   (  186):     #05  pc 00045447  /system/lib/libdvm.so (dvmAbort+78)
I/DEBUG   (  186):     #06  pc 00001fab  /system/lib/libnativehelper.so (jniRegisterNativeMethods+42)
I/DEBUG   (  186):     #07  pc 0004dfa9  /system/lib/libandroid_runtime.so
I/DEBUG   (  186):     #08  pc 0004e295  /system/lib/libandroid_runtime.so (android::AndroidRuntime::startReg(_JNIEnv*)+24)
I/DEBUG   (  186):     #09  pc 0004ece5  /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, char const*)+184)
I/DEBUG   (  186):     #10  pc 000010bf  /system/bin/app_process
I/DEBUG   (  186):     #11  pc 0000e3af  /system/lib/libc.so (__libc_init+50)
I/DEBUG   (  186):     #12  pc 00000dac  /system/bin/app_process
I/DEBUG   (  186): 
I/DEBUG   (  186): stack:

@upwell
I'll try to look at this issue, but I need to flush old MIUI with android 4.* to my Mi2s, so it'll take a while.
Seems, that something is wrong with boot classpath.

@xSAVIKx
Thanks for your effort. I googled around to find the possible solution.
It seems /system/bin/am script is using the same way, and it works fine. Is it possible that MyInjectEventApp.jar is not compatible with MI3?
One clue is that /system/framework/am.jar is compiled with java 1.6, while MyInjectEventApp.jar is compiled with java 1.7. Not sure, just a guess.
I'm now working on compiling MyInjectEventApp.jar with jdk 1.6. I'll update the result here once I have it done.

@upwell
It maybe problem, but as far as I remember I don't use any features of java 1.7, so it should be easy to compile client using jdk 1.6.
Be aware that you'll need dx and aapt in your PATH.

@xSAVIKx
I compiled client using jdk 1.6, still no help.
As I googled around, I found another command which can execute the jar file successfully on android shell:

/system/bin/dalvikvm -classpath /data/local/tmp/MyInjectEventApp.jar com.github.xsavikx.android.screencast.client.Main 8776

Have no idea why app_process is not working.

@upwell
It's great that you've found another solution.
Did you change sources and recompile InjectApp ?
If so - you can do pull request or I will do it later by myself as a quick fix. I think I'll provide both methods, so if one doesn't work, another will be tried.

@xSAVIKx
I submitted a pull request to include this quick fix. Please help review.:)

@upwell
Hi. I've merged your pull request, but after that I've deleted your receiver due to update in ddmlib - there are new exceptions, so I can handle situation when command don't run successfully.
I also created new pre-release, so you can try to use it now.
Thanks for your assistance.