Android下设置国产流氓软件权限静默

同一个软件在iOS平台有的话首选iOS,权限控制更严格且程序无法作出反抗。如果遇到因为地区限制(比如某国产流媒体音乐服务软件仅限在中国市场下载)只能在Android上安装的话就需要手工设置部分权限静默。

以下内容参考了这篇文章

首先需要安装adb。MacOS下可以用homebrew
brew install android-platform-tools

开启手机usb debugging (Settings -> About phone -> Build number连续点击10次开启developer mode)
连接上手机后首先查找一下安装的软件包名。
在这个例子中用的虾米音乐
adb shell pm list packages|grep -i xiami
package:fm.xiami.main

得到结果是fm.xiami.main

之后用appops把某些权限设置为ignore。不能设置成deny因为程序在检测到没有获得该项权限时会拒绝服务(所以我们叫他流氓软件)设置成ignore的话程序无法detect到这个变化。不过第一次启动程序还是不得不授予所需的权限否则程序拒绝启动,这一点不知道是否将来有workaround。


adb shell appops set fm.xiami.main WRITE_SMS ignore
adb shell appops set fm.xiami.main OP_READ_PHONE_STATE ignore

这两个权限一个是发送短信另一个是读取电话信息权限。一个音乐软件要求电话管理以及发送SMS权限实属过分。

检查该软件获得的所有权限

$adb shell appops get fm.xiami.main
COARSE_LOCATION: ignore
FINE_LOCATION: allow; time=+21m35s704ms ago; rejectTime=+12m39s614ms ago
POST_NOTIFICATION: allow; time=+14m32s602ms ago
CALL_PHONE: ignore
WRITE_SMS: ignore; rejectTime=+15m8s617ms ago
WRITE_SETTINGS: default; rejectTime=+15m15s701ms ago
READ_CLIPBOARD: allow; time=+12m35s36ms ago
WRITE_CLIPBOARD: allow; time=+12m35s34ms ago
TAKE_AUDIO_FOCUS: allow; time=+18m42s431ms ago
TOAST_WINDOW: allow; time=+14m30s54ms ago; duration=+2s527ms
OP_READ_PHONE_STATE: ignore; rejectTime=+13m13s115ms ago
READ_EXTERNAL_STORAGE: allow; time=+15m7s9ms ago
WRITE_EXTERNAL_STORAGE: allow; time=+15m7s9ms ago
RUN_IN_BACKGROUND: allow; time=+3m11s711ms ago

其中FINE_LOCATION 设置ignore但不知出于何种原因无法生效。此外在权限后没有出现time的即意味着程序没有请求该项权限(我事先禁止了CALL_PHONE) 对于FINE_LOCATION,据 @yegle建议可以通过禁止RUN_IN_BACKGROUND 权限来达到程序关闭即无法探知用户位置实现。

Leave a Reply

Your email address will not be published. Required fields are marked *