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)

    - 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)


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

    • fastboot flash boot insert_your_boot_image_name_here.img
    • fastboot erase cache

    • 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')

    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
    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 /
    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 file to .class (java code)
    • (NO AndroidManifest.xml; need to use apktool)

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

    apk: jd-gui

    1) running jd-gui yield error on ubuntu 13.10
    • "error while loading shared libraries: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory"
    2) Perlu  install ia32-libs-gtk
    • sudo apt-get install ia32-libs-gtk

    3) Tapi pada Ubuntu saucy 13.10, akan error
    • E: Package 'ia32-libs' has no installation candidate

    4) sudo apt-get install libgtk2.0-0:i386

    ref::  http://wiki.phoenixviewer.com/ia32-libs-in-ubuntu-13-10

    23 January 2014

    Logical Volume

    usefull command:
    • lvs
    • fdisk
      • create partition with Label ID: 8e
    • pvcreate
    • vgcreate    (utk tambah saiz, tak perlu yg ini)
    • lvcreate
    • vgextend 
      • vgextend vg_data /dev/sda6
    • lvextend
      • lvextend -L +100G /dev/mapper/vg_data /dev/sda6
    • resize2fs
      • resize2fs /dev/mapper/vg_data-lvdata
    • other
      • vgdisplay
      • lvdisplay
      • pvdisplay

    1) create partition baru, type 8e
    2) create volume group guna partition itu
    3) create logical volume(guna semua saiz partition atau sebahagian)
    4) jika hanya guna sebahagian, nanti bila dah penuh boleh extend(dengan lvextend)

    Besarkan saiz guna partition baru(berlainan):
    1) add partition baru ke volume group sedia ada (vgextend)
    2) besarkan logical volume, guna ruang dari partition baru
            lvextend -L +G /dev/mapper/vg_data /dev/sda6
    3) resize file system (resize2fs)

    ref>>  http://www.linuxuser.co.uk/features/resize-your-disks-on-the-fly-with-lvm
    ref>> http://stackoverflow.com/questions/16515739/extending-logical-volume-in-ubuntu