21 November 2014

tambah syscall sendiri

Cara nak tambah syscall sendiri ke dalam linux kernel. Melibatkan recompile kernel

// 1)  source_path/arch/x86/syscalls/syscall_32.tbl
# The format is:
356     i386    memfd_create            sys_memfd_create
357     i386     mhsyscall            sys_mhsyscall  ( new line)

// 2)  source_path/include/linux/syscalls.h

// last line
asmlinkage long sys_opsyscall(const char *test);

// 3)   source_path/mhsyscall/mhfzsyscall.c   ( nama c file suka hati)


//The system call
asmlinkage long sys_mhsyscall(const char *test)
   printk(KERN_ALERT "Called with string: %s\n", test);
   // 0 for success
   return 0;

// 4)   source_path/mhsyscall/Makefile

// Include the object in the kernel core
obj-y := mhfzsyscall.o

// 5)    source_path/Makefile

# Objects we will link into vmlinux / subdirs we need to visit
init-y          := init/
drivers-y       := drivers/ sound/ firmware/
net-y           := net/
libs-y          := lib/
core-y          := usr/ mhsyscall/   ( edit line )

// 6)  compile
# make

//  7) userspace binary to call mhsyscall (pemanggil.c)


int main(){
   syscall(357, "Mesage from user space program");
   return 0;
//  gcc -o pemanggil pemanggil.c

ref https://www.youtube.com/watch?v=5rr_VoQCOgE&feature=youtu.be

20 November 2014

aosp mirror

These instructions assume that the mirror is created in /usr/local/aosp/mirror. The first step is to create and sync the mirror itself, which uses close to 13GB of network bandwidth and a similar amount of disk space. Notice the --mirror flag, which can only be specified when creating a new client:
$ mkdir -p /usr/local/aosp/mirror
$ cd /usr/local/aosp/mirror
$ repo init -u https://android.googlesource.com/mirror/manifest --mirror
$ repo sync
Once the mirror is synced, new clients can be created from it. Note that it's important to specify an absolute path:
$ mkdir -p /usr/local/aosp/kitkat
$ cd /usr/local/aosp/kitkat
$ repo init -u /usr/local/aosp/mirror/platform/manifest.git -b android-4.4.4
$ repo sync
Finally, to sync a client against the server, the mirror needs to be synced against the server, then the client against the mirror:
$ cd /usr/local/aosp/mirror
$ repo sync
$ cd /usr/local/aosp/kitkat
$ repo sync

ref:  http://stackoverflow.com/questions/15870217/android-source-code-and-repo-what-exactly-is-happening-when-getting-code

18 November 2014

android system_process

android 4.3.1_r1


frameworks/base/core/java/android/app/ActivityThread.java:4977:            android.ddm.DdmHandleAppName.setAppName("system_process",

06 November 2014

android selfnote

1) getPackageManager().queryBroadcastReceivers(it,0) hanya bergantung pada AndroidManifest
  • Dynamically registered(in code via registerReceiver) tak dapat kenal
2) pm.getInstalledPackages(PackageManager.GET_DISABLED_COMPONENTS | PackageManager.GET_RECEIVERS)

  • Dynamically registered(in code via registerReceiver) tak dapat kenal

  • 3)  Extended class
    • PackageItemInfo
      • ComponentInfo
        • ActivityInfo
    • so >>  ActivityInfo = PackageItemInfo;  // is allowed

    Start Intent dari ResolveInfo

    Get ResolveInfo dari queryBroadcastReceivers()

    Given a ResolveInfo named launchable:
    ActivityInfo activity=launchable.activityInfo;
    ComponentName name=new ComponentName(activity.applicationInfo.packageName,
    Intent i=new Intent(Intent.ACTION_MAIN);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |

    ref: http://stackoverflow.com/questions/12504954/how-to-start-an-intent-from-a-resolveinfo

    05 November 2014

    install Gapps (Google Play) dalam emulator


    1) list avd

    • tukar default home dir for ANDROID_SDK_HOME
      • ANDROID_SDK_HOME="/home/my_home/"
    • android list avd

    2) open avd with specific system partition size

    emulator -avd VM_NAME_HERE -partition-size 500 -no-audio -no-boot-anim

    3) download gapp(names ~ gapps-jb-20130813-signed.zip)
    • http://wiki.rootzwiki.com/Google_Apps#Universal_Packages_2

    # Remount in rw mode
    adb shell mount -o remount,rw -t yaffs2 /dev/block/mtdblock0 /system
    # Allow writing to app directory on system partition
    adb shell chmod 777 /system/app
    # Install following apk
    adb push GoogleLoginService.apk /system/app/.
    adb push GoogleServicesFramework.apk /system/app/.
    adb push Phonesky.apk /system/app/. # Vending.apk in older versions
    adb shell rm /system/app/SdkSetup*

    ref :http://stackoverflow.com/questions/11154222/google-play-on-android-4-0-emulator

    04 November 2014

    dnsmasq: forward ke dns berbeza, bergantung domain

    1) file /etc/resolv.conf
    # local dnsmasq server
    # Your main dns server (dnsmasq will forward all requests to this server)

    2) file /etc/dnsmasq.conf
    # Tells dnsmasq to forward anything with the domain of remote.local to dns server
    # Listen to requests only coming from the local machine
    # Do not cache anything
    # A decent dns server will already cache for your local network

    ref: http://pyther.net/2010/12/dns-conditional-forwarding-dnsmasq/