customize chrome home page on Android

用安裝ChromeCutomization.apk 的方式解
這邊有說明原本chrome 就有支援客製化首頁書籤等等
看起來該是有實做這個 `public class PartnerBrowserCustomizationsProviderExample extends ContentProvider` 就可以, no need platform key sign
但是有條件限制
  1. 一定要放進 system partition
  2. adb install 安裝進去的不會有效果
  3. no need platform key
  4. package name no need to be org.chromium.example.partnercustomizations
  5. android:name must be android:name=".PartnerBrowserCustomizationsProvider"
目前先用cyngn 的ChromeCutomization.apk decompile 換一些字串來用
LUNA測過有效
我想之後案子都也可以用這個方法去設定首頁

what is handyphone from tech view point

我們跟鴻海買了手機,然後改裝成handyphone。簡單來說就是這樣

細節來講

  1. 因為要更換 system, 所以 boot.img 裡面的fstab verity 要拿掉
  2. 如果有開 emmc write protection 的話要跟 OEM 拿一個關閉 WP 的 LK , 通常大的手機廠如 hTC 會提供官方解鎖工具,但這個方式也必須一台一台解,頂多開發初期使用,不適合大量生產。目前我經手過得機器也只有sharp M04 的機器有開WP,其他FIH 的手機沒開WP(似乎也都沒有fuse blown)
  3. 更換boot.img 裡面的sepolicy, 讓 handy app 可以寫資訊到AOSP 不允許寫的地方。使用的工具是 super bootimg
  4. 更換 boot animation,如果 AOSP 的路徑還能用(沒有被OEM拔掉)那就放 AOSP 定義的路徑,不然就要找出 OEM 把開機動畫擺哪裡,然後換掉,FIH 的手機開機動畫放在 CDA image 裡面
  5. 修改 init.rc ,handy phone 預期房客到了房間之後可以立刻使用手機,不需要跑一次 setup wizard
  6. 換掉系統預設背景圖片,在 launcher 啟動之前持續顯示開機動畫的圖片。這是使得 UX 會好很多的一個修改
  7. 移除開機音效(如果有的話),這個簡單,CDA裡面的開機音效檔案拿掉就好
  8. phone prefer app 設定為 handyphone ,當初研究這個需求讓我驚訝的發現AOSP 裡面竟然留了prefer app setting 這種非常 OEM friendly 的設定
  9. 修改 /system/etc/security/mac_permission.xml 讓 handy app 也能執行在 system_app domain
  10. 學會用mitproxy 抓手機網路封包觀察手機app 執行過程,這是為了釐清 bug 需要學的技能
  11. decompile 一個 chrome customize app 用來設定 chrome 開啟的首頁,或者能找到一個可以編譯的 chrome customize app source code 或者寫一個也都可以,反編一個是我找到最快的方法
  12. 自行開發一個OTA流程, AOSP OTA 是使用者主動觸發才會開始的,但是 handy phone 不可能等房客觸發OTA, 房客是來玩的也不會有空 OTA,所以 handy phone 自行開發了 OTA client 在房客checkout 的時候一併完成erase data and OTA
  13. 修改erase data,酒店 wifi data 等等資料需要保留的則不能刪掉, 所以實際上並不是 erase userdata …
  14. 修改 system.img 裡面的 apk 滿足 apk level 辦不到的事情,例如禁止關閉GPS,有 xposed 的話使用 xposed 完成是最簡單的,否則就要apktool d SystemUI.apk 然後修改 smali
  15. 也會經常 decompile OEM 修改過得 SystemUI, Settings 之類的 apk 來解 issue。例如 M04 手機上面 settings sharp 加了一個 magic twist 功能,是翻轉手機會回到上一個 recent app,不知道為什麼安裝了 handy phone app 之後這個功能的設定頁面進入就 crash,後來發現是 setting 頁面裡面取得 app name 的時候,如果 app name 有用 html tag 加工的話就會炸掉,因為 html tag 加工是 AOSP 允許的事情,所以必須先用 xposed 幫忙work around 掉 sharp bug,當然也有發信跟sharp 說這邊需要改進
  16. 因為拿不到手機 source code ,所以開發跟修改還有debug 都比系統廠辛苦一點 …

 

先筆記到這邊,之後有想到更多值得紀錄的再來寫

libphonenumber US number format fail

I got an issue , when user dial 1234567, the phone app will actually dial +1 1234567 , then call fail, because that is not an valid number

I expect +1 671 123 4567 or 123 4567 but not +1 123 4567

at first, I try prefix area code (country code + area code + local number), and it works, but this will make things complicated, because user may dial area code + local number or some other country don’t have area code. So I get rid of this

then I look into handyphone xposed function about the number process

and found that number become +1 123 4567 after below code

String directMobileCalledNumberTemp= phoneNumberUtil.formatNumberForMobileDialing(phoneNumberParsed,srcCountryName,false);

but still cannot figure out why only prefix country code and I also cannot find the way to add area code into the function
libphonenumber API doc

then I think of that, this API maybe got a bug return wrong format

so I just try update from 7.4.1 to 8.5.0

-    compile 'com.googlecode.libphonenumber:libphonenumber:7.4.1'
+    compile 'com.googlecode.libphonenumber:libphonenumber:8.5.0'

then things works great … weird

enable chrome remote desktop from ssh

you may encounter below problem when you ssh -XC to a remote PC and want to enable chrome remote desktop

org.freedesktop.PolicyKit1.Error.Failed: No session for cookie

I fix by sudo vim /etc/group and append my id to group “chrome-remote-desktop:x:1007:owen"

echo "chrome-remote-desktop:x:1007:owen" >> /etc/group

google-chrome-remote using pkexec to run as root and try to modify /etc/group, but pkexec cannot grant permission via ssh

so just add the group and add your account

How to customize FIH phone default wallpaper by rom level

this is the file control wallpaper, so you can simply find which app provide “com.evenwell.foxlauncher.action.PARTNER_CUSTOMIZATION" then add a new resource file and update /system/etc/wallpaper_config.xml default to your new file

$ cat /system/etc/wallpaper_config.xml
<?xml version="1.0" encoding="utf-8"?>
<Wallpaper>
    <project name="default">
        <sku id="default">
            <item name="ACTION_PARTNER_CUSTOMIZATION">com.evenwell.foxlauncher.action.PARTNER_CUSTOMIZATION</item>
            <item name="default_property">06</item>
            <mapping-wallpaper type="propertyWallpaper" value="01">wallpaper_color</mapping-wallpaper>
            <mapping-wallpaper type="propertyWallpaper" value="02">wallpaper_color</mapping-wallpaper>
            <mapping-wallpaper type="propertyWallpaper" value="04">wallpaper_color</mapping-wallpaper>
            <mapping-wallpaper type="propertyWallpaper" value="06">handy_wallpaper_01</mapping-wallpaper>
        </sku>
    </project>
</Wallpaper>

find the apk path

$ adb shell pm list packages -f | grep -i foxlauncher                                                                                  
package:/system/app/InFoucsLauncherPartner/InFoucsLauncherPartner.apk=com.evenwell.foxlauncher.partner

adb pull the apk file
apktool d InFoucsLauncherPartner.apk
update resource file and apktool b InFoucsLauncherPartner
sign the app, sign command refer below or google it

java -jar /home/owenwen/disk2/overlay/tools/signapk/signapk.jar ~/Downloads/Owen.x509.pem ~/Downloads/Owen.pkcs8 InFoucsLauncherPartner/dist/InFoucsLauncherPartner.apk InFoucsLauncherPartner/dist/InFoucsLauncherPartner_signed.apk

adb show front end app

adb shell dumpsys activity

Running activities (most recent first):
TaskRecord{a17c38e #47 A=android.task.contacts.phone U=0 sz=1}
Run #3: ActivityRecord{40f597f u0 com.android.contacts/.activities.DialtactsActivity t47}
TaskRecord{f1ab7bc #44 A=com.tinklabs.launcher U=0 sz=1}
Run #2: ActivityRecord{bcf2750 u0 com.tinklabs.launcher/.activities.LauncherActivity t44}
TaskRecord{5508a9a #45 A=com.tinklabs.handyphone U=0 sz=1}
Run #1: ActivityRecord{5b1c96e u0 com.tinklabs.handyphone/.features.MainActivity t45}
TaskRecord{aa21fcb #40 I=com.android.settings/.deviceinfo.MtpEnableActivity U=0 sz=1}
Run #0: ActivityRecord{22b9e97 u0 com.android.settings/.deviceinfo.MtpEnableActivity t40}