分類
Android 小鴨幹線 攔截電話

小鴨 @ Android P Preview 1 測試

由於 Android P 會收緊對 hidden API 的管制,而 Android 掛線動作只能透過 hidden API 進行(見前文),因此近日 Android P 推出 Preview 後,便立刻下載 emulator 來測試。

結果:

成功攔截!

此外,在給予通知存取權後,也可進行接通再掛線。

不過在 log 出現了幾個系統警告訊息:

W/zygote: Accessing hidden method Landroid/telephony/TelephonyManager;->getITelephony()Lcom/android/internal/telephony/ITelephony; (light greylist, reflection)
W/zygote: Accessing hidden method Landroid/telephony/TelephonyManager;->isNetworkRoaming(I)Z (light greylist, reflection)
W/zygote: Accessing hidden method Landroid/telephony/TelephonyManager;->getSimOperator(I)Ljava/lang/String; (light greylist, reflection)
W/zygote: Accessing hidden method Landroid/telephony/SubscriptionManager;->getActiveSubscriptionIdList()[I (dark greylist, reflection)

即是說,程式攔截電話時透過 Reflection 使用了 Android 的數個 hidden API,包括 TelephonyManager 的 getITelephony,isNetworkRoaming 及 getSimOperator,和 SubscriptionManager 的 getActiveSubscriptionIdList。 前三者已被列入”light greylist”內, 而後者則屬”dark greylist”。

正如 Google 在最近的 developer blog上所指,

In the next Android developer preview, you’ll be able to run your existing apps and see warnings when you use a non-SDK interface that will be subject to blacklist or greylist in the final release. It’s always a best practice to make sure your app runs on the developer preview, but you should pay specific attention to the interface compatibility warnings if you are concerned that you may be impacted.

而在最新的Developer Preview 文件

There are two greylists: The light greylist contains methods and fields which continue to function in Android P, but to which we do not guarantee access in future versions of the platform. If there is a reason that you cannot implement an alternative strategy to a light-greylisted API, you may file a bug to request reconsideration of the restriction.

The dark greylist contains methods intended to be made inaccessible in a future Developer Preview release.

換句話說,Google尚未在 Android P 版一刀切 blacklist 所有 hidden API,而是分段進行,小鴨用到的 hidden API, 電話攔截用到的只屬 “light greylist”,即(除非 Google 改變主意,否則)暫時在 Android P 上仍可進行攔截

不過,獲取電話中 Subscription ID list(即雙卡電話來電紀錄中見到的 “SIM識別碼”,多數是個位數字的 API,在 Android P 便要以另行方法代替(這個實際上是有另行方法的,不過較間接)。

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *