diff --git a/.classpath b/.classpath index 75ddfe0..63cbd5d 100755 --- a/.classpath +++ b/.classpath @@ -3,6 +3,7 @@ - - + + + diff --git a/.gitignore b/.gitignore index ba077a4..3976471 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ bin +gen +libs +obj diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 48c11df..c8e3040 100755 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,49 +1,74 @@ - - - + package="org.onaips.vnc" + android:versionCode="56" + android:versionName="1.0a3" > + + + + + + + + + + + + - - - - - + + + + + - - - - + + + + + + - - - - - + + + + + + - - - - - - + + + - - - - - - - - - - + + + + + + + + + + + + + + + + - - \ No newline at end of file + \ No newline at end of file diff --git a/CHANGELOG b/CHANGELOG index 0c6fa76..8a6620c 100755 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,7 @@ +v1.1a -- Changed to official libvncserver 0.9- Changed to official libvncserver 0.99 -- Decoupled native screen grabber from jni sources, you wont need to have AOSP anymore - +- Changed to official libvncserver v0.9.9. +- Decoupled native screen grabber from jni sources, you wont need to have AOSP anymore, just the precompiled libs. v1.0a diff --git a/README b/README index 778b5a7..46198fa 100644 --- a/README +++ b/README @@ -1,12 +1,9 @@ -the Droid VNC server projects consists in two parts: the daemon and GUI. +The droid-VNC-server projects consists in two parts: the daemon and GUI. - -GUI handles general user input, and connects to the daemon using local IPC. You can compile it using Eclipse or Ant (not tested for long time). +GUI handles general user input, and connects to the daemon using local IPC. You can compile it using Eclipse or Ant (the latter not tested though). If you wish to contribute to the project, just fork it and commit some interesting features... - - -------------- Compile C daemon ------------------- NOTE: to compile the C daemon you must have a working AOSP source tree, and copy it to external folder. Do something like: diff --git a/TODO b/TODO index b491a08..fb3b8d6 100755 --- a/TODO +++ b/TODO @@ -1,5 +1,9 @@ -- change tcp socket to unix socket -- click on address field will iterate show interface addresses -- map volume keys -- custom key mapping -- add MIPS and X86 to APP_ABI (and more) +[ADD] GnuTLS support (already working on libvncserver) +[ADD] Map volume keys +[ADD] Custom key mapping +[ADD] MIPS and X86 to APP_ABI (and more) +[ADD] Key/Touch injection though WindowManagerService/Binder mechanism (looking for a aidl->cpp translator) + +[CHANGE] Tcp socket to unix socket + +[FIX] Click on address field will iterate show interface addresses diff --git a/default.properties b/default.properties deleted file mode 100755 index 66db0d1..0000000 --- a/default.properties +++ /dev/null @@ -1,11 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "build.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-10 diff --git a/droidvncgrab/Android.mk b/droidvncgrab/Android.mk deleted file mode 100755 index 83ff374..0000000 --- a/droidvncgrab/Android.mk +++ /dev/null @@ -1,24 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES = \ - droidVncGrab.cpp - -#LOCAL_CFLAGS += -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION) - -LOCAL_C_INCLUDES += $(LOCAL_PATH) - -LOCAL_PRELINK_MODULE:=false #override prelink map -LOCAL_MODULE:= droidvncgrab_sdk$(PLATFORM_SDK_VERSION) -LOCAL_MODULE_TAGS:= optional - -ifeq ($(PLATFORM_SDK_VERSION),9) -LOCAL_SHARED_LIBRARIES := libsurfaceflinger_client libui libbinder libutils libcutils #libcrypto libssl libhardware -else ifeq ($(PLATFORM_SDK_VERSION),15) -LOCAL_SHARED_LIBRARIES := libgui libui libbinder libcutils -else -#add here more sdk versions -LOCAL_SHARED_LIBRARIES := libsurfaceflinger_client libui libbinder libutils libcutils #libcrypto libssl libhardware -endif - -include $(BUILD_SHARED_LIBRARY) diff --git a/droidvncgrab/README b/droidvncgrab/README deleted file mode 100644 index 28eb82f..0000000 --- a/droidvncgrab/README +++ /dev/null @@ -1 +0,0 @@ -This diff --git a/droidvncgrab/droidVncGrab.cpp b/droidvncgrab/droidVncGrab.cpp deleted file mode 100755 index 95d7a2e..0000000 --- a/droidvncgrab/droidVncGrab.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - droid vnc server - Android VNC server - Copyright (C) 2009 Jose Pereira - - 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 "droidVncGrab.h" -#include "screenFormat.h" - -#include -#include -#include - -#include -#include -#include - -using namespace android; - -ScreenshotClient *screenshotClient=NULL; - -extern "C" screenFormat getScreenFormat() -{ - //get format on PixelFormat struct - PixelFormat f=screenshotClient->getFormat(); - - PixelFormatInfo pf; - getPixelFormatInfo(f,&pf); - - screenFormat format; - - format.bitsPerPixel = pf.bitsPerPixel; - format.width = screenshotClient->getWidth(); - format.height = screenshotClient->getHeight(); - format.size = pf.bitsPerPixel*format.width*format.height/CHAR_BIT; - format.redShift = pf.l_red; - format.redMax = pf.h_red; - format.greenShift = pf.l_green; - format.greenMax = pf.h_green-pf.h_red; - format.blueShift = pf.l_blue; - format.blueMax = pf.h_blue-pf.h_green; - format.alphaShift = pf.l_alpha; - format.alphaMax = pf.h_alpha-pf.h_blue; - - return format; -} - - -extern "C" int initScreenGrab() -{ - int errno; - - L("--Initializing gingerbread access method--\n"); - - screenshotClient=new ScreenshotClient(); - errno=screenshotClient->update(); - if (errno != NO_ERROR) { - L("screen capture failed: %s\n", strerror(-errno)); - return -1; - } - - return 0; -} - -extern "C" unsigned int * getScreenBuffer() -{ - screenshotClient->update(); - return (unsigned int*)screenshotClient->getPixels(); -} - diff --git a/droidvncgrab/droidVncGrab.h b/droidvncgrab/droidVncGrab.h deleted file mode 100755 index 76366b3..0000000 --- a/droidvncgrab/droidVncGrab.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - droid vnc server - Android VNC server - Copyright (C) 2009 Jose Pereira - - 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 - */ - -#ifndef DISPLAY_BINDER -#define DISPLAY_BINDER - -#ifdef __cplusplus -#define L(...) __android_log_print(ANDROID_LOG_INFO,"VNCserver",__VA_ARGS__);printf(__VA_ARGS__); - - -extern "C" { -#endif - unsigned int * updateScreen(); - int initScreenGrab(); -#ifdef __cplusplus -} - -#endif - -#endif diff --git a/droidvncgrab/screenFormat.h b/droidvncgrab/screenFormat.h deleted file mode 100644 index a8d35ff..0000000 --- a/droidvncgrab/screenFormat.h +++ /dev/null @@ -1,26 +0,0 @@ -#include - - -typedef struct _screenFormat -{ - - uint16_t width; - uint16_t height; - - uint8_t bitsPerPixel; - - uint16_t redMax; - uint16_t greenMax; - uint16_t blueMax; - uint16_t alphaMax; - - uint8_t redShift; - uint8_t greenShift; - uint8_t blueShift; - uint8_t alphaShift; - - uint32_t size; - - uint32_t pad; - -} screenFormat; diff --git a/jni/openssl/Android.mk b/jni/openssl/Android.mk index 207311a..95f9371 100644 --- a/jni/openssl/Android.mk +++ b/jni/openssl/Android.mk @@ -3,7 +3,6 @@ LOCAL_PATH := $(call my-dir) subdirs := $(addprefix $(LOCAL_PATH)/,$(addsuffix /Android.mk, \ crypto \ ssl \ -# apps \ )) include $(subdirs) diff --git a/jni/openssl/crypto/Android.mk b/jni/openssl/crypto/Android.mk index 6f09fa5..5b94649 100644 --- a/jni/openssl/crypto/Android.mk +++ b/jni/openssl/crypto/Android.mk @@ -470,12 +470,11 @@ local_src_files := \ x509v3/v3err.c local_c_includes := \ - external/openssl \ - external/openssl/crypto/asn1 \ - external/openssl/crypto/evp \ - external/openssl/include \ - external/openssl/include/openssl \ - external/zlib + $(LOCAL_PATH)/../ \ + $(LOCAL_PATH)/../crypto/asn1 \ + $(LOCAL_PATH)/../crypto/evp \ + $(LOCAL_PATH)/../include \ + $(LOCAL_PATH)/../include/openssl local_c_flags := -DNO_WINDOWS_BRAINDEATH @@ -504,56 +503,56 @@ include $(BUILD_STATIC_LIBRARY) ####################################### # target shared library -include $(CLEAR_VARS) -include $(LOCAL_PATH)/../android-config.mk - -ifneq ($(TARGET_ARCH),x86) -LOCAL_NDK_VERSION := 5 -LOCAL_SDK_VERSION := 9 -# Use the NDK prebuilt libz and libdl. -LOCAL_LDFLAGS += -lz -ldl -else -LOCAL_SHARED_LIBRARIES += libz libdl -endif - -LOCAL_SRC_FILES += $(local_src_files) -LOCAL_CFLAGS += $(local_c_flags) -LOCAL_C_INCLUDES += $(local_c_includes) -ifeq ($(TARGET_ARCH),arm) - LOCAL_SRC_FILES += $(arm_src_files) - LOCAL_CFLAGS += $(arm_cflags) -else - LOCAL_SRC_FILES += $(non_arm_src_files) -endif -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE:= libcrypto -include $(BUILD_SHARED_LIBRARY) - -####################################### -# host shared library -include $(CLEAR_VARS) -include $(LOCAL_PATH)/../android-config.mk -LOCAL_SRC_FILES += $(local_src_files) -LOCAL_CFLAGS += $(local_c_flags) -DPURIFY -LOCAL_C_INCLUDES += $(local_c_includes) -LOCAL_SRC_FILES += $(non_arm_src_files) -LOCAL_STATIC_LIBRARIES += libz -LOCAL_LDLIBS += -ldl -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE:= libcrypto -include $(BUILD_HOST_SHARED_LIBRARY) - +#include $(CLEAR_VARS) +#include $(LOCAL_PATH)/../android-config.mk +# +#ifneq ($(TARGET_ARCH),x86) +#LOCAL_NDK_VERSION := 5 +#LOCAL_SDK_VERSION := 9 +## Use the NDK prebuilt libz and libdl. +#LOCAL_LDFLAGS += -lz -ldl +#else +#LOCAL_SHARED_LIBRARIES += libz libdl +#endif +# +#LOCAL_SRC_FILES += $(local_src_files) +#LOCAL_CFLAGS += $(local_c_flags) +#LOCAL_C_INCLUDES += $(local_c_includes) +#ifeq ($(TARGET_ARCH),arm) +# LOCAL_SRC_FILES += $(arm_src_files) +# LOCAL_CFLAGS += $(arm_cflags) +#else +# LOCAL_SRC_FILES += $(non_arm_src_files) +#endif +#LOCAL_MODULE_TAGS := optional +#LOCAL_MODULE:= libcrypto +#include $(BUILD_SHARED_LIBRARY) +# ######################################## -# host static library, which is used by some SDK tools. - -include $(CLEAR_VARS) -include $(LOCAL_PATH)/../android-config.mk -LOCAL_SRC_FILES += $(local_src_files) -LOCAL_CFLAGS += $(local_c_flags) -DPURIFY -LOCAL_C_INCLUDES += $(local_c_includes) -LOCAL_SRC_FILES += $(non_arm_src_files) -LOCAL_STATIC_LIBRARIES += libz -LOCAL_LDLIBS += -ldl -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE:= libcrypto_static -include $(BUILD_HOST_STATIC_LIBRARY) +## host shared library +#include $(CLEAR_VARS) +#include $(LOCAL_PATH)/../android-config.mk +#LOCAL_SRC_FILES += $(local_src_files) +#LOCAL_CFLAGS += $(local_c_flags) -DPURIFY +#LOCAL_C_INCLUDES += $(local_c_includes) +#LOCAL_SRC_FILES += $(non_arm_src_files) +#LOCAL_STATIC_LIBRARIES += libz +#LOCAL_LDLIBS += -ldl +#LOCAL_MODULE_TAGS := optional +#LOCAL_MODULE:= libcrypto +#include $(BUILD_HOST_SHARED_LIBRARY) +# +######################################### +## host static library, which is used by some SDK tools. +# +#include $(CLEAR_VARS) +#include $(LOCAL_PATH)/../android-config.mk +#LOCAL_SRC_FILES += $(local_src_files) +#LOCAL_CFLAGS += $(local_c_flags) -DPURIFY +#LOCAL_C_INCLUDES += $(local_c_includes) +#LOCAL_SRC_FILES += $(non_arm_src_files) +#LOCAL_STATIC_LIBRARIES += libz +#LOCAL_LDLIBS += -ldl +#LOCAL_MODULE_TAGS := optional +#LOCAL_MODULE:= libcrypto_static +#include $(BUILD_HOST_STATIC_LIBRARY) diff --git a/jni/openssl/ssl/Android.mk b/jni/openssl/ssl/Android.mk index 487aabb..ed31ae6 100644 --- a/jni/openssl/ssl/Android.mk +++ b/jni/openssl/ssl/Android.mk @@ -1,9 +1,10 @@ LOCAL_PATH:= $(call my-dir) local_c_includes := \ - external/openssl \ - external/openssl/include \ - external/openssl/crypto + $(LOCAL_PATH)/../ \ + $(LOCAL_PATH)/../ssl\ + $(LOCAL_PATH)/../include \ + $(LOCAL_PATH)/../crypto local_src_files:= \ s2_meth.c \ @@ -61,38 +62,38 @@ include $(BUILD_STATIC_LIBRARY) ####################################### # target shared library -include $(CLEAR_VARS) -include $(LOCAL_PATH)/../android-config.mk - -ifneq ($(TARGET_ARCH),x86) -LOCAL_NDK_VERSION := 5 -LOCAL_SDK_VERSION := 9 -endif -LOCAL_SRC_FILES += $(local_src_files) -LOCAL_C_INCLUDES += $(local_c_includes) -LOCAL_SHARED_LIBRARIES += libcrypto -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE:= libssl -include $(BUILD_SHARED_LIBRARY) - -####################################### -# host shared library -include $(CLEAR_VARS) -include $(LOCAL_PATH)/../android-config.mk -LOCAL_SRC_FILES += $(local_src_files) -LOCAL_C_INCLUDES += $(local_c_includes) -LOCAL_SHARED_LIBRARIES += libcrypto -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE:= libssl -include $(BUILD_HOST_SHARED_LIBRARY) - -####################################### -# ssltest -include $(CLEAR_VARS) -include $(LOCAL_PATH)/../android-config.mk -LOCAL_SRC_FILES:= ssltest.c -LOCAL_C_INCLUDES += $(local_c_includes) -LOCAL_SHARED_LIBRARIES := libssl libcrypto -LOCAL_MODULE:= ssltest -LOCAL_MODULE_TAGS := optional -include $(BUILD_EXECUTABLE) +#include $(CLEAR_VARS) +#include $(LOCAL_PATH)/../android-config.mk +# +#ifneq ($(TARGET_ARCH),x86) +#LOCAL_NDK_VERSION := 5 +#LOCAL_SDK_VERSION := 9 +#endif +#LOCAL_SRC_FILES += $(local_src_files) +#LOCAL_C_INCLUDES += $(local_c_includes) +#LOCAL_SHARED_LIBRARIES += libcrypto +#LOCAL_MODULE_TAGS := optional +#LOCAL_MODULE:= libssl +#include $(BUILD_SHARED_LIBRARY) +# +######################################## +## host shared library +#include $(CLEAR_VARS) +#include $(LOCAL_PATH)/../android-config.mk +#LOCAL_SRC_FILES += $(local_src_files) +#LOCAL_C_INCLUDES += $(local_c_includes) +#LOCAL_SHARED_LIBRARIES += libcrypto +#LOCAL_MODULE_TAGS := optional +#LOCAL_MODULE:= libssl +#include $(BUILD_HOST_SHARED_LIBRARY) +# +######################################## +## ssltest +#include $(CLEAR_VARS) +#include $(LOCAL_PATH)/../android-config.mk +#LOCAL_SRC_FILES:= ssltest.c +#LOCAL_C_INCLUDES += $(local_c_includes) +#LOCAL_SHARED_LIBRARIES := libssl libcrypto +#LOCAL_MODULE:= ssltest +#LOCAL_MODULE_TAGS := optional +#include $(BUILD_EXECUTABLE) diff --git a/jni/vnc/adb_method.c b/jni/vnc/adb_method.c deleted file mode 100755 index 7da3e1a..0000000 --- a/jni/vnc/adb_method.c +++ /dev/null @@ -1,284 +0,0 @@ -/* -droid vnc server - Android VNC server -Copyright (C) 2009 Jose Pereira - -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 "adb_method.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -//#include "common.h" - - - -#define A_CNXN 0x4e584e43 -#define A_OKAY 0x59414b4f -#define A_CLSE 0x45534c43 -#define A_WRTE 0x45545257 - - -#define DDMS_RAWIMAGE_VERSION 1 - -char connect_string[] = { -0x43, 0x4e, 0x58, 0x4e, 0x00, 0x00, 0x00, 0x01, -0x00, 0x10, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, -0x32, 0x02, 0x00, 0x00, 0xbc, 0xb1, 0xa7, 0xb1, -0x68, 0x6f, 0x73, 0x74, 0x3a, 0x3a, 0x00 }; - -char framebuffer_string[] = { -0x4f, 0x50, 0x45, 0x4e, 0x01, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, -0xbf, 0x04, 0x00, 0x00, 0xb0, 0xaf, 0xba, 0xb1, -0x66, 0x72, 0x61, 0x6d, 0x65, 0x62, 0x75, 0x66, -0x66, 0x65, 0x72, 0x3a, 0x00 }; - -char okay_string[24]; - -struct fbinfo *fb_info; -struct _message *message,*okay_message; -int sockfd; - -ssize_t write_socket(int fd, const void *buf, size_t count) -{ -// L("--Writing %d \n",count); - - int n = write(fd,buf,count); - - if (n < 0) - perror("ERROR writing to socket"); - - return n; -} - - -void read_socket(int fd, void *buf, size_t count) -{ - int n=0; - - while (count>0) - { - n=read(fd,buf,count); - - if (n < 0) - L("ERROR reading from socket\n"); - - - count-=n; - } - return; -} - -void send_connect_string() -{ - write_socket(sockfd,connect_string,sizeof(connect_string)); - - read_socket(sockfd,message,sizeof(struct _message)); - - if (message->command!=A_CNXN) - L("bad A_CNXN response\n"); - - //lets read, i don't want this - read_socket(sockfd,message,message->data_length); -} - -void send_framebuffer_string(); - -int initADB() -{ - L("--Initializing adb access method--\n"); - int portno; - struct sockaddr_in serv_addr; - struct hostent *server; - adbbuf=NULL; - - property_set("service.adb.tcp.port", "5555"); - system("setprop service.adb.tcp.port 5555"); - system("adbd"); - - message=malloc(sizeof(struct _message)); - okay_message=malloc(sizeof(struct _message)); - - -// L("1\n"); - - portno = 5555; - sockfd = socket(AF_INET, SOCK_STREAM, 0); - if (sockfd < 0) - { - L("adb ERROR opening socket\n"); - return -1; - } -#ifdef ANDROID - server = gethostbyname("127.0.0.1"); -#else - server = gethostbyname("192.168.10.6"); -#endif - if (server == NULL) { - L("adb ERROR, no such host\n"); - return -1; - } - -// L("2\n"); - - bzero((char *) &serv_addr, sizeof(serv_addr)); - serv_addr.sin_family = AF_INET; - bcopy((char *)server->h_addr, - (char *)&serv_addr.sin_addr.s_addr, - server->h_length); - serv_addr.sin_port = htons(portno); - if (connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0) - { - L("adb ERROR connecting\n"); - return -1; - } - -// L("3\n"); - send_connect_string(); -// L("4\n"); -return 0; - } - - - -void send_framebuffer_string()//returns the fb struct size from adb -{ - int n; - char *buffer=NULL; - write_socket(sockfd,framebuffer_string,sizeof(framebuffer_string)); - read_socket(sockfd,okay_message,sizeof(struct _message)); - - if (okay_message->command!=A_OKAY) - { - L("---\ncommand=%32X\narg0=%32X\narg1=%32X\ndata_len=%d\n---\n",message->command,message->arg0,message->arg1,message->data_length); - L("bad OKAY response on send_framebuffer_string\n"); - - } - - n=okay_message->arg0; - okay_message->arg0=okay_message->arg1; - okay_message->arg1=n; - - -// L("arg0=%08X\narg1=%08X\n",okay_message->arg0,okay_message->arg1); - //we now have our okay message - - //lets receive fb info... - read_socket(sockfd,message,sizeof(struct _message)); - - - if (message->command!=A_WRTE) - L("bad WRTE response\n"); - -// L("---\ncommand=%32X\narg0=%32X\narg1=%32X\ndata_len=%d\n---\n",message->command,message->arg0,message->arg1,message->data_length); - -// if (message->data_length!=sizeof(struct _message)) -// error("Size should match..."); - - buffer=(char*)malloc(sizeof(char)*message->data_length); - - read_socket(sockfd,&displayInfo,sizeof(struct fbinfo)); - -// L("sizeof(struct fbinfo)=%d\n",sizeof(struct fbinfo)); - -// L("ADB framebuffer method:\nversion=%d\nbpp=%d\nsize=%d bytes\nwidth=%dpx\nheight=%dpx\nsize=%d\n", -// displayInfo.version,displayInfo.bpp,displayInfo.size,displayInfo.width,displayInfo.height,displayInfo.size); - -// L("sizeof(struct _message)=%d\n",sizeof(struct _message)); - write_socket(sockfd,okay_message,sizeof(struct _message)); - if (adbbuf==NULL) - adbbuf=(unsigned int*)malloc(displayInfo.size); - -} - -void updateADBFrame() - { - int n=0; - int count=0; - - send_framebuffer_string(); - -// L("1\n"); - - while (message->command!=A_CLSE) - { - read_socket(sockfd,message,sizeof(struct _message)); - -// L("---\ncommand=%32X\narg0=%32X\narg1=%32X\ndata_len=%d\n---\n",message->command,message->arg0,message->arg1,message->data_length); - - if (message->command==A_CLSE) - break; - else if (message->command!=A_WRTE) - { - L("Weird command received... %08X\n",message->command); - L("---\ncommand=%32X\narg0=%32X\narg1=%32X\ndata_len=%d\n---\n",message->command,message->arg0,message->arg1,message->data_length); - } - - - char * s=(char*)adbbuf+count; - read_socket(sockfd,s,message->data_length); - count+=message->data_length; - -// L("ahah %d %d\n",message->data_length,n); - - n=write_socket(sockfd,okay_message,sizeof(struct _message)); - if (n<0) - break; - } - -// L("Exit updating...\n"); -// L("Received %d bytes\n",count); - -// if (resp!=A_OKAY) -// error("bad OKAY response"); - - } - -#ifndef ANDROID - void main() -{ - connect_to_adb(); - L("up\n"); - update_frame(); - L("up\n"); - update_frame(); -} - -#endif -// int main(int argc, char *argv[]) -// { -// message=(struct _message*)malloc(sizeof(struct _message)); -// okay_message=(struct _message*)malloc(sizeof(struct _message)); -// -// connect_to_adb(); -// -// // adbbuf=calloc(fb_info->size,1); -// -// update_frame(); -// -// -// close(sockfd); -// return 0; -// } diff --git a/jni/vnc/adb_method.h b/jni/vnc/adb_method.h deleted file mode 100755 index 68631b0..0000000 --- a/jni/vnc/adb_method.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -droid vnc server - Android VNC server -Copyright (C) 2009 Jose Pereira - -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 -*/ - -#ifndef ADB_CONNECT_METHOD -#define ADB_CONNECT_METHOD - -#include -#include -#include -#include -#include -#include -#include -#include -// #include - -#include "common.h" - - - -#define A_CNXN 0x4e584e43 -#define A_OKAY 0x59414b4f -#define A_CLSE 0x45534c43 -#define A_WRTE 0x45545257 - - -#define DDMS_RAWIMAGE_VERSION 1 - -struct _message { - unsigned int command; /* command identifier constant */ - unsigned int arg0; /* first argument */ - unsigned int arg1; /* second argument */ - unsigned int data_length; /* length of payload (0 is allowed) */ - unsigned int data_crc32; /* crc32 of data payload */ - unsigned int magic; /* command ^ 0xffffffff */ -} __attribute__((packed)); - - - -// void error(const char *msg); -// ssize_t write_socket(int fd, const void *buf, size_t count); -// ssize_t read_socket(int fd, void *buf, size_t count); -// void send_connect_string(); - -int initADB(); -void updateADBFrame(); - -unsigned int *adbbuf; - -#endif diff --git a/jni/vnc/common.h b/jni/vnc/common.h deleted file mode 100755 index f4fd1b3..0000000 --- a/jni/vnc/common.h +++ /dev/null @@ -1,97 +0,0 @@ -/* -droid vnc server - Android VNC server -Copyright (C) 2009 Jose Pereira - -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 -*/ - -#ifndef COMMON_H -#define COMMON_H - -//android log -#include - - -#ifndef __cplusplus -/* libvncserver */ -#include "rfb/rfb.h" -#include "libvncserver/scale.h" -#include "rfb/keysym.h" -#include "suinput.h" - - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include /* For makedev() */ - -#include -#include -#include - -#include -#include - -#define SOCK_PATH "org.onaips.vnc.gui" - - -#include - - -// #define L(...) do { __android_log_print(ANDROID_LOG_INFO,"VNCserver",__VA_ARGS__); } while (0) - -// #define L(...) __android_log_print(ANDROID_LOG_INFO,"VNCserver",__VA_ARGS__);printf(__VA_ARGS__); - #define L(...) do{ __android_log_print(ANDROID_LOG_INFO,"VNCserver",__VA_ARGS__);printf(__VA_ARGS__); } while (0); -#endif - -struct fbinfo { - unsigned int version; - unsigned int bpp; - unsigned int size; - unsigned int width; - unsigned int height; - unsigned int red_offset; - unsigned int red_length; - unsigned int blue_offset; - unsigned int blue_length; - unsigned int green_offset; - unsigned int green_length; - unsigned int alpha_offset; - unsigned int alpha_length; -} __attribute__((packed)); - - - -void rotate(int); -int getCurrentRotation(); -int isIdle(); -void setIdle(int i); -void close_app(); -struct fbinfo displayInfo; - - - -#endif diff --git a/jni/vnc/displaybinder.cpp b/jni/vnc/displaybinder.cpp deleted file mode 100755 index 703c8f6..0000000 --- a/jni/vnc/displaybinder.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* -droid vnc server - Android VNC server -Copyright (C) 2009 Jose Pereira - -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 "displaybinder.h" -#include "common.h" - -#include -#include -#include - -#include -#include -#include - -using namespace android; - -ScreenshotClient *screenshotclient; - -extern "C" int initGingerbreadMethod() -{ - - L("--Initializing gingerbread access method--\n"); - - screenshotclient=new ScreenshotClient(); - int err=screenshotclient->update(); - if (err != NO_ERROR) { - L("screen capture failed: %s\n", strerror(-err)); - //mandar msg incompatible - return -1; - } - - PixelFormat f=screenshotclient->getFormat(); - - PixelFormatInfo pf; - getPixelFormatInfo(f,&pf); - - - displayInfo.bpp = pf.bitsPerPixel; - displayInfo.width = screenshotclient->getWidth(); - displayInfo.height = screenshotclient->getHeight();; - displayInfo.size = pf.bitsPerPixel*displayInfo.width*displayInfo.height/CHAR_BIT; - displayInfo.red_offset = pf.l_red; - displayInfo.red_length = pf.h_red; - displayInfo.green_offset = pf.l_green; - displayInfo.green_length = pf.h_green-pf.h_red; - displayInfo.blue_offset = pf.l_blue; - displayInfo.blue_length = pf.h_blue-pf.h_green; - displayInfo.alpha_offset = pf.l_alpha; - displayInfo.alpha_length = pf.h_alpha-pf.h_blue; - - return 0; - } - -extern "C" void updateScreen() -{ - screenshotclient->update(); - gingerbuf=(unsigned int*)screenshotclient->getPixels(); -} - diff --git a/jni/vnc/displaybinder.h b/jni/vnc/displaybinder.h deleted file mode 100755 index 99ee228..0000000 --- a/jni/vnc/displaybinder.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -droid vnc server - Android VNC server -Copyright (C) 2009 Jose Pereira - -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 -*/ - -#ifndef DISPLAY_BINDER -#define DISPLAY_BINDER - - -unsigned int *gingerbuf; - -#ifdef __cplusplus -#define L(...) __android_log_print(ANDROID_LOG_INFO,"VNCserver",__VA_ARGS__);printf(__VA_ARGS__); - - -extern "C" { -#endif -void updateScreen(); -int initGingerbreadMethod(); - -#ifdef __cplusplus -} - -#endif - - - -#endif \ No newline at end of file diff --git a/jni/vnc/framebuffer_method.c b/jni/vnc/framebuffer_method.c deleted file mode 100755 index 63acd8e..0000000 --- a/jni/vnc/framebuffer_method.c +++ /dev/null @@ -1,136 +0,0 @@ -/* -droid VNC server - a vnc server for android -Copyright (C) 2011 Jose Pereira - -Other contributors: -Oleksandr Andrushchenko - -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 "framebuffer_method.h" -#include "common.h" -#include "gui.h" - -int fbfd = -1; - - -char framebuffer_device[256] = "/dev/graphics/fb0"; - - -void setFramebufferDevice(char *s) -{ - strcpy(framebuffer_device,s); -} - - -int initFramebuffer(void) -{ - L("--Initializing framebuffer access method--\n"); - - fbmmap = MAP_FAILED; - - if ((fbfd = open(framebuffer_device, O_RDWR)) == -1) - { - L("Cannot open fb device %s\n", framebuffer_device); - sendMsgToGui("~SHOW|Cannot open fb device, please try out other display grab method\n"); - return -1; - } - - update_fb_info(); - - - if (ioctl(fbfd, FBIOGET_FSCREENINFO, &fscrinfo) != 0) - { - L("ioctl error\n"); - return -1; - } - - L("line_lenght=%d xres=%d, yres=%d, xresv=%d, yresv=%d, xoffs=%d, yoffs=%d, bpp=%d\n", - (int)fscrinfo.line_length,(int)scrinfo.xres, (int)scrinfo.yres, - (int)scrinfo.xres_virtual, (int)scrinfo.yres_virtual, - (int)scrinfo.xoffset, (int)scrinfo.yoffset, - (int)scrinfo.bits_per_pixel); - - - - - size_t size=scrinfo.yres_virtual; - if (size - -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 -*/ - -#ifndef ADB_FRAMEBUFFER_METHOD -#define ADB_FRAMEBUFFER_METHOD - -#include "common.h" - -unsigned int *fbmmap; - -struct fb_var_screeninfo scrinfo; -struct fb_fix_screeninfo fscrinfo; - -int initFramebuffer(void); -void cleanupFramebuffer(void); -void update_fb_info(); -int roundUpToPageSize(int x); -void setFramebufferDevice(char *); - -#endif \ No newline at end of file diff --git a/jni/vnc/gralloc_method.c b/jni/vnc/gralloc_method.c deleted file mode 100644 index 59f3506..0000000 --- a/jni/vnc/gralloc_method.c +++ /dev/null @@ -1,245 +0,0 @@ -/* -droid vnc server - Android VNC server -Copyright (C) 2011 Jose Pereira - -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 "gralloc_method.h" -#include "common.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define r(fd, ptr, size) (read((fd), (ptr), (size)) != (int)(size)) -#define w(fd, ptr, size) (write((fd), (ptr), (size)) != (int)(size)) - - -static int fill_format(struct fbinfo* info, int format) -{ - // bpp, red, green, blue, alpha - - static const int format_map[][9] = { - {0, 0, 0, 0, 0, 0, 0, 0, 0}, // INVALID - {32, 0, 8, 8, 8, 16, 8, 24, 8}, // HAL_PIXEL_FORMAT_RGBA_8888 - {32, 0, 8, 8, 8, 16, 8, 0, 0}, // HAL_PIXEL_FORMAT_RGBX_8888 - {24, 16, 8, 8, 8, 0, 8, 0, 0}, // HAL_PIXEL_FORMAT_RGB_888 - {16, 11, 5, 5, 6, 0, 5, 0, 0}, // HAL_PIXEL_FORMAT_RGB_565 - {32, 16, 8, 8, 8, 0, 8, 24, 8}, // HAL_PIXEL_FORMAT_BGRA_8888 - {16, 11, 5, 6, 5, 1, 5, 0, 1}, // HAL_PIXEL_FORMAT_RGBA_5551 - {16, 12, 4, 8, 4, 4, 4, 0, 4} // HAL_PIXEL_FORMAT_RGBA_4444 - }; - const int *p; - - if (format == 0 || format > HAL_PIXEL_FORMAT_RGBA_4444) - return -ENOTSUP; - - p = format_map[format]; - - info->bpp = *(p++); - info->red_offset = *(p++); - info->red_length = *(p++); - info->green_offset = *(p++); - info->green_length = *(p++); - info->blue_offset = *(p++); - info->blue_length = *(p++); - info->alpha_offset = *(p++); - info->alpha_length = *(p++); - - return 0; -} -#if 0 -static int readfb_devfb (int fd) -{ - struct fb_var_screeninfo vinfo; - int fb, offset; - char x[256]; - int rv = -ENOTSUP; - - struct fbinfo fbinfo; - unsigned i, bytespp; - - fb = open("/dev/graphics/fb0", O_RDONLY); - if (fb < 0) goto done; - - if (ioctl(fb, FBIOGET_VSCREENINFO, &vinfo) < 0) goto done; - fcntl(fb, F_SETFD, FD_CLOEXEC); - - bytespp = vinfo.bits_per_pixel / 8; - - fbinfo.bpp = vinfo.bits_per_pixel; - fbinfo.size = vinfo.xres * vinfo.yres * bytespp; - fbinfo.width = vinfo.xres; - fbinfo.height = vinfo.yres; - fbinfo.red_offset = vinfo.red.offset; - fbinfo.red_length = vinfo.red.length; - fbinfo.green_offset = vinfo.green.offset; - fbinfo.green_length = vinfo.green.length; - fbinfo.blue_offset = vinfo.blue.offset; - fbinfo.blue_length = vinfo.blue.length; - fbinfo.alpha_offset = vinfo.transp.offset; - fbinfo.alpha_length = vinfo.transp.length; - - /* HACK: for several of our 3d cores a specific alignment - * is required so the start of the fb may not be an integer number of lines - * from the base. As a result we are storing the additional offset in - * xoffset. This is not the correct usage for xoffset, it should be added - * to each line, not just once at the beginning */ - offset = vinfo.xoffset * bytespp; - - offset += vinfo.xres * vinfo.yoffset * bytespp; - - rv = 0; - - if (w(fd, &fbinfo, sizeof(fbinfo))) goto done; - - lseek(fb, offset, SEEK_SET); - for (i = 0; i < fbinfo.size; i += 256) { - if (r(fb, &x, 256)) goto done; - if (w(fd, &x, 256)) goto done; - } - - if (r(fb, &x, fbinfo.size % 256)) goto done; - if (w(fd, &x, fbinfo.size % 256)) goto done; - -done: - if (fb >= 0) close(fb); - return rv; -} - -#endif - - -struct gralloc_module_t *gralloc; -struct framebuffer_device_t *fbdev = 0; -struct alloc_device_t *allocdev = 0; -buffer_handle_t buf = 0; -unsigned char* data = 0; -int stride; - -#define CHECK_RV if (rv != 0){close_gralloc();return -1;} - -int init_gralloc() -{ - L("--Initializing gralloc access method--\n"); - grallocfb=0; - - int linebytes; - int rv; - - rv = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t**)&gralloc); - - CHECK_RV; - - rv = framebuffer_open(&gralloc->common, &fbdev); - - CHECK_RV; - - if (!fbdev->read) { - rv = -ENOTSUP; - close_gralloc(); - return rv; - } - - rv = gralloc_open(&gralloc->common, &allocdev); - - CHECK_RV; - - rv = allocdev->alloc(allocdev, fbdev->width, fbdev->height, - fbdev->format, GRALLOC_USAGE_SW_READ_OFTEN, - &buf, &stride); - - - rv = fbdev->read(fbdev, buf); - - CHECK_RV; - - rv = gralloc->lock(gralloc, buf, GRALLOC_USAGE_SW_READ_OFTEN, 0, 0, - fbdev->width, fbdev->height, (void**)&data); - CHECK_RV; - - rv = fill_format(&displayInfo, fbdev->format); - - CHECK_RV; - - stride *= (displayInfo.bpp >> 3); - linebytes = fbdev->width * (displayInfo.bpp >> 3); - displayInfo.size = linebytes * fbdev->height; - displayInfo.width = fbdev->width; - displayInfo.height = fbdev->height; - - // point of no return: don't attempt alternative means of reading - // after this - rv = 0; - - grallocfb=malloc(displayInfo.size); - - L("Stride=%d Linebytes=%d %p\n",stride,linebytes,fbdev->setUpdateRect); - - memcpy(grallocfb,data,displayInfo.size); - - if (data) - gralloc->unlock(gralloc, buf); - - L("Copy %d bytes\n",displayInfo.size); - - L("Returning rv=%d\n",rv); - return rv; -} - - -void close_gralloc() -{ - if (buf) - allocdev->free(allocdev, buf); - if (allocdev) - gralloc_close(allocdev); - if (fbdev) - framebuffer_close(fbdev); -} - - - - -int readfb_gralloc () -{ - int rv; - - - rv = fbdev->read(fbdev, buf); - - CHECK_RV; - - rv = gralloc->lock(gralloc, buf, GRALLOC_USAGE_SW_READ_OFTEN, 0, 0, - fbdev->width, fbdev->height, (void**)&data); - CHECK_RV; - - memcpy(grallocfb,data,displayInfo.size); - - if (data) - gralloc->unlock(gralloc, buf); - - return rv; -} - - diff --git a/jni/vnc/gralloc_method.h b/jni/vnc/gralloc_method.h deleted file mode 100644 index c55eee8..0000000 --- a/jni/vnc/gralloc_method.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -droid vnc server - Android VNC server -Copyright (C) 2009 Jose Pereira - -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 -*/ - -#ifndef GRALLOC_H -#define GRALLOC_H - - -unsigned int *grallocfb; - -int init_gralloc(); -int readfb_gralloc(); -void close_gralloc(); - - -#endif \ No newline at end of file diff --git a/jni/vnc/input.c b/jni/vnc/input.c deleted file mode 100755 index 9467054..0000000 --- a/jni/vnc/input.c +++ /dev/null @@ -1,325 +0,0 @@ -/* -droid VNC server - a vnc server for android -Copyright (C) 2011 Jose Pereira - -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 "input.h" - -int inputfd = -1; -// keyboard code modified from remote input by http://www.math.bme.hu/~morap/RemoteInput/ - -// q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l,z,x,c,v,b,n,m -int qwerty[] = {30,48,46,32,18,33,34,35,23,36,37,38,50,49,24,25,16,19,31,20,22,47,17,45,21,44}; -// ,!,",#,$,%,&,',(,),*,+,,,-,.,/ -int spec1[] = {57,2,40,4,5,6,8,40,10,11,9,13,51,12,52,52}; -int spec1sh[] = {0,1,1,1,1,1,1,0,1,1,1,1,0,0,0,1}; -// :,;,<,=,>,?,@ -int spec2[] = {39,39,227,13,228,53,215}; -int spec2sh[] = {1,0,1,1,1,1,0}; -// [,\,],^,_,` -int spec3[] = {26,43,27,7,12,399}; -int spec3sh[] = {0,0,0,1,1,0}; -// {,|,},~ -int spec4[] = {26,43,27,215,14}; -int spec4sh[] = {1,1,1,1,0}; - - -void initInput() -{ - L("---Initializing uinput...---\n"); - struct input_id id = { - BUS_VIRTUAL, /* Bus type. */ - 1, /* Vendor id. */ - 1, /* Product id. */ - 1 /* Version id. */ - }; - - if((inputfd = suinput_open("qwerty", &id)) == -1) - { - L("cannot create virtual kbd device.\n"); - sendMsgToGui("~SHOW|Cannot create virtual input device!\n"); - // exit(EXIT_FAILURE); do not exit, so we still can see the framebuffer - } -} - - -int keysym2scancode(rfbBool down, rfbKeySym c, rfbClientPtr cl, int *sh, int *alt) -{ - int real=1; - if ('a' <= c && c <= 'z') - return qwerty[c-'a']; - if ('A' <= c && c <= 'Z') - { - (*sh)=1; - return qwerty[c-'A']; - } - if ('1' <= c && c <= '9') - return c-'1'+2; - if (c == '0') - return 11; - if (32 <= c && c <= 47) - { - (*sh) = spec1sh[c-32]; - return spec1[c-32]; - } - if (58 <= c && c <= 64) - { - (*sh) = spec2sh[c-58]; - return spec2[c-58]; - } - if (91 <= c && c <= 96) - { - (*sh) = spec3sh[c-91]; - return spec3[c-91]; - } - if (123 <= c && c <= 127) - { - (*sh) = spec4sh[c-123]; - return spec4[c-123]; - } - switch(c) - { - case 0xff08: return 14;// backspace - case 0xff09: return 15;// tab - case 1: (*alt)=1; return 34;// ctrl+a - case 3: (*alt)=1; return 46;// ctrl+c - case 4: (*alt)=1; return 32;// ctrl+d - case 18: (*alt)=1; return 31;// ctrl+r - case 0xff0D: return 28;// enter - case 0xff1B: return 158;// esc -> back - case 0xFF51: return 105;// left -> DPAD_LEFT - case 0xFF53: return 106;// right -> DPAD_RIGHT - case 0xFF54: return 108;// down -> DPAD_DOWN - case 0xFF52: return 103;// up -> DPAD_UP - // case 360: return 232;// end -> DPAD_CENTER (ball click) - case 0xff50: return KEY_HOME;// home - case 0xFFC8: rfbShutdownServer(cl->screen,TRUE); return 0; //F11 disconnect - case 0xFFC9: - L("F12 closing..."); - exit(0); //F10 closes daemon - break; - case 0xffc1: down?rotate(-1):0; return 0; // F4 rotate - 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 - case 0xffc3: return 212;// F6 -> camera - case 0xffc4: return 150;// F7 -> explorer - case 0xffc5: return 155;// F8 -> envelope - - case 50081: - case 225: (*alt)=1; - if (real) return 48; //a with acute - return 30; //a with acute -> a with ring above - case 50049: - case 193:(*sh)=1; (*alt)=1; - if (real) return 48; //A with acute - return 30; //A with acute -> a with ring above - case 50089: - case 233: (*alt)=1; return 18; //e with acute - case 50057: - case 201:(*sh)=1; (*alt)=1; return 18; //E with acute - case 50093: - case 0xffbf: (*alt)=1; - if (real) return 36; //i with acute - return 23; //i with acute -> i with grave - case 50061: - case 205: (*sh)=1; (*alt)=1; - if (real) return 36; //I with acute - return 23; //I with acute -> i with grave - case 50099: - case 243:(*alt)=1; - if (real) return 16; //o with acute - return 24; //o with acute -> o with grave - case 50067: - case 211:(*sh)=1; (*alt)=1; - if (real) return 16; //O with acute - return 24; //O with acute -> o with grave - case 50102: - case 246: (*alt)=1; return 25; //o with diaeresis - case 50070: - case 214: (*sh)=1; (*alt)=1; return 25; //O with diaeresis - case 50577: - case 245:(*alt)=1; - if (real) return 19; //Hungarian o - return 25; //Hungarian o -> o with diaeresis - case 50576: - case 213: (*sh)=1; (*alt)=1; - if (real) return 19; //Hungarian O - return 25; //Hungarian O -> O with diaeresis - case 50106: - // case 0xffbe: (*alt)=1; - // if (real) return 17; //u with acute - // return 22; //u with acute -> u with grave - case 50074: - case 218: (*sh)=1; (*alt)=1; - if (real) return 17; //U with acute - return 22; //U with acute -> u with grave - case 50108: - case 252: (*alt)=1; return 47; //u with diaeresis - case 50076: - case 220:(*sh)=1; (*alt)=1; return 47; //U with diaeresis - case 50609: - case 251: (*alt)=1; - if (real) return 45; //Hungarian u - return 47; //Hungarian u -> u with diaeresis - case 50608: - case 219: (*sh)=1; (*alt)=1; - if (real) return 45; //Hungarian U - return 47; //Hungarian U -> U with diaeresis - - } - return 0; -} - - -void keyEvent(rfbBool down, rfbKeySym key, rfbClientPtr cl) -{ - int code; -// L("Got keysym: %04x (down=%d)\n", (unsigned int)key, (int)down); - - setIdle(0); - int sh = 0; - int alt = 0; - - if ((code = keysym2scancode(down, key, cl,&sh,&alt))) - { - - int ret=0; - - if (key && down) - { - if (sh) suinput_press(inputfd, 42); //left shift - if (alt) suinput_press(inputfd, 56); //left alt - - ret=suinput_press(inputfd,code); - ret=suinput_release(inputfd,code); - - if (alt) suinput_release(inputfd, 56); //left alt - if (sh) suinput_release(inputfd, 42); //left shift - } - else - ;//ret=suinput_release(inputfd,code); - -// L("injectKey (%d, %d) ret=%d\n", code , down,ret); - } -} - - - -void ptrEvent(int buttonMask, int x, int y, rfbClientPtr cl) -{ - - static int leftClicked=0,rightClicked=0,middleClicked=0; - setIdle(0); - transformTouchCoordinates(&x,&y,cl->screen->width,cl->screen->height); - - if((buttonMask & 1)&& leftClicked) {//left btn clicked and moving - static int i=0; - i=i+1; - - if (i%10==1)//some tweak to not report every move event - { - suinput_write(inputfd, EV_ABS, ABS_X, x); - suinput_write(inputfd, EV_ABS, ABS_Y, y); - suinput_write(inputfd, EV_SYN, SYN_REPORT, 0); - } - } - else if (buttonMask & 1)//left btn clicked - { - leftClicked=1; - - suinput_write(inputfd, EV_ABS, ABS_X, x); - suinput_write(inputfd, EV_ABS, ABS_Y, y); - suinput_write(inputfd,EV_KEY,BTN_TOUCH,1); - suinput_write(inputfd, EV_SYN, SYN_REPORT, 0); - - - } - else if (leftClicked)//left btn released - { - leftClicked=0; - suinput_write(inputfd, EV_ABS, ABS_X, x); - suinput_write(inputfd, EV_ABS, ABS_Y, y); - suinput_write(inputfd,EV_KEY,BTN_TOUCH,0); - suinput_write(inputfd, EV_SYN, SYN_REPORT, 0); - } - - if (buttonMask & 4)//right btn clicked - { - rightClicked=1; - suinput_press(inputfd,158); //back key - } - else if (rightClicked)//right button released - { - rightClicked=0; - suinput_release(inputfd,158); - } - - if (buttonMask & 2)//mid btn clicked - { - middleClicked=1; - suinput_press( inputfd,KEY_END); - } - else if (middleClicked)// mid btn released - { - middleClicked=0; - suinput_release( inputfd,KEY_END); - } -} - - -inline void transformTouchCoordinates(int *x, int *y,int width,int height) -{ - int scale=4096.0; - int old_x=*x,old_y=*y; - int rotation=getCurrentRotation(); - - if (rotation==0) - { - *x = old_x*scale/width-scale/2.0; - *y = old_y*scale/height-scale/2.0; - } - else if (rotation==90) - { - *x =old_y*scale/height-scale/2.0; - *y = (width - old_x)*scale/width-scale/2.0; - } - else if (rotation==180) - { - *x =(width - old_x)*scale/width-scale/2.0; - *y =(height - old_y)*scale/height-scale/2.0; - } - else if (rotation==270) - { - *y =old_x*scale/width-scale/2.0; - *x =(height - old_y)*scale/height-scale/2.0; - } - -} - - -void cleanupInput() -{ - if(inputfd != -1) - { - suinput_close(inputfd); - } -} \ No newline at end of file diff --git a/jni/vnc/input.h b/jni/vnc/input.h deleted file mode 100755 index e7ce5b9..0000000 --- a/jni/vnc/input.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -droid VNC server - a vnc server for android -Copyright (C) 2011 Jose Pereira - -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 -*/ - -#ifndef KEYMANIP_H -#define KEYMANIP_H - -#include "common.h" -#include "gui.h" -#define BUS_VIRTUAL 0x06 - - - -void initInput(); -int keysym2scancode(rfbBool down, rfbKeySym c, rfbClientPtr cl, int *sh, int *alt); -void transformTouchCoordinates(int *x, int *y,int,int); -void ptrEvent(int buttonMask, int x, int y, rfbClientPtr cl); -void keyEvent(rfbBool down, rfbKeySym key, rfbClientPtr cl); -void cleanupInput(); - -#endif diff --git a/jni/vnc/screenMethods/displaybinder.cpp b/jni/vnc/screenMethods/displaybinder.cpp deleted file mode 100755 index 4d491d5..0000000 --- a/jni/vnc/screenMethods/displaybinder.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* -droid vnc server - Android VNC server -Copyright (C) 2009 Jose Pereira - -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 -*/ -#if 0 -#include "displaybinder.h" -#include "common.h" - -#include -#include -#include - -#include -#include -#include - -using namespace android; - -ScreenshotClient *screenshotclient; - -extern "C" int initGingerbreadMethod() -{ - - L("--Initializing gingerbread access method--\n"); - - screenshotclient=new ScreenshotClient(); - int err=screenshotclient->update(); - if (err != NO_ERROR) { - L("screen capture failed: %s\n", strerror(-err)); - //mandar msg incompatible - return -1; - } - - PixelFormat f=screenshotclient->getFormat(); - - PixelFormatInfo pf; - getPixelFormatInfo(f,&pf); - - - displayInfo.bpp = pf.bitsPerPixel; - displayInfo.width = screenshotclient->getWidth(); - displayInfo.height = screenshotclient->getHeight();; - displayInfo.size = pf.bitsPerPixel*displayInfo.width*displayInfo.height/CHAR_BIT; - displayInfo.red_offset = pf.l_red; - displayInfo.red_length = pf.h_red; - displayInfo.green_offset = pf.l_green; - displayInfo.green_length = pf.h_green-pf.h_red; - displayInfo.blue_offset = pf.l_blue; - displayInfo.blue_length = pf.h_blue-pf.h_green; - displayInfo.alpha_offset = pf.l_alpha; - displayInfo.alpha_length = pf.h_alpha-pf.h_blue; - - return 0; - } - -extern "C" void updateScreen() -{ - screenshotclient->update(); - gingerbuf=(unsigned int*)screenshotclient->getPixels(); -} -#endif diff --git a/jni/vnc/screenMethods/displaybinder.h b/jni/vnc/screenMethods/displaybinder.h deleted file mode 100644 index 517c9b2..0000000 --- a/jni/vnc/screenMethods/displaybinder.h +++ /dev/null @@ -1,21 +0,0 @@ -/* -droid vnc server - Android VNC server -Copyright (C) 2009 Jose Pereira - -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 -*/ - - -unsigned int *flingerbuf; diff --git a/jni/vnc/suinput.c b/jni/vnc/suinput.c deleted file mode 100755 index 3f7f18d..0000000 --- a/jni/vnc/suinput.c +++ /dev/null @@ -1,225 +0,0 @@ -/* -suinput - Simple C-API to the Linux uinput-system. -Copyright (C) 2009 Tuomas Räsänen - -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 -#include -#include -#include -#include -#include -#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(uinput_fd, EV_KEY, code, 1); -} - -int suinput_release(int uinput_fd, uint16_t code) -{ - return suinput_write(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); -} diff --git a/jni/vnc/suinput.h b/jni/vnc/suinput.h deleted file mode 100755 index 14c2e66..0000000 --- a/jni/vnc/suinput.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -suinput - Simple C-API to the Linux uinput-system. -Copyright (C) 2009 Tuomas Räsänen - -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 -*/ - -#ifndef SUINPUT_H -#define SUINPUT_H -#include - -#include -#include - -int suinput_write(int uinput_fd, - uint16_t type, uint16_t code, int32_t value); -/* - Creates and opens a connection to the event device. Returns an uinput file - descriptor on success. On error, -1 is returned, and errno is set - appropriately. -*/ -int suinput_open(const char* device_name, const struct input_id* id); - -/* - Destroys and closes a connection to the event device. Returns 0 on success. - On error, -1 is returned, and errno is set appropriately. - - Behaviour is undefined when passed a file descriptor not returned by - suinput_open(). -*/ -int suinput_close(int uinput_fd); - -/* - Sends a relative pointer motion event to the event device. Values increase - towards right-bottom. Returns 0 on success. On error, -1 is returned, and - errno is set appropriately. - - Behaviour is undefined when passed a file descriptor not returned by - suinput_open(). -*/ -int suinput_move_pointer(int uinput_fd, int32_t x, int32_t y); -int suinput_set_pointer(int uinput_fd, int32_t x, int32_t y); - -/* - Sends a press event to the event device. Event is repeated after - a short delay until a release event is sent. Returns 0 on success. - On error, -1 is returned, and errno is set appropriately. - - Behaviour is undefined when passed a file descriptor not returned by - suinput_open(). - - All possible values of `code` are defined in linux/input.h prefixed - by KEY_ or BTN_. -*/ -int suinput_press(int uinput_fd, uint16_t code); - -/* - Sends a release event to the event device. Returns 0 on success. - On error, -1 is returned, and errno is set appropriately. - - Behaviour is undefined when passed a file descriptor not returned by - suinput_open(). - - All possible values of `code` are defined in linux/input.h prefixed - by KEY_ or BTN_. -*/ -int suinput_release(int uinput_fd, uint16_t code); - -/* - Sends a press and release events to the event device. Returns 0 on - success. On error, -1 is returned, and errno is set appropriately. - - Behaviour is undefined when passed a file descriptor not returned by - suinput_open(). - - All possible values of `code` are defined in linux/input.h prefixed - by KEY_ or BTN_. - - This function is provided as a convenience and has effectively the - same result as calling suinput_press() and suinput_release() sequentially. -*/ -int suinput_click(int uinput_fd, uint16_t code); - -#endif /* SUINPUT_H */ diff --git a/jni/vnc/update_screen.c b/jni/vnc/update_screen.c deleted file mode 100755 index 5721c01..0000000 --- a/jni/vnc/update_screen.c +++ /dev/null @@ -1,211 +0,0 @@ -/* -droid VNC server - a vnc server for android -Copyright (C) 2011 Jose Pereira - -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 -*/ - -#define OUT_T CONCAT3E(uint,OUT,_t) -#define FUNCTION CONCAT2E(update_screen_,OUT) - -void FUNCTION(void) -{ - int i,j; - int offset=0,pixelToVirtual; - OUT_T* a; - OUT_T* b=0; - - - if (method==FRAMEBUFFER) - update_fb_info();//important for doubleframebuffing_* - else if (method==ADB) - updateADBFrame(); - else if (method==GRALLOC) - readfb_gralloc(); - #ifndef ANDROID_FROYO - else if (method==GINGERBREAD) - updateScreen(); - #endif - - a = (OUT_T*)cmpbuf; - - if (method==FRAMEBUFFER) - b = (OUT_T*)fbmmap; - else if (method==ADB) - b = (OUT_T*)adbbuf; - else if (method==GRALLOC) - b = (OUT_T*)grallocfb; - #ifndef ANDROID_FROYO - else if (method==GINGERBREAD) - b = (OUT_T*)gingerbuf; - #endif - - int max_x=-1,max_y=-1, min_x=99999, min_y=99999; - idle=1; - - if (rotation==0) - { - for (j = 0; j < vncscr->height; j++) - { - for (i = 0; i < vncscr->width; i++) - { - offset = j * vncscr->width; - - if (method==FRAMEBUFFER) - pixelToVirtual = PIXEL_TO_VIRTUALPIXEL_FB(i,j); - else - pixelToVirtual = PIXEL_TO_VIRTUALPIXEL(i,j); - - if (a[i + offset]!=b[pixelToVirtual]) - { - a[i + offset]=b[pixelToVirtual]; - if (i>max_x) - max_x=i; - if (imax_y) - max_y=j; - if (jwidth*vncscr->height*scrinfo.bits_per_pixel/CHAR_BIT); - } - else if (rotation==90) - { - for (j = 0; j < vncscr->width; j++) - { - for (i = 0; i < vncscr->height; i++) - - { - offset = i * vncscr->width; - - if (method==FRAMEBUFFER) - pixelToVirtual = PIXEL_TO_VIRTUALPIXEL_FB(i,j); - else - pixelToVirtual = PIXEL_TO_VIRTUALPIXEL(i,j); - - if (a[(vncscr->width - 1 - j + offset)] != b[pixelToVirtual]) - { - a[(vncscr->width - 1 - j + offset)] = b[pixelToVirtual]; - - if (i>max_y) - max_y=i; - if (iwidth-j; - - if (h < min_x) - min_x=vncscr->width-j; - if (h > max_x) - max_x=vncscr->width-j; - - idle=0; - } - } - } - } - else if (rotation==180) - { - for (j = 0; j < vncscr->height; j++) - { - for (i = 0; i < vncscr->width; i++) - { - offset = (vncscr->height - 1 - j) * vncscr->width; - - if (method==FRAMEBUFFER) - pixelToVirtual = PIXEL_TO_VIRTUALPIXEL_FB(i,j); - else - pixelToVirtual = PIXEL_TO_VIRTUALPIXEL(i,j); - - if (a[((vncscr->width - 1 - i) + offset )]!=b[pixelToVirtual]) - { - a[((vncscr->width - 1 - i) + offset )]=b[pixelToVirtual]; - - - if (i>max_x) - max_x=i; - if (iheight-j; - - if (h < min_y) - min_y=vncscr->height-j; - if (h > max_y) - max_y=vncscr->height-j; - - idle=0; - } - } - } - } - else if (rotation==270) - { - for (j = 0; j < vncscr->width; j++) - { - for (i = 0; i < vncscr->height; i++) - { - offset = (vncscr->height - 1 - i) * vncscr->width; - - if (method==FRAMEBUFFER) - pixelToVirtual = PIXEL_TO_VIRTUALPIXEL_FB(i,j); - else - pixelToVirtual = PIXEL_TO_VIRTUALPIXEL(i,j); - - if(a[j + offset] != b[pixelToVirtual]) - { - a[j + offset] = b[pixelToVirtual]; - - if (i>max_y) - max_y=i; - if (i max_x) - max_x=j; - - idle=0; - } - } - } -} - - - if (!idle) - { - memcpy(vncbuf,a,displayInfo.width*displayInfo.height*displayInfo.bpp/CHAR_BIT); - - min_x--; - min_x--; - max_x++; - max_y++; - -// L("Changed x(%d-%d) y(%d-%d)\n",min_x,max_x,min_y,max_y); - - rfbMarkRectAsModified(vncscr, min_x, min_y, max_x, max_y); - } - -} - - - diff --git a/res/layout/main.xml b/res/layout/main.xml index 97691f1..e24d26f 100755 --- a/res/layout/main.xml +++ b/res/layout/main.xml @@ -1,41 +1,83 @@ - - - + - - - - - - - + + + + + + + + + + + + + + + + + - - - + - + \ No newline at end of file diff --git a/src/org/onaips/vnc/MainActivity.java b/src/org/onaips/vnc/MainActivity.java index b202840..7f736c0 100755 --- a/src/org/onaips/vnc/MainActivity.java +++ b/src/org/onaips/vnc/MainActivity.java @@ -16,12 +16,8 @@ import java.util.TimerTask; import java.util.regex.Matcher; import java.util.regex.Pattern; -import com.google.ads.AdRequest; -import com.google.ads.AdView; - import android.app.Activity; import android.app.AlertDialog; -import android.app.ProgressDialog; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; @@ -33,8 +29,8 @@ import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; import android.content.pm.PackageManager.NameNotFoundException; +import android.content.pm.ResolveInfo; import android.graphics.Color; import android.net.ConnectivityManager; import android.net.NetworkInfo; @@ -49,16 +45,21 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; -import android.view.Window; import android.view.View.OnClickListener; +import android.view.Window; import android.view.animation.Animation; -import android.view.animation.AnimationUtils; import android.view.animation.Animation.AnimationListener; +import android.view.animation.AnimationUtils; import android.widget.Button; import android.widget.EditText; +import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; +import com.google.ads.AdRequest; +import com.google.ads.AdSize; +import com.google.ads.AdView; + public class MainActivity extends Activity { private static final int MENU_QUIT = 0; @@ -69,13 +70,12 @@ public class MainActivity extends Activity static final int APP_ID = 123; static final String VNC_LOG ="VNCserver"; - - private ServerManager s; - - Animation buttonAnimation=null; - SharedPreferences preferences; - ProgressDialog dialog=null; - AlertDialog startDialog; + + private AdView adView = null; + private ServerManager s = null; + private Animation buttonAnimation=null; + private SharedPreferences preferences; + private AlertDialog startDialog; void doBindService() { bindService(new Intent(this, ServerManager.class), mConnection, @@ -124,6 +124,8 @@ public class MainActivity extends Activity @Override protected void onDestroy() { + if (adView != null) + adView.destroy(); super.onDestroy(); unregisterReceiver(mReceiver); } @@ -131,7 +133,7 @@ public class MainActivity extends Activity //rodar vnc com acc - + /** Called when the activity is first created. */ @Override @@ -186,7 +188,7 @@ public class MainActivity extends Activity { // Look up the AdView as a resource and load a request. - AdView adView = (AdView)this.findViewById(R.id.adView); + adView = (AdView)this.findViewById(R.id.adView); adView.loadAd(new AdRequest()); } @@ -226,7 +228,8 @@ public class MainActivity extends Activity }); } - + + public void log(String s) { Log.v(VNC_LOG,s);