Archive for the android Category

Note: Create a local mirror repo of CyanogenMod

Posted in android with tags on 2014 年 08 月 14 日 by Kun-Yi

1. create an AOSP local mirror repos
    mkdir -p ~/mirror_aosp
    cd ~/mirror_aosp
    repo init -u https://android.googlesource.com/mirror/manifest –mirror
    repo sync -j4

2. create CyanogenMod special branch/tag mirror repos
    mkdir ~/mirror_cm11
    cd ~/mirror_cm11
    repo init -u git://github.com/CyangenMod/android.git -b cm-11.0 –mirror –reference=~/mirror_aosp
    repo sync -j4

3. fetch for local development
    mkdir ~/dev_cm11
    cd ~/dev_cm11
    repo init -u ~/mirror_cm11 -b cm-11.0 –reference=~/mirror_cm11
    repo sync -j10

ref.

  1. https://source.android.com/source/downloading.html#using-a-local-mirror
  2. https://www.excentral.org/archives/2011/02/24/android-repo-mirroring

Note: Android default/preferred network setting for RIL

Posted in android with tags , on 2014 年 08 月 11 日 by Kun-Yi

check the code snippet in DatabaseHelper.java for Android Jelly bean,

“property ro.telephony.default_network"

// Set the preferred network mode to 0 = Global, CDMA default
int type;
if (TelephonyManager.getLteOnCdmaModeStatic() == PhoneConstants.LTE_ON_CDMA_TRUE) {
type = Phone.NT_MODE_GLOBAL;
} else {
type = SystemProperties.getInt(“ro.telephony.default_network", RILConstants.PREFERRED_NETWORK_MODE);
}

loadSetting(stmt, Settings.Global.PREFERRED_NETWORK_MODE, type);

Note: Android HWC and CTS test item android.view.cts.DisplayRefreshRateTest

Posted in android with tags , , on 2014 年 07 月 01 日 by Kun-Yi

https://source.android.com/devices/reference/hwcomposer_8h_source.html

裏面有提到 HWComposer 需要回報 display 的一些資訊 如Resolution/DPI/Refresh rate 等等..

常見 android.view.cts.DisplayRefreshRateTest 測試不過就是這邊回報的值不正確

目前OMAP4 平台上是直接修改 hardware/ti/omap4xxx/hwc/display.c 內的 LCD_DISPLAY_FPS

更好的作法是kernel 按照目前的 pixel clock 與 LCD timinig 去算出正確的 refresh rate 然後 HAL 起來的時候去讀

更好的改法如下 (for OMAP4)

 

@@ -195,7 +195,10 @@ static void setup_config(display_config_t *config, int xres, int yres, struct ds
 
 static void setup_lcd_config(display_config_t *config, int xres, int yres, struct dsscomp_display_info *info)
 {
-    setup_config(config, xres, yres, info, LCD_DISPLAY_FPS, LCD_DISPLAY_DEFAULT_DPI);
+    const uint32_t ht = info->timings.x_res + info->timings.hsw + info->timings.hfp + info->timings.hbp;
+    const uint32_t vt = info->timings.y_res + info->timings.vsw + info->timings.vfp + info->timings.vbp;
+    int fps = (info->timings.pixel_clock*100)/((ht*vt)/10);
+    setup_config(config, xres, yres, info, fps, LCD_DISPLAY_DEFAULT_DPI);
 }

Note: Intel defined an ACPI _DSM for Android power button event on x86 platform

Posted in ACPI, android with tags , , , on 2014 年 06 月 24 日 by Kun-Yi

_DSM Parameters
Arg0(Buffer) : UUID : “9c355bcb-35fa-44f7-8a67-447359c36a03″
Arg1(Integer): Revision: 0
Arg2(Integer): Function Index :
0: PWRB_PROBE, detect support power button state method
1: PWRB_REGISTER, enable/register Power button release notify
2: PWRB_LEVEL, get current level of power button
Arg3(package): NULL

Return of Function index
Function 0: PWRB_PROBE
Type: Buffer,
return a bitmask of supported functions as a buffer. Return a failure here as 0:
method not present or not function correctly means “no functions support"

bitmask:
bit 0: supported PWRB_REGISTER(DSM notify)
bit 1: supported PWRB_LEVEL (DSM polling)
Just need support one method, if all support OS driver will use DSM notify method.

Function 1: PWRB_REGISTER
Type: Integer,
0 is success register a support control method power button device.
Notify(PWRB_Obj, 0x80) // 0x80 for press state
Notify(PWRB_Obj, 0xC0) // 0xC0 for release state

Function 2: PWRB_LEVEL
Type: Integer,
1 or 0,  return 1 when press button , others return 0

Note: Android Open Accessory protocol

Posted in android, AOA, USB with tags , , on 2014 年 06 月 14 日 by Kun-Yi

沒有深入瞭解AOA以前, 一直以為是 Android Device(Phone ot Tablet)當成 USB host 端, 然後 Accessory 當 client 畢竟 Accessories 就是給我 client 的聯想, 但是事情不是我這笨人想的那麼簡單, Google 反過來設計 由 Accessories 當作 Host 當 Android device attached 上Accessories 時, 他會透過 AOA 的 protocol 中的 GetProtocol 去確認是否是一個Android powered device. 最早的 AOA 只有 Accessory + adb 模式, 到了 AOA 2.0 (Google I/O 發表 ADK2012) 則多了 Audio, 然後除了透過USB 也可以透過特定的Bluetooth profile 支援

不過已經過去 將近2年, 市場上好像還是沒有受到消費者青睞, 我猜想有幾個原因,

  • 因為各個Device 外型都不同, 不容易設計特定的Dock 吻合多數Android device.
  • 沒有真的開發出Killer app 需要配合的device.
  • Accessory 開發有一定困難, 開發Accessory 的公司很多都很小型, 要他們弄個 USB Host/Bluetooh 方案, 個人覺得還蠻困難的!

不過因為目前工作原因, 覺得有其需要了解, 也利用了 libusb 寫了一個 AOA init 的程式, 可以用來騙 Android device 進入Accessory mode 而且是騙Device 這是一個ADK2012, 所以如果Device 有裝ADK2012 app會被launch, 但是會停在畫面很久. 因為只做到 init stage 還沒完成後續protocol communication 處理!

source code 在 https://github.com/KunYi/pcaoa

PS: Code default 是針對 Samsung Note2 GT-N7100 可以簡單修改 程式碼內的定義針對其他不同的Device

目前改成支援偵測 GT-N7100, HongMi, Blaze (因為我手上就只有這幾台機器, 是可以改成不管VID:PID直接用getProtocol 輪詢, 但是不是很想這樣搞), 優先權依排序順序, 下一步將補齊 protocol process 再來實作 linux audio play, 這樣就完整了

Note: apktool basic operation

Posted in android with tags , on 2013 年 08 月 03 日 by Kun-Yi

 

1. download apktool & setup apktool from https://code.google.com/p/android-apktool/

currently my work on Ubunutu 12.04 LTS, so  download the below packages

apktool1.5.2.tar.bz2 & apktool-install-linux-r05-ibot.tar.bz2

extract them into  ~/bin folder & export PATH=~/bin:$PATH

2. install framework resource into apktool folder

run  ‘apktool if framework-res.apk  tomcat’

you can get framework-res.apk from device /system/framework/ folder, tomcat is tag name

3.   decompile your want modify package, currently still use framework-res.apk, due to we will change default wallpaper file

execute ‘apktool d -t tomcat framework-res.apk f

decompile framework-res.apk to f folder

4. replace default wallpaper

replace all default_wallpaper.jpg  under drawable-*nodpi folders

currently you should find three directory, drawable-large-nodpi, drawable-nodpi and drawable-xlarge-nodpi

 

5. repacking framework-res.apk

run ‘apktool b -f f f_unsign.apk’

packing f folder to f_unsign.apk

6.  sing the package, but you need the platform key, if you don’t have the key, please google ‘modify framework-res.apk winrar’

run ‘./signapk.jar security/platform.x509.pem security/platform.pk8 f_unsign.apk f_sign.apk

7.  align the compress package

run   ‘zipalign -f 4 f_sign.apk f-res.apk’

8.  finish step, push the package into your devices then reboot the device

Note: Key repeat & long press timeout/delay of Android ICS

Posted in android on 2013 年 01 月 17 日 by Kun-Yi

 

keyRepeatTimeout(500 * 1000000LL) ; nanosecond, so the value equal 500 msec,

keyRepeatTimeout for initial repeat timeout

keyRepeatDelay(50 * 1000000LL)  ; nanosecond, so the value equal 50msec
       keyRepeatDelay for Inter-key delay

 

When repeatCount == 1, than KeyEvent |= AKEY_EVENT_FLAG_LONG_PRESS;   // defined in dispatchKeyLocked()

but the Timeout/Delay values is adjustable, see NativeInputManager::getDispatcherConfiguration(), defined in com_android_server_InputManager.cpp