Skip to content

Commit

Permalink
so much things...
Browse files Browse the repository at this point in the history
  • Loading branch information
oNaiPs committed Jun 12, 2012
1 parent 1574f13 commit cedbda8
Show file tree
Hide file tree
Showing 56 changed files with 354 additions and 6,529 deletions.
8 changes: 4 additions & 4 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?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" >
android:versionCode="57"
android:versionName="1.1RC0" >

<uses-sdk android:minSdkVersion="5" />

Expand All @@ -11,8 +11,8 @@

<application
android:name="MainApplication"
android:debuggable="true"
android:icon="@drawable/icon"
android:debuggable="true"
android:icon="@drawable/icon"
android:label="droid VNC server" >
<activity
android:name=".MainActivity"
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
v1.1a

- ICS support
- 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.
- Fixed misc random segfault
- Added display rotation to 180, for zte

v1.0a

Expand Down
3 changes: 2 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Connects to the daemon using local IPC.
-------------- Compile C daemon ---------------------
On project folder:
$ ndk-build
$ cp libs/armeabi/androidvncserver /res/raw
$ mv libs/armeabi/androidvncserver /res/raw/androidvncserver.mp3 :O mp3 overcomes the 1MB limitation on some resources

-------------- Compile Wrapper libs -----------------
$ cd <aosp_folder>
Expand All @@ -27,6 +27,7 @@ On project folder:

To build:
$ mm external/nativeMethods
$ cp <droid-vnc-folder>/nativeMethods/lib/* <droid-vnc-folder>/res/raw


-------------- Compile GUI------- -------------------
Expand Down
Binary file modified bin/droid-VNC-server.apk
Binary file not shown.
Binary file added jni/vnc/.droidvncserver.c.swp
Binary file not shown.
2 changes: 1 addition & 1 deletion jni/vnc/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ LOCAL_C_INCLUDES += \

LOCAL_STATIC_LIBRARIES := libjpeg libpng libssl_static libcrypto_static

LOCAL_MODULE:= androidvncserver
LOCAL_MODULE := androidvncserver

include $(BUILD_EXECUTABLE)
4 changes: 2 additions & 2 deletions jni/vnc/LibVNCServer-0.9.9/rfb/rfbconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,9 @@
/* #undef LIBVNCSERVER_HAVE_XTESTGRABCONTROL */

/* Enable IPv6 support */
#ifndef LIBVNCSERVER_IPv6
/*#ifndef LIBVNCSERVER_IPv6
#define LIBVNCSERVER_IPv6 1
#endif
#endif*/

/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
slash. */
Expand Down
69 changes: 41 additions & 28 deletions jni/vnc/droidvncserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ unsigned int *vncbuf;
static rfbScreenInfoPtr vncscr;

uint32_t idle = 0;
uint32_t standby = 0;
uint32_t standby = 1;
uint16_t rotation = 0;
uint16_t scaling = 100;
uint8_t display_rotate_180 = 0;

//reverse connection
char *rhost = NULL;
Expand Down Expand Up @@ -80,11 +81,6 @@ inline int getCurrentRotation()
return rotation;
}

inline int isIdle()
{
return idle;
}

void setIdle(int i)
{
idle=i;
Expand Down Expand Up @@ -175,8 +171,9 @@ void initVncServer(int argc, char **argv)
vncscr->passwordCheck = rfbCheckPasswordByList;
}

vncscr->httpDir="/data/data/org.onaips.vnc/files/";
vncscr->sslcertfile="self.pem";
vncscr->httpDir = "webclients/";
// vncscr->httpEnableProxyConnect = TRUE;
vncscr->sslcertfile = "self.pem";

vncscr->serverFormat.redShift = screenformat.redShift;
vncscr->serverFormat.greenShift = screenformat.greenShift;
Expand Down Expand Up @@ -206,7 +203,8 @@ void initVncServer(int argc, char **argv)
vncscr->serverFormat.bitsPerPixel);

sendMsgToGui("~SHOW|Unsupported pixel depth, please send bug report.\n");
return;
close_app();
exit(-1);
}

/* Mark as dirty since we haven't sent any updates at all yet. */
Expand All @@ -218,7 +216,7 @@ void initVncServer(int argc, char **argv)
void rotate(int value)
{

L("rotate()");
L("rotate()\n");

if (value == -1 ||
((value == 90 || value == 270) && (rotation == 0 || rotation == 180)) ||
Expand Down Expand Up @@ -302,16 +300,22 @@ void initGrabberMethod()
method = GRALLOC;
else if (initFB() != -1) {
method = FRAMEBUFFER;
} else if (initADB() != -1) {
}
#if 0
else if (initADB() != -1) {
method = ADB;
readBufferADB();
}
#endif
} else if (method == FRAMEBUFFER)
initFB();
#if 0
else if (method == ADB) {
initADB();
readBufferADB();
} else if (method == GRALLOC)
}
#endif
else if (method == GRALLOC)
initGralloc();
else if (method == FLINGER)
initFlinger();
Expand All @@ -326,7 +330,8 @@ void printUsage(char **argv)
"-p <password>\t- Password to access server\n"
"-r <rotation>\t- Screen rotation (degrees) (0,90,180,270)\n"
"-R <host:port>\t- Host for reverse connection\n"
"-s <scale>\t- Scale percentage (20,30,50,100,150)\n\n" );
"-s <scale>\t- Scale percentage (20,30,50,100,150)\n"
"-z\t- Rotate display 180º (for zte compatibility)\n\n");
}


Expand All @@ -336,6 +341,7 @@ int main(int argc, char **argv)
signal(SIGINT, close_app);
signal(SIGKILL, close_app);
signal(SIGILL, close_app);
long usec;

if(argc > 1) {
int i=1;
Expand All @@ -355,6 +361,10 @@ int main(int argc, char **argv)
i++;
FB_setDevice(argv[i]);
break;
case 'z':
i++;
display_rotate_180=1;
break;
case 'P':
i++;
VNC_PORT=atoi(argv[i]);
Expand Down Expand Up @@ -396,12 +406,12 @@ int main(int argc, char **argv)
} else {
L("Grab method \"%s\" not found, sticking with auto-detection.\n",argv[i]);
}
break;
}
}
i++;
}
}
break;
}
}
i++;
}
}

L("Initializing grabber method...\n");
initGrabberMethod();
Expand Down Expand Up @@ -440,20 +450,23 @@ i++;
}
}

rfbRunEventLoop(vncscr,-1,TRUE);

while (1) {
usleep(300000*(standby/2.0));

usec=vncscr->deferUpdateTime*2000*standby;
rfbProcessEvents(vncscr,usec);

if (idle)
standby++;
standby++;
else
standby=2;

standby=2;
if (vncscr->clientHead == NULL)
continue;
{
idle=1;
standby=50;
continue;
}

update_screen();
}
close_app();
}
}
2 changes: 1 addition & 1 deletion jni/vnc/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void *handle_connections()
n = recvfrom(hServerSocket,pBuffer,BUFFER_SIZE,0,(struct sockaddr *)&from,&fromlen);
if (n < 0) perror("recvfrom");

L("Recebido: %s\n",pBuffer);
//L("Recebido: %s\n",pBuffer);

if (strstr(pBuffer,"~PING|")!=NULL)
{
Expand Down
24 changes: 18 additions & 6 deletions jni/vnc/screenMethods/flinger.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,21 @@ getscreenformat_fn_type getscreenformat_flinger = NULL;
int initFlinger(void)
{
L("--Loading flinger native lib--\n");

flinger_lib = dlopen("/data/libdvnc_flinger_sdk14.so", RTLD_NOW);
if(flinger_lib == NULL) {
L("Couldnt load library! Error string: %s\n",dlerror());
return -1;
int i,len;
char lib_name[64];

len=ARR_LEN(compiled_sdks);
for (i=0;i<len;i++) {
sprintf(lib_name, DVNC_FILES_PATH "/libdvnc_flinger_sdk%d.so",compiled_sdks[i]);

L("Loading lib: %s\n",lib_name);
flinger_lib = dlopen(lib_name, RTLD_NOW);
if (flinger_lib != NULL)
break;
else if(i+1 == len) {
L("Couldnt load any flinger library! Error string: %s\n",dlerror());
return -1;
}
}

init_fn_type init_flinger = dlsym(flinger_lib,"init_flinger");
Expand All @@ -61,12 +71,15 @@ int initFlinger(void)
L("Couldn't load get_screenformat! Error string: %s\n",dlerror());
return -1;
}
L("AKI1\n");

int ret = init_flinger();
L("AKII12");
if (ret == -1) {
L("flinger method not supported by this device!\n");
return -1;
}
L("AKI2\n");

screenformat = getScreenFormatFlinger();
if ( screenformat.width <= 0 ) {
Expand All @@ -78,7 +91,6 @@ int initFlinger(void)
L("Error: Could not read surfaceflinger buffer!\n");
return -1;
}

return 0;
}

Expand Down
9 changes: 4 additions & 5 deletions jni/vnc/screenMethods/framebuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ void update_fb_info(void)
}
}

inline int roundUpToPageSize(int x) {
return (x + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1);
}

int initFB(void)
{
L("--Initializing framebuffer access method--\n");
Expand Down Expand Up @@ -124,8 +128,3 @@ unsigned int *readBufferFB(void)
update_fb_info();
return fbmmap;
}

inline int roundUpToPageSize(int x) {
return (x + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1);
}

19 changes: 15 additions & 4 deletions jni/vnc/screenMethods/gralloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,21 @@ int initGralloc(void)
{
L("--Loading gralloc native lib--\n");

gralloc_lib = dlopen("/data/libdvnc_gralloc_sdk14.so", RTLD_NOW);
if(gralloc_lib == NULL) {
L("Couldnt load library! Error string: %s\n",dlerror());
return -1;
int i,len;
char lib_name[64];

len=ARR_LEN(compiled_sdks);
for (i=0;i<len;i++) {
sprintf(lib_name, DVNC_FILES_PATH "/libdvnc_gralloc_sdk%d.so",compiled_sdks[i]);
L("Loading lib: %s\n",lib_name);

gralloc_lib = dlopen(lib_name, RTLD_NOW);
if (gralloc_lib != NULL)
break;
else if(i+1 == len) {
L("Couldnt load library! Error string: %s\n",dlerror());
return -1;
}
}

init_fn_type init_gralloc = dlsym(gralloc_lib,"init_gralloc");
Expand Down
11 changes: 9 additions & 2 deletions jni/vnc/updateScreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

void FUNCTION(void)
{
int i,j;
int i,j,r;
int offset=0,pixelToVirtual;
OUT_T* a;
OUT_T* b=0;
struct fb_var_screeninfo scrinfo; //we'll need this to detect double FB on framebuffer

if (display_rotate_180){
r=rotation;
rotation+=180;
}

if (method==FRAMEBUFFER) {
scrinfo = FB_getscrinfo();
b = (OUT_T*) readBufferFB();
Expand Down Expand Up @@ -176,7 +181,9 @@ void FUNCTION(void)
// 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);
}
}
if (display_rotate_180)
rotation=r;
}


Expand Down
Binary file removed libs/armeabi/androidvncserver
Binary file not shown.
5 changes: 5 additions & 0 deletions nativeMethods/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,9 @@ void setIdle(int i);
void close_app();
screenFormat screenformat;

#define DVNC_FILES_PATH "/data/data/org.onaips.vnc/files/"

#define ARR_LEN(a) (sizeof(a)/sizeof(a)[0])
static int compiled_sdks[] = {10, 14};

#endif
2 changes: 2 additions & 0 deletions nativeMethods/flinger/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ ifeq ($(PLATFORM_SDK_VERSION),9)
LOCAL_SHARED_LIBRARIES := libsurfaceflinger_client libui libbinder libutils libcutils #libcrypto libssl libhardware
else ifeq ($(PLATFORM_SDK_VERSION),10)
LOCAL_SHARED_LIBRARIES := libsurfaceflinger_client libui libbinder libutils libcutils #libcrypto libssl libhardware
else ifeq ($(PLATFORM_SDK_VERSION),14)
LOCAL_SHARED_LIBRARIES := libgui libui libbinder libcutils
else ifeq ($(PLATFORM_SDK_VERSION),15)
LOCAL_SHARED_LIBRARIES := libgui libui libbinder libcutils
else
Expand Down
Loading

0 comments on commit cedbda8

Please sign in to comment.