Must be a color value, in the form of "#rgb
", "#argb
",
-"#rrggbb
", or "#aarrggbb
".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name
") or
-theme attribute (in the form
-"?[package:][type:]name
")
-containing a value of this type.
- */
- public static final int backgroundColor=0x7f010000;
- /**
Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character. -
This may also be a reference to a resource (in the form
-"@[package:]type:name
") or
-theme attribute (in the form
-"?[package:][type:]name
")
-containing a value of this type.
- */
- public static final int keywords=0x7f010003;
- /**
Must be a color value, in the form of "#rgb
", "#argb
",
-"#rrggbb
", or "#aarrggbb
".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name
") or
-theme attribute (in the form
-"?[package:][type:]name
")
-containing a value of this type.
- */
- public static final int primaryTextColor=0x7f010001;
- /**
Must be an integer value, such as "100
".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name
") or
-theme attribute (in the form
-"?[package:][type:]name
")
-containing a value of this type.
- */
- public static final int refreshInterval=0x7f010004;
- /**
Must be a color value, in the form of "#rgb
", "#argb
",
-"#rrggbb
", or "#aarrggbb
".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name
") or
-theme attribute (in the form
-"?[package:][type:]name
")
-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.
-
Includes the following attributes:
-Attribute | Description |
---|---|
{@link #com_admob_android_ads_AdView_backgroundColor org.onaips.vnc:backgroundColor} | |
{@link #com_admob_android_ads_AdView_keywords org.onaips.vnc:keywords} | |
{@link #com_admob_android_ads_AdView_primaryTextColor org.onaips.vnc:primaryTextColor} | |
{@link #com_admob_android_ads_AdView_refreshInterval org.onaips.vnc:refreshInterval} | |
{@link #com_admob_android_ads_AdView_secondaryTextColor org.onaips.vnc:secondaryTextColor} |
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. - - -
Must be a color value, in the form of "#rgb
", "#argb
",
-"#rrggbb
", or "#aarrggbb
".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name
") or
-theme attribute (in the form
-"?[package:][type:]name
")
-containing a value of this type.
- @attr name android:backgroundColor
- */
- public static final int com_admob_android_ads_AdView_backgroundColor = 0;
- /**
-
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. - - -
Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character. -
This may also be a reference to a resource (in the form
-"@[package:]type:name
") or
-theme attribute (in the form
-"?[package:][type:]name
")
-containing a value of this type.
- @attr name android:keywords
- */
- public static final int com_admob_android_ads_AdView_keywords = 3;
- /**
-
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. - - -
Must be a color value, in the form of "#rgb
", "#argb
",
-"#rrggbb
", or "#aarrggbb
".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name
") or
-theme attribute (in the form
-"?[package:][type:]name
")
-containing a value of this type.
- @attr name android:primaryTextColor
- */
- public static final int com_admob_android_ads_AdView_primaryTextColor = 1;
- /**
-
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. - - -
Must be an integer value, such as "100
".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name
") or
-theme attribute (in the form
-"?[package:][type:]name
")
-containing a value of this type.
- @attr name android:refreshInterval
- */
- public static final int com_admob_android_ads_AdView_refreshInterval = 4;
- /**
-
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. - - -
Must be a color value, in the form of "#rgb
", "#argb
",
-"#rrggbb
", or "#aarrggbb
".
-
This may also be a reference to a resource (in the form
-"@[package:]type:name
") or
-theme attribute (in the form
-"?[package:][type:]name
")
-containing a value of this type.
- @attr name android:secondaryTextColor
- */
- public static final int com_admob_android_ads_AdView_secondaryTextColor = 2;
- };
-}
diff --git a/gen/org/onaips/vnc_donate/R.java b/gen/org/onaips/vnc_donate/R.java
index 6f5b982..ec66fad 100644
--- a/gen/org/onaips/vnc_donate/R.java
+++ b/gen/org/onaips/vnc_donate/R.java
@@ -9,11 +9,13 @@ package org.onaips.vnc_donate;
public final class R {
public static final class array {
+ public static final int rotation_strings=0x7f070001;
public static final int rotation_values=0x7f070000;
- public static final int scale_strings=0x7f070002;
- public static final int scale_values=0x7f070001;
- public static final int sleep_strings=0x7f070003;
- public static final int startonboot_values=0x7f070004;
+ public static final int scale_strings=0x7f070003;
+ public static final int scale_values=0x7f070002;
+ public static final int sleep_strings=0x7f070004;
+ public static final int startonboot_strings=0x7f070005;
+ public static final int startonboot_values=0x7f070006;
}
public static final class attr {
/**
Must be a color value, in the form of "#rgb
", "#argb
",
@@ -87,13 +89,13 @@ containing a value of this type.
}
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 int busybox=0x7f050001;
+ public static final int indexvnc=0x7f050002;
+ public static final int vncviewer=0x7f050003;
}
public static final class string {
public static final int app_name=0x7f060000;
public static final int device_info_fmt=0x7f060001;
- public static final int package_name=0x7f060002;
}
public static final class xml {
public static final int preferences=0x7f040000;
diff --git a/jni/vnc/fbvncserver.c b/jni/vnc/fbvncserver.c
index f243634..a26cdde 100755
--- a/jni/vnc/fbvncserver.c
+++ b/jni/vnc/fbvncserver.c
@@ -143,7 +143,7 @@ static void init_fb(void)
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)
@@ -238,10 +238,11 @@ static void init_fb_server(int argc, char **argv)
}
#ifdef DONATE_VERSION
- vncscr->httpDir="/data/data/org.onaips.vnc_donate/";
+ vncscr->httpDir="/data/data/org.onaips.vnc_donate/files/";
#else
- vncscr->httpDir="/data/data/org.onaips.vnc/";
+ vncscr->httpDir="/data/data/org.onaips.vnc/files/";
#endif
+
vncscr->serverFormat.redShift=scrinfo.red.offset;
vncscr->serverFormat.greenShift=scrinfo.green.offset;
vncscr->serverFormat.blueShift=scrinfo.blue.offset;
@@ -315,7 +316,7 @@ static void keyevent(rfbBool down, rfbKeySym key, rfbClientPtr cl)
else
;//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"," port: %d\n", (int)VNC_PORT);
init_fb_server(argc, argv);
- /*
- rfbRunEventLoop(vncscr,-1,TRUE);
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)
rfbProcessEvents(vncscr, 100000);
diff --git a/jni/vnc/fbvncserver.c~ b/jni/vnc/fbvncserver.c~
index 049c81f..17d3c4f 100755
--- a/jni/vnc/fbvncserver.c~
+++ b/jni/vnc/fbvncserver.c~
@@ -57,7 +57,7 @@
char VNC_PASSWORD[256] = "";
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_fix_screeninfo fscrinfo;
@@ -143,7 +143,7 @@ static void init_fb(void)
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)
@@ -238,9 +238,9 @@ static void init_fb_server(int argc, char **argv)
}
#ifdef DONATE_VERSION
- vncscr->httpDir="/data/data/org.onaips.vnc_donate/";
+ vncscr->httpDir="/data/data/org.onaips.vnc_donate/files/";
#else
- vncscr->httpDir="/data/data/org.onaips.vnc/";
+ vncscr->httpDir="/data/data/org.onaips.vnc/files/";
#endif
vncscr->serverFormat.redShift=scrinfo.red.offset;
vncscr->serverFormat.greenShift=scrinfo.green.offset;
@@ -315,7 +315,7 @@ static void keyevent(rfbBool down, rfbKeySym key, rfbClientPtr cl)
else
;//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"," port: %d\n", (int)VNC_PORT);
init_fb_server(argc, argv);
- /*
- rfbRunEventLoop(vncscr,-1,TRUE);
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)
rfbProcessEvents(vncscr, 100000);
diff --git a/jni/vnc/suinput.c b/jni/vnc/suinput.c
index 364a551..3f7f18d 100644
--- a/jni/vnc/suinput.c
+++ b/jni/vnc/suinput.c
@@ -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)
{
- 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)
{
- 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)
diff --git a/jni/vnc/suinput.c~ b/jni/vnc/suinput.c~
new file mode 100644
index 0000000..364a551
--- /dev/null
+++ b/jni/vnc/suinput.c~
@@ -0,0 +1,225 @@
+/*
+suinput - Simple C-API to the Linux uinput-system.
+Copyright (C) 2009 Tuomas Räsänen
- [Add] Server-side screen scaling (change it in preferences - BETA)
- [Fix] Half-screen bug
New icon
Courtesy of Sandro Forbice (@sandroforbice)
- [Fix] Double buffering now supported
- [Add] Low CPU on idle screen while connected
- [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:
" + 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:
Right Click -> Back
Middle Click -> End Call
Left Click -> Touch
Keyboard Mappings
" +
- "Home Key -> Home
Escape -> Back
Page Up ->Menu
Left Ctrl -> Search
PgDown -> Start Call
" +
- "End Key -> End Call
F4 -> Rotate
F11 -> Disconnect Server
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() + "
developed by oNaiPs
Graphics: Sandro Forbice (@sandroforbice)
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
- [Add] Start daemon on boot (set on prefs)
-[Add] Change port on preferences
- [Add] Changelog on menu
- [Add] Dynamic network state detection
- [Fix] HTTP client now working again
- [Rem] Initial screen is only showed on new versions
- [Add] Don't let device sleep (set on prefs)
- [Fix] Better start/stop handling";
+ private static final String changelog="(i'm looking for someone to write a tutorial for vnc server)
- [Fix] Everything working again :D
- [Fix] Now contains busybox binary for better device compatibility
- [Fix] FC on preferences menu, for real this time (thanks Piki for the hints)";
private PowerManager.WakeLock wakeLock = null;
private Timer watchdogTimer=null;
@@ -112,19 +112,11 @@ public class MainActivity extends Activity
//System.exit(-1);
}
- if (!hasBusybox())
- {
-
- showTextOnScreen("I didn't find busybox, you may not be able to close server");
- }
showInitialScreen(false);
- createBinary();
-
boolean serverRunning=isAndroidServerRunning();
-
if (("On".equals(preferences.getString("sleep", "Off"))) && serverRunning)
{
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
@@ -142,14 +134,12 @@ public class MainActivity extends Activity
mReceiver receiver=new mReceiver();
this.registerReceiver(receiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
+ setStateLabels(isAndroidServerRunning());
findViewById(R.id.Button01).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
-
startServerButtonClicked();
-
-
return;
}
}) ;
@@ -162,8 +152,6 @@ public class MainActivity extends Activity
return;
}
-
-
prepareWatchdog("Stopping server. Please wait...","Couldn't Stop server",false);
Thread t=new Thread(){
@@ -206,17 +194,14 @@ public class MainActivity extends Activity
String version=packageVersion();
- {
- if (forceShow)
- ;
- else if (version.equals(preferences.getString("version", "")))
- return;
- editor.putString("version", version);
- editor.commit();
- }
+ if ((!forceShow) && (version.equals(preferences.getString("version", ""))))
+ return;
+
+ editor.putString("version", version);
+ editor.commit();
startDialog = new AlertDialog.Builder(this).create();
- startDialog.setTitle("Changelog");
+ startDialog.setTitle("Version " + version);
startDialog.setMessage(Html.fromHtml(changelog));
startDialog.setIcon(R.drawable.icon);
@@ -230,8 +215,6 @@ public class MainActivity extends Activity
}
});
-
-
startDialog.setButton2("Donate Version", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
@@ -247,10 +230,6 @@ public class MainActivity extends Activity
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();
inflater.inflate(R.menu.menu, menu);
- menu.add(0,MENU_SENDLOG,0,"Send debug info");
- menu.add(0,MENU_CHANGELOG,0,"Changelog");
- menu.add(0,MENU_ONAIPS,0,"About");
- menu.add(0, MENU_HELP, 0, "Help");
- menu.add(0, MENU_QUIT, 0, "Close");
+ menu.add(0, MENU_SENDLOG ,0,"Report issue");
+ menu.add(0, MENU_CHANGELOG,0,"Changelog");
+ menu.add(0, MENU_ONAIPS ,0,"About");
+ menu.add(0, MENU_HELP ,0, "Help");
+ menu.add(0, MENU_QUIT ,0, "Close");
return true;
}
@@ -303,6 +282,23 @@ public class MainActivity extends Activity
}, (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)
{
@@ -327,13 +323,14 @@ public class MainActivity extends Activity
port="5901";
httpport="5801";
}
-
+
String ip=getIpAddress();
if (ip.equals(""))
- t.setText("Not connected to a network");
+ t.setText(Html.fromHtml("Not connected to a network.
You can connect through USB with:
localhost:" + port + "
or
http://localhost:" + httpport + "
(use adb to forward ports)"));
else
- t.setText(Html.fromHtml("Connect to:
" + getIpAddress()+":" + port + "
or
http://" + getIpAddress() + ":" + httpport + ""));
+ t.setText(Html.fromHtml("Connect to:
" + ip+":" + port + "
or
http://" + ip + ":" + httpport + ""));
+
}
else
t.setText("");
@@ -357,17 +354,6 @@ public class MainActivity extends Activity
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()
{
@@ -378,16 +364,16 @@ public class MainActivity extends Activity
OutputStream os = sh.getOutputStream();
- if (hasBusybox())
- {
- writeCommand(os, "busybox killall androidvncserver");
- writeCommand(os, "busybox killall -KILL androidvncserver");
- }
- else
+ if (hasExecutable("killall"))
{
writeCommand(os, "killall 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");
@@ -405,10 +391,7 @@ public class MainActivity extends Activity
public void startServerButtonClicked()
{
if (isAndroidServerRunning())
- {
-
showTextOnScreen("Server is already running, stop it first");
- }
else
{
prepareWatchdog("Starting server. Please wait...","Couldn't Start server", true);
@@ -439,6 +422,7 @@ public class MainActivity extends Activity
rotation="-r " + rotation;
String scaling=preferences.getString("scale", "100");
+
String scaling_string="";
if (!scaling.equals("0"))
scaling_string="-s " + scaling;
@@ -458,8 +442,7 @@ public class MainActivity extends Activity
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 + " " + port_string);
+ writeCommand(os, getFilesDir().getAbsolutePath() + "/androidvncserver "+ password_check + " " + rotation + " " + scaling_string + " " + port_string);
} 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()
{
new AlertDialog.Builder(this)
@@ -510,7 +463,7 @@ public class MainActivity extends Activity
.setMessage(Html.fromHtml("Mouse Mappings:
Right Click -> Back
Middle Click -> End Call
Left Click -> Touch
Keyboard Mappings
" +
"Home Key -> Home
Escape -> Back
Page Up ->Menu
Left Ctrl -> Search
PgDown -> Start Call
" +
"End Key -> End Call
F4 -> Rotate
F11 -> Disconnect Server
F12 -> Stop Server Daemon"))
- .setPositiveButton("Fechar", null)
+ .setPositiveButton("Quit", null)
.setNegativeButton("Open Website", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
@@ -570,11 +523,10 @@ public class MainActivity extends Activity
String result="";
Process sh;
try {
- if (hasBusybox())
- sh = Runtime.getRuntime().exec("busybox ps");
- else
+ if (hasExecutable("ps"))
sh = Runtime.getRuntime().exec("ps");
-
+ else
+ sh = Runtime.getRuntime().exec(getFilesDir().getAbsolutePath() + "/busybox ps w");
InputStream is=sh.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
@@ -596,28 +548,10 @@ public class MainActivity extends Activity
Log.v("VNC"," isAndroidServerRunning():" + e.getMessage());
}
- //Log.v("VNC",result);
-
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() {
boolean rooted = true;
@@ -634,54 +568,6 @@ public class MainActivity extends Activity
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;
}
@@ -720,7 +606,7 @@ public class MainActivity extends Activity
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")
+ .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(){
public void onClick(DialogInterface dialog, int whichButton){
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -728,9 +614,7 @@ public class MainActivity extends Activity
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
@@ -806,6 +690,12 @@ public class MainActivity extends Activity
return version;
}
+
+ static void writeCommand(OutputStream os, String command) throws Exception
+ {
+ os.write((command + "\n").getBytes("ASCII"));
+ }
+
class mReceiver extends BroadcastReceiver {
@Override public void onReceive(Context context, Intent intent) {
NetworkInfo info = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
@@ -814,8 +704,4 @@ public class MainActivity extends Activity
}
}
};
-}
-
-
-
-
+}
\ No newline at end of file
diff --git a/src/org/onaips/vnc_donate/MainApplication.java b/src/org/onaips/vnc_donate/MainApplication.java
new file mode 100644
index 0000000..db2fc17
--- /dev/null
+++ b/src/org/onaips/vnc_donate/MainApplication.java
@@ -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"));
+ }
+}
diff --git a/src/org/onaips/vnc_donate/StartAtBootService.java b/src/org/onaips/vnc_donate/StartAtBootService.java
index 8ad64ce..f5dad2d 100644
--- a/src/org/onaips/vnc_donate/StartAtBootService.java
+++ b/src/org/onaips/vnc_donate/StartAtBootService.java
@@ -34,8 +34,8 @@ public class StartAtBootService extends Service {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
//Lets see if i need to boot daemon...
- String startOnBoot=preferences.getString("startonboot", "False");
- if (startOnBoot.equals("False"))
+ String startOnBoot=preferences.getString("startonboot", "Off");
+ if (startOnBoot.equals("Off"))
return;
@@ -53,6 +53,7 @@ public class StartAtBootService extends Service {
rotation="-r " + rotation;
String scaling=preferences.getString("scale", "100");
+
String scaling_string="";
if (!scaling.equals("0"))
scaling_string="-s " + scaling;
@@ -72,9 +73,7 @@ public class StartAtBootService extends Service {
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 + " " + port_string);
-
+ writeCommand(os, getFilesDir().getAbsolutePath() + "/androidvncserver "+ password_check + " " + rotation + " " + scaling_string + " " + port_string);
} catch (IOException e) {
Log.v("VNC","startServer():" + e.getMessage());