2010年12月7日 星期二

[Android] Application Business Model

1. Paid Applications: Note. Unconditional Refund in 24 Hours 
2. Advertisement
2.1 ADMob (Acquired by Google)
2.2 Google AdSense for Mobile Applications  (not public, need high download ap)

2.3 mobclix
3. Donation (e.g., Paypal)



[] http://www.programmer.com.cn/2038/
[] 如何在 Android 程式中置入 AdMob 廣告?
[] http://ysl-paradise.blogspot.com/2010/04/android.html

2010年11月17日 星期三

慢跑運動傷害與跟腱炎(阿基里斯腱炎) 治療

跟腱炎(阿基里斯腱炎)  
  • 症狀
  1. 早上起床後的第一步時感到特別疼痛
  2. 當坐下休息一段長時間後再走動時會出現疼
  • 病因
  1. 跑步愛好者後腳跟疼痛
  2. 打羽毛球,跳起殺球後著地衝擊力過大, 跟腱應聲斷裂

  • 預防:
  1. 運動前一定要有熱身運動,以弓箭步伸展跟腱來增加柔軟度,
  2. 避免突然增加運動時間和強度,要循序漸進,不可過量。
  3. 不可以在過硬的地面上從事運動
  • 保守治療 (約三-六個月)
1. 口服非類固醇消炎止痛藥 或 外用消炎止痛貼布 
2. 休息
3. 離心收縮運動(Eccentric Contraction): 透過運動增強肌腱的拉力及強度,減輕患者痛楚。 
    3.1 弓箭步伸展

    3.2 固定腳跟, 上下腳尖 (e.g., 腳指練習撿起地面上的毛巾)

    3.3 固定腳跟, 回轉腳踝劃圓圈運動
    3.4 用腳尖寫字
    4. 物理復健(冷熱療法、超聲波深部熱療、雷射療法): 每天晚上睡前用溫熱水泡腳,有助改善足部血循環,對慢性的疼痛有改善的效果。
    5.使用足部矯形保護用品(如:足跟墊)以抬高足跟部位,減少跟腱的拉伸力。
    • Note: 若保守治療不成功,便需要考慮使用外科手術切除壞死的肌腱或引發病變的骨組織。
    []http://www.toi.com.hk/articles/sportsoho.pdf 
    []慢跑好處多 保暖多費心

    2010年10月14日 星期四

    [Eclipse] Tricks

    * Use a Java library inside your Android project:
      1. Create a folder (e.g. “lib”)
      2. Place .jar into this folder
      3. Right-click the jar and select “Build Path” -> Add to build path.

    2010年10月12日 星期二

    [Android] Startup

    1. Boot Code (in Chip)
      *Configure Chip: CPU, UART, Memory, (SD), Interrupt controller, watchdog, ...
      *Download Boot Loader into Memory (Internal SRAM or external DRAM)
    2. Boot Loader (e.g., U-boot)
      *Initialize Source Sevice: NAND, SD, NOR, USB, Ethernet, ...
      *Initialize Target memory: DRAM, ...
      *Setup file system, network support, memory protections and security options, ...
      *Download kernel & application images from source storage to target memory
    3. Linux Kernel
      *Set up interrupt controllers, MMU memory protections, caches and scheduling.
    4. Android Init
     
      4.1 Entry Point main() in ~/android/system/core/init/init.c
      4.1.1 Clear the umask
      4.1.2 Setup the basic filesystem (/dev, /proc, /sys)
      4.1.3 Creates device nodes for kmsg and null (not /)
      4.1.4 Initialize Log
      4.1.5 Parse init.rc
      4.1.6 Pull the kernel commandline and ramdisk properties file in
      4.1.7 Parse hardware platform init.xxx.rc

      4.1.8 Trigger "early-init"
      4.1.9 device_init();
      4.1.10 property_init();
      4.1.11 Listen for keychords
      4.1.12 Open console
      4.1.13 Show "Android" by load_565rle_image(INIT_IMAGE_FILE)
      4.1.14 property_set("ro.xxx", ...);
      4.1.15 Trigger "init" (refer to init.rc)
      4.1.16 start_property_service();
      4.1.17 Create a signalling mechanism for the sigchld handler
      4.1.18 Trigger "early-boot"
      4.1.19 Trigger "boot" (refer to init.rc)
      4.1.20 Run all property triggers
      4.1.21 Register file descriptors with polling events

      4.1.22 Infinite Loop
      4.1.22.1  restart_processes() if needed
      4.1.22 .2 Poll registered file descriptors
      4.1.22 .3 Handle revents

      4.2 Start Services in ~/android/system/core/rootdir/init.rc
        *Services: console, adbd, servicemanager,  vold, netd, debuggerd, ril-daemon, zygote,  media, bootanim, dbus, bluetoothd, hfag, opush, pbap, installd, flash_recovery, racoon, mtpd, keystore, dumpstate
        *See the following 
    root@android:/ # ps
    USER     PID   PPID  VSIZE  RSS     WCHAN    PC         NAME
    root      1     0     296    204   c009b74c 0000caac S /init
    root      2     0     0      0     c004e72c 00000000 S kthreadd
    root      3     2     0      0     c003fdc8 00000000 S ksoftirqd/0
    root      4     2     0      0     c004b2c4 00000000 S events/0
    root      5     2     0      0     c004b2c4 00000000 S khelper
    root      6     2     0      0     c004b2c4 00000000 S suspend
    root      7     2     0      0     c004b2c4 00000000 S kblockd/0
    root      8     2     0      0     c004b2c4 00000000 S cqueue
    root      9     2     0      0     c018179c 00000000 S kseriod
    root      10    2     0      0     c004b2c4 00000000 S kmmcd
    root      11    2     0      0     c006fc74 00000000 S pdflush
    root      12    2     0      0     c006fc74 00000000 S pdflush
    root      13    2     0      0     c00744e4 00000000 S kswapd0
    root      14    2     0      0     c004b2c4 00000000 S aio/0
    root      22    2     0      0     c017ef48 00000000 S mtdblockd
    root      23    2     0      0     c004b2c4 00000000 S kstriped
    root      24    2     0      0     c004b2c4 00000000 S hid_compat
    root      25    2     0      0     c004b2c4 00000000 S rpciod/0
    root      26    1     728    404   c0025d68 afd0e56c S /system/bin/sh
    system    27    1     836    264   c01a94a4 afd0dd3c S /system/bin/servicemanager
    root      28    1     3760   528   ffffffff afd0e3ac S /system/bin/vold
    root      29    1     3736   516   ffffffff afd0e3ac S /system/bin/netd
    root      30    1     700    268   c01b52b4 afd0e6cc S /system/bin/debuggerd
    radio     31    1     3356   656   ffffffff afd0e3ac S /system/bin/rild
    nobody    32    1     63140  22560 00000000 8021c5f8 R zygote
    media     33        19852  3724  ffffffff afd0dd3c S /system/bin/mediaserver
    bluetooth 34    1     1288   600   c009b74c afd0eb7c S /system/bin/dbus-daemon
    root      35        832    276   c01b52b4 afd0e6cc S /system/bin/installd
    keystore  36    1     1644   404   c01b52b4 afd0e6cc S /system/bin/keystore
    root      37    1     724    372   c0025d68 afd0e56c S /system/bin/sh
    root      38        852    336   c00b8fec afd0eafc S /system/bin/qemud
    root      40    1     1320   152   ffffffff 0000ee04 S /sbin/adbd
    root      56    37    820    272   c02181f4 afd0da9c S /system/bin/qemu-props
    root      64    26    924    348   00000000 afd0da9c R ps


      *kthreadd: Linex kernel thread daemon
      4.3 Zygote: Start a Dalvik VM instance and System Server.
                In ~/android/frameworks/base/cmds/app_process/app_main.cpp:
                runtime.start("com.android.internal.os.ZygoteInit",
                    startSystemServer); 

                In  ~/android/frameworks/base/core/jni/AndroidRuntime.cpp:
               void AndroidRuntime::start(const char* className, const bool startSystemServer)
               if (startVm(&mJavaVM, &env) != 0)
                In ~/android/frameworks/base/services/java/com/android/server/SystemServer.java:
                startSystemServer();  4.3.1 Dalvik VM
      4.3.2 System Server: Add Critical System Services
              In ~/android/frameworks/base/services/java/com/android/server/SystemServer.java
            // Critical services...
            try {
                Slog.i(TAG, "Entropy Service");
                ServiceManager.addService("entropy", new EntropyService());

                Slog.i(TAG, "Power Manager");
                power = new PowerManagerService();
                ServiceManager.addService(Context.POWER_SERVICE, power);

                Slog.i(TAG, "Activity Manager");
                context = ActivityManagerService.main(factoryTest);

                Slog.i(TAG, "Telephony Registry");
                ServiceManager.addService("telephony.registry", new TelephonyRegistry(context));

                AttributeCache.init(context);
                Slog.i(TAG, "Package Manager");
                pm = PackageManagerService.main(context,
                        factoryTest != SystemServer.FACTORY_TEST_OFF);

                ActivityManagerService.setSystemProcess();
                mContentResolver = context.getContentResolver();
                // The AccountManager must come before the ContentService
                try {
                    Slog.i(TAG, "Account Manager");
                    ServiceManager.addService(Context.ACCOUNT_SERVICE,
                            new AccountManagerService(context));
                } catch (Throwable e) {
                    Slog.e(TAG, "Failure starting Account Manager", e);
                }

                Slog.i(TAG, "Content Manager");
                ContentService.main(context,
                        factoryTest == SystemServer.FACTORY_TEST_LOW_LEVEL);
                Slog.i(TAG, "System Content Providers");
                ActivityManagerService.installSystemProviders();
                Slog.i(TAG, "Battery Service");
                battery = new BatteryService(context);
                ServiceManager.addService("battery", battery);
                Slog.i(TAG, "Lights Service");
                lights = new LightsService(context);
                Slog.i(TAG, "Vibrator Service");
                ServiceManager.addService("vibrator", new VibratorService(context));
                // only initialize the power service after we have started the
                // lights service, content providers and the battery service.
                power.init(context, lights, ActivityManagerService.getDefault(), battery);
                Slog.i(TAG, "Alarm Manager");
                AlarmManagerService alarm = new AlarmManagerService(context);
                ServiceManager.addService(Context.ALARM_SERVICE, alarm);
                Slog.i(TAG, "Init Watchdog");
                Watchdog.getInstance().init(context, battery, power, alarm,
                        ActivityManagerService.self());
                // Sensor Service is needed by Window Manager, so this goes first
                Slog.i(TAG, "Sensor Service");
                ServiceManager.addService(Context.SENSOR_SERVICE, new SensorService(context));
                Slog.i(TAG, "Window Manager");
                wm = WindowManagerService.main(context, power,
                        factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL);
                ServiceManager.addService(Context.WINDOW_SERVICE, wm);
                ((ActivityManagerService)ServiceManager.getService("activity"))
                        .setWindowManager(wm);

    5. Start-up Complete
      *Broadcast ACTION_BOOT_COMPLETED



    [] http://hi.baidu.com/j_fo/blog/item/c782b11bbb16f1178618bf82.html
    []The Android boot process from power on
    [] 如何去寫Android init.rc (Android init language)
    [] http://source.android.com/porting/bring_up.html
    [] http://blog.chinaunix.net/u2/87328/showart_1678365.html
    [] Android Zygote Startup

    2010年10月7日 星期四

    Android Porting: Make Kernel (Example: MSM)

    1. Get Android kernel source code
       git clone git://android.git.kernel.org/kernel/common.git

    2. Set Environment Variables for ARM Compiler
     in ~/.bashrc, add
    export ARCH=arm
    export CROSS_COMPLIE=arm-eabi-
    export PATH=$PATH:~/android/prebuilt/linux-x86/toolchain/arm-eabi-4.3.1/bin

    3.  Set Kernel Configuration
    *Based on ~/Documentation/android.txt
    *Use MSM as default config
     hmtsay@ubuntu:~/kernel/froyo$ make msm_defconfig
     Then, customized by  $make menuconfig
    Device Drivers  ---> 
    Network device support  --->
     Wireless LAN  --->
        [*] Wireless LAN (IEEE 802.11)   
        [*] IEEE 802.11 for Host AP (Prism2/2.5/3 and WEP/TKIP/CCMP)   
        [*]   Support downloading firmware images with Host AP driver  
        [*]     Support for non-volatile firmware download

      [*] Power supply class support  --->
        [*]   Generic PDA/phone power driver
      [*] MMC/SD card support  --->


    4. add Options in Makefile
    ARCH=arm
    CROSS_COMPILE=../../android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-

    5. make
    hmtsay@ubuntu:~/kernel/froyo/arch/arm/boot$ ls -l -a
    ...
    -rwxr-xr-x  1 hmtsay hmtsay 1159504 2010-10-07 06:38 zImage
    [] http://nemustech.blogspot.com/2009/04/android-on-s3c6410-target-board.html