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"?>
|
<?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"
|
||||||
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" />
|
<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:name="MainApplication">
|
android:label="droid VNC server" android:name="MainApplication">
|
||||||
@ -19,6 +19,7 @@
|
|||||||
<activity android:name="com.mobclix.android.sdk.MobclixBrowserActivity" />
|
<activity android:name="com.mobclix.android.sdk.MobclixBrowserActivity" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<service android:name="StartAtBootService">
|
<service android:name="StartAtBootService">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="org.onaips.vnc.StartAtBootService"></action>
|
<action android:name="org.onaips.vnc.StartAtBootService"></action>
|
||||||
@ -34,14 +35,8 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<receiver android:name=".DaemonCommunication">
|
<service android:name="avncservice"></service>
|
||||||
<intent-filter>
|
</application>
|
||||||
<action android:name="org.onaips.vnc.intent.action.DaemonCommunication.ClientConnected" />
|
|
||||||
<action android:name="org.onaips.vnc.intent.action.DaemonCommunication.ClientDisconnected" />
|
|
||||||
</intent-filter>
|
|
||||||
</receiver>
|
|
||||||
|
|
||||||
</application>
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>
|
||||||
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"></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.GET_TASKS"></uses-permission>
|
||||||
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
|
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
|
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
|
||||||
|
|
||||||
</manifest>
|
</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 rotation_values=0x7f070000;
|
||||||
public static final int scale_strings=0x7f070003;
|
public static final int scale_strings=0x7f070003;
|
||||||
public static final int scale_values=0x7f070002;
|
public static final int scale_values=0x7f070002;
|
||||||
public static final int sleep_strings=0x7f070004;
|
public static final int sleep_strings=0x7f070005;
|
||||||
public static final int startonboot_strings=0x7f070005;
|
public static final int startonboot_strings=0x7f070006;
|
||||||
public static final int startonboot_values=0x7f070006;
|
public static final int startonboot_values=0x7f070007;
|
||||||
|
public static final int test_mode_strings=0x7f070004;
|
||||||
}
|
}
|
||||||
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>",
|
||||||
|
Binary file not shown.
@ -27,6 +27,13 @@
|
|||||||
<item>30</item>
|
<item>30</item>
|
||||||
<item>20</item>
|
<item>20</item>
|
||||||
</string-array>
|
</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">
|
<string-array name="sleep_strings">
|
||||||
<item>On</item>
|
<item>On</item>
|
||||||
<item>Off</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="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="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>
|
<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>
|
</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.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.lang.reflect.Array;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.NetworkInterface;
|
import java.net.NetworkInterface;
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
@ -59,6 +61,8 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
|||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.DhcpInfo;
|
import android.net.DhcpInfo;
|
||||||
|
import android.net.LocalServerSocket;
|
||||||
|
import android.net.LocalSocket;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.net.NetworkInfo.DetailedState;
|
import android.net.NetworkInfo.DetailedState;
|
||||||
@ -66,8 +70,10 @@ import android.net.wifi.WifiInfo;
|
|||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.text.ClipboardManager;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
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_SENDLOG = 3;
|
||||||
private static final int MENU_CHANGELOG = 4;
|
private static final int MENU_CHANGELOG = 4;
|
||||||
private static final int APP_ID = 123;
|
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 PowerManager.WakeLock wakeLock = null;
|
||||||
private Timer watchdogTimer=null;
|
private Timer watchdogTimer=null;
|
||||||
@ -99,13 +107,12 @@ public class MainActivity extends Activity
|
|||||||
ProgressDialog dialog=null;
|
ProgressDialog dialog=null;
|
||||||
AlertDialog startDialog;
|
AlertDialog startDialog;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy()
|
protected void onDestroy()
|
||||||
{
|
{
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
unregisterReceiver(mReceiver);
|
unregisterReceiver(mReceiver);
|
||||||
unregisterReceiver(activityReceiver);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -161,8 +168,9 @@ public class MainActivity extends Activity
|
|||||||
|
|
||||||
// register wifi event receiver
|
// register wifi event receiver
|
||||||
registerReceiver(mReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
|
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());
|
setStateLabels(isAndroidServerRunning());
|
||||||
@ -258,10 +266,6 @@ public class MainActivity extends Activity
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean free_version()
|
|
||||||
{
|
|
||||||
return getPackageName().equals("org.onaips.vnc");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showInitialScreen(boolean forceShow)
|
public void showInitialScreen(boolean forceShow)
|
||||||
{
|
{
|
||||||
@ -282,29 +286,26 @@ public class MainActivity extends Activity
|
|||||||
startDialog.setMessage(Html.fromHtml(changelog));
|
startDialog.setMessage(Html.fromHtml(changelog));
|
||||||
startDialog.setIcon(R.drawable.icon);
|
startDialog.setIcon(R.drawable.icon);
|
||||||
|
|
||||||
if (free_version())
|
|
||||||
{
|
|
||||||
startDialog.setButton(AlertDialog.BUTTON1,"OK", new DialogInterface.OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
startDialog.setButton(AlertDialog.BUTTON1,"OK", new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface arg0, int arg1) {
|
|
||||||
startDialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
startDialog.setButton2("Donate Version", new DialogInterface.OnClickListener() {
|
@Override
|
||||||
@Override
|
public void onClick(DialogInterface arg0, int arg1) {
|
||||||
public void onClick(DialogInterface arg0, int arg1) {
|
startDialog.dismiss();
|
||||||
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=org.onaips.vnc_donate"));
|
}
|
||||||
startActivity(myIntent);
|
});
|
||||||
|
|
||||||
}
|
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
|
else
|
||||||
{
|
{
|
||||||
|
writeCommand(os, "killall androidvncserver");
|
||||||
|
writeCommand(os, "killall -KILL androidvncserver");
|
||||||
if (findExecutableOnPath("killall")==null)
|
if (findExecutableOnPath("killall")==null)
|
||||||
{
|
{
|
||||||
showTextOnScreen("I couldn't find the killall executable, please install busybox or i can't stop server");
|
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");
|
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");
|
writeCommand(os, "exit");
|
||||||
@ -497,9 +498,10 @@ public class MainActivity extends Activity
|
|||||||
if (!scaling.equals("0"))
|
if (!scaling.equals("0"))
|
||||||
scaling_string="-s " + scaling;
|
scaling_string="-s " + scaling;
|
||||||
|
|
||||||
String donate=free_version()?"":" -d ";
|
|
||||||
|
|
||||||
String port=preferences.getString("port", "5901");
|
String port=preferences.getString("port", "5901");
|
||||||
|
|
||||||
|
String tm=preferences.getString("testmode", "0");
|
||||||
|
String testmode="-t " + tm;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int port1=Integer.parseInt(port);
|
int port1=Integer.parseInt(port);
|
||||||
@ -516,10 +518,10 @@ public class MainActivity extends Activity
|
|||||||
OutputStream os = sh.getOutputStream();
|
OutputStream os = sh.getOutputStream();
|
||||||
|
|
||||||
writeCommand(os, "chmod 777 " + getFilesDir().getAbsolutePath() + "/androidvncserver");
|
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
|
//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) {
|
} catch (IOException e) {
|
||||||
@ -603,16 +605,16 @@ public class MainActivity extends Activity
|
|||||||
sh = Runtime.getRuntime().exec("ps");
|
sh = Runtime.getRuntime().exec("ps");
|
||||||
else*/
|
else*/
|
||||||
if (hasBusybox())
|
if (hasBusybox())
|
||||||
{
|
{
|
||||||
sh = Runtime.getRuntime().exec("busybox ps w");
|
sh = Runtime.getRuntime().exec("busybox ps w");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (findExecutableOnPath("ps")==null)
|
if (findExecutableOnPath("ps")==null)
|
||||||
showTextOnScreen("I cant find the ps executable, please install busybox or i'm wont be able to check server state");
|
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");
|
sh = Runtime.getRuntime().exec("ps");
|
||||||
}
|
}
|
||||||
|
|
||||||
InputStream is=sh.getInputStream();
|
InputStream is=sh.getInputStream();
|
||||||
InputStreamReader isr = new InputStreamReader(is);
|
InputStreamReader isr = new InputStreamReader(is);
|
||||||
BufferedReader br = new BufferedReader(isr);
|
BufferedReader br = new BufferedReader(isr);
|
||||||
@ -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;
|
public void showClientConnected(String c)
|
||||||
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
|
{
|
||||||
|
String ns = Context.NOTIFICATION_SERVICE;
|
||||||
|
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
|
||||||
|
|
||||||
int icon = R.drawable.icon;
|
int icon = R.drawable.icon;
|
||||||
CharSequence tickerText = intent.getStringExtra("clientip") + " connected to VNC server";
|
CharSequence tickerText = c + " connected to VNC server";
|
||||||
long when = System.currentTimeMillis();
|
long when = System.currentTimeMillis();
|
||||||
|
|
||||||
|
|
||||||
Notification notification = new Notification(icon, tickerText, when);
|
Notification notification = new Notification(icon, tickerText, when);
|
||||||
|
|
||||||
Context context = getApplicationContext();
|
Context context = getApplicationContext();
|
||||||
CharSequence contentTitle = "Droid VNC Server";
|
CharSequence contentTitle = "Droid VNC Server";
|
||||||
CharSequence contentText = "Client Connected from " + intent.getStringExtra("clientip");
|
CharSequence contentText = "Client Connected from " + c;
|
||||||
Intent notificationIntent = new Intent();
|
Intent notificationIntent = new Intent();
|
||||||
PendingIntent contentIntent = PendingIntent.getActivity(context1, 0, notificationIntent, 0);
|
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))
|
||||||
//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");
|
||||||
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
wakeLock.acquire();
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
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)
|
private static File findExecutableOnPath(String executableName)
|
||||||
{
|
{
|
||||||
|
@ -60,6 +60,8 @@ public class MainApplication extends Application {
|
|||||||
|
|
||||||
OutputStream os = sh.getOutputStream();
|
OutputStream os = sh.getOutputStream();
|
||||||
|
|
||||||
|
writeCommand(os, "killall androidvncserver");
|
||||||
|
writeCommand(os, "killall -KILL androidvncserver");
|
||||||
//chmod 777 SHOULD exist
|
//chmod 777 SHOULD exist
|
||||||
writeCommand(os, "chmod 777 " + getFilesDir().getAbsolutePath() + "/androidvncserver");
|
writeCommand(os, "chmod 777 " + getFilesDir().getAbsolutePath() + "/androidvncserver");
|
||||||
os.close();
|
os.close();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user