stage for 1.1a1

This commit is contained in:
JosePereira 2012-06-11 20:08:48 +01:00
parent a3403ab062
commit 115d35c09a
33 changed files with 279 additions and 2387 deletions

View File

@ -3,6 +3,7 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="/home/onaips/Dropbox/projectos/workspace/droidVNCserver/libs/GoogleAdMobAdsSdk-4.1.1.jar"/>
<classpathentry kind="output" path="bin"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="lib" path="libs/GoogleAdMobAdsSdk-6.0.1.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

3
.gitignore vendored
View File

@ -1 +1,4 @@
bin
gen
libs
obj

View File

@ -1,49 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.onaips.vnc" android:versionCode="56" android:versionName="1.0a3">
package="org.onaips.vnc"
android:versionCode="56"
android:versionName="1.0a3" >
<uses-sdk android:minSdkVersion="5" />
<uses-permission android:name="android.permission.WRITE_SETTINGS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_SETTINGS" >
</uses-permission>
<application android:label="droid VNC server" android:icon="@drawable/icon"
android:name="MainApplication" android:debuggable="true">
<activity android:name=".MainActivity" android:launchMode="singleInstance"
android:label="@string/app_name" android:icon="@drawable/icon">
<application
android:name="MainApplication"
android:debuggable="true"
android:icon="@drawable/icon"
android:label="droid VNC server" >
<activity
android:name=".MainActivity"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:launchMode="singleInstance" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="org.onaips.vnc.ACTIVITY_UPDATE" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="org.onaips.vnc.ACTIVITY_UPDATE" />
</intent-filter>
</activity>
<activity android:name="preferences" android:label="Preferences"></activity>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation" />
<activity
android:name="preferences"
android:label="Preferences" >
</activity>
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<service android:name=".ServerManager" >
<intent-filter>
<action android:name="org.onaips.vnc.ServerManager"></action>
<action android:name="org.onaips.vnc.ServerManager" >
</action>
</intent-filter>
</service>
<receiver android:name=".StartServiceAtBootReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
<service android:name="avncservice"></service>
</application><uses-permission android:name="android.permission.READ_FRAME_BUFFER"></uses-permission>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.GET_TASKS"></uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
<service android:name="avncservice" >
</service>
</application>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" >
</uses-permission>
<uses-permission android:name="android.permission.ACCESS_SUPERUSER" >
</uses-permission>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" >
</uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" >
</uses-permission>
<uses-permission android:name="android.permission.INTERNET" >
</uses-permission>
<uses-permission android:name="android.permission.GET_TASKS" >
</uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE" >
</uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK" >
</uses-permission>
</manifest>

View File

@ -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

7
README
View File

@ -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:

14
TODO
View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -1 +0,0 @@
This

View File

@ -1,83 +0,0 @@
/*
droid vnc server - Android VNC server
Copyright (C) 2009 Jose Pereira <onaips@gmail.com>
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 <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
#include <binder/IMemory.h>
#include <surfaceflinger/ISurfaceComposer.h>
#include <surfaceflinger/SurfaceComposerClient.h>
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();
}

View File

@ -1,36 +0,0 @@
/*
droid vnc server - Android VNC server
Copyright (C) 2009 Jose Pereira <onaips@gmail.com>
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

View File

@ -1,26 +0,0 @@
#include <stdint.h>
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;

View File

@ -3,7 +3,6 @@ LOCAL_PATH := $(call my-dir)
subdirs := $(addprefix $(LOCAL_PATH)/,$(addsuffix /Android.mk, \
crypto \
ssl \
# apps \
))
include $(subdirs)

View File

@ -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)

View File

@ -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)

View File

@ -1,284 +0,0 @@
/*
droid vnc server - Android VNC server
Copyright (C) 2009 Jose Pereira <onaips@gmail.com>
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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <cutils/properties.h>
//#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;
// }

View File

@ -1,66 +0,0 @@
/*
droid vnc server - Android VNC server
Copyright (C) 2009 Jose Pereira <onaips@gmail.com>
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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
// #include <cutils/properties.h>
#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

View File

@ -1,97 +0,0 @@
/*
droid vnc server - Android VNC server
Copyright (C) 2009 Jose Pereira <onaips@gmail.com>
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 <android/log.h>
#ifndef __cplusplus
/* libvncserver */
#include "rfb/rfb.h"
#include "libvncserver/scale.h"
#include "rfb/keysym.h"
#include "suinput.h"
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/sysmacros.h> /* For makedev() */
#include <fcntl.h>
#include <linux/fb.h>
#include <linux/input.h>
#include <assert.h>
#include <errno.h>
#define SOCK_PATH "org.onaips.vnc.gui"
#include <cutils/log.h>
// #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

View File

@ -1,75 +0,0 @@
/*
droid vnc server - Android VNC server
Copyright (C) 2009 Jose Pereira <onaips@gmail.com>
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 <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
#include <binder/IMemory.h>
#include <surfaceflinger/ISurfaceComposer.h>
#include <surfaceflinger/SurfaceComposerClient.h>
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();
}

View File

@ -1,42 +0,0 @@
/*
droid vnc server - Android VNC server
Copyright (C) 2009 Jose Pereira <onaips@gmail.com>
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

View File

@ -1,136 +0,0 @@
/*
droid VNC server - a vnc server for android
Copyright (C) 2011 Jose Pereira <onaips@gmail.com>
Other contributors:
Oleksandr Andrushchenko <andr2000@gmail.com>
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<scrinfo.yres*2)
{
L("Using Droid workaround\n");
size=scrinfo.yres*2;
}
if ((scrinfo.bits_per_pixel==24))// && (fscrinfo.line_length/scrinfo.xres_virtual==CHAR_BIT*4))
{
scrinfo.bits_per_pixel=32;
L("24-bit XRGB display detected\n");
}
size_t fbSize = roundUpToPageSize(fscrinfo.line_length * size);
fbmmap = mmap(NULL, fbSize , PROT_READ|PROT_WRITE , MAP_SHARED , fbfd, 0);
if (fbmmap == MAP_FAILED)
{
L("mmap failed\n");
sendMsgToGui("~SHOW|Framebuffer mmap failed, please try out other display grab method\n");
return -1;
}
displayInfo.bpp = scrinfo.bits_per_pixel;
displayInfo.size = scrinfo.xres * scrinfo.yres * scrinfo.bits_per_pixel / CHAR_BIT;
displayInfo.width = scrinfo.xres;
displayInfo.height = scrinfo.yres;
displayInfo.red_offset = scrinfo.red.offset;
displayInfo.red_length = scrinfo.red.length;
displayInfo.green_offset = scrinfo.green.offset;
displayInfo.green_length = scrinfo.green.length;
displayInfo.blue_offset = scrinfo.blue.offset;
displayInfo.blue_length = scrinfo.blue.length;
displayInfo.alpha_offset = scrinfo.transp.offset;
displayInfo.alpha_length = scrinfo.transp.length;
return 1;
}
void cleanupFramebuffer(void)
{
if(fbfd != -1)
{
close(fbfd);
}
}
void update_fb_info()
{
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &scrinfo) != 0)
{
L("ioctl error\n");
sendMsgToGui("~SHOW|Framebuffer ioctl error, please try out other display grab method\n");
exit(EXIT_FAILURE);
}
}
inline int roundUpToPageSize(int x) {
return (x + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1);
}

View File

@ -1,36 +0,0 @@
/*
droid VNC server - a vnc server for android
Copyright (C) 2011 Jose Pereira <onaips@gmail.com>
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

View File

@ -1,245 +0,0 @@
/*
droid vnc server - Android VNC server
Copyright (C) 2011 Jose Pereira <onaips@gmail.com>
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 <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <linux/fb.h>
#include <hardware/hardware.h>
#include <hardware/gralloc.h>
#include <cutils/log.h>
#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;
}

View File

@ -1,31 +0,0 @@
/*
droid vnc server - Android VNC server
Copyright (C) 2009 Jose Pereira <onaips@gmail.com>
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

View File

@ -1,325 +0,0 @@
/*
droid VNC server - a vnc server for android
Copyright (C) 2011 Jose Pereira <onaips@gmail.com>
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);
}
}

View File

@ -1,36 +0,0 @@
/*
droid VNC server - a vnc server for android
Copyright (C) 2011 Jose Pereira <onaips@gmail.com>
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

View File

@ -1,75 +0,0 @@
/*
droid vnc server - Android VNC server
Copyright (C) 2009 Jose Pereira <onaips@gmail.com>
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 <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
#include <binder/IMemory.h>
#include <surfaceflinger/ISurfaceComposer.h>
#include <surfaceflinger/SurfaceComposerClient.h>
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

View File

@ -1,21 +0,0 @@
/*
droid vnc server - Android VNC server
Copyright (C) 2009 Jose Pereira <onaips@gmail.com>
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;

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(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);
}

View File

@ -1,96 +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
*/
#ifndef SUINPUT_H
#define SUINPUT_H
#include <stdint.h>
#include <linux/input.h>
#include <linux/uinput.h>
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 */

View File

@ -1,211 +0,0 @@
/*
droid VNC server - a vnc server for android
Copyright (C) 2011 Jose Pereira <onaips@gmail.com>
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 (i<min_x)
min_x=i;
if (j>max_y)
max_y=j;
if (j<min_y)
min_y=j;
idle=0;
}
}
}
// memcpy(a,b,vncscr->width*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 (i<min_y)
min_y=i;
int h=vncscr->width-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 (i<min_x)
min_x=i;
int h=vncscr->height-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<min_y)
min_y=i;
if (j < min_x)
min_x=j;
if (j > 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);
}
}

View File

@ -1,41 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_height="fill_parent" android:orientation="vertical"
android:background="@drawable/bg" android:layout_width="match_parent" android:gravity="top">
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg"
android:gravity="top"
android:orientation="vertical"
android:id="@+id/mainLayout">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center_horizontal"
>
android:orientation="vertical" >
<ImageView
android:layout_marginTop="24dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/droidvnclogo" android:scaleType="fitStart"/>
<RelativeLayout android:layout_width="match_parent" android:layout_marginTop="10dp"
android:id="@+id/relativeLayout1" android:layout_height="200dp">
<Button android:background="@drawable/btnstart" android:id="@+id/Button01"
android:layout_width="200dp" android:layout_height="200dp"
android:layout_centerHorizontal="true"></Button>
<Button android:layout_alignParentBottom="true" android:background="@drawable/restart_normal"
android:id="@+id/Button02" android:layout_toRightOf="@id/Button01"
android:layout_width="30dp" android:layout_height="30dp"></Button>
</RelativeLayout>
<TextView android:shadowRadius="0.5" android:id="@+id/stateLabel" android:layout_width="wrap_content" android:text="@+id/TextView01" android:shadowDy="1.0" android:shadowColor="#111" android:textSize="30sp" android:layout_height="wrap_content" android:paddingTop="10dp"></TextView>
<TextView android:gravity="center" android:shadowRadius="0.5" android:id="@+id/TextView01" android:layout_width="wrap_content" android:text="@+id/TextView02" android:shadowDy="1.0" android:shadowColor="#111" android:textSize="15sp" android:layout_height="wrap_content" android:paddingTop="10dp"></TextView>
android:layout_marginTop="24dp"
android:scaleType="fitStart"
android:src="@drawable/droidvnclogo" />
</LinearLayout>
<com.google.ads.AdView android:id="@+id/adView"
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginTop="10dp" >
<Button
android:id="@+id/Button01"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
android:background="@drawable/btnstart" >
</Button>
<Button
android:id="@+id/Button02"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@id/Button01"
android:background="@drawable/restart_normal" >
</Button>
</RelativeLayout>
<TextView
android:id="@+id/stateLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:shadowColor="#111"
android:shadowDy="1.0"
android:shadowRadius="0.5"
android:text="@+id/TextView01"
android:textSize="30sp" >
</TextView>
<TextView
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="10dp"
android:shadowColor="#111"
android:shadowDy="1.0"
android:shadowRadius="0.5"
android:text="@+id/TextView02"
android:textSize="15sp" >
</TextView>
</LinearLayout>
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="a14c45a1d8a1817"
ads:adSize="BANNER"/>
android:gravity="center_horizontal" />
</RelativeLayout>

View File

@ -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;
@ -70,12 +71,11 @@ 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);
}
@ -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());
}
@ -227,6 +229,7 @@ public class MainActivity extends Activity
}
public void log(String s)
{
Log.v(VNC_LOG,s);