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
//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"
@ -64,8 +65,6 @@ 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)
@ -79,23 +78,19 @@ void read_socket(int fd, void *buf, size_t count)
{
int n=0;
while (count>0)
{
while (count>0) {
n=read(fd,buf,count);
if (n < 0)
L("ERROR reading from socket\n");
count-=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)
@ -110,20 +105,29 @@ void send_framebuffer_string();
int initADB()
{
L("--Initializing adb access method--\n");
pid_t pid;
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));
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;
}
// L("1\n");
sleep(1);
message = malloc(sizeof(struct _message));
okay_message = malloc(sizeof(struct _message));
portno = 5555;
sockfd = socket(AF_INET, SOCK_STREAM, 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
// int main(int argc, char *argv[])
// {

View File

@ -35,15 +35,13 @@ 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)
{
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;
@ -52,8 +50,7 @@ int initFramebuffer(void)
update_fb_info();
if (ioctl(fbfd, FBIOGET_FSCREENINFO, &fscrinfo) != 0)
{
if (ioctl(fbfd, FBIOGET_FSCREENINFO, &fscrinfo) != 0) {
L("ioctl error\n");
return -1;
}
@ -64,19 +61,14 @@ int initFramebuffer(void)
(int)scrinfo.xoffset, (int)scrinfo.yoffset,
(int)scrinfo.bits_per_pixel);
size_t size=scrinfo.yres_virtual;
if (size<scrinfo.yres*2)
{
size_t size = scrinfo.yres_virtual;
if (size < scrinfo.yres * 2) {
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))
{
scrinfo.bits_per_pixel=32;
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");
}
@ -85,8 +77,7 @@ int initFramebuffer(void)
fbmmap = mmap(NULL, fbSize , PROT_READ|PROT_WRITE , MAP_SHARED , fbfd, 0);
if (fbmmap == MAP_FAILED)
{
if (fbmmap == MAP_FAILED) {
L("mmap failed\n");
sendMsgToGui("~SHOW|Framebuffer mmap failed, please try out other display grab method\n");
return -1;
@ -111,18 +102,12 @@ int initFramebuffer(void)
void cleanupFramebuffer(void)
{
if(fbfd != -1)
{
close(fbfd);
}
}
void update_fb_info()
{
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &scrinfo) != 0)
{
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);

BIN
libs/GoogleAdMobAdsSdk-6.0.1.jar Executable file

Binary file not shown.