Preferences menu fixed, more things
This commit is contained in:
parent
07d442b9fc
commit
8eee54e5dd
8
.classpath
Normal file
8
.classpath
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="src" path="gen"/>
|
||||||
|
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||||
|
<classpathentry kind="lib" path="libs/mobclix.jar"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
3
.directory
Normal file
3
.directory
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[Dolphin]
|
||||||
|
ShowPreview=true
|
||||||
|
Timestamp=2010,9,24,20,26,16
|
@ -1,9 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:versionName="0.89" android:versionCode="40" package="org.onaips.vnc_donate">
|
package="org.onaips.vnc_donate" android:versionName="v0.91" android:versionCode="42">
|
||||||
<uses-sdk android:minSdkVersion="3" />
|
<uses-sdk android:minSdkVersion="3" />
|
||||||
<application android:debuggable="false" android:icon="@drawable/icon"
|
<application android:debuggable="false" android:icon="@drawable/icon"
|
||||||
android:label="droid VNC server">
|
android:label="droid VNC server" android:name="MainApplication">
|
||||||
<activity android:name=".MainActivity" android:label="@string/app_name"
|
<activity android:name=".MainActivity" android:label="@string/app_name"
|
||||||
android:icon="@drawable/icon" android:launchMode="singleInstance"
|
android:icon="@drawable/icon" android:launchMode="singleInstance"
|
||||||
android:screenOrientation="portrait">
|
android:screenOrientation="portrait">
|
||||||
|
BIN
bin/avnc.apk
BIN
bin/avnc.apk
Binary file not shown.
Binary file not shown.
BIN
bin/avnc_signed_free.apk
Normal file
BIN
bin/avnc_signed_free.apk
Normal file
Binary file not shown.
BIN
bin/classes.dex
BIN
bin/classes.dex
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bin/org/onaips/vnc_donate/MainApplication.class
Normal file
BIN
bin/org/onaips/vnc_donate/MainApplication.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,197 +0,0 @@
|
|||||||
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
|
||||||
*
|
|
||||||
* This class was automatically generated by the
|
|
||||||
* aapt tool from the resource data it found. It
|
|
||||||
* should not be modified by hand.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.onaips.vnc;
|
|
||||||
|
|
||||||
public final class R {
|
|
||||||
public static final class array {
|
|
||||||
public static final int rotation_values=0x7f070000;
|
|
||||||
public static final int scale_strings=0x7f070002;
|
|
||||||
public static final int scale_values=0x7f070001;
|
|
||||||
}
|
|
||||||
public static final class attr {
|
|
||||||
/** <p>Must be a color value, in the form of "<code>#<i>rgb</i></code>", "<code>#<i>argb</i></code>",
|
|
||||||
"<code>#<i>rrggbb</i></code>", or "<code>#<i>aarrggbb</i></code>".
|
|
||||||
<p>This may also be a reference to a resource (in the form
|
|
||||||
"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
|
|
||||||
theme attribute (in the form
|
|
||||||
"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
|
|
||||||
containing a value of this type.
|
|
||||||
*/
|
|
||||||
public static final int backgroundColor=0x7f010000;
|
|
||||||
/** <p>Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
|
|
||||||
<p>This may also be a reference to a resource (in the form
|
|
||||||
"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
|
|
||||||
theme attribute (in the form
|
|
||||||
"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
|
|
||||||
containing a value of this type.
|
|
||||||
*/
|
|
||||||
public static final int keywords=0x7f010003;
|
|
||||||
/** <p>Must be a color value, in the form of "<code>#<i>rgb</i></code>", "<code>#<i>argb</i></code>",
|
|
||||||
"<code>#<i>rrggbb</i></code>", or "<code>#<i>aarrggbb</i></code>".
|
|
||||||
<p>This may also be a reference to a resource (in the form
|
|
||||||
"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
|
|
||||||
theme attribute (in the form
|
|
||||||
"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
|
|
||||||
containing a value of this type.
|
|
||||||
*/
|
|
||||||
public static final int primaryTextColor=0x7f010001;
|
|
||||||
/** <p>Must be an integer value, such as "<code>100</code>".
|
|
||||||
<p>This may also be a reference to a resource (in the form
|
|
||||||
"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
|
|
||||||
theme attribute (in the form
|
|
||||||
"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
|
|
||||||
containing a value of this type.
|
|
||||||
*/
|
|
||||||
public static final int refreshInterval=0x7f010004;
|
|
||||||
/** <p>Must be a color value, in the form of "<code>#<i>rgb</i></code>", "<code>#<i>argb</i></code>",
|
|
||||||
"<code>#<i>rrggbb</i></code>", or "<code>#<i>aarrggbb</i></code>".
|
|
||||||
<p>This may also be a reference to a resource (in the form
|
|
||||||
"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
|
|
||||||
theme attribute (in the form
|
|
||||||
"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
|
|
||||||
containing a value of this type.
|
|
||||||
*/
|
|
||||||
public static final int secondaryTextColor=0x7f010002;
|
|
||||||
}
|
|
||||||
public static final class drawable {
|
|
||||||
public static final int bg=0x7f020000;
|
|
||||||
public static final int btnstart=0x7f020001;
|
|
||||||
public static final int btnstart_normal=0x7f020002;
|
|
||||||
public static final int btnstart_pressed=0x7f020003;
|
|
||||||
public static final int btnstop=0x7f020004;
|
|
||||||
public static final int btnstop_normal=0x7f020005;
|
|
||||||
public static final int btnstop_pressed=0x7f020006;
|
|
||||||
public static final int droidvnclogo=0x7f020007;
|
|
||||||
public static final int icon=0x7f020008;
|
|
||||||
}
|
|
||||||
public static final class id {
|
|
||||||
public static final int Button01=0x7f090000;
|
|
||||||
public static final int Button02=0x7f090001;
|
|
||||||
public static final int TextView01=0x7f090002;
|
|
||||||
public static final int TextView02=0x7f090004;
|
|
||||||
public static final int banner_adview=0x7f090005;
|
|
||||||
public static final int preferences=0x7f090006;
|
|
||||||
public static final int stateLabel=0x7f090003;
|
|
||||||
}
|
|
||||||
public static final class layout {
|
|
||||||
public static final int main=0x7f030000;
|
|
||||||
}
|
|
||||||
public static final class menu {
|
|
||||||
public static final int menu=0x7f080000;
|
|
||||||
}
|
|
||||||
public static final class raw {
|
|
||||||
public static final int androidvncserver=0x7f050000;
|
|
||||||
public static final int indexvnc=0x7f050001;
|
|
||||||
public static final int vncviewer=0x7f050002;
|
|
||||||
}
|
|
||||||
public static final class string {
|
|
||||||
public static final int app_name=0x7f060000;
|
|
||||||
public static final int device_info_fmt=0x7f060002;
|
|
||||||
public static final int password=0x7f060001;
|
|
||||||
}
|
|
||||||
public static final class xml {
|
|
||||||
public static final int preferences=0x7f040000;
|
|
||||||
}
|
|
||||||
public static final class styleable {
|
|
||||||
/** Attributes that can be used with a com_admob_android_ads_AdView.
|
|
||||||
<p>Includes the following attributes:</p>
|
|
||||||
<table>
|
|
||||||
<colgroup align="left" />
|
|
||||||
<colgroup align="left" />
|
|
||||||
<tr><th>Attribute</th><th>Description</th></tr>
|
|
||||||
<tr><td><code>{@link #com_admob_android_ads_AdView_backgroundColor org.onaips.vnc:backgroundColor}</code></td><td></td></tr>
|
|
||||||
<tr><td><code>{@link #com_admob_android_ads_AdView_keywords org.onaips.vnc:keywords}</code></td><td></td></tr>
|
|
||||||
<tr><td><code>{@link #com_admob_android_ads_AdView_primaryTextColor org.onaips.vnc:primaryTextColor}</code></td><td></td></tr>
|
|
||||||
<tr><td><code>{@link #com_admob_android_ads_AdView_refreshInterval org.onaips.vnc:refreshInterval}</code></td><td></td></tr>
|
|
||||||
<tr><td><code>{@link #com_admob_android_ads_AdView_secondaryTextColor org.onaips.vnc:secondaryTextColor}</code></td><td></td></tr>
|
|
||||||
</table>
|
|
||||||
@see #com_admob_android_ads_AdView_backgroundColor
|
|
||||||
@see #com_admob_android_ads_AdView_keywords
|
|
||||||
@see #com_admob_android_ads_AdView_primaryTextColor
|
|
||||||
@see #com_admob_android_ads_AdView_refreshInterval
|
|
||||||
@see #com_admob_android_ads_AdView_secondaryTextColor
|
|
||||||
*/
|
|
||||||
public static final int[] com_admob_android_ads_AdView = {
|
|
||||||
0x7f010000, 0x7f010001, 0x7f010002, 0x7f010003,
|
|
||||||
0x7f010004
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
<p>This symbol is the offset where the {@link org.onaips.vnc.R.attr#backgroundColor}
|
|
||||||
attribute's value can be found in the {@link #com_admob_android_ads_AdView} array.
|
|
||||||
|
|
||||||
|
|
||||||
<p>Must be a color value, in the form of "<code>#<i>rgb</i></code>", "<code>#<i>argb</i></code>",
|
|
||||||
"<code>#<i>rrggbb</i></code>", or "<code>#<i>aarrggbb</i></code>".
|
|
||||||
<p>This may also be a reference to a resource (in the form
|
|
||||||
"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
|
|
||||||
theme attribute (in the form
|
|
||||||
"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
|
|
||||||
containing a value of this type.
|
|
||||||
@attr name android:backgroundColor
|
|
||||||
*/
|
|
||||||
public static final int com_admob_android_ads_AdView_backgroundColor = 0;
|
|
||||||
/**
|
|
||||||
<p>This symbol is the offset where the {@link org.onaips.vnc.R.attr#keywords}
|
|
||||||
attribute's value can be found in the {@link #com_admob_android_ads_AdView} array.
|
|
||||||
|
|
||||||
|
|
||||||
<p>Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
|
|
||||||
<p>This may also be a reference to a resource (in the form
|
|
||||||
"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
|
|
||||||
theme attribute (in the form
|
|
||||||
"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
|
|
||||||
containing a value of this type.
|
|
||||||
@attr name android:keywords
|
|
||||||
*/
|
|
||||||
public static final int com_admob_android_ads_AdView_keywords = 3;
|
|
||||||
/**
|
|
||||||
<p>This symbol is the offset where the {@link org.onaips.vnc.R.attr#primaryTextColor}
|
|
||||||
attribute's value can be found in the {@link #com_admob_android_ads_AdView} array.
|
|
||||||
|
|
||||||
|
|
||||||
<p>Must be a color value, in the form of "<code>#<i>rgb</i></code>", "<code>#<i>argb</i></code>",
|
|
||||||
"<code>#<i>rrggbb</i></code>", or "<code>#<i>aarrggbb</i></code>".
|
|
||||||
<p>This may also be a reference to a resource (in the form
|
|
||||||
"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
|
|
||||||
theme attribute (in the form
|
|
||||||
"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
|
|
||||||
containing a value of this type.
|
|
||||||
@attr name android:primaryTextColor
|
|
||||||
*/
|
|
||||||
public static final int com_admob_android_ads_AdView_primaryTextColor = 1;
|
|
||||||
/**
|
|
||||||
<p>This symbol is the offset where the {@link org.onaips.vnc.R.attr#refreshInterval}
|
|
||||||
attribute's value can be found in the {@link #com_admob_android_ads_AdView} array.
|
|
||||||
|
|
||||||
|
|
||||||
<p>Must be an integer value, such as "<code>100</code>".
|
|
||||||
<p>This may also be a reference to a resource (in the form
|
|
||||||
"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
|
|
||||||
theme attribute (in the form
|
|
||||||
"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
|
|
||||||
containing a value of this type.
|
|
||||||
@attr name android:refreshInterval
|
|
||||||
*/
|
|
||||||
public static final int com_admob_android_ads_AdView_refreshInterval = 4;
|
|
||||||
/**
|
|
||||||
<p>This symbol is the offset where the {@link org.onaips.vnc.R.attr#secondaryTextColor}
|
|
||||||
attribute's value can be found in the {@link #com_admob_android_ads_AdView} array.
|
|
||||||
|
|
||||||
|
|
||||||
<p>Must be a color value, in the form of "<code>#<i>rgb</i></code>", "<code>#<i>argb</i></code>",
|
|
||||||
"<code>#<i>rrggbb</i></code>", or "<code>#<i>aarrggbb</i></code>".
|
|
||||||
<p>This may also be a reference to a resource (in the form
|
|
||||||
"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
|
|
||||||
theme attribute (in the form
|
|
||||||
"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
|
|
||||||
containing a value of this type.
|
|
||||||
@attr name android:secondaryTextColor
|
|
||||||
*/
|
|
||||||
public static final int com_admob_android_ads_AdView_secondaryTextColor = 2;
|
|
||||||
};
|
|
||||||
}
|
|
@ -9,11 +9,13 @@ package org.onaips.vnc_donate;
|
|||||||
|
|
||||||
public final class R {
|
public final class R {
|
||||||
public static final class array {
|
public static final class array {
|
||||||
|
public static final int rotation_strings=0x7f070001;
|
||||||
public static final int rotation_values=0x7f070000;
|
public static final int rotation_values=0x7f070000;
|
||||||
public static final int scale_strings=0x7f070002;
|
public static final int scale_strings=0x7f070003;
|
||||||
public static final int scale_values=0x7f070001;
|
public static final int scale_values=0x7f070002;
|
||||||
public static final int sleep_strings=0x7f070003;
|
public static final int sleep_strings=0x7f070004;
|
||||||
public static final int startonboot_values=0x7f070004;
|
public static final int startonboot_strings=0x7f070005;
|
||||||
|
public static final int startonboot_values=0x7f070006;
|
||||||
}
|
}
|
||||||
public static final class attr {
|
public static final class attr {
|
||||||
/** <p>Must be a color value, in the form of "<code>#<i>rgb</i></code>", "<code>#<i>argb</i></code>",
|
/** <p>Must be a color value, in the form of "<code>#<i>rgb</i></code>", "<code>#<i>argb</i></code>",
|
||||||
@ -87,13 +89,13 @@ containing a value of this type.
|
|||||||
}
|
}
|
||||||
public static final class raw {
|
public static final class raw {
|
||||||
public static final int androidvncserver=0x7f050000;
|
public static final int androidvncserver=0x7f050000;
|
||||||
public static final int indexvnc=0x7f050001;
|
public static final int busybox=0x7f050001;
|
||||||
public static final int vncviewer=0x7f050002;
|
public static final int indexvnc=0x7f050002;
|
||||||
|
public static final int vncviewer=0x7f050003;
|
||||||
}
|
}
|
||||||
public static final class string {
|
public static final class string {
|
||||||
public static final int app_name=0x7f060000;
|
public static final int app_name=0x7f060000;
|
||||||
public static final int device_info_fmt=0x7f060001;
|
public static final int device_info_fmt=0x7f060001;
|
||||||
public static final int package_name=0x7f060002;
|
|
||||||
}
|
}
|
||||||
public static final class xml {
|
public static final class xml {
|
||||||
public static final int preferences=0x7f040000;
|
public static final int preferences=0x7f040000;
|
||||||
|
@ -143,7 +143,7 @@ static void init_fb(void)
|
|||||||
|
|
||||||
size_t fbSize = roundUpToPageSize(fscrinfo.line_length * scrinfo.yres_virtual);
|
size_t fbSize = roundUpToPageSize(fscrinfo.line_length * scrinfo.yres_virtual);
|
||||||
|
|
||||||
fbmmap = mmap(NULL, fbSize , PROT_READ|PROT_WRITE , MAP_SHARED , fbfd, 0);
|
fbmmap = mmap(NULL, fbSize , PROT_READ|PROT_WRITE , MAP_SHARED , fbfd, 0);
|
||||||
|
|
||||||
|
|
||||||
if (fbmmap == MAP_FAILED)
|
if (fbmmap == MAP_FAILED)
|
||||||
@ -238,10 +238,11 @@ static void init_fb_server(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DONATE_VERSION
|
#ifdef DONATE_VERSION
|
||||||
vncscr->httpDir="/data/data/org.onaips.vnc_donate/";
|
vncscr->httpDir="/data/data/org.onaips.vnc_donate/files/";
|
||||||
#else
|
#else
|
||||||
vncscr->httpDir="/data/data/org.onaips.vnc/";
|
vncscr->httpDir="/data/data/org.onaips.vnc/files/";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vncscr->serverFormat.redShift=scrinfo.red.offset;
|
vncscr->serverFormat.redShift=scrinfo.red.offset;
|
||||||
vncscr->serverFormat.greenShift=scrinfo.green.offset;
|
vncscr->serverFormat.greenShift=scrinfo.green.offset;
|
||||||
vncscr->serverFormat.blueShift=scrinfo.blue.offset;
|
vncscr->serverFormat.blueShift=scrinfo.blue.offset;
|
||||||
@ -315,7 +316,7 @@ static void keyevent(rfbBool down, rfbKeySym key, rfbClientPtr cl)
|
|||||||
else
|
else
|
||||||
;//ret=suinput_release(inputfd,code);
|
;//ret=suinput_release(inputfd,code);
|
||||||
|
|
||||||
//__android_log_print(ANDROID_LOG_INFO,"VNC","injectKey (%d, %d) ret=%d\n", code , down,ret);
|
__android_log_print(ANDROID_LOG_INFO,"VNC","injectKey (%d, %d) ret=%d\n", code , down,ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -738,25 +739,8 @@ int main(int argc, char **argv)
|
|||||||
__android_log_print(ANDROID_LOG_INFO,"VNC"," bpp: %d\n", (int)scrinfo.bits_per_pixel);
|
__android_log_print(ANDROID_LOG_INFO,"VNC"," bpp: %d\n", (int)scrinfo.bits_per_pixel);
|
||||||
__android_log_print(ANDROID_LOG_INFO,"VNC"," port: %d\n", (int)VNC_PORT);
|
__android_log_print(ANDROID_LOG_INFO,"VNC"," port: %d\n", (int)VNC_PORT);
|
||||||
init_fb_server(argc, argv);
|
init_fb_server(argc, argv);
|
||||||
/*
|
|
||||||
rfbRunEventLoop(vncscr,-1,TRUE);
|
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
|
||||||
while (vncscr->clientHead == NULL)
|
|
||||||
sleep(1);
|
|
||||||
|
|
||||||
if (standby>60)
|
|
||||||
sleep(2);
|
|
||||||
else if (standby>30)
|
|
||||||
sleep(1);
|
|
||||||
else
|
|
||||||
usleep(100000);
|
|
||||||
|
|
||||||
update_screen();
|
|
||||||
}*/
|
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
{
|
||||||
while (vncscr->clientHead == NULL)
|
while (vncscr->clientHead == NULL)
|
||||||
rfbProcessEvents(vncscr, 100000);
|
rfbProcessEvents(vncscr, 100000);
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
char VNC_PASSWORD[256] = "";
|
char VNC_PASSWORD[256] = "";
|
||||||
char framebuffer_device[256] = "/dev/graphics/fb0";
|
char framebuffer_device[256] = "/dev/graphics/fb0";
|
||||||
char VNC_PORT[10]="5901";
|
int VNC_PORT=5901;
|
||||||
|
|
||||||
static struct fb_var_screeninfo scrinfo;
|
static struct fb_var_screeninfo scrinfo;
|
||||||
static struct fb_fix_screeninfo fscrinfo;
|
static struct fb_fix_screeninfo fscrinfo;
|
||||||
@ -143,7 +143,7 @@ static void init_fb(void)
|
|||||||
|
|
||||||
size_t fbSize = roundUpToPageSize(fscrinfo.line_length * scrinfo.yres_virtual);
|
size_t fbSize = roundUpToPageSize(fscrinfo.line_length * scrinfo.yres_virtual);
|
||||||
|
|
||||||
fbmmap = mmap(NULL, fbSize , PROT_READ|PROT_WRITE , MAP_SHARED , fbfd, 0);
|
fbmmap = mmap(NULL, fbSize , PROT_READ|PROT_WRITE , MAP_SHARED , fbfd, 0);
|
||||||
|
|
||||||
|
|
||||||
if (fbmmap == MAP_FAILED)
|
if (fbmmap == MAP_FAILED)
|
||||||
@ -238,9 +238,9 @@ static void init_fb_server(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DONATE_VERSION
|
#ifdef DONATE_VERSION
|
||||||
vncscr->httpDir="/data/data/org.onaips.vnc_donate/";
|
vncscr->httpDir="/data/data/org.onaips.vnc_donate/files/";
|
||||||
#else
|
#else
|
||||||
vncscr->httpDir="/data/data/org.onaips.vnc/";
|
vncscr->httpDir="/data/data/org.onaips.vnc/files/";
|
||||||
#endif
|
#endif
|
||||||
vncscr->serverFormat.redShift=scrinfo.red.offset;
|
vncscr->serverFormat.redShift=scrinfo.red.offset;
|
||||||
vncscr->serverFormat.greenShift=scrinfo.green.offset;
|
vncscr->serverFormat.greenShift=scrinfo.green.offset;
|
||||||
@ -315,7 +315,7 @@ static void keyevent(rfbBool down, rfbKeySym key, rfbClientPtr cl)
|
|||||||
else
|
else
|
||||||
;//ret=suinput_release(inputfd,code);
|
;//ret=suinput_release(inputfd,code);
|
||||||
|
|
||||||
//__android_log_print(ANDROID_LOG_INFO,"VNC","injectKey (%d, %d) ret=%d\n", code , down,ret);
|
__android_log_print(ANDROID_LOG_INFO,"VNC","injectKey (%d, %d) ret=%d\n", code , down,ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -738,25 +738,8 @@ int main(int argc, char **argv)
|
|||||||
__android_log_print(ANDROID_LOG_INFO,"VNC"," bpp: %d\n", (int)scrinfo.bits_per_pixel);
|
__android_log_print(ANDROID_LOG_INFO,"VNC"," bpp: %d\n", (int)scrinfo.bits_per_pixel);
|
||||||
__android_log_print(ANDROID_LOG_INFO,"VNC"," port: %d\n", (int)VNC_PORT);
|
__android_log_print(ANDROID_LOG_INFO,"VNC"," port: %d\n", (int)VNC_PORT);
|
||||||
init_fb_server(argc, argv);
|
init_fb_server(argc, argv);
|
||||||
/*
|
|
||||||
rfbRunEventLoop(vncscr,-1,TRUE);
|
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
|
||||||
while (vncscr->clientHead == NULL)
|
|
||||||
sleep(1);
|
|
||||||
|
|
||||||
if (standby>60)
|
|
||||||
sleep(2);
|
|
||||||
else if (standby>30)
|
|
||||||
sleep(1);
|
|
||||||
else
|
|
||||||
usleep(100000);
|
|
||||||
|
|
||||||
update_screen();
|
|
||||||
}*/
|
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
{
|
||||||
while (vncscr->clientHead == NULL)
|
while (vncscr->clientHead == NULL)
|
||||||
rfbProcessEvents(vncscr, 100000);
|
rfbProcessEvents(vncscr, 100000);
|
||||||
|
@ -209,12 +209,12 @@ int suinput_set_pointer(int uinput_fd, int32_t x, int32_t y)
|
|||||||
|
|
||||||
int suinput_press(int uinput_fd, uint16_t code)
|
int suinput_press(int uinput_fd, uint16_t code)
|
||||||
{
|
{
|
||||||
return suinput_write_syn(uinput_fd, EV_KEY, code, 1);
|
return suinput_write(uinput_fd, EV_KEY, code, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int suinput_release(int uinput_fd, uint16_t code)
|
int suinput_release(int uinput_fd, uint16_t code)
|
||||||
{
|
{
|
||||||
return suinput_write_syn(uinput_fd, EV_KEY, code, 0);
|
return suinput_write(uinput_fd, EV_KEY, code, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int suinput_click(int uinput_fd, uint16_t code)
|
int suinput_click(int uinput_fd, uint16_t code)
|
||||||
|
225
jni/vnc/suinput.c~
Normal file
225
jni/vnc/suinput.c~
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
/*
|
||||||
|
suinput - Simple C-API to the Linux uinput-system.
|
||||||
|
Copyright (C) 2009 Tuomas Räsänen <tuos@codegrove.org>
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 3 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <linux/uinput.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "suinput.h"
|
||||||
|
|
||||||
|
char* UINPUT_FILEPATHS[] = {
|
||||||
|
"/android/dev/uinput",
|
||||||
|
"/dev/uinput",
|
||||||
|
"/dev/input/uinput",
|
||||||
|
"/dev/misc/uinput",
|
||||||
|
};
|
||||||
|
#define UINPUT_FILEPATHS_COUNT (sizeof(UINPUT_FILEPATHS) / sizeof(char*))
|
||||||
|
|
||||||
|
int suinput_write(int uinput_fd,
|
||||||
|
uint16_t type, uint16_t code, int32_t value)
|
||||||
|
{
|
||||||
|
struct input_event event;
|
||||||
|
memset(&event, 0, sizeof(event));
|
||||||
|
gettimeofday(&event.time, 0); /* This should not be able to fail ever.. */
|
||||||
|
event.type = type;
|
||||||
|
event.code = code;
|
||||||
|
event.value = value;
|
||||||
|
if (write(uinput_fd, &event, sizeof(event)) != sizeof(event))
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int suinput_write_syn(int uinput_fd,
|
||||||
|
uint16_t type, uint16_t code, int32_t value)
|
||||||
|
{
|
||||||
|
if (suinput_write(uinput_fd, type, code, value))
|
||||||
|
return -1;
|
||||||
|
return suinput_write(uinput_fd, EV_SYN, SYN_REPORT, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int suinput_open(const char* device_name, const struct input_id* id)
|
||||||
|
{
|
||||||
|
int original_errno = 0;
|
||||||
|
int uinput_fd = -1;
|
||||||
|
struct uinput_user_dev user_dev;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < UINPUT_FILEPATHS_COUNT; ++i) {
|
||||||
|
uinput_fd = open(UINPUT_FILEPATHS[i], O_WRONLY | O_NONBLOCK);
|
||||||
|
if (uinput_fd != -1)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uinput_fd == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set device to handle following types of events: */
|
||||||
|
|
||||||
|
/* Key and button events */
|
||||||
|
if (ioctl(uinput_fd, UI_SET_EVBIT, EV_KEY) == -1)
|
||||||
|
goto err;
|
||||||
|
//
|
||||||
|
// /* Key and button repetition events */
|
||||||
|
if (ioctl(uinput_fd, UI_SET_EVBIT, EV_REP) == -1)
|
||||||
|
goto err;
|
||||||
|
//
|
||||||
|
// /* Relative pointer motions */
|
||||||
|
// if (ioctl(uinput_fd, UI_SET_EVBIT, EV_REL) == -1)
|
||||||
|
// goto err;
|
||||||
|
|
||||||
|
/* Absolute pointer motions */
|
||||||
|
|
||||||
|
if (ioctl(uinput_fd, UI_SET_EVBIT, EV_ABS) == -1)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
/* Synchronization events, this is probably set implicitely too. */
|
||||||
|
if (ioctl(uinput_fd, UI_SET_EVBIT, EV_SYN) == -1)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Configure device to handle relative x and y axis. */
|
||||||
|
// if (ioctl(uinput_fd, UI_SET_RELBIT, REL_X) == -1)
|
||||||
|
// goto err;
|
||||||
|
// if (ioctl(uinput_fd, UI_SET_RELBIT, REL_Y) == -1)
|
||||||
|
// goto err;
|
||||||
|
|
||||||
|
/* Configure device to handle absolute x and y axis. */
|
||||||
|
if (ioctl(uinput_fd, UI_SET_ABSBIT, ABS_X) == -1)
|
||||||
|
goto err;
|
||||||
|
if (ioctl(uinput_fd, UI_SET_ABSBIT, ABS_Y) == -1)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Configure device to handle all keys, see linux/input.h. */
|
||||||
|
for (i = 0; i < KEY_MAX; i++) {
|
||||||
|
if (ioctl(uinput_fd, UI_SET_KEYBIT, i) == -1)
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set device-specific information. */
|
||||||
|
memset(&user_dev, 0, sizeof(user_dev));
|
||||||
|
strncpy(user_dev.name, device_name, UINPUT_MAX_NAME_SIZE);
|
||||||
|
user_dev.id.bustype = id->bustype;
|
||||||
|
user_dev.id.vendor = id->vendor;
|
||||||
|
user_dev.id.product = id->product;
|
||||||
|
user_dev.id.version = id->version;
|
||||||
|
|
||||||
|
//minor tweak to support ABSolute events
|
||||||
|
user_dev.absmin[ABS_X] = -2047;
|
||||||
|
user_dev.absmax[ABS_X] = 2048;
|
||||||
|
user_dev.absfuzz[ABS_X] = 0;
|
||||||
|
user_dev.absflat[ABS_X] = 0;
|
||||||
|
|
||||||
|
user_dev.absmin[ABS_Y] = -2047;
|
||||||
|
user_dev.absmax[ABS_Y] = 2048;
|
||||||
|
user_dev.absfuzz[ABS_Y] = 0;
|
||||||
|
user_dev.absflat[ABS_Y] = 0;
|
||||||
|
|
||||||
|
if (write(uinput_fd, &user_dev, sizeof(user_dev)) != sizeof(user_dev))
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
|
||||||
|
if (ioctl(uinput_fd, UI_DEV_CREATE) == -1)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
/*
|
||||||
|
The reason for generating a small delay is that creating succesfully
|
||||||
|
an uinput device does not guarantee that the device is ready to process
|
||||||
|
input events. It's probably due the asynchronous nature of the udev.
|
||||||
|
However, my experiments show that the device is not ready to process input
|
||||||
|
events even after a device creation event is received from udev.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//sleep(2);
|
||||||
|
|
||||||
|
return uinput_fd;
|
||||||
|
|
||||||
|
err:
|
||||||
|
|
||||||
|
/*
|
||||||
|
At this point, errno is set for some reason. However, cleanup-actions
|
||||||
|
can also fail and reset errno, therefore we store the original one
|
||||||
|
and reset it before returning.
|
||||||
|
*/
|
||||||
|
original_errno = errno;
|
||||||
|
|
||||||
|
/* Cleanup. */
|
||||||
|
close(uinput_fd); /* Might fail, but we don't care anymore at this point. */
|
||||||
|
|
||||||
|
errno = original_errno;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int suinput_close(int uinput_fd)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Sleep before destroying the device because there still can be some
|
||||||
|
unprocessed events. This is not the right way, but I am still
|
||||||
|
looking for better ways. The question is: how to know whether there
|
||||||
|
are any unprocessed uinput events?
|
||||||
|
*/
|
||||||
|
sleep(2);
|
||||||
|
|
||||||
|
if (ioctl(uinput_fd, UI_DEV_DESTROY) == -1) {
|
||||||
|
close(uinput_fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (close(uinput_fd) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int suinput_move_pointer(int uinput_fd, int32_t x, int32_t y)
|
||||||
|
{
|
||||||
|
if (suinput_write(uinput_fd, EV_REL, REL_X, x))
|
||||||
|
return -1;
|
||||||
|
return suinput_write_syn(uinput_fd, EV_REL, REL_Y, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
int suinput_set_pointer(int uinput_fd, int32_t x, int32_t y)
|
||||||
|
{
|
||||||
|
if (suinput_write(uinput_fd, EV_ABS, ABS_X, x))
|
||||||
|
return -1;
|
||||||
|
return suinput_write_syn(uinput_fd, EV_ABS, ABS_Y, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
int suinput_press(int uinput_fd, uint16_t code)
|
||||||
|
{
|
||||||
|
return suinput_write_syn(uinput_fd, EV_KEY, code, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int suinput_release(int uinput_fd, uint16_t code)
|
||||||
|
{
|
||||||
|
return suinput_write_syn(uinput_fd, EV_KEY, code, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int suinput_click(int uinput_fd, uint16_t code)
|
||||||
|
{
|
||||||
|
if (suinput_press(uinput_fd, code))
|
||||||
|
return -1;
|
||||||
|
return suinput_release(uinput_fd, code);
|
||||||
|
}
|
Binary file not shown.
@ -54,19 +54,10 @@
|
|||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
>
|
>
|
||||||
</TextView>
|
</TextView>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<!--
|
|
||||||
<TextView
|
<!--
|
||||||
android:textSize="15sp"
|
|
||||||
android:text="Click on ad to support project"
|
|
||||||
android:id="@+id/stateLabel"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingTop="20px"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_gravity="bottom"
|
|
||||||
></TextView>
|
|
||||||
|
|
||||||
<com.mobclix.android.sdk.MobclixMMABannerXLAdView
|
<com.mobclix.android.sdk.MobclixMMABannerXLAdView
|
||||||
android:id="@+id/banner_adview"
|
android:id="@+id/banner_adview"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu
|
<menu
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item android:id="@+id/preferences" android:title="Preferences"></item>
|
<item android:id="@+id/preferences" android:title="Settings"></item>
|
||||||
</menu>
|
</menu>
|
||||||
|
Binary file not shown.
BIN
res/raw/busybox
Normal file
BIN
res/raw/busybox
Normal file
Binary file not shown.
@ -1,7 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||||
<string name="app_name">droid VNC server</string>
|
<string name="app_name">droid VNC server</string>
|
||||||
<string-array name="rotation_values"><item>0</item>
|
<string-array name="rotation_values">
|
||||||
|
<item>0</item>
|
||||||
|
<item>90</item>
|
||||||
|
<item>180</item>
|
||||||
|
<item>270</item>
|
||||||
|
</string-array>
|
||||||
|
<string-array name="rotation_strings">
|
||||||
|
<item>0</item>
|
||||||
<item>90</item>
|
<item>90</item>
|
||||||
<item>180</item>
|
<item>180</item>
|
||||||
<item>270</item>
|
<item>270</item>
|
||||||
@ -14,19 +21,23 @@
|
|||||||
<item>20</item>
|
<item>20</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="scale_strings">
|
<string-array name="scale_strings">
|
||||||
<item>150 %</item>
|
<item>150</item>
|
||||||
<item>100 %</item>
|
<item>100</item>
|
||||||
<item>50 %</item>
|
<item>50</item>
|
||||||
<item>30 %</item>
|
<item>30</item>
|
||||||
<item>20 %</item>
|
<item>20</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="sleep_strings">
|
<string-array name="sleep_strings">
|
||||||
<item>On</item>
|
<item>On</item>
|
||||||
<item>Off</item>
|
<item>Off</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="startonboot_values">
|
<string-array name="startonboot_strings">
|
||||||
<item>True</item>
|
<item>True</item>
|
||||||
<item>False</item>
|
<item>False</item>
|
||||||
|
</string-array>
|
||||||
|
<string-array name="startonboot_values">
|
||||||
|
<item>On</item>
|
||||||
|
<item>Off</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string name="device_info_fmt">
|
<string name="device_info_fmt">
|
||||||
droid VNC version: <xliff:g id="application_version">%s</xliff:g>\n
|
droid VNC version: <xliff:g id="application_version">%s</xliff:g>\n
|
||||||
@ -34,6 +45,5 @@ Device model: <xliff:g id="device_model">%s</xliff:g>\n
|
|||||||
Firmware version: <xliff:g id="firmware_revision">%s</xliff:g>\n
|
Firmware version: <xliff:g id="firmware_revision">%s</xliff:g>\n
|
||||||
Kernel version: <xliff:g id="kernel_version">%s</xliff:g>\n
|
Kernel version: <xliff:g id="kernel_version">%s</xliff:g>\n
|
||||||
Build number: <xliff:g id="build_number">%s</xliff:g>\n
|
Build number: <xliff:g id="build_number">%s</xliff:g>\n
|
||||||
</string>
|
</string>
|
||||||
<string name="package_name">org.onaips.vnc</string>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<EditTextPreference android:key="password" android:title="VNC password" android:password="true" android:summary="Protect your VNC connection"></EditTextPreference>
|
<EditTextPreference android:key="password" android:title="VNC password" android:password="true" android:summary="Protect your VNC connection"></EditTextPreference>-->
|
||||||
<ListPreference android:key="rotation" android:title="Rotation" android:entries="@array/rotation_values" android:entryValues="@array/rotation_values" android:summary="Rotate screen if you like"></ListPreference>
|
<ListPreference android:defaultValue="0" android:key="rotation" android:title="Rotation" android:entries="@array/rotation_strings" android:entryValues="@array/rotation_values" android:summary="Rotate screen if you like"></ListPreference>
|
||||||
<ListPreference android:key="scale" android:title="Scale Screen" android:entries="@array/scale_strings" android:entryValues="@array/scale_values" android:summary="Only 50% working for now"></ListPreference>
|
<ListPreference android:defaultValue="100" android:key="scale" android:title="Scale Screen" android:entries="@array/scale_strings" android:entryValues="@array/scale_values" android:summary="Only 100 and 50 working for now"></ListPreference>
|
||||||
<ListPreference android:key="sleep" android:title="Don't let screen turn off" android:entries="@array/sleep_strings" android:entryValues="@array/sleep_strings"></ListPreference>
|
<ListPreference android:defaultValue="Off" android:key="sleep" android:title="Don't let screen turn off" android:entries="@array/sleep_strings" android:entryValues="@array/sleep_strings"></ListPreference>
|
||||||
<EditTextPreference android:key="port" android:title="VNC port" android:summary="Note: It will not show error if cannot bind port"></EditTextPreference>
|
<EditTextPreference android:inputType="number" android:defaultValue="5901" android:key="port" android:title="VNC port" android:summary="Note: It will not show error if cannot bind port"></EditTextPreference>
|
||||||
<ListPreference android:key="startonboot" android:title="Start server on boot" android:entryValues="@array/startonboot_values" android:entries="@array/startonboot_values" android:summary="Warning! Just activate if you have your daemon running fine."></ListPreference>
|
<ListPreference android:defaultValue="Off" android:key="startonboot" android:title="Start server on boot" android:entries="@array/startonboot_strings" android:summary="Warning! Just activate if you have your daemon running fine." android:entryValues="@array/startonboot_values"></ListPreference>
|
||||||
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
@ -1,713 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2009 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.onaips.vnc;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Timer;
|
|
||||||
import java.util.TimerTask;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.ProgressDialog;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.pm.PackageInfo;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.content.pm.ResolveInfo;
|
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.net.DhcpInfo;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.net.wifi.WifiInfo;
|
|
||||||
import android.net.wifi.WifiManager;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.text.Html;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
public class MainActivity extends Activity
|
|
||||||
{
|
|
||||||
private static final int MENU_QUIT = 0;
|
|
||||||
private static final int MENU_HELP = 1;
|
|
||||||
private static final int MENU_ONAIPS = 2;
|
|
||||||
private static final int MENU_SENDLOG = 3;
|
|
||||||
private static final String changelog="-PLEASE REPORT FEEDBACK! (send debug info in menu)<br>- [Add] Server-side screen scaling (change it in preferences - BETA)<br>- [Fix] Half-screen bug<br>New icon<br>Courtesy of Sandro Forbice (@sandroforbice)<br>- [Fix] Double buffering now supported<br>- [Add] Low CPU on idle screen while connected<br>- [Fix] Update while rotated";
|
|
||||||
|
|
||||||
|
|
||||||
SharedPreferences preferences;
|
|
||||||
ProgressDialog dialog=null;
|
|
||||||
AlertDialog startDialog;
|
|
||||||
|
|
||||||
|
|
||||||
/** Called when the activity is first created. */
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState)
|
|
||||||
{
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
setContentView(R.layout.main);
|
|
||||||
|
|
||||||
|
|
||||||
// Initialize preferences
|
|
||||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
|
||||||
|
|
||||||
if (!hasRootPermission())
|
|
||||||
{
|
|
||||||
Log.v("VNC","You don't have root permissions...!!!");
|
|
||||||
showTextOnScreen("You don't have root permissions...Please ROOT your phone first!!!");
|
|
||||||
//System.exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
showInitialScreen();
|
|
||||||
createBinary();
|
|
||||||
|
|
||||||
|
|
||||||
boolean serverRunning=isAndroidServerRunning();
|
|
||||||
|
|
||||||
setStateLabel(serverRunning);
|
|
||||||
TextView t=(TextView)findViewById(R.id.TextView01);
|
|
||||||
|
|
||||||
if (serverRunning)
|
|
||||||
t.setText("Connect to:\n" + getIpAddress()+":5901" + "\nor\nhttp://" + getIpAddress() + ":5801");
|
|
||||||
else
|
|
||||||
t.setText("");
|
|
||||||
|
|
||||||
|
|
||||||
findViewById(R.id.Button01).setOnClickListener(new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View arg0) {
|
|
||||||
Thread t=new Thread(){
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
startServerButtonClicked();
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
t.start();
|
|
||||||
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
for (int i=0;i<5;i++)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!isAndroidServerRunning())
|
|
||||||
Thread.sleep(1000);
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
Log.v("VNC","Button01_click:"+ e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean s=isAndroidServerRunning();
|
|
||||||
if (!s)
|
|
||||||
showTextOnScreen("Couldn't start VNC Server");
|
|
||||||
//setStateLabel(s);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}) ;
|
|
||||||
findViewById(R.id.Button02).setOnClickListener(new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View arg0) {
|
|
||||||
|
|
||||||
Thread t=new Thread(){
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
stopServer();
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
t.start();
|
|
||||||
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
|
|
||||||
|
|
||||||
for (int i=0;i<5;i++)
|
|
||||||
{
|
|
||||||
if (isAndroidServerRunning())
|
|
||||||
Thread.sleep(1000);
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Log.v("VNC","Button02_click:"+ e.getMessage());
|
|
||||||
|
|
||||||
}
|
|
||||||
boolean s=isAndroidServerRunning();
|
|
||||||
if (s)
|
|
||||||
showTextOnScreen("Couldn't Stop VNC Server\nTry hitting F12 on a connected client");
|
|
||||||
//setStateLabel(s);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public String packageVersion()
|
|
||||||
{
|
|
||||||
String version = "";
|
|
||||||
try {
|
|
||||||
PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0);
|
|
||||||
version = pi.versionName;
|
|
||||||
} catch (NameNotFoundException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
Log.v("VNC","onOptionsItemSelected: "+ e.getMessage());
|
|
||||||
};
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean free_version()
|
|
||||||
{
|
|
||||||
return getPackageName().equals("org.onaips.vnc");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showInitialScreen()
|
|
||||||
{
|
|
||||||
// Initialize preferences
|
|
||||||
preferences = PreferenceManager.getDefaultSharedPreferences(this );
|
|
||||||
SharedPreferences.Editor editor = preferences.edit();
|
|
||||||
|
|
||||||
String message="Changelog:<br><br>" + changelog;
|
|
||||||
|
|
||||||
String version=packageVersion();
|
|
||||||
|
|
||||||
if (!free_version())
|
|
||||||
{
|
|
||||||
if (version.equals(preferences.getString("version", "")))
|
|
||||||
return;
|
|
||||||
editor.putString("version", version);
|
|
||||||
editor.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
startDialog = new AlertDialog.Builder(this).create();
|
|
||||||
startDialog.setTitle("droid VNC Server " + version);
|
|
||||||
startDialog.setMessage(Html.fromHtml(message));
|
|
||||||
startDialog.setIcon(R.drawable.icon);
|
|
||||||
|
|
||||||
if (free_version())
|
|
||||||
{
|
|
||||||
startDialog.setButton(AlertDialog.BUTTON1,"Wait...", new DialogInterface.OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface arg0, int arg1) {
|
|
||||||
startDialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
startDialog.setButton2("Donate Version", new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface arg0, int arg1) {
|
|
||||||
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=org.onaips.vnc_donate"));
|
|
||||||
startActivity(myIntent);
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
startDialog.setCancelable(false);
|
|
||||||
startDialog.show();
|
|
||||||
|
|
||||||
Button b=(Button)startDialog.getButton(AlertDialog.BUTTON1);
|
|
||||||
b.setEnabled(false);
|
|
||||||
|
|
||||||
Timer t1=new Timer();
|
|
||||||
t1.schedule(new TimerTask() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
runOnUiThread(new Runnable(){
|
|
||||||
public void run() {
|
|
||||||
// ((DialogInterface) startDialog).dismiss();
|
|
||||||
Button b=(Button)startDialog.getButton(AlertDialog.BUTTON1);
|
|
||||||
b.setEnabled(true);
|
|
||||||
b.setText("OK");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, (long)10000);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
startDialog.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void writeCommand(OutputStream os, String command) throws Exception
|
|
||||||
{
|
|
||||||
os.write((command + "\n").getBytes("ASCII"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void showTextOnScreen(final String t)
|
|
||||||
{
|
|
||||||
runOnUiThread(new Runnable(){
|
|
||||||
public void run() {
|
|
||||||
Toast.makeText(MainActivity.this,t,Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
MenuInflater inflater = getMenuInflater();
|
|
||||||
inflater.inflate(R.menu.menu, menu);
|
|
||||||
|
|
||||||
menu.add(0,MENU_SENDLOG,0,"Send debug info");
|
|
||||||
menu.add(0,MENU_ONAIPS,0,"About");
|
|
||||||
menu.add(0, MENU_HELP, 0, "Help");
|
|
||||||
menu.add(0, MENU_QUIT, 0, "Close");
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStateLabel(boolean state)
|
|
||||||
{
|
|
||||||
TextView stateLabel=(TextView)findViewById(R.id.stateLabel);
|
|
||||||
stateLabel.setText(state?"Running":"Stopped");
|
|
||||||
stateLabel.setTextColor(state?Color.GREEN:Color.RED);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIpAddress()
|
|
||||||
{
|
|
||||||
WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
|
|
||||||
DhcpInfo dhcpInfo = wifiManager.getDhcpInfo();
|
|
||||||
|
|
||||||
|
|
||||||
return intToIp(dhcpInfo.ipAddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean wifiConnected()
|
|
||||||
{
|
|
||||||
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
|
|
||||||
WifiInfo info = wifi.getConnectionInfo();
|
|
||||||
|
|
||||||
return info.getBSSID()!=null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String intToIp(int i) {
|
|
||||||
return ( i & 0xFF) + "." + ((i >> 8 ) & 0xFF) + "." + ((i >> 16 ) & 0xFF) + "." + ((i >> 24 ) & 0xFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stopServer()
|
|
||||||
{
|
|
||||||
try{
|
|
||||||
Process sh;
|
|
||||||
|
|
||||||
sh = Runtime.getRuntime().exec("su");
|
|
||||||
OutputStream os = sh.getOutputStream();
|
|
||||||
writeCommand(os, "killall androidvncserver");
|
|
||||||
writeCommand(os, "killall -KILL androidvncserver");
|
|
||||||
writeCommand(os, "exit");
|
|
||||||
|
|
||||||
os.flush();
|
|
||||||
os.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
showTextOnScreen("stopServer()" + e.getMessage());
|
|
||||||
Log.v("VNC","stopServer()" + e.getMessage());
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.v("VNC","stopServer()" + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startServerButtonClicked()
|
|
||||||
{
|
|
||||||
if (isAndroidServerRunning())
|
|
||||||
{
|
|
||||||
new AlertDialog.Builder(this)
|
|
||||||
.setTitle("Alert")
|
|
||||||
.setMessage(Html.fromHtml("There is another daemon already running, do you want to kill it?"))
|
|
||||||
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface arg0, int arg1) {
|
|
||||||
stopServer();
|
|
||||||
startServer();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface arg0, int arg1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
startServer();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void startServer()
|
|
||||||
{
|
|
||||||
try{
|
|
||||||
Process sh;
|
|
||||||
|
|
||||||
String password=preferences.getString("password", "");
|
|
||||||
String password_check="";
|
|
||||||
if (!password.equals(""))
|
|
||||||
password_check="-p " + password;
|
|
||||||
|
|
||||||
|
|
||||||
String rotation=preferences.getString("rotation", "0");
|
|
||||||
rotation="-r " + rotation;
|
|
||||||
|
|
||||||
String scaling=preferences.getString("scale", "100");
|
|
||||||
String scaling_string="";
|
|
||||||
if (!scaling.equals("0"))
|
|
||||||
scaling_string="-s " + scaling;
|
|
||||||
|
|
||||||
|
|
||||||
sh = Runtime.getRuntime().exec("su");
|
|
||||||
OutputStream os = sh.getOutputStream();
|
|
||||||
writeCommand(os, "chmod 777 /data/data/"+getPackageName()+"/androidvncserver");
|
|
||||||
writeCommand(os, "/data/data/"+getPackageName()+"/androidvncserver "+ password_check + " " + rotation + " " + scaling_string);
|
|
||||||
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.v("VNC","startServer():" + e.getMessage());
|
|
||||||
showTextOnScreen("startServer():" + e.getMessage());
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.v("VNC","startServer():" + e.getMessage());
|
|
||||||
showTextOnScreen("startServer():" + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void copyBinary(int id,String path)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
InputStream ins = getResources().openRawResource(id);
|
|
||||||
int size = ins.available();
|
|
||||||
|
|
||||||
// Read the entire resource into a local byte buffer.
|
|
||||||
byte[] buffer = new byte[size];
|
|
||||||
ins.read(buffer);
|
|
||||||
ins.close();
|
|
||||||
|
|
||||||
FileOutputStream fos = new FileOutputStream(path);
|
|
||||||
fos.write(buffer);
|
|
||||||
fos.close();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Log.v("VNC","public void createBinary(): " + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
public void createBinary()
|
|
||||||
{
|
|
||||||
copyBinary(R.raw.androidvncserver, "/data/data/" + getPackageName() + "/androidvncserver");
|
|
||||||
copyBinary(R.raw.vncviewer, "/data/data/"+getPackageName()+"/VncViewer.jar");
|
|
||||||
copyBinary(R.raw.indexvnc, "/data/data/"+getPackageName()+"/index.vnc");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showHelp()
|
|
||||||
{
|
|
||||||
new AlertDialog.Builder(this)
|
|
||||||
.setTitle("Help")
|
|
||||||
.setMessage(Html.fromHtml("Mouse Mappings:<br><br>Right Click -> Back<br>Middle Click -> End Call<br>Left Click -> Touch<br><br>Keyboard Mappings<br><br>" +
|
|
||||||
"Home Key -> Home<br>Escape -> Back<br>Page Up ->Menu<br>Left Ctrl -> Search<br>PgDown -> Start Call<br>" +
|
|
||||||
"End Key -> End Call<br>F4 -> Rotate<br>F11 -> Disconnect Server<br>F12 -> Stop Server Daemon"))
|
|
||||||
.setPositiveButton("Fechar", null)
|
|
||||||
.setNegativeButton("Open Website", new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface arg0, int arg1) {
|
|
||||||
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://onaips.blogspot.com"));
|
|
||||||
startActivity(myIntent);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
// This method is called once the menu is selected
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
// We have only one menu option
|
|
||||||
case R.id.preferences:
|
|
||||||
// Launch Preference activity
|
|
||||||
Intent i = new Intent(MainActivity.this, preferences.class);
|
|
||||||
startActivity(i);
|
|
||||||
|
|
||||||
showTextOnScreen("Don't forget to stop/start the server after changes");
|
|
||||||
|
|
||||||
break;
|
|
||||||
case MENU_QUIT:
|
|
||||||
System.exit(1);
|
|
||||||
break;
|
|
||||||
case MENU_HELP:
|
|
||||||
showHelp();
|
|
||||||
break;
|
|
||||||
case MENU_SENDLOG:
|
|
||||||
collectAndSendLog();
|
|
||||||
break;
|
|
||||||
case MENU_ONAIPS:
|
|
||||||
|
|
||||||
new AlertDialog.Builder(this)
|
|
||||||
.setTitle("About")
|
|
||||||
.setMessage(Html.fromHtml("version " + packageVersion() + "<br><br>developed by oNaiPs<br><br>Graphics: Sandro Forbice (@sandroforbice)<br><br>Open-Source Software"))
|
|
||||||
.setPositiveButton("Close", null)
|
|
||||||
.setNegativeButton("Open Website", new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface arg0, int arg1) {
|
|
||||||
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://onaips.blogspot.com"));
|
|
||||||
startActivity(myIntent);
|
|
||||||
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAndroidServerRunning()
|
|
||||||
{
|
|
||||||
String result="";
|
|
||||||
Process sh;
|
|
||||||
try {
|
|
||||||
sh = Runtime.getRuntime().exec("ps");
|
|
||||||
|
|
||||||
|
|
||||||
InputStream is=sh.getInputStream();
|
|
||||||
InputStreamReader isr = new InputStreamReader(is);
|
|
||||||
BufferedReader br = new BufferedReader(isr);
|
|
||||||
String line;
|
|
||||||
|
|
||||||
while ((line = br.readLine()) != null) {
|
|
||||||
result+=line;
|
|
||||||
if (result.indexOf("androidvncserver")>0)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
OutputStream os = sh.getOutputStream();
|
|
||||||
writeCommand(os, "exit");
|
|
||||||
os.flush();
|
|
||||||
os.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.v("VNC"," isAndroidServerRunning():" + e.getMessage());
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.v("VNC"," isAndroidServerRunning():" + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
//Log.v("VNC",result);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean hasRootPermission() {
|
|
||||||
boolean rooted = true;
|
|
||||||
try {
|
|
||||||
File su = new File("/system/bin/su");
|
|
||||||
if (su.exists() == false) {
|
|
||||||
su = new File("/system/xbin/su");
|
|
||||||
if (su.exists() == false) {
|
|
||||||
rooted = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.v("VNC", "Can't obtain root - Here is what I know: "+e.getMessage());
|
|
||||||
rooted = false;
|
|
||||||
}
|
|
||||||
Process sh;
|
|
||||||
try {
|
|
||||||
String result="";
|
|
||||||
|
|
||||||
sh = Runtime.getRuntime().exec("whoami");
|
|
||||||
|
|
||||||
InputStream is=sh.getInputStream();
|
|
||||||
InputStreamReader isr = new InputStreamReader(is);
|
|
||||||
BufferedReader br = new BufferedReader(isr);
|
|
||||||
String line;
|
|
||||||
|
|
||||||
while ((line = br.readLine()) != null) {
|
|
||||||
result+=line;
|
|
||||||
if (result.indexOf("androidvncserver")>0)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Process sh1=Runtime.getRuntime().exec("su");
|
|
||||||
|
|
||||||
//Log.v("aaaaaa","chgrp -R " + result + " /data/data/org.onaips.vnc/");
|
|
||||||
|
|
||||||
OutputStream os = sh1.getOutputStream();
|
|
||||||
|
|
||||||
writeCommand(os, "chown -R " + result + " /data/data/" + getPackageName() + "/");
|
|
||||||
writeCommand(os, "chgrp -R " + result + " /data/data/" + getPackageName() + "/");
|
|
||||||
os.flush();
|
|
||||||
os.close();
|
|
||||||
isr.close();
|
|
||||||
is.close();
|
|
||||||
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return rooted;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final String LOG_COLLECTOR_PACKAGE_NAME = "com.xtralogic.android.logcollector";//$NON-NLS-1$
|
|
||||||
public static final String ACTION_SEND_LOG = "com.xtralogic.logcollector.intent.action.SEND_LOG";//$NON-NLS-1$
|
|
||||||
public static final String EXTRA_SEND_INTENT_ACTION = "com.xtralogic.logcollector.intent.extra.SEND_INTENT_ACTION";//$NON-NLS-1$
|
|
||||||
public static final String EXTRA_DATA = "com.xtralogic.logcollector.intent.extra.DATA";//$NON-NLS-1$
|
|
||||||
public static final String EXTRA_ADDITIONAL_INFO = "com.xtralogic.logcollector.intent.extra.ADDITIONAL_INFO";//$NON-NLS-1$
|
|
||||||
public static final String EXTRA_SHOW_UI = "com.xtralogic.logcollector.intent.extra.SHOW_UI";//$NON-NLS-1$
|
|
||||||
public static final String EXTRA_FILTER_SPECS = "com.xtralogic.logcollector.intent.extra.FILTER_SPECS";//$NON-NLS-1$
|
|
||||||
public static final String EXTRA_FORMAT = "com.xtralogic.logcollector.intent.extra.FORMAT";//$NON-NLS-1$
|
|
||||||
public static final String EXTRA_BUFFER = "com.xtralogic.logcollector.intent.extra.BUFFER";//$NON-NLS-1$
|
|
||||||
|
|
||||||
void collectAndSendLog(){
|
|
||||||
final PackageManager packageManager = getPackageManager();
|
|
||||||
final Intent intent = new Intent(ACTION_SEND_LOG);
|
|
||||||
List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
|
|
||||||
final boolean isInstalled = list.size() > 0;
|
|
||||||
|
|
||||||
if (!isInstalled){
|
|
||||||
new AlertDialog.Builder(this)
|
|
||||||
.setTitle(getString(R.string.app_name))
|
|
||||||
.setIcon(android.R.drawable.ic_dialog_info)
|
|
||||||
.setMessage("Please install Log Collector application to collect the device log and send it to dev.")
|
|
||||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
|
|
||||||
public void onClick(DialogInterface dialog, int whichButton){
|
|
||||||
Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:" + LOG_COLLECTOR_PACKAGE_NAME));
|
|
||||||
marketIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
startActivity(marketIntent);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
new AlertDialog.Builder(this)
|
|
||||||
.setTitle(getString(R.string.app_name))
|
|
||||||
.setIcon(android.R.drawable.ic_dialog_info)
|
|
||||||
.setMessage("Do you want to send debug info to the dev? Please specify what problem is ocurring.\n\nMake sure you started/stopped the server before submitting")
|
|
||||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
|
|
||||||
public void onClick(DialogInterface dialog, int whichButton){
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
intent.putExtra(EXTRA_SEND_INTENT_ACTION, Intent.ACTION_SENDTO);
|
|
||||||
final String email = "onaips@gmail.com";
|
|
||||||
intent.putExtra(EXTRA_DATA, Uri.parse("mailto:" + email));
|
|
||||||
intent.putExtra(EXTRA_ADDITIONAL_INFO,"Problem Description: \n\n\n\n---------DEBUG--------\n" + getString(R.string.device_info_fmt,getVersionNumber(getApplicationContext()),Build.MODEL,Build.VERSION.RELEASE, getFormattedKernelVersion(), Build.DISPLAY));
|
|
||||||
|
|
||||||
intent.putExtra(Intent.EXTRA_SUBJECT, "droid VNC server: Debug Info");
|
|
||||||
|
|
||||||
intent.putExtra(EXTRA_FORMAT, "time");
|
|
||||||
|
|
||||||
//The log can be filtered to contain data relevant only to your app
|
|
||||||
String[] filterSpecs = new String[4];
|
|
||||||
filterSpecs[0] = "VNC:I";
|
|
||||||
filterSpecs[1] = "VNC:D";
|
|
||||||
filterSpecs[2] = "VNC:V";
|
|
||||||
filterSpecs[3] = "*:S";
|
|
||||||
intent.putExtra(EXTRA_FILTER_SPECS, filterSpecs);
|
|
||||||
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getFormattedKernelVersion()
|
|
||||||
{
|
|
||||||
String procVersionStr;
|
|
||||||
|
|
||||||
try {
|
|
||||||
BufferedReader reader = new BufferedReader(new FileReader("/proc/version"), 256);
|
|
||||||
try {
|
|
||||||
procVersionStr = reader.readLine();
|
|
||||||
} finally {
|
|
||||||
reader.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
final String PROC_VERSION_REGEX =
|
|
||||||
"\\w+\\s+" + /* ignore: Linux */
|
|
||||||
"\\w+\\s+" + /* ignore: version */
|
|
||||||
"([^\\s]+)\\s+" + /* group 1: 2.6.22-omap1 */
|
|
||||||
"\\(([^\\s@]+(?:@[^\\s.]+)?)[^)]*\\)\\s+" + /* group 2: (xxxxxx@xxxxx.constant) */
|
|
||||||
"\\([^)]+\\)\\s+" + /* ignore: (gcc ..) */
|
|
||||||
"([^\\s]+)\\s+" + /* group 3: #26 */
|
|
||||||
"(?:PREEMPT\\s+)?" + /* ignore: PREEMPT (optional) */
|
|
||||||
"(.+)"; /* group 4: date */
|
|
||||||
|
|
||||||
Pattern p = Pattern.compile(PROC_VERSION_REGEX);
|
|
||||||
Matcher m = p.matcher(procVersionStr);
|
|
||||||
|
|
||||||
if (!m.matches()) {
|
|
||||||
Log.e("VNC", "Regex did not match on /proc/version: " + procVersionStr);
|
|
||||||
return "Unavailable";
|
|
||||||
} else if (m.groupCount() < 4) {
|
|
||||||
Log.e("VNC", "Regex match on /proc/version only returned " + m.groupCount()
|
|
||||||
+ " groups");
|
|
||||||
return "Unavailable";
|
|
||||||
} else {
|
|
||||||
return (new StringBuilder(m.group(1)).append("\n").append(
|
|
||||||
m.group(2)).append(" ").append(m.group(3)).append("\n")
|
|
||||||
.append(m.group(4))).toString();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.e("VNC", "IO Exception when getting kernel version for Device Info screen", e);
|
|
||||||
|
|
||||||
return "Unavailable";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getVersionNumber(Context context)
|
|
||||||
{
|
|
||||||
String version = "?";
|
|
||||||
try
|
|
||||||
{
|
|
||||||
PackageInfo packagInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
|
||||||
version = packagInfo.versionName;
|
|
||||||
}
|
|
||||||
catch (PackageManager.NameNotFoundException e){};
|
|
||||||
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
|||||||
package org.onaips.vnc;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.preference.PreferenceActivity;
|
|
||||||
|
|
||||||
public class preferences extends PreferenceActivity {
|
|
||||||
|
|
||||||
/** Called when the activity is first created. */
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
addPreferencesFromResource(R.xml.preferences);
|
|
||||||
}
|
|
||||||
}
|
|
@ -72,13 +72,13 @@ import android.widget.TextView;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class MainActivity extends Activity
|
public class MainActivity extends Activity
|
||||||
{
|
{
|
||||||
private static final int MENU_QUIT = 0;
|
private static final int MENU_QUIT = 0;
|
||||||
private static final int MENU_HELP = 1;
|
private static final int MENU_HELP = 1;
|
||||||
private static final int MENU_ONAIPS = 2;
|
private static final int MENU_ONAIPS = 2;
|
||||||
private static final int MENU_SENDLOG = 3;
|
private static final int MENU_SENDLOG = 3;
|
||||||
private static final int MENU_CHANGELOG = 4;
|
private static final int MENU_CHANGELOG = 4;
|
||||||
private static final String changelog="-PLEASE GIVE FEEDBACK! (send debug info in menu)<br><br>- [Add] Start daemon on boot (set on prefs)<br>-[Add] Change port on preferences<br>- [Add] Changelog on menu<br>- [Add] Dynamic network state detection<br>- [Fix] HTTP client now working again<br>- [Rem] Initial screen is only showed on new versions<br>- [Add] Don't let device sleep (set on prefs)<br>- [Fix] Better start/stop handling";
|
private static final String changelog="(i'm looking for someone to write a tutorial for vnc server)<br><br>- [Fix] Everything working again :D<br>- [Fix] Now contains busybox binary for better device compatibility<br> - [Fix] FC on preferences menu, for real this time (thanks Piki for the hints)";
|
||||||
|
|
||||||
private PowerManager.WakeLock wakeLock = null;
|
private PowerManager.WakeLock wakeLock = null;
|
||||||
private Timer watchdogTimer=null;
|
private Timer watchdogTimer=null;
|
||||||
@ -112,19 +112,11 @@ public class MainActivity extends Activity
|
|||||||
//System.exit(-1);
|
//System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasBusybox())
|
|
||||||
{
|
|
||||||
|
|
||||||
showTextOnScreen("I didn't find busybox, you may not be able to close server");
|
|
||||||
}
|
|
||||||
|
|
||||||
showInitialScreen(false);
|
showInitialScreen(false);
|
||||||
createBinary();
|
|
||||||
|
|
||||||
|
|
||||||
boolean serverRunning=isAndroidServerRunning();
|
boolean serverRunning=isAndroidServerRunning();
|
||||||
|
|
||||||
|
|
||||||
if (("On".equals(preferences.getString("sleep", "Off"))) && serverRunning)
|
if (("On".equals(preferences.getString("sleep", "Off"))) && serverRunning)
|
||||||
{
|
{
|
||||||
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||||
@ -142,14 +134,12 @@ public class MainActivity extends Activity
|
|||||||
mReceiver receiver=new mReceiver();
|
mReceiver receiver=new mReceiver();
|
||||||
this.registerReceiver(receiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
|
this.registerReceiver(receiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
|
||||||
|
|
||||||
|
setStateLabels(isAndroidServerRunning());
|
||||||
|
|
||||||
findViewById(R.id.Button01).setOnClickListener(new OnClickListener() {
|
findViewById(R.id.Button01).setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View arg0) {
|
public void onClick(View arg0) {
|
||||||
|
|
||||||
startServerButtonClicked();
|
startServerButtonClicked();
|
||||||
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}) ;
|
}) ;
|
||||||
@ -162,8 +152,6 @@ public class MainActivity extends Activity
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
prepareWatchdog("Stopping server. Please wait...","Couldn't Stop server",false);
|
prepareWatchdog("Stopping server. Please wait...","Couldn't Stop server",false);
|
||||||
|
|
||||||
Thread t=new Thread(){
|
Thread t=new Thread(){
|
||||||
@ -206,17 +194,14 @@ public class MainActivity extends Activity
|
|||||||
|
|
||||||
String version=packageVersion();
|
String version=packageVersion();
|
||||||
|
|
||||||
{
|
if ((!forceShow) && (version.equals(preferences.getString("version", ""))))
|
||||||
if (forceShow)
|
return;
|
||||||
;
|
|
||||||
else if (version.equals(preferences.getString("version", "")))
|
editor.putString("version", version);
|
||||||
return;
|
editor.commit();
|
||||||
editor.putString("version", version);
|
|
||||||
editor.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
startDialog = new AlertDialog.Builder(this).create();
|
startDialog = new AlertDialog.Builder(this).create();
|
||||||
startDialog.setTitle("Changelog");
|
startDialog.setTitle("Version " + version);
|
||||||
startDialog.setMessage(Html.fromHtml(changelog));
|
startDialog.setMessage(Html.fromHtml(changelog));
|
||||||
startDialog.setIcon(R.drawable.icon);
|
startDialog.setIcon(R.drawable.icon);
|
||||||
|
|
||||||
@ -230,8 +215,6 @@ public class MainActivity extends Activity
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
startDialog.setButton2("Donate Version", new DialogInterface.OnClickListener() {
|
startDialog.setButton2("Donate Version", new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface arg0, int arg1) {
|
public void onClick(DialogInterface arg0, int arg1) {
|
||||||
@ -247,10 +230,6 @@ public class MainActivity extends Activity
|
|||||||
startDialog.show();
|
startDialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void writeCommand(OutputStream os, String command) throws Exception
|
|
||||||
{
|
|
||||||
os.write((command + "\n").getBytes("ASCII"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -267,11 +246,11 @@ public class MainActivity extends Activity
|
|||||||
MenuInflater inflater = getMenuInflater();
|
MenuInflater inflater = getMenuInflater();
|
||||||
inflater.inflate(R.menu.menu, menu);
|
inflater.inflate(R.menu.menu, menu);
|
||||||
|
|
||||||
menu.add(0,MENU_SENDLOG,0,"Send debug info");
|
menu.add(0, MENU_SENDLOG ,0,"Report issue");
|
||||||
menu.add(0,MENU_CHANGELOG,0,"Changelog");
|
menu.add(0, MENU_CHANGELOG,0,"Changelog");
|
||||||
menu.add(0,MENU_ONAIPS,0,"About");
|
menu.add(0, MENU_ONAIPS ,0,"About");
|
||||||
menu.add(0, MENU_HELP, 0, "Help");
|
menu.add(0, MENU_HELP ,0, "Help");
|
||||||
menu.add(0, MENU_QUIT, 0, "Close");
|
menu.add(0, MENU_QUIT ,0, "Close");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -303,6 +282,23 @@ public class MainActivity extends Activity
|
|||||||
}, (long)5000);
|
}, (long)5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasExecutable(String s)
|
||||||
|
{
|
||||||
|
boolean has = true;
|
||||||
|
try {
|
||||||
|
File exe = new File("/system/bin/" + s);
|
||||||
|
if (exe.exists() == false) {
|
||||||
|
exe = new File("/system/xbin/" + s);
|
||||||
|
if (exe.exists() == false) {
|
||||||
|
has = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
has = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return has;
|
||||||
|
}
|
||||||
|
|
||||||
public void setStateLabels(boolean state)
|
public void setStateLabels(boolean state)
|
||||||
{
|
{
|
||||||
@ -327,13 +323,14 @@ public class MainActivity extends Activity
|
|||||||
port="5901";
|
port="5901";
|
||||||
httpport="5801";
|
httpport="5801";
|
||||||
}
|
}
|
||||||
|
|
||||||
String ip=getIpAddress();
|
String ip=getIpAddress();
|
||||||
if (ip.equals(""))
|
if (ip.equals(""))
|
||||||
t.setText("Not connected to a network");
|
t.setText(Html.fromHtml("Not connected to a network.<br> You can connect through USB with:<br>localhost:" + port + "<br>or<br>http://localhost:" + httpport + "<br>(use adb to forward ports)</font>"));
|
||||||
else
|
else
|
||||||
t.setText(Html.fromHtml("<font align=\"center\">Connect to:<br>" + getIpAddress()+":" + port + "<br>or<br>http://" + getIpAddress() + ":" + httpport + "</font>"));
|
t.setText(Html.fromHtml("<font align=\"center\">Connect to:<br>" + ip+":" + port + "<br>or<br>http://" + ip + ":" + httpport + "</font>"));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
t.setText("");
|
t.setText("");
|
||||||
@ -357,17 +354,6 @@ public class MainActivity extends Activity
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean wifiConnected()
|
|
||||||
{
|
|
||||||
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
|
|
||||||
WifiInfo info = wifi.getConnectionInfo();
|
|
||||||
|
|
||||||
return info.getBSSID()!=null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String intToIp(int i) {
|
|
||||||
return ( i & 0xFF) + "." + ((i >> 8 ) & 0xFF) + "." + ((i >> 16 ) & 0xFF) + "." + ((i >> 24 ) & 0xFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stopServer()
|
public void stopServer()
|
||||||
{
|
{
|
||||||
@ -378,16 +364,16 @@ public class MainActivity extends Activity
|
|||||||
OutputStream os = sh.getOutputStream();
|
OutputStream os = sh.getOutputStream();
|
||||||
|
|
||||||
|
|
||||||
if (hasBusybox())
|
if (hasExecutable("killall"))
|
||||||
{
|
|
||||||
writeCommand(os, "busybox killall androidvncserver");
|
|
||||||
writeCommand(os, "busybox killall -KILL androidvncserver");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
writeCommand(os, "killall androidvncserver");
|
writeCommand(os, "killall androidvncserver");
|
||||||
writeCommand(os, "killall -KILL androidvncserver");
|
writeCommand(os, "killall -KILL androidvncserver");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writeCommand(os, getFilesDir().getAbsolutePath() + "/busybox killall androidvncserver");
|
||||||
|
writeCommand(os, getFilesDir().getAbsolutePath() + "/busybox killall -KILL androidvncserver");
|
||||||
|
}
|
||||||
|
|
||||||
writeCommand(os, "exit");
|
writeCommand(os, "exit");
|
||||||
|
|
||||||
@ -405,10 +391,7 @@ public class MainActivity extends Activity
|
|||||||
public void startServerButtonClicked()
|
public void startServerButtonClicked()
|
||||||
{
|
{
|
||||||
if (isAndroidServerRunning())
|
if (isAndroidServerRunning())
|
||||||
{
|
|
||||||
|
|
||||||
showTextOnScreen("Server is already running, stop it first");
|
showTextOnScreen("Server is already running, stop it first");
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
prepareWatchdog("Starting server. Please wait...","Couldn't Start server", true);
|
prepareWatchdog("Starting server. Please wait...","Couldn't Start server", true);
|
||||||
@ -439,6 +422,7 @@ public class MainActivity extends Activity
|
|||||||
rotation="-r " + rotation;
|
rotation="-r " + rotation;
|
||||||
|
|
||||||
String scaling=preferences.getString("scale", "100");
|
String scaling=preferences.getString("scale", "100");
|
||||||
|
|
||||||
String scaling_string="";
|
String scaling_string="";
|
||||||
if (!scaling.equals("0"))
|
if (!scaling.equals("0"))
|
||||||
scaling_string="-s " + scaling;
|
scaling_string="-s " + scaling;
|
||||||
@ -458,8 +442,7 @@ public class MainActivity extends Activity
|
|||||||
|
|
||||||
sh = Runtime.getRuntime().exec("su");
|
sh = Runtime.getRuntime().exec("su");
|
||||||
OutputStream os = sh.getOutputStream();
|
OutputStream os = sh.getOutputStream();
|
||||||
writeCommand(os, "chmod 777 /data/data/"+getPackageName()+"/androidvncserver");
|
writeCommand(os, getFilesDir().getAbsolutePath() + "/androidvncserver "+ password_check + " " + rotation + " " + scaling_string + " " + port_string);
|
||||||
writeCommand(os, "/data/data/"+getPackageName()+"/androidvncserver "+ password_check + " " + rotation + " " + scaling_string + " " + port_string);
|
|
||||||
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -473,36 +456,6 @@ public class MainActivity extends Activity
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void copyBinary(int id,String path)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
InputStream ins = getResources().openRawResource(id);
|
|
||||||
int size = ins.available();
|
|
||||||
|
|
||||||
// Read the entire resource into a local byte buffer.
|
|
||||||
byte[] buffer = new byte[size];
|
|
||||||
ins.read(buffer);
|
|
||||||
ins.close();
|
|
||||||
|
|
||||||
FileOutputStream fos = new FileOutputStream(path);
|
|
||||||
fos.write(buffer);
|
|
||||||
fos.close();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Log.v("VNC","public void createBinary(): " + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
public void createBinary()
|
|
||||||
{
|
|
||||||
copyBinary(R.raw.androidvncserver, "/data/data/" + getPackageName() + "/androidvncserver");
|
|
||||||
copyBinary(R.raw.vncviewer, "/data/data/"+getPackageName()+"/VncViewer.jar");
|
|
||||||
copyBinary(R.raw.indexvnc, "/data/data/"+getPackageName()+"/index.vnc");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showHelp()
|
public void showHelp()
|
||||||
{
|
{
|
||||||
new AlertDialog.Builder(this)
|
new AlertDialog.Builder(this)
|
||||||
@ -510,7 +463,7 @@ public class MainActivity extends Activity
|
|||||||
.setMessage(Html.fromHtml("Mouse Mappings:<br><br>Right Click -> Back<br>Middle Click -> End Call<br>Left Click -> Touch<br><br>Keyboard Mappings<br><br>" +
|
.setMessage(Html.fromHtml("Mouse Mappings:<br><br>Right Click -> Back<br>Middle Click -> End Call<br>Left Click -> Touch<br><br>Keyboard Mappings<br><br>" +
|
||||||
"Home Key -> Home<br>Escape -> Back<br>Page Up ->Menu<br>Left Ctrl -> Search<br>PgDown -> Start Call<br>" +
|
"Home Key -> Home<br>Escape -> Back<br>Page Up ->Menu<br>Left Ctrl -> Search<br>PgDown -> Start Call<br>" +
|
||||||
"End Key -> End Call<br>F4 -> Rotate<br>F11 -> Disconnect Server<br>F12 -> Stop Server Daemon"))
|
"End Key -> End Call<br>F4 -> Rotate<br>F11 -> Disconnect Server<br>F12 -> Stop Server Daemon"))
|
||||||
.setPositiveButton("Fechar", null)
|
.setPositiveButton("Quit", null)
|
||||||
.setNegativeButton("Open Website", new DialogInterface.OnClickListener() {
|
.setNegativeButton("Open Website", new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface arg0, int arg1) {
|
public void onClick(DialogInterface arg0, int arg1) {
|
||||||
@ -570,11 +523,10 @@ public class MainActivity extends Activity
|
|||||||
String result="";
|
String result="";
|
||||||
Process sh;
|
Process sh;
|
||||||
try {
|
try {
|
||||||
if (hasBusybox())
|
if (hasExecutable("ps"))
|
||||||
sh = Runtime.getRuntime().exec("busybox ps");
|
|
||||||
else
|
|
||||||
sh = Runtime.getRuntime().exec("ps");
|
sh = Runtime.getRuntime().exec("ps");
|
||||||
|
else
|
||||||
|
sh = Runtime.getRuntime().exec(getFilesDir().getAbsolutePath() + "/busybox ps w");
|
||||||
|
|
||||||
InputStream is=sh.getInputStream();
|
InputStream is=sh.getInputStream();
|
||||||
InputStreamReader isr = new InputStreamReader(is);
|
InputStreamReader isr = new InputStreamReader(is);
|
||||||
@ -596,28 +548,10 @@ public class MainActivity extends Activity
|
|||||||
Log.v("VNC"," isAndroidServerRunning():" + e.getMessage());
|
Log.v("VNC"," isAndroidServerRunning():" + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Log.v("VNC",result);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasBusybox()
|
|
||||||
{
|
|
||||||
boolean has = true;
|
|
||||||
try {
|
|
||||||
File su = new File("/system/bin/busybox");
|
|
||||||
if (su.exists() == false) {
|
|
||||||
su = new File("/system/xbin/busybox");
|
|
||||||
if (su.exists() == false) {
|
|
||||||
has = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.v("VNC", "I didn't find busybox, you may not be able to close server - Here is what I know: "+e.getMessage());
|
|
||||||
has = false;
|
|
||||||
}
|
|
||||||
return has;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasRootPermission() {
|
public boolean hasRootPermission() {
|
||||||
boolean rooted = true;
|
boolean rooted = true;
|
||||||
@ -634,54 +568,6 @@ public class MainActivity extends Activity
|
|||||||
rooted = false;
|
rooted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Process sh;
|
|
||||||
try {
|
|
||||||
String result="";
|
|
||||||
|
|
||||||
sh = Runtime.getRuntime().exec("whoami");
|
|
||||||
|
|
||||||
InputStream is=sh.getInputStream();
|
|
||||||
InputStreamReader isr = new InputStreamReader(is);
|
|
||||||
BufferedReader br = new BufferedReader(isr);
|
|
||||||
String line;
|
|
||||||
|
|
||||||
while ((line = br.readLine()) != null) {
|
|
||||||
result+=line;
|
|
||||||
if (result.indexOf("androidvncserver")>0)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Process sh1=Runtime.getRuntime().exec("su");
|
|
||||||
|
|
||||||
//Log.v("aaaaaa","chgrp -R " + result + " /data/data/org.onaips.vnc/");
|
|
||||||
|
|
||||||
OutputStream os = sh1.getOutputStream();
|
|
||||||
|
|
||||||
if (hasBusybox())
|
|
||||||
{
|
|
||||||
writeCommand(os, "busybox chown -R " + result + " /data/data/" + getPackageName() + "/");
|
|
||||||
writeCommand(os, "busybox chgrp -R " + result + " /data/data/" + getPackageName() + "/");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
writeCommand(os, "chown -R " + result + " /data/data/" + getPackageName() + "/");
|
|
||||||
writeCommand(os, "chgrp -R " + result + " /data/data/" + getPackageName() + "/");
|
|
||||||
}
|
|
||||||
|
|
||||||
os.flush();
|
|
||||||
os.close();
|
|
||||||
isr.close();
|
|
||||||
is.close();
|
|
||||||
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return rooted;
|
return rooted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -720,7 +606,7 @@ public class MainActivity extends Activity
|
|||||||
new AlertDialog.Builder(this)
|
new AlertDialog.Builder(this)
|
||||||
.setTitle(getString(R.string.app_name))
|
.setTitle(getString(R.string.app_name))
|
||||||
.setIcon(android.R.drawable.ic_dialog_info)
|
.setIcon(android.R.drawable.ic_dialog_info)
|
||||||
.setMessage("Do you want to send debug info to the dev? Please specify what problem is ocurring.\n\nMake sure you started/stopped the server before submitting")
|
.setMessage("Do you want to send a bug report to the dev? Please specify what problem is ocurring.\n\nMake sure you started & stopped the server before submitting")
|
||||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
|
||||||
public void onClick(DialogInterface dialog, int whichButton){
|
public void onClick(DialogInterface dialog, int whichButton){
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
@ -728,9 +614,7 @@ public class MainActivity extends Activity
|
|||||||
final String email = "onaips@gmail.com";
|
final String email = "onaips@gmail.com";
|
||||||
intent.putExtra(EXTRA_DATA, Uri.parse("mailto:" + email));
|
intent.putExtra(EXTRA_DATA, Uri.parse("mailto:" + email));
|
||||||
intent.putExtra(EXTRA_ADDITIONAL_INFO,"Problem Description: \n\n\n\n---------DEBUG--------\n" + getString(R.string.device_info_fmt,getVersionNumber(getApplicationContext()),Build.MODEL,Build.VERSION.RELEASE, getFormattedKernelVersion(), Build.DISPLAY));
|
intent.putExtra(EXTRA_ADDITIONAL_INFO,"Problem Description: \n\n\n\n---------DEBUG--------\n" + getString(R.string.device_info_fmt,getVersionNumber(getApplicationContext()),Build.MODEL,Build.VERSION.RELEASE, getFormattedKernelVersion(), Build.DISPLAY));
|
||||||
|
|
||||||
intent.putExtra(Intent.EXTRA_SUBJECT, "droid VNC server: Debug Info");
|
intent.putExtra(Intent.EXTRA_SUBJECT, "droid VNC server: Debug Info");
|
||||||
|
|
||||||
intent.putExtra(EXTRA_FORMAT, "time");
|
intent.putExtra(EXTRA_FORMAT, "time");
|
||||||
|
|
||||||
//The log can be filtered to contain data relevant only to your app
|
//The log can be filtered to contain data relevant only to your app
|
||||||
@ -806,6 +690,12 @@ public class MainActivity extends Activity
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void writeCommand(OutputStream os, String command) throws Exception
|
||||||
|
{
|
||||||
|
os.write((command + "\n").getBytes("ASCII"));
|
||||||
|
}
|
||||||
|
|
||||||
class mReceiver extends BroadcastReceiver {
|
class mReceiver extends BroadcastReceiver {
|
||||||
@Override public void onReceive(Context context, Intent intent) {
|
@Override public void onReceive(Context context, Intent intent) {
|
||||||
NetworkInfo info = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
|
NetworkInfo info = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
|
||||||
@ -814,8 +704,4 @@ public class MainActivity extends Activity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
73
src/org/onaips/vnc_donate/MainApplication.java
Normal file
73
src/org/onaips/vnc_donate/MainApplication.java
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package org.onaips.vnc_donate;
|
||||||
|
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
public class MainApplication extends Application {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
super.onCreate();
|
||||||
|
|
||||||
|
createBinary();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void createBinary()
|
||||||
|
{
|
||||||
|
copyBinary(R.raw.androidvncserver, getFilesDir().getAbsolutePath() + "/androidvncserver");
|
||||||
|
copyBinary(R.raw.vncviewer, getFilesDir().getAbsolutePath()+"/VncViewer.jar");
|
||||||
|
copyBinary(R.raw.indexvnc, getFilesDir().getAbsolutePath()+"/index.vnc");
|
||||||
|
copyBinary(R.raw.busybox, getFilesDir().getAbsolutePath()+"/busybox");
|
||||||
|
Process sh;
|
||||||
|
try {
|
||||||
|
sh = Runtime.getRuntime().exec("su");
|
||||||
|
|
||||||
|
OutputStream os = sh.getOutputStream();
|
||||||
|
|
||||||
|
//chmod 777 SHOULD exist
|
||||||
|
writeCommand(os, "chmod 777 " + getFilesDir().getAbsolutePath() + "/androidvncserver");
|
||||||
|
writeCommand(os, "chmod 777 " + getFilesDir().getAbsolutePath() +"/busybox");
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.v("VNC",e.getMessage());
|
||||||
|
}catch (Exception e) {
|
||||||
|
Log.v("VNC",e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void copyBinary(int id,String path)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
InputStream ins = getResources().openRawResource(id);
|
||||||
|
int size = ins.available();
|
||||||
|
|
||||||
|
// Read the entire resource into a local byte buffer.
|
||||||
|
byte[] buffer = new byte[size];
|
||||||
|
ins.read(buffer);
|
||||||
|
ins.close();
|
||||||
|
|
||||||
|
FileOutputStream fos = new FileOutputStream(path);
|
||||||
|
fos.write(buffer);
|
||||||
|
fos.close();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.v("VNC","public void createBinary(): " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void writeCommand(OutputStream os, String command) throws Exception
|
||||||
|
{
|
||||||
|
os.write((command + "\n").getBytes("ASCII"));
|
||||||
|
}
|
||||||
|
}
|
@ -34,8 +34,8 @@ public class StartAtBootService extends Service {
|
|||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
||||||
//Lets see if i need to boot daemon...
|
//Lets see if i need to boot daemon...
|
||||||
String startOnBoot=preferences.getString("startonboot", "False");
|
String startOnBoot=preferences.getString("startonboot", "Off");
|
||||||
if (startOnBoot.equals("False"))
|
if (startOnBoot.equals("Off"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
@ -53,6 +53,7 @@ public class StartAtBootService extends Service {
|
|||||||
rotation="-r " + rotation;
|
rotation="-r " + rotation;
|
||||||
|
|
||||||
String scaling=preferences.getString("scale", "100");
|
String scaling=preferences.getString("scale", "100");
|
||||||
|
|
||||||
String scaling_string="";
|
String scaling_string="";
|
||||||
if (!scaling.equals("0"))
|
if (!scaling.equals("0"))
|
||||||
scaling_string="-s " + scaling;
|
scaling_string="-s " + scaling;
|
||||||
@ -72,9 +73,7 @@ public class StartAtBootService extends Service {
|
|||||||
|
|
||||||
sh = Runtime.getRuntime().exec("su");
|
sh = Runtime.getRuntime().exec("su");
|
||||||
OutputStream os = sh.getOutputStream();
|
OutputStream os = sh.getOutputStream();
|
||||||
writeCommand(os, "chmod 777 /data/data/"+getPackageName()+"/androidvncserver");
|
writeCommand(os, getFilesDir().getAbsolutePath() + "/androidvncserver "+ password_check + " " + rotation + " " + scaling_string + " " + port_string);
|
||||||
writeCommand(os, "/data/data/"+getPackageName()+"/androidvncserver "+ password_check + " " + rotation + " " + scaling_string + " " + port_string);
|
|
||||||
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.v("VNC","startServer():" + e.getMessage());
|
Log.v("VNC","startServer():" + e.getMessage());
|
||||||
|
Loading…
Reference in New Issue
Block a user