added misc things

This commit is contained in:
JosePereira 2012-06-11 20:03:54 +01:00
parent dd50528b71
commit b9c47879aa
3 changed files with 46 additions and 69 deletions

View File

@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
// //
//STATE - NOT WORKING //STATE - NOT WORKING
//TODO execute adb in custom tcp port on method initialization //TODO execute adb in custom tcp port on method initialization
//we must kill previous adb process or it wont be able to bind to listener install
#include "adb.h" #include "adb.h"
@ -64,8 +65,6 @@ int sockfd;
ssize_t write_socket(int fd, const void *buf, size_t count) ssize_t write_socket(int fd, const void *buf, size_t count)
{ {
// L("--Writing %d \n",count);
int n = write(fd,buf,count); int n = write(fd,buf,count);
if (n < 0) if (n < 0)
@ -79,23 +78,19 @@ void read_socket(int fd, void *buf, size_t count)
{ {
int n=0; int n=0;
while (count>0) while (count>0) {
{
n=read(fd,buf,count); n=read(fd,buf,count);
if (n < 0) if (n < 0)
L("ERROR reading from socket\n"); L("ERROR reading from socket\n");
count -= n; count -= n;
} }
return;
} }
void send_connect_string() void send_connect_string()
{ {
write_socket(sockfd,connect_string,sizeof(connect_string)); write_socket(sockfd,connect_string,sizeof(connect_string));
read_socket(sockfd,message,sizeof(struct _message)); read_socket(sockfd,message,sizeof(struct _message));
if (message->command!=A_CNXN) if (message->command!=A_CNXN)
@ -110,21 +105,30 @@ void send_framebuffer_string();
int initADB() int initADB()
{ {
L("--Initializing adb access method--\n"); L("--Initializing adb access method--\n");
pid_t pid;
int portno; int portno;
struct sockaddr_in serv_addr; struct sockaddr_in serv_addr;
struct hostent *server; struct hostent *server;
adbbuf=NULL; adbbuf=NULL;
// property_set("service.adb.tcp.port", "5555"); // property_set("service.adb.tcp.port", "5555");
system("setprop service.adb.tcp.port 5555");
system("adbd");
switch (pid = fork()) {
case -1:
perror("adb::fork()");
exit(EXIT_FAILURE);
case 0: // in the child
system("killall adbd");
system("setprop service.adb.tcp.port -1");
system("/sbin/adbd");
return;
break;
}
sleep(1);
message = malloc(sizeof(struct _message)); message = malloc(sizeof(struct _message));
okay_message = malloc(sizeof(struct _message)); okay_message = malloc(sizeof(struct _message));
// L("1\n");
portno = 5555; portno = 5555;
sockfd = socket(AF_INET, SOCK_STREAM, 0); sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0) if (sockfd < 0)
@ -256,18 +260,6 @@ void updateADBFrame()
} }
#ifndef ANDROID
void main()
{
connect_to_adb();
L("up\n");
update_frame();
L("up\n");
update_frame();
}
#endif
// test start point // test start point
// int main(int argc, char *argv[]) // int main(int argc, char *argv[])
// { // {

View File

@ -35,15 +35,13 @@ void setFramebufferDevice(char *s)
strcpy(framebuffer_device,s); strcpy(framebuffer_device,s);
} }
int initFramebuffer(void) int initFramebuffer(void)
{ {
L("--Initializing framebuffer access method--\n"); L("--Initializing framebuffer access method--\n");
fbmmap = MAP_FAILED; fbmmap = MAP_FAILED;
if ((fbfd = open(framebuffer_device, O_RDWR)) == -1) if ((fbfd = open(framebuffer_device, O_RDWR)) == -1) {
{
L("Cannot open fb device %s\n", framebuffer_device); L("Cannot open fb device %s\n", framebuffer_device);
sendMsgToGui("~SHOW|Cannot open fb device, please try out other display grab method\n"); sendMsgToGui("~SHOW|Cannot open fb device, please try out other display grab method\n");
return -1; return -1;
@ -52,8 +50,7 @@ int initFramebuffer(void)
update_fb_info(); update_fb_info();
if (ioctl(fbfd, FBIOGET_FSCREENINFO, &fscrinfo) != 0) if (ioctl(fbfd, FBIOGET_FSCREENINFO, &fscrinfo) != 0) {
{
L("ioctl error\n"); L("ioctl error\n");
return -1; return -1;
} }
@ -64,18 +61,13 @@ int initFramebuffer(void)
(int)scrinfo.xoffset, (int)scrinfo.yoffset, (int)scrinfo.xoffset, (int)scrinfo.yoffset,
(int)scrinfo.bits_per_pixel); (int)scrinfo.bits_per_pixel);
size_t size = scrinfo.yres_virtual; size_t size = scrinfo.yres_virtual;
if (size<scrinfo.yres*2) if (size < scrinfo.yres * 2) {
{
L("Using Droid workaround\n"); L("Using Droid workaround\n");
size = scrinfo.yres * 2; size = scrinfo.yres * 2;
} }
if ((scrinfo.bits_per_pixel==24))// && (fscrinfo.line_length/scrinfo.xres_virtual==CHAR_BIT*4)) if ((scrinfo.bits_per_pixel == 24)) {// && (fscrinfo.line_length/scrinfo.xres_virtual==CHAR_BIT*4))
{
scrinfo.bits_per_pixel = 32; scrinfo.bits_per_pixel = 32;
L("24-bit XRGB display detected\n"); L("24-bit XRGB display detected\n");
@ -85,8 +77,7 @@ int initFramebuffer(void)
fbmmap = mmap(NULL, fbSize , PROT_READ|PROT_WRITE , MAP_SHARED , fbfd, 0); fbmmap = mmap(NULL, fbSize , PROT_READ|PROT_WRITE , MAP_SHARED , fbfd, 0);
if (fbmmap == MAP_FAILED) if (fbmmap == MAP_FAILED) {
{
L("mmap failed\n"); L("mmap failed\n");
sendMsgToGui("~SHOW|Framebuffer mmap failed, please try out other display grab method\n"); sendMsgToGui("~SHOW|Framebuffer mmap failed, please try out other display grab method\n");
return -1; return -1;
@ -111,18 +102,12 @@ int initFramebuffer(void)
void cleanupFramebuffer(void) void cleanupFramebuffer(void)
{ {
if(fbfd != -1) if(fbfd != -1)
{
close(fbfd); close(fbfd);
} }
}
void update_fb_info() void update_fb_info()
{ {
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &scrinfo) != 0) {
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &scrinfo) != 0)
{
L("ioctl error\n"); L("ioctl error\n");
sendMsgToGui("~SHOW|Framebuffer ioctl error, please try out other display grab method\n"); sendMsgToGui("~SHOW|Framebuffer ioctl error, please try out other display grab method\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);

BIN
libs/GoogleAdMobAdsSdk-6.0.1.jar Executable file

Binary file not shown.