DroidX sliding fixed (must confirm),Seach was not working in Ctrl button,system notification when client connects

This commit is contained in:
Jose Pereira 2010-09-27 11:03:40 +01:00
parent 8eee54e5dd
commit c515298af4
87 changed files with 264 additions and 460 deletions

View File

@ -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_donate" android:versionName="v0.91" android:versionCode="42">
android:versionCode="43" android:versionName="0.92 DroidX sliding fixed (must confirm),Seach was not working in Ctrl button,system notification when client connects" package="org.onaips.vnc">
<uses-sdk android:minSdkVersion="3" />
<application android:debuggable="false" android:icon="@drawable/icon"
android:label="droid VNC server" android:name="MainApplication">
@ -22,7 +22,7 @@
<service android:name="StartAtBootService">
<intent-filter>
<action android:name="org.onaips.vnc_donate.StartAtBootService"></action>
<action android:name="org.onaips.vnc.StartAtBootService"></action>
</intent-filter>
</service>
@ -34,6 +34,14 @@
</category>
</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>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>

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/R.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.

View File

@ -5,7 +5,7 @@
* should not be modified by hand.
*/
package org.onaips.vnc_donate;
package org.onaips.vnc;
public final class R {
public static final class array {
@ -78,7 +78,8 @@ containing a value of this type.
public static final int Button02=0x7f090001;
public static final int TextView01=0x7f090002;
public static final int TextView02=0x7f090004;
public static final int preferences=0x7f090005;
public static final int banner_adview=0x7f090005;
public static final int preferences=0x7f090006;
public static final int stateLabel=0x7f090003;
}
public static final class layout {
@ -107,11 +108,11 @@ containing a value of this type.
<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_donate:backgroundColor}</code></td><td></td></tr>
<tr><td><code>{@link #com_admob_android_ads_AdView_keywords org.onaips.vnc_donate:keywords}</code></td><td></td></tr>
<tr><td><code>{@link #com_admob_android_ads_AdView_primaryTextColor org.onaips.vnc_donate:primaryTextColor}</code></td><td></td></tr>
<tr><td><code>{@link #com_admob_android_ads_AdView_refreshInterval org.onaips.vnc_donate:refreshInterval}</code></td><td></td></tr>
<tr><td><code>{@link #com_admob_android_ads_AdView_secondaryTextColor org.onaips.vnc_donate:secondaryTextColor}</code></td><td></td></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
@ -124,7 +125,7 @@ containing a value of this type.
0x7f010004
};
/**
<p>This symbol is the offset where the {@link org.onaips.vnc_donate.R.attr#backgroundColor}
<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.
@ -139,7 +140,7 @@ containing a value of this type.
*/
public static final int com_admob_android_ads_AdView_backgroundColor = 0;
/**
<p>This symbol is the offset where the {@link org.onaips.vnc_donate.R.attr#keywords}
<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.
@ -153,7 +154,7 @@ containing a value of this type.
*/
public static final int com_admob_android_ads_AdView_keywords = 3;
/**
<p>This symbol is the offset where the {@link org.onaips.vnc_donate.R.attr#primaryTextColor}
<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.
@ -168,7 +169,7 @@ containing a value of this type.
*/
public static final int com_admob_android_ads_AdView_primaryTextColor = 1;
/**
<p>This symbol is the offset where the {@link org.onaips.vnc_donate.R.attr#refreshInterval}
<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.
@ -182,7 +183,7 @@ containing a value of this type.
*/
public static final int com_admob_android_ads_AdView_refreshInterval = 4;
/**
<p>This symbol is the offset where the {@link org.onaips.vnc_donate.R.attr#secondaryTextColor}
<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.

View File

@ -1,7 +1,6 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS += -DDONATE_VERSION
LOCAL_CFLAGS += -Wall

View File

@ -1,7 +1,7 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
#LOCAL_CFLAGS += -DDONATE_VERSION
LOCAL_CFLAGS += -DDONATE_VERSION
LOCAL_CFLAGS += -Wall

View File

@ -73,7 +73,7 @@ static unsigned int *cmpbuf;
static rfbScreenInfoPtr vncscr;
int idle=0,standby=0,change=0;
int idle=0,standby=0,change=0,donate_version=0;
static int rotation=0,scaling=0;
/*****************************************************************************/
@ -95,9 +95,8 @@ void update_fb_info()
}
#define PIXEL_TO_VIRTUALPIXEL(i,j) ((j+scrinfo.yoffset)*scrinfo.xres_virtual+i)
// #define PIXEL_TO_VIRTUALPIXEL(i,j) ((j+scrinfo.yoffset)*scrinfo.xres_virtual+i+scrinfo.xoffset)
// #define PIXEL_TO_VIRTUALPIXEL(i,j) ((j+scrinfo.yoffset)*scrinfo.xres_virtual+i)
#define PIXEL_TO_VIRTUALPIXEL(i,j) ((j+scrinfo.yoffset)*scrinfo.xres_virtual+i+scrinfo.xoffset)
#define OUT 32
#include "update_screen.c"
#define OUT 8
@ -112,7 +111,6 @@ inline size_t roundUpToPageSize(size_t x) {
static void init_fb(void)
{
size_t pixels;
size_t bytespp;
if ((fbfd = open(framebuffer_device, O_RDWR)) == -1)
@ -130,7 +128,6 @@ static void init_fb(void)
exit(EXIT_FAILURE);
}
pixels = scrinfo.xres * scrinfo.yres;
bytespp = scrinfo.bits_per_pixel /CHAR_BIT;
__android_log_print(ANDROID_LOG_INFO,"VNC", "line_lenght=%d xres=%d, yres=%d, xresv=%d, yresv=%d, xoffs=%d, yoffs=%d, bpp=%d\n",
@ -139,9 +136,16 @@ static void init_fb(void)
(int)scrinfo.xoffset, (int)scrinfo.yoffset,
(int)scrinfo.bits_per_pixel);
printf("AKII\n");
size_t fbSize = roundUpToPageSize(fscrinfo.line_length * scrinfo.yres_virtual);
size_t size=scrinfo.yres_virtual;
if (size<scrinfo.yres*2)
{
__android_log_print(ANDROID_LOG_INFO,"VNC","Using Droid workaround\n");
size=scrinfo.yres*2;
}
size_t fbSize = roundUpToPageSize(fscrinfo.line_length * size);
fbmmap = mmap(NULL, fbSize , PROT_READ|PROT_WRITE , MAP_SHARED , fbfd, 0);
@ -186,6 +190,28 @@ static void cleanup_kbd()
}
/*****************************************************************************/
void *sendClientDisconnectedNotification(void *t)
{
system("am broadcast -a org.onaips.vnc.intent.action.DaemonCommunication.ClientDisconnected");
pthread_exit(NULL);
}
void *sendClientConnectedNotification(void *t)
{
system("am broadcast -a org.onaips.vnc.intent.action.DaemonCommunication.ClientConnected");
pthread_exit(NULL);
}
static ClientGoneHookPtr clientGone(rfbClientPtr cl)
{
pthread_t t;
pthread_create(&t, NULL, sendClientDisconnectedNotification, NULL);
return 0;
}
static rfbNewClientHookPtr clientHook(rfbClientPtr cl)
{
@ -195,6 +221,11 @@ static rfbNewClientHookPtr clientHook(rfbClientPtr cl)
}
pthread_t t;
pthread_create(&t, NULL, sendClientConnectedNotification, NULL);
cl->clientGoneHook=clientGone;
return RFB_CLIENT_ACCEPT;
}
@ -237,11 +268,12 @@ static void init_fb_server(int argc, char **argv)
vncscr->passwordCheck = rfbCheckPasswordByList;
}
#ifdef DONATE_VERSION
if (donate_version)
vncscr->httpDir="/data/data/org.onaips.vnc_donate/files/";
#else
else
vncscr->httpDir="/data/data/org.onaips.vnc/files/";
#endif
vncscr->serverFormat.redShift=scrinfo.red.offset;
vncscr->serverFormat.greenShift=scrinfo.green.offset;
@ -292,7 +324,7 @@ static void keyevent(rfbBool down, rfbKeySym key, rfbClientPtr cl)
{
int code;
__android_log_print(ANDROID_LOG_INFO,"VNC","Got keysym: %04x (down=%d)\n", (unsigned int)key, (int)down);
// __android_log_print(ANDROID_LOG_INFO,"VNC","Got keysym: %04x (down=%d)\n", (unsigned int)key, (int)down);
int sh = 0;
int alt = 0;
@ -300,7 +332,7 @@ static void keyevent(rfbBool down, rfbKeySym key, rfbClientPtr cl)
if ((code = keysym2scancode(down, key, cl,&sh,&alt)))
{
int ret;
int ret=0;
if (key && down)
{
@ -316,7 +348,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);
}
}
@ -396,6 +428,7 @@ static int keysym2scancode(rfbBool down, rfbKeySym c, rfbClientPtr cl, int *sh,
case 0xffff: return 158;// del -> back
case 0xff55: return 229;// PgUp -> menu
case 0xffcf: return 127;// F2 -> search
case 0xffe3: return 127;// left ctrl -> search
case 0xff56: return 61;// PgUp -> call
case 0xff57: return 107;// End -> endcall
case 0xffc2: return 211;// F5 -> focus
@ -705,6 +738,9 @@ int main(int argc, char **argv)
i++;
VNC_PORT=atoi(argv[i]);
break;
case 'd':
donate_version=1;
break;
case 'r':
i++;
r=atoi(argv[i]);
@ -754,7 +790,6 @@ int main(int argc, char **argv)
else
rfbProcessEvents(vncscr, 10000);
update_screen();
}

View File

@ -73,7 +73,7 @@ static unsigned int *cmpbuf;
static rfbScreenInfoPtr vncscr;
int idle=0,standby=0,change=0;
int idle=0,standby=0,change=0,donate_version=0;
static int rotation=0,scaling=0;
/*****************************************************************************/
@ -95,9 +95,8 @@ void update_fb_info()
}
#define PIXEL_TO_VIRTUALPIXEL(i,j) ((j+scrinfo.yoffset)*scrinfo.xres_virtual+i)
// #define PIXEL_TO_VIRTUALPIXEL(i,j) ((j+scrinfo.yoffset)*scrinfo.xres_virtual+i+scrinfo.xoffset)
// #define PIXEL_TO_VIRTUALPIXEL(i,j) ((j+scrinfo.yoffset)*scrinfo.xres_virtual+i)
#define PIXEL_TO_VIRTUALPIXEL(i,j) ((j+scrinfo.yoffset)*scrinfo.xres_virtual+i+scrinfo.xoffset)
#define OUT 32
#include "update_screen.c"
#define OUT 8
@ -112,7 +111,6 @@ inline size_t roundUpToPageSize(size_t x) {
static void init_fb(void)
{
size_t pixels;
size_t bytespp;
if ((fbfd = open(framebuffer_device, O_RDWR)) == -1)
@ -130,7 +128,6 @@ static void init_fb(void)
exit(EXIT_FAILURE);
}
pixels = scrinfo.xres * scrinfo.yres;
bytespp = scrinfo.bits_per_pixel /CHAR_BIT;
__android_log_print(ANDROID_LOG_INFO,"VNC", "line_lenght=%d xres=%d, yres=%d, xresv=%d, yresv=%d, xoffs=%d, yoffs=%d, bpp=%d\n",
@ -139,9 +136,16 @@ static void init_fb(void)
(int)scrinfo.xoffset, (int)scrinfo.yoffset,
(int)scrinfo.bits_per_pixel);
printf("AKII\n");
size_t fbSize = roundUpToPageSize(fscrinfo.line_length * scrinfo.yres_virtual);
size_t size=scrinfo.yres_virtual;
if (size<scrinfo.yres*2)
{
__android_log_print(ANDROID_LOG_INFO,"VNC","Using Droid workaround\n");
size=scrinfo.yres*2;
}
size_t fbSize = roundUpToPageSize(fscrinfo.line_length * size);
fbmmap = mmap(NULL, fbSize , PROT_READ|PROT_WRITE , MAP_SHARED , fbfd, 0);
@ -186,6 +190,28 @@ static void cleanup_kbd()
}
/*****************************************************************************/
void *sendClientDisconnectedNotification(void *t)
{
system("am broadcast -a org.onaips.vnc.intent.action.DaemonCommunication.ClientDisconnected");
pthread_exit(NULL);
}
void *sendClientConnectedNotification(void *t)
{
system("am broadcast -a org.onaips.vnc.intent.action.DaemonCommunication.ClientConnected");
pthread_exit(NULL);
}
static ClientGoneHookPtr clientGone(rfbClientPtr cl)
{
pthread_t t;
pthread_create(&t, NULL, sendClientDisconnectedNotification, NULL);
return 0;
}
static rfbNewClientHookPtr clientHook(rfbClientPtr cl)
{
@ -195,6 +221,11 @@ static rfbNewClientHookPtr clientHook(rfbClientPtr cl)
}
pthread_t t;
pthread_create(&t, NULL, sendClientConnectedNotification, NULL);
cl->clientGoneHook=clientGone;
return RFB_CLIENT_ACCEPT;
}
@ -237,11 +268,13 @@ static void init_fb_server(int argc, char **argv)
vncscr->passwordCheck = rfbCheckPasswordByList;
}
#ifdef DONATE_VERSION
if (donate_version)
vncscr->httpDir="/data/data/org.onaips.vnc_donate/files/";
#else
else
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;
@ -291,7 +324,7 @@ static void keyevent(rfbBool down, rfbKeySym key, rfbClientPtr cl)
{
int code;
__android_log_print(ANDROID_LOG_INFO,"VNC","Got keysym: %04x (down=%d)\n", (unsigned int)key, (int)down);
// __android_log_print(ANDROID_LOG_INFO,"VNC","Got keysym: %04x (down=%d)\n", (unsigned int)key, (int)down);
int sh = 0;
int alt = 0;
@ -299,7 +332,7 @@ static void keyevent(rfbBool down, rfbKeySym key, rfbClientPtr cl)
if ((code = keysym2scancode(down, key, cl,&sh,&alt)))
{
int ret;
int ret=0;
if (key && down)
{
@ -315,7 +348,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);
}
}
@ -395,6 +428,7 @@ static int keysym2scancode(rfbBool down, rfbKeySym c, rfbClientPtr cl, int *sh,
case 0xffff: return 158;// del -> back
case 0xff55: return 229;// PgUp -> menu
case 0xffcf: return 127;// F2 -> search
case 0xffe3: return 127;// left ctrl -> search
case 0xff56: return 61;// PgUp -> call
case 0xff57: return 107;// End -> endcall
case 0xffc2: return 211;// F5 -> focus
@ -704,6 +738,9 @@ int main(int argc, char **argv)
i++;
VNC_PORT=atoi(argv[i]);
break;
case 'd':
donate_version=1;
break;
case 'r':
i++;
r=atoi(argv[i]);
@ -753,7 +790,6 @@ int main(int argc, char **argv)
else
rfbProcessEvents(vncscr, 10000);
update_screen();
}

View File

@ -1,225 +0,0 @@
/*
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);
}

View File

@ -1,165 +0,0 @@
#define OUT_T CONCAT3E(uint,OUT,_t)
#define FUNCTION CONCAT2E(update_screen_,OUT)
void FUNCTION(void)
{
static int i,j;
update_fb_info();
// // detect active buffer
// offset= (scrinfo.xoffset) * (scrinfo.bits_per_pixel/8) +
// (scrinfo.yoffset) * scrinfo.xres;
// if (scrinfo.yoffset)
// offset=scrinfo.xres*scrinfo.yoffset;
// else
// offset=0;
// offset = scrinfo.xres * scrinfo.yoffset + scrinfo.xoffset * scrinfo.bits_per_pixel / CHAR_BIT;
OUT_T* a = (OUT_T*)cmpbuf;
OUT_T* b = (OUT_T*)fbmmap;
int max_x=-1,max_y=-1, min_x=9999, min_y=9999;
idle=1;
if (rotation==0)
{
//memcpy(vncbuf,fbmmap,vncscr->width*vncscr->height*scrinfo.bits_per_pixel/CHAR_BIT);
for (j = 0; j < scrinfo.yres; j++)
{
for (i = 0; i < scrinfo.xres; i++)
{
if (a[i + j * scrinfo.xres]!=b[PIXEL_TO_VIRTUALPIXEL(i,j)])
{
a[i + j * scrinfo.xres]=b[PIXEL_TO_VIRTUALPIXEL(i,j)];
if (i>max_x)
max_x=i;
if (i<min_x)
min_x=i;
if (j>max_y)
max_y=j;
if (j<min_y)
min_y=j;
if (idle)
idle=0;
}
}
}
}
else if (rotation==90)
{
for (j = 0; j < scrinfo.yres; j++)
{
for (i = 0; i < scrinfo.xres; i++)
{
if (a[(scrinfo.yres - 1 - j + i * scrinfo.yres)] != b[PIXEL_TO_VIRTUALPIXEL(i,j)])
{
a[(scrinfo.yres - 1 - j + i * scrinfo.yres)] = b[PIXEL_TO_VIRTUALPIXEL(i,j)];
if (i>max_y)
max_y=i;
if (i<min_y)
min_y=i;
int h=scrinfo.yres-j;
if (h < min_x)
min_x=scrinfo.yres-j;
if (h > max_x)
max_x=scrinfo.yres-j;
if (idle)
idle=0;
}
}
}
}
else if (rotation==180)
{
for (j = 0; j < scrinfo.yres; j++)
{
for (i = 0; i < scrinfo.xres; i++)
{
if (a[((scrinfo.xres - 1 - i) + (scrinfo.yres - 1 - j) * scrinfo.xres)]!=b[PIXEL_TO_VIRTUALPIXEL(i,j)])
{
a[((scrinfo.xres - 1 - i) + (scrinfo.yres - 1 - j) * scrinfo.xres)]=b[PIXEL_TO_VIRTUALPIXEL(i,j)];
if (i>max_x)
max_x=i;
if (i<min_x)
min_x=i;
int h=scrinfo.yres-j;
if (h < min_y)
min_y=scrinfo.yres-j;
if (h > max_y)
max_y=scrinfo.yres-j;
if (idle)
idle=0;
}
}
}
}
else if (rotation==270)
{
for (j = 0; j < scrinfo.yres; j++)
{
for (i = 0; i < scrinfo.xres; i++)
{
if(a[j + (scrinfo.xres - 1 - i) * scrinfo.yres] != b[PIXEL_TO_VIRTUALPIXEL(i,j)])
{
a[j + (scrinfo.xres - 1 - i) * scrinfo.yres] = b[PIXEL_TO_VIRTUALPIXEL(i,j)];
if (i>max_y)
max_y=i;
if (i<min_y)
min_y=i;
if (j < min_x)
min_x=j;
if (j > max_x)
max_x=j;
if (idle)
idle=0;
}
}
}
}
memcpy(vncbuf,a,vncscr->width*vncscr->height*scrinfo.bits_per_pixel/CHAR_BIT);
if (min_x!=9999 && min_y!=9999 && max_x!=-1 && max_y!=-1)
{
max_x++;
max_y++;
rfbMarkRectAsModified(vncscr, min_x, min_y, max_x, max_y);
rfbProcessEvents(vncscr, 100000);
}
if (idle)
{
standby=standby+1;
//__android_log_print(ANDROID_LOG_INFO,"VNC","standby %d xoff=%d yoff=%d offset=%d\n",standby,scrinfo.xoffset,scrinfo.yoffset,PIXEL_TO_VIRTUALPIXEL(i,j));
change=0;
}
else
{
change=change+1;
standby=0;
// __android_log_print(ANDROID_LOG_INFO,"VNC","change %d\tmin_x=%d max_x=%d min_y=%d max_y=%d xoff=%d yoff=%d offset=%d\n",change,min_x,max_x,min_y,max_y,scrinfo.xoffset,scrinfo.yoffset,PIXEL_TO_VIRTUALPIXEL(i,j));
}
}

Binary file not shown.

View File

@ -57,7 +57,6 @@
</LinearLayout>
<!--
<com.mobclix.android.sdk.MobclixMMABannerXLAdView
android:id="@+id/banner_adview"
@ -65,5 +64,5 @@ android:layout_height="50dip"
android:layout_width="320dip"
android:layout_gravity="bottom"
android:layout_alignParentBottom="true"
/> -->
/>
</RelativeLayout>

Binary file not shown.

View File

@ -0,0 +1,55 @@
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);
if (action.equalsIgnoreCase("org.onaips.vnc.intent.action.DaemonCommunication.ClientConnected"))
{
// String ns = Context.NOTIFICATION_SERVICE;
//NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
Log.v("VNC","daemoncom");
Intent i = new Intent("org.onaips.vnc.CLIENTCONNECTED");
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); }
else if (action.equalsIgnoreCase("org.onaips.vnc.intent.action.DaemonCommunication.ClientDisconnected"))
{
Log.v("VNC","daemoncom");
Intent 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);
}
}
}

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onaips.vnc_donate;
package org.onaips.vnc;
import java.io.BufferedReader;
import java.io.File;
@ -37,6 +37,9 @@ import java.util.regex.Pattern;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
@ -78,7 +81,8 @@ public class MainActivity extends Activity
private static final int MENU_ONAIPS = 2;
private static final int MENU_SENDLOG = 3;
private static final int MENU_CHANGELOG = 4;
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 static final int APP_ID = 123;
private static final String changelog="(i'm looking for someone to write a tutorial for vnc server)<br><br>- DroidX not sliding now (must confirm)<br>- [Fix] Seach was not working in Ctrl<br>- [Add] System notification when client connects";
private PowerManager.WakeLock wakeLock = null;
private Timer watchdogTimer=null;
@ -132,7 +136,11 @@ public class MainActivity extends Activity
// register wifi event receiver
mReceiver receiver=new mReceiver();
this.registerReceiver(receiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
registerReceiver(receiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
registerReceiver(receiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
registerReceiver(activityReceiver, new IntentFilter("org.onaips.vnc.CLIENTCONNECTED"));
registerReceiver(activityReceiver, new IntentFilter("org.onaips.vnc.CLIENTDISCONNECTED"));
setStateLabels(isAndroidServerRunning());
@ -379,6 +387,11 @@ public class MainActivity extends Activity
os.flush();
os.close();
//lets clear notifications
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
mNotificationManager.cancel(APP_ID);
} catch (IOException e) {
showTextOnScreen("stopServer()" + e.getMessage());
Log.v("VNC","stopServer()" + e.getMessage());
@ -427,6 +440,8 @@ public class MainActivity extends Activity
if (!scaling.equals("0"))
scaling_string="-s " + scaling;
String donate=free_version()?"":" -d ";
String port=preferences.getString("port", "5901");
try
{
@ -442,7 +457,7 @@ public class MainActivity extends Activity
sh = Runtime.getRuntime().exec("su");
OutputStream os = sh.getOutputStream();
writeCommand(os, getFilesDir().getAbsolutePath() + "/androidvncserver "+ password_check + " " + rotation + " " + scaling_string + " " + port_string);
writeCommand(os, getFilesDir().getAbsolutePath() + "/androidvncserver "+ password_check + " " + rotation + " " + scaling_string + " " + port_string + donate);
} catch (IOException e) {
@ -704,4 +719,40 @@ public class MainActivity extends Activity
}
}
};
public BroadcastReceiver activityReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context1, Intent intent) {
final int HELLO_ID = 1;
if (intent.getAction().equalsIgnoreCase("org.onaips.vnc.CLIENTCONNECTED"))
{
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
int icon = R.drawable.icon;
CharSequence tickerText = "Client connected to VNC server";
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
Context context = getApplicationContext();
CharSequence contentTitle = "Droid VNC Server";
CharSequence contentText = "Client Connected";
Intent notificationIntent = new Intent();
PendingIntent contentIntent = PendingIntent.getActivity(context1, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
mNotificationManager.notify(APP_ID, notification);
}
else if (intent.getAction().equalsIgnoreCase("org.onaips.vnc.CLIENTDISCONNECTED"))
{
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
mNotificationManager.cancel(APP_ID);
}
}
};
}

View File

@ -1,4 +1,4 @@
package org.onaips.vnc_donate;
package org.onaips.vnc;
import java.io.FileOutputStream;
import java.io.IOException;

View File

@ -1,4 +1,4 @@
package org.onaips.vnc_donate;
package org.onaips.vnc;
import java.io.IOException;
import java.io.OutputStream;
@ -29,6 +29,12 @@ public class StartAtBootService extends Service {
}
public boolean free_version()
{
return getPackageName().equals("org.onaips.vnc");
}
public void startServer()
{
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
@ -43,6 +49,7 @@ public class StartAtBootService extends Service {
try{
Process sh;
String password=preferences.getString("password", "");
String password_check="";
if (!password.equals(""))
@ -58,6 +65,8 @@ public class StartAtBootService extends Service {
if (!scaling.equals("0"))
scaling_string="-s " + scaling;
String donate=free_version()?"":" -d ";
String port=preferences.getString("port", "5901");
try
{
@ -73,7 +82,8 @@ public class StartAtBootService extends Service {
sh = Runtime.getRuntime().exec("su");
OutputStream os = sh.getOutputStream();
writeCommand(os, getFilesDir().getAbsolutePath() + "/androidvncserver "+ password_check + " " + rotation + " " + scaling_string + " " + port_string);
writeCommand(os, getFilesDir().getAbsolutePath() + "/androidvncserver "+ password_check + " " + rotation + " " + scaling_string + " " + port_string + donate);
} catch (IOException e) {
Log.v("VNC","startServer():" + e.getMessage());

View File

@ -1,4 +1,4 @@
package org.onaips.vnc_donate;
package org.onaips.vnc;
import android.content.BroadcastReceiver;
import android.content.Context;
@ -11,7 +11,7 @@ public class StartAtBootServiceReceiver extends BroadcastReceiver
{
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
Intent i = new Intent();
i.setAction(context.getPackageName() + ".StartAtBootService");
i.setAction("org.onaips.vnc.StartAtBootService");
context.startService(i);
}
}

View File

@ -1,4 +1,4 @@
package org.onaips.vnc_donate;
package org.onaips.vnc;