2017年11月24日星期五

為Android還原Wifi設定的終極方法

近日有朋友轉了新手機,我一如以往的幫忙由舊機過渡至新機。一直以來,Android系統舊機換新機是極度方便簡單,只需要在新機第一次設定時以相同的Google帳號登入,系統便會給你選擇是否由其他手機轉移資料至新機,所有應用程式及部份應用程式的資料、甚至wallpaper都會自動經雲端過渡至新機上,基本上只需處理whatsapp與wechat的資料轉換即可。

但不知道是Huawei EMUI的問題還是Android Oreo的變動問題,新機上所有wifi 設定一個也沒有給還原過來!在網上搜尋過一些手動處理 Android還原的方法,包括手動用bmgr (Android backup manager)和 adb backup都不見效,由於新舊機都沒有ROOT,所以直接抄 wpa_supplicant.conf這個方案亦不可行,舊機70多個wifi設定要手動逐個逐個重新設定實在不是辦法。

最後,唯有用一些時間,寫了個十分簡單的app,以讀取經 adb backup檔 extract出來的設定檔(extract 方法見 "How to extract, create or edit android adb backups")或是直接抄出來的wpa_supplicant.conf,自動化地在新機重新設定所有wifi網絡。Case closed!

既然app已寫好,雖然簡單,但亦發佈至Play Store,供有緣人發現及使用。

WifiConfigRestorer

2017年10月25日星期三

一次為國內版Samsung Galaxy S6 (SM-G9209) root機及安裝 Google Service過程

是咁的,話說有朋友有部國內版Samsung Galaxy S6 (SM-G9209),問我點解無Google Play Store,裝Apps好麻煩,可唔可以裝返Google Play Store

事前準備:
1. 要root/裝 Google Play Service,當然係先裝個 custom recovery。用開TWRP,當然係上TWRP網站下載對應型號的recovery

2. 喺Samsung機上改recovery,當然係要用Odin,所以亦上Odin網站下載了

3. Google Play Service安裝檔,當然係上OpenGApps下載。S6 CPU係ARM64,Android Version係6,唔想裝咁多嘢,所以揀nano variant

4. Root的部份,以往會用SuperSU,但今時今日識用梗係用Magisk,Open source得嚟仲可以自由隱藏root,唔洗root完連開個Pokemon Go都唔得

5. 要用Odin成功連接PC與S6,下載Samsung Android USB driver

萬事俱備(我以為係),開工。

過程:
1. 安裝 Samsung Android USB driver,關S6,按vol down+home+power進入download mode,連接PC,運行Odin,成功!

2.嘗試用Odin寫入TWRP recovery,出現"CROM locked"而失敗;上網搵到原來要上Samsung Apps下載一個叫CROM Service的App去unlock bootloader先;

3. Unlock了bootloader同入download mode,用Odin寫入TWRP recovery,成功!但reboot後發現recovery就置換回原本的;

4. 試了幾次都如是,所以先嘗試root了機先,由於無TWRP,所以Magisk亦裝不了,唯有用ChainFire的CF-Auto-Root,下載了相應型號的CF-Auto-Root,再用Odin寫入,成功了!

5. 因為始終想用Magisk,所以root了後,dump了boot partition出來,用Magisk Manager的Patch功能來改Boot partition,然後用SuperSU的unroot清除CF-Auto-Root,最後再用Odin寫入已Patch的Magisk Boot Partition,成功用Magisk root!

6. 在已root的情況下寫入TWRP不同version,但皆無法進入custom recovery,反反覆覆嘗試都失敗,唯有回復至原廠recovery;

7. 在沒有custom recovery的情況下,下載ChainFire的FlashFire app,嘗試安裝Google Play Service,但出現error說system partition不夠空間;

8. 下載所需空間更小的pico variant,再次嘗試,但都係出現system partition空間不足情況。翻查記錄檔,原來只差1xx KB左右的空間。上網找資料,原來可以用gapps-config檔可微調安裝的元件。

9. 以gapps-config排除了Google TTS元件,終於成功安裝Google Play Service。Reboot 後終於見到Google登入和Google Play Store

10. 但會每隔一段時間出現"Google Play服務已終止",查logcat說取不到location權限。最後進入應用程式,查看每一個與Google有關的應用,檢查權限,發現Google Play Service一個權限也沒被授予,設定完權限後,已再沒有"Google Play服務已終止",所有功能亦正常使用,成功了!

結案!

2017年2月6日星期一

Privacy Policy of "WifiDuck"

This Privacy Policy is meant to help you understand what data this app collects, why this app collects it and what this app does with it.

Information this app collects
"WifDuck" does NOT process or store any data on our servers.

Privacy Policy of "ContactSyncDuck for Facebook"

This Privacy Policy is meant to help you understand what data this app collects, why this app collects it and what this app does with it.

Information this app collects

"ContactSyncDuck for Facebook" DO NOT store any data on our servers.  NO data is processed and stored on our servers. NO device-specific information is collected and we DO NOT associate your device identifiers with the facebook id.

Why it is collected and how we use it

The facebook id is stored only on your device. This app use the facebook id to download the profile picture when this app runs on your device.

How the data is transmitted

The facebook id is transmitted to Facebook servers (not our servers) using encrypted https traffic. 

How to request data deletion

 Since we do not store any data on our servers. You need not request data deletion. You can delete the facebook id you entered in the note filed on your contacts whenever you want.

2017年1月9日星期一

Java Program存取使用 Let's encrypt證書的 SSL網站

為推動全網使用https,一群大機構贊助成立了 Let's encrypt為網站發出免費SSL證書。因為免費、安全、申請及更新全自動化等因素,可以預期越來越多網站會使用 Let's encrypt證書。

現時 Let's encrypt所發出的證書由 IdenTrust的DST Root CA X3作為根憑證,一般的較近代的系統及瀏覽器都已預設信任,認受性已很高。

不過,如果所使用的JDK版本較舊(Java 7 < 7u111, Java 8 < 8u101),而又有種種原因未能即時升級的話,在其運行的程式遇上 Let's encrypt的證書時便會發生錯誤:javax.net.ssl.SSLHandshakeException。

要解決的話,只需於 IdenTrust網站上下載 DST Root CA X3證書,匯入至有關 JDK的 cacerts檔案內便可:

1. 下載DST Root CA X3證書,儲存為檔案 DSTRootCAX3.pem,內容像這樣:
-----BEGIN CERTIFICATE-----
上述連結的下載內若
-----END CERTIFICATE-----

2. 以JDK內的 keytool程式匯入該證書至 cacerts內,例如:
/jrockit64_160_28/jre/bin/keytool -trustcacerts -keystore /jrockit64_160_28/jre/lib/security/cacerts -storepass changeit -noprompt -importcert -alias dstrootcax3 -file DSTRootCAX3.pem

當中:cacerts的檔案位置一般在以下地方,密碼為: changeit
{jdkroot}/jre/lib/security/cacerts

完成後,便不會發生 javax.net.ssl.SSLHandshakeException 錯誤了。