Clipboard Support, added test mode for debugging purposes
This commit is contained in:
parent
160c4b7447
commit
0d977f4689
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.onaips.vnc" android:versionName="0.98 will now use only busybox, if you don't have it, it will ask for it. I'm going to merge donate and free versions in time." android:versionCode="50">
|
||||
package="org.onaips.vnc" android:versionName="0.991" android:versionCode="52">
|
||||
<uses-sdk android:minSdkVersion="3" />
|
||||
<application android:debuggable="false" android:icon="@drawable/icon"
|
||||
android:label="droid VNC server" android:name="MainApplication">
|
||||
@ -19,6 +19,7 @@
|
||||
<activity android:name="com.mobclix.android.sdk.MobclixBrowserActivity" />
|
||||
|
||||
|
||||
|
||||
<service android:name="StartAtBootService">
|
||||
<intent-filter>
|
||||
<action android:name="org.onaips.vnc.StartAtBootService"></action>
|
||||
@ -34,14 +35,8 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver android:name=".DaemonCommunication">
|
||||
<intent-filter>
|
||||
<action android:name="org.onaips.vnc.intent.action.DaemonCommunication.ClientConnected" />
|
||||
<action android:name="org.onaips.vnc.intent.action.DaemonCommunication.ClientDisconnected" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
<service android:name="avncservice"></service>
|
||||
</application>
|
||||
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>
|
||||
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"></uses-permission>
|
||||
@ -51,5 +46,6 @@
|
||||
<uses-permission android:name="android.permission.GET_TASKS"></uses-permission>
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
|
||||
|
||||
</manifest>
|
||||
|
BIN
bin/avnc.apk
BIN
bin/avnc.apk
Binary file not shown.
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.
@ -13,9 +13,10 @@ public final class R {
|
||||
public static final int rotation_values=0x7f070000;
|
||||
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 int sleep_strings=0x7f070005;
|
||||
public static final int startonboot_strings=0x7f070006;
|
||||
public static final int startonboot_values=0x7f070007;
|
||||
public static final int test_mode_strings=0x7f070004;
|
||||
}
|
||||
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>",
|
||||
|
Binary file not shown.
@ -27,6 +27,13 @@
|
||||
<item>30</item>
|
||||
<item>20</item>
|
||||
</string-array>
|
||||
<string-array name="test_mode_strings">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
</string-array>
|
||||
<string-array name="sleep_strings">
|
||||
<item>On</item>
|
||||
<item>Off</item>
|
||||
|
@ -11,5 +11,7 @@
|
||||
<CheckBoxPreference android:key="screenturnoff" android:title="Don't let screen turn off" android:defaultValue="false"></CheckBoxPreference>
|
||||
<CheckBoxPreference android:key="notifyclient" android:title="Notify when client connects" android:summary="Show notification on status bar" android:defaultValue="true"></CheckBoxPreference>
|
||||
<CheckBoxPreference android:key="hidead" android:defaultValue="false" android:title="Disable Bottom Ad" android:summary="Select this if you don't want to view the ad."></CheckBoxPreference>
|
||||
|
||||
<ListPreference android:title="Screen Test Mode" android:summary="DANGEROUS: enable this to fix screen issues" android:key="testmode" android:entries="@array/test_mode_strings" android:entryValues="@array/test_mode_strings"></ListPreference>
|
||||
</PreferenceScreen>
|
||||
|
@ -1,48 +0,0 @@
|
||||
package org.onaips.vnc;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentSender.SendIntentException;
|
||||
import android.util.Log;
|
||||
|
||||
public class DaemonCommunication extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
|
||||
Log.v("VNC","daemoncom" + action);
|
||||
Intent i=null;
|
||||
|
||||
if (action.equalsIgnoreCase("org.onaips.vnc.intent.action.DaemonCommunication.ClientConnected"))
|
||||
{
|
||||
|
||||
i = new Intent("org.onaips.vnc.CLIENTCONNECTED");
|
||||
i.putExtra("clientip", intent.getStringExtra("clientip"));
|
||||
|
||||
}
|
||||
else if (action.equalsIgnoreCase("org.onaips.vnc.intent.action.DaemonCommunication.ClientDisconnected"))
|
||||
{
|
||||
|
||||
i = new Intent("org.onaips.vnc.CLIENTDISCONNECTED");
|
||||
|
||||
}
|
||||
|
||||
context.sendOrderedBroadcast(i, null, new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
int result = getResultCode();
|
||||
if (result != Activity.RESULT_CANCELED) {
|
||||
Log.d("VNC", "Activity caught the broadcast, result "+result);
|
||||
return; // Activity caught it
|
||||
}
|
||||
Log.d("VNC", "Activity did not catch the broadcast");
|
||||
}
|
||||
}, null, Activity.RESULT_CANCELED, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,9 +23,11 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Array;
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
@ -59,6 +61,8 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.graphics.Color;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.DhcpInfo;
|
||||
import android.net.LocalServerSocket;
|
||||
import android.net.LocalSocket;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
import android.net.NetworkInfo.DetailedState;
|
||||
@ -66,8 +70,10 @@ import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.ClipboardManager;
|
||||
import android.text.Html;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
@ -90,7 +96,9 @@ public class MainActivity extends Activity
|
||||
private static final int MENU_SENDLOG = 3;
|
||||
private static final int MENU_CHANGELOG = 4;
|
||||
private static final int APP_ID = 123;
|
||||
private static final String changelog="- [Fix] Start/stop server now handled by busybox, it will ask if you don't have it (please report if you still have the issue) - Sorry for that";
|
||||
private static final String changelog="- [Add] Clipboard text support!";
|
||||
public static String SOCKET_ADDRESS = "org.onaips.vnc.localsocket";
|
||||
|
||||
|
||||
private PowerManager.WakeLock wakeLock = null;
|
||||
private Timer watchdogTimer=null;
|
||||
@ -105,7 +113,6 @@ public class MainActivity extends Activity
|
||||
{
|
||||
super.onDestroy();
|
||||
unregisterReceiver(mReceiver);
|
||||
unregisterReceiver(activityReceiver);
|
||||
}
|
||||
|
||||
|
||||
@ -161,8 +168,9 @@ public class MainActivity extends Activity
|
||||
|
||||
// register wifi event receiver
|
||||
registerReceiver(mReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
|
||||
registerReceiver(activityReceiver, new IntentFilter("org.onaips.vnc.CLIENTCONNECTED"));
|
||||
registerReceiver(activityReceiver, new IntentFilter("org.onaips.vnc.CLIENTDISCONNECTED"));
|
||||
|
||||
SocketListener s=new SocketListener();
|
||||
s.start();
|
||||
|
||||
|
||||
setStateLabels(isAndroidServerRunning());
|
||||
@ -258,10 +266,6 @@ public class MainActivity extends Activity
|
||||
return version;
|
||||
}
|
||||
|
||||
public boolean free_version()
|
||||
{
|
||||
return getPackageName().equals("org.onaips.vnc");
|
||||
}
|
||||
|
||||
public void showInitialScreen(boolean forceShow)
|
||||
{
|
||||
@ -282,29 +286,26 @@ public class MainActivity extends Activity
|
||||
startDialog.setMessage(Html.fromHtml(changelog));
|
||||
startDialog.setIcon(R.drawable.icon);
|
||||
|
||||
if (free_version())
|
||||
{
|
||||
startDialog.setButton(AlertDialog.BUTTON1,"OK", new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface arg0, int arg1) {
|
||||
startDialog.dismiss();
|
||||
}
|
||||
});
|
||||
startDialog.setButton(AlertDialog.BUTTON1,"OK", new DialogInterface.OnClickListener() {
|
||||
|
||||
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);
|
||||
@Override
|
||||
public void onClick(DialogInterface arg0, int arg1) {
|
||||
startDialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
startDialog.setButton2("Donate", 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.donate"));
|
||||
startActivity(myIntent);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
startDialog.show();
|
||||
|
||||
startDialog.show();
|
||||
}
|
||||
else
|
||||
startDialog.show();
|
||||
}
|
||||
|
||||
|
||||
@ -431,13 +432,13 @@ public class MainActivity extends Activity
|
||||
}
|
||||
else
|
||||
{
|
||||
writeCommand(os, "killall androidvncserver");
|
||||
writeCommand(os, "killall -KILL androidvncserver");
|
||||
if (findExecutableOnPath("killall")==null)
|
||||
{
|
||||
showTextOnScreen("I couldn't find the killall executable, please install busybox or i can't stop server");
|
||||
Log.v("VNC","I couldn't find the killall executable, please install busybox or i can't stop server");
|
||||
}
|
||||
writeCommand(os, "killall androidvncserver");
|
||||
writeCommand(os, "killall -KILL androidvncserver");
|
||||
}
|
||||
|
||||
writeCommand(os, "exit");
|
||||
@ -497,9 +498,10 @@ public class MainActivity extends Activity
|
||||
if (!scaling.equals("0"))
|
||||
scaling_string="-s " + scaling;
|
||||
|
||||
String donate=free_version()?"":" -d ";
|
||||
|
||||
String port=preferences.getString("port", "5901");
|
||||
|
||||
String tm=preferences.getString("testmode", "0");
|
||||
String testmode="-t " + tm;
|
||||
try
|
||||
{
|
||||
int port1=Integer.parseInt(port);
|
||||
@ -516,10 +518,10 @@ public class MainActivity extends Activity
|
||||
OutputStream os = sh.getOutputStream();
|
||||
|
||||
writeCommand(os, "chmod 777 " + getFilesDir().getAbsolutePath() + "/androidvncserver");
|
||||
writeCommand(os,getFilesDir().getAbsolutePath() + "/androidvncserver "+ password_check + " " + rotation + " " + scaling_string + " " + port_string + donate);
|
||||
writeCommand(os,getFilesDir().getAbsolutePath() + "/androidvncserver "+ password_check + " " + rotation + " " + scaling_string + " " + port_string +" " + testmode);
|
||||
|
||||
//dont show password on logcat
|
||||
Log.v("VNC","Starting " + getFilesDir().getAbsolutePath() + "/androidvncserver " + " " + rotation + " " + scaling_string + " " + port_string + donate);
|
||||
Log.v("VNC","Starting " + getFilesDir().getAbsolutePath() + "/androidvncserver " + " " + rotation + " " + scaling_string + " " + port_string + " " + testmode);
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
@ -603,15 +605,15 @@ public class MainActivity extends Activity
|
||||
sh = Runtime.getRuntime().exec("ps");
|
||||
else*/
|
||||
if (hasBusybox())
|
||||
{
|
||||
{
|
||||
sh = Runtime.getRuntime().exec("busybox ps w");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
if (findExecutableOnPath("ps")==null)
|
||||
showTextOnScreen("I cant find the ps executable, please install busybox or i'm wont be able to check server state");
|
||||
sh = Runtime.getRuntime().exec("ps");
|
||||
}
|
||||
}
|
||||
|
||||
InputStream is=sh.getInputStream();
|
||||
InputStreamReader isr = new InputStreamReader(is);
|
||||
@ -789,53 +791,96 @@ public class MainActivity extends Activity
|
||||
}
|
||||
};
|
||||
|
||||
public BroadcastReceiver activityReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context1, Intent intent) {
|
||||
if (intent.getAction().equalsIgnoreCase("org.onaips.vnc.CLIENTCONNECTED") && (preferences.getBoolean("notifyclient", true)))
|
||||
{
|
||||
|
||||
String ns = Context.NOTIFICATION_SERVICE;
|
||||
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
|
||||
public void showClientConnected(String c)
|
||||
{
|
||||
String ns = Context.NOTIFICATION_SERVICE;
|
||||
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
|
||||
|
||||
int icon = R.drawable.icon;
|
||||
CharSequence tickerText = intent.getStringExtra("clientip") + " connected to VNC server";
|
||||
long when = System.currentTimeMillis();
|
||||
int icon = R.drawable.icon;
|
||||
CharSequence tickerText = c + " connected to VNC server";
|
||||
long when = System.currentTimeMillis();
|
||||
|
||||
|
||||
Notification notification = new Notification(icon, tickerText, when);
|
||||
Notification notification = new Notification(icon, tickerText, when);
|
||||
|
||||
Context context = getApplicationContext();
|
||||
CharSequence contentTitle = "Droid VNC Server";
|
||||
CharSequence contentText = "Client Connected from " + intent.getStringExtra("clientip");
|
||||
Intent notificationIntent = new Intent();
|
||||
PendingIntent contentIntent = PendingIntent.getActivity(context1, 0, notificationIntent, 0);
|
||||
Context context = getApplicationContext();
|
||||
CharSequence contentTitle = "Droid VNC Server";
|
||||
CharSequence contentText = "Client Connected from " + c;
|
||||
Intent notificationIntent = new Intent();
|
||||
PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0);
|
||||
|
||||
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
|
||||
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
|
||||
|
||||
mNotificationManager.notify(APP_ID, notification);
|
||||
|
||||
mNotificationManager.notify(APP_ID, notification);
|
||||
|
||||
//lets see if we should keep screen on
|
||||
if (preferences.getBoolean("screenturnoff", false))
|
||||
{
|
||||
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK,"VNC");
|
||||
wakeLock.acquire();
|
||||
}
|
||||
}
|
||||
else if (intent.getAction().equalsIgnoreCase("org.onaips.vnc.CLIENTDISCONNECTED"))
|
||||
{
|
||||
String ns = Context.NOTIFICATION_SERVICE;
|
||||
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
|
||||
mNotificationManager.cancel(APP_ID);
|
||||
|
||||
if (wakeLock!=null && wakeLock.isHeld())
|
||||
wakeLock.release();
|
||||
}
|
||||
|
||||
//lets see if we should keep screen on
|
||||
if (preferences.getBoolean("screenturnoff", false))
|
||||
{
|
||||
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK,"VNC");
|
||||
wakeLock.acquire();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void showClientDisconnected()
|
||||
{
|
||||
String ns = Context.NOTIFICATION_SERVICE;
|
||||
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
|
||||
mNotificationManager.cancel(APP_ID);
|
||||
|
||||
if (wakeLock!=null && wakeLock.isHeld())
|
||||
wakeLock.release();
|
||||
}
|
||||
|
||||
|
||||
class SocketListener extends Thread {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
LocalServerSocket server = new LocalServerSocket(SOCKET_ADDRESS);
|
||||
while (true) {
|
||||
LocalSocket receiver = server.accept();
|
||||
if (receiver != null) {
|
||||
InputStream input = receiver.getInputStream();
|
||||
|
||||
int readed = input.read();
|
||||
|
||||
StringBuffer bytes=new StringBuffer(2048);
|
||||
while (readed != -1) {
|
||||
bytes.append((char) readed);
|
||||
readed = input.read();
|
||||
}
|
||||
//showTextOnScreen(bytes.toString());
|
||||
Log.v("VNC",bytes.substring(0, 6));
|
||||
|
||||
|
||||
if (bytes.substring(0, 6).equals("~CLIP|"))
|
||||
{
|
||||
bytes.delete(0, 6);
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
|
||||
clipboard.setText(bytes.toString());
|
||||
}
|
||||
else if (preferences.getBoolean("notifyclient", true))
|
||||
{
|
||||
if (bytes.substring(0, 11).equals("~CONNECTED|"))
|
||||
{
|
||||
bytes.delete(0, 11);
|
||||
showClientConnected(bytes.toString());
|
||||
}
|
||||
else if (bytes.substring(0, 14).equals("~DISCONNECTED|"))
|
||||
{
|
||||
showClientDisconnected();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(getClass().getName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static File findExecutableOnPath(String executableName)
|
||||
{
|
||||
|
@ -60,6 +60,8 @@ public class MainApplication extends Application {
|
||||
|
||||
OutputStream os = sh.getOutputStream();
|
||||
|
||||
writeCommand(os, "killall androidvncserver");
|
||||
writeCommand(os, "killall -KILL androidvncserver");
|
||||
//chmod 777 SHOULD exist
|
||||
writeCommand(os, "chmod 777 " + getFilesDir().getAbsolutePath() + "/androidvncserver");
|
||||
os.close();
|
||||
|
Loading…
Reference in New Issue
Block a user