04 July 2014

Android Build Process

[Java Source Code.]
      |
      | (javac)
      |
[Java class Files]
      |
      | (dx)
      |
[classes.dex]
      |
      | (apkbuilder)
      |
[App-unaligned.apk]
      |
      | (zipalign)
      |
[Apk.apk]


[BinaryOutputs]
(tools)

04 June 2014

Android Binder

Actor:

  • ServiceManager
  • ServiceProvider (class service)
  • ServiceUser (class activity, or any which call another service)


  1. SeriveManager mesti yg pertama start.
    Daftar dengan BinderDriver, guna handle 0.
  2. ServiceProvider bila start register dengan BinderDriver.
    Binder akan generate handle, eg 10.
    ServiceManager simpan nama service dan handle.
  3. Client akan guna handle 0 utk comunicate dengan ServiceManager.
    Client request base on service Name.
    ServiceManager akan beritahu no handle.
    Client talk using the handle through Binder


04 April 2014

Android cmd



  • pm
    • pm install /sdcard/myapk.apk
    • pm list packages | grep my
    • pm path com.myapk
  • top
  • ps
  • mount
    • mount -o rw,remount -t "filesystem" "Device" "Mount Point"
      • mount -o rw,remount -t rootfs /
      • mount -o rw,remount -t yaffs2 /dev/block/mtdblock4 /system

      • busybox mount -o remount,rw /system
      • mount -o loop /sdcard/myimage.img myimage
    • getprop


    ref : http://android.stackexchange.com/questions/11052/what-useful-android-shell-commands-do-you-know

    02 April 2014

    Android Terms

    Factory Reset

    • /system  tak usik
    • /data padam
    • /cache padam
    • /sdcard  tak usik
    # hati hati kalau dah install custom ROM atau root. Biasanya ok, tapi kadang kadang boleh menjadikan telefon 'brick'


    GSM vs CDMA

    - Global System for Mobile Communications
    - Ada SIM kad, senang tukar device.
    - Kat US, telefon murah, tapi carrief 'lock' device
    - - user tak boleh guna SIM kad company lain. (kecuali setelah unlock dulu)


    BootLoader
    - Secara mudah, boleh anggap telefon android spt harddisk
    - Ada beberapa partition
    - - /system   : Operating System(linux)
    - - /data       : Data utk aps
    - - dan lain-lain
    - bootloader: program yg mula bila phone boot/hidup
    - bootloader akan decide nak run program dari partition mana.
    - bootloader ditulis oleh pengilang, sgt spesifik kepada device

    25 March 2014

    Install Cyanogenmod

    Jgn guna cwm, tapi twrp utk custom recover.

    ref : http://forum.xda-developers.com/showthread.php?t=2213910

    stable : cm-10.2 (cm-11 belum stable)

    tools:
    -fastboot

    • fastboot flash recovery TWRPrecovery.img 
    • fastboot erase cache
    • ---

    • fastboot flash boot insert_your_boot_image_name_here.img
    • fastboot erase cache

    -adb
    • adb reboot-bootloader

    19 March 2014

    Android Threading

    - AsyncTask tak boleh execute AsyncTask yg lain.
    - IntentService tak boleh panggil IntentService yg lain
    -AsyncTask, IntentService, Service & Thread boleh panggil Service atau Thread
    #(Rujuk row 'Triggered From')





    ServiceThreadIntentServiceAsyncTask
    When to use ?Task with no UI, but shouldn't be too long. Use threads within service for long tasks.- Long task in general.

    - For tasks in parallel use Multiple threads (traditional mechanisms)
    - Long task usually with no communication to main thread.
    (Update)- If communication is required, can use main thread handler or broadcast intents[3]

    - When callbacks are needed (Intent triggered tasks). 
    - Long task having to communicate with main thread.

    - For tasks in parallel use multiple instances OR Executor [1]
    TriggerCall to method
    onStartService()
    Thread start() methodIntentCall to method execute()
    Triggered From (thread)Any threadAny ThreadMain Thread (Intent is received on main thread and then worker thread is spawed)Main Thread
    Runs On (thread)Main ThreadIts own threadSeparate worker threadWorker thread. However, Main thread methods may be invoked in between to publish progress.
    Limitations /
    Drawbacks
    May block main thread- Manual thread management

    - Code may become difficult to read
    - Cannot run tasks in parallel.

    - Multiple intents are queued on the same worker thread.
    - one instance can only be executed once (hence cannot run in a loop) [2]

    - Must be created and executed from the Main thread


    ref: http://techtej.blogspot.com.es/2011/03/android-thread-constructspart-4.html

    20 February 2014

    apk: analysis

    1) apktool ( apktool d filename.apk)

    • convert apk to human readable
      • AndroidManifest.xml    
      • .smali(class file into java byte code)
    2)  dex2jar (d2j-dex2jar.sh filename.apk)
    • convert apk to standard jar file.

    3) jd-gui
    • convert jar(.class) file to java code
    • (NO AndroidManifest.xml; need to use apktool)




    ref:  http://blog.nviso.be/2013/06/step-by-step-analysis-of-android.html