Rice University logo
Top blue bar image

Update android.jar – custom jar

October 23rd, 2013 by mhyun

cp ~/android_gns/out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes/* . -R

zip -r android.jar .

Adding System Call in Android bionic library

September 25th, 2013 by mhyun

Copied from http://android-harvest.blogspot.com/2012/09/adding-system-call-in-android-bionic.html

Adding System Call in Android bionic library

Finally after long time gap I am in my blog again. This time I will explore adding system call in bionic libc.For simplicity sake let me tell about getpid() system call which is already presentKernel Changes :

1.  kernel/include/linux/syscalls.h
This header file provides syscall function prototype
eg:   asmlinkage long sys_getpid(void);
return type: long
asmlinkage macro tells the compiler to pass all function arguments on the stack.

2. kernel/kernel/timer.c
This source file contains actuall function definition

// Body of getpid() function.

3. kernel/arch/arm/include/asm/unistd.h

The system call need to be given a number in kernel that piece of code is done here
eg: #define __NR_getpid         (__NR_SYSCALL_BASE+ 20)

4. kernel/arch/arm/kernel/calls.S

The declared system call need to be exposed in syscall_table that is done here
eg: CALL(sys_getpid)

This completes Kernel part of exposing syscall getpid()

Bionic Changes:

5. bionic/libc/SYSCALLS.TXT

This is the only place getpid need to exposed in userpace, rest all is taken care automatically by gensyscalls.py python script.
The syntax goes likes this
return_type func_name[:syscall_name][:call_id]([parameter_list])  (#syscall_number|stub)

eg: pid_t getpid()  20

gensyscalls.py script automatically creates getpid.S Stub file and placed in 2 different locations as given below
a. bionic/libc/arch-arm/syscalls.mk
eg: syscall_src += arch-arm/syscalls/getpid.S

b. bionic/libc/arch-arm/syscalls/getpid.S

With both the changes cross-compile kernel and platform binaries so that you can enjoy the syscall interface between userspace and kernel space.

Please do comment if something is missed…

Always brighter side of the world…



Added by me.

In Bionic side,

  • Copy the unistd.h to android/external/kernel-headers/original/asm-arm
  • Run bionic/libc/kernel/tools/update_all.py to update bionic/libc/kernel/arch-arm/asm/unistd.h
  • Run bionic/libc/tools/gensyscalls.py

Old, but still necessary and working docs from IBM

September 23rd, 2013 by mhyun


CPU Governors

September 14th, 2013 by mhyun

The document in Kernel:



Brief compares:




Interactive Governor: https://lkml.org/lkml/2012/2/7/483


Related Paper:





Microsoft cuts touchscreen lag to 1ms, makes other panels look silly

September 11th, 2013 by mhyun


1ms is my goal

Latency Numbers Every Programmer Should Know (Berkely)

August 29th, 2013 by mhyun

Latency Numbers Every Programmer Should Know (Berkely)

Processing Binaries

August 29th, 2013 by mhyun


Processing Bytecodes

August 29th, 2013 by mhyun

apktool to extract bytecodes
dex2jar to convert Dalvik bytecodes toJava bytecodes
BCEL to modify Java bytecodes

Inject touch events

August 29th, 2013 by mhyun

#!/usr/bin/env python

import os

os.system(‘adb shell sendevent /dev/input/event1 3 57 100’)
os.system(‘adb shell sendevent /dev/input/event1 3 48 15’)
os.system(‘adb shell sendevent /dev/input/event1 3 58a 191’)
os.system(‘adb shell sendevent /dev/input/event1 3 53 347’)
os.system(‘adb shell sendevent /dev/input/event1 3 54 482’)
os.system(‘adb shell sendevent /dev/input/event1 0 0 0’)
os.system(‘adb shell sendevent /dev/input/event1 3 57 0’)
os.system(‘adb shell sendevent /dev/input/event1 0 0 0’)

event1 can be changed. Run getevent

Change loglevel

August 29th, 2013 by mhyun

echo 3 > /proc/sys/kernel/printk
The number, 3, can be changed.