Linux commands

Wednesday, October 17, 2012

Different ways of compilations in android

Different compilations are used for android code

1. Compilation of complete code
$make
2. Compiling android kernel
$make bootimage
3. compiling system img
$make systemimage
4. compilation of an apk
open Android.mk of an apk
LOCAL_MODULE := xyz_module_name
$make xyz_module_name

5. mm is command to compile the indiviual modules . TO work this command first all the code should compile atleast once

Monday, September 3, 2012

how to compile SystemUI

Go to base SystemUI folder and type
$mm

SystemUI.apk is generated in out folder

//install to phone
adb root
adb remount
adb push SystemUI.apk /system/app/

adb reboot

Wednesday, August 22, 2012

Reverse single linked list.



#include<stdio.h>
#include<stdlib.h>
typedef struct node {
int data;
struct node *next;
};

struct node *head=NULL;

void push(int d)
{
struct node *tmp = (struct node *)malloc(sizeof(struct node*));
struct node *ptr = head;
if( head == NULL)
{
tmp->data = d;
tmp->next = NULL;
head = tmp;
} else {
tmp->data = d;
tmp->next = NULL;
while(ptr->next != NULL)
{
ptr = ptr->next;
}
ptr->next = tmp;
}
}

void display()
{
struct node *ptr = head;
while(ptr)
{
printf("%d",ptr->data);
ptr = ptr->next;
}
}

void delete(int n)
{
struct node *ptr=head;
struct node *pre;
int i=1;
if(head != NULL && n==1)
{
head = head->next;
free(ptr);
return;
}
while(ptr != NULL)
{
if(i == n)
{
pre->next = ptr->next;
free(ptr);
ptr=pre->next;
break;
}
pre= ptr;
ptr= ptr->next;
i++;
}
}

void reverse()
{
struct node *ptr=head;
struct node *tmp=NULL;
struct node *next=NULL;
while(ptr)
{
next = ptr->next;
ptr->next = tmp;
tmp=ptr;
ptr=next;
}
head = tmp;
}
main()
{
int d=0,i=0;
while(i<5)
{
i++;
scanf("%d",&d);
push(d);
}
display();
scanf("%d",&d);
delete(d);
display();
printf("reverse ");
reverse();
display();
}



Tuesday, August 21, 2012

delete nth element linked list

void delete(int n)
{
        struct node *ptr=head;
        struct node *pre;
        int i=1;
        if((ptr != NULL) && n == 1)
        {
                head = head->next;
                free(ptr);
                return;
        }
        while(ptr != NULL)
        {
                if(i == n)
                {
                        pre->next = ptr->next;
                        free(ptr);
                        ptr=pre->next;
                        break;
                }
                pre= ptr;
                ptr= ptr->next;
                i++;
        }
}

Thursday, July 5, 2012

How to declare new system property in Android

Go to init.rc

//define property
setprop  sys.xyz 0

//use in your code
int ret;
char prop_value[MAX];
ret = property_get("sys.xyz",prop_value,NULL)

Friday, June 29, 2012

Thursday, June 21, 2012

No manual entry for pthread_create


library is required to install in system

apt-get install glibc-doc
apt-get install manpages-dev
apt-get install manpages-posix-dev