从shell禁用DeviceAdmin?

问题描述 投票:7回答:3

我正在尝试从shell卸载应用程序,但是此应用程序作为设备管理员运行,因此shell> adb uninstall com.example.test无法正常工作。

如何从shell禁用设备管理员?

android shell adb uninstall administrator
3个回答
14
投票

通常,通过“设备管理员”屏幕撤消管理访问权限,然后卸载应用程序。在随后的示例中,我将假设airdroid(com.sand.airdroid)已被配置为设备管理员,并将被卸载。因此,要定制此示例,请使用您自己的应用名称替换com.sand.airdroid的实例。

干净的方法

要访问设备管理员,请导航:设置→安全性→设备管理员。然后,取消选中要取消设置管理访问权限的应用程序。

也可以使用shell打开这个活动:

adb shell am start -S "com.android.settings/.Settings\$DeviceAdminSettingsActivity"

完成此操作后,可以正常卸载活动:

adb uninstall com.sand.airdroid

蛮力方法(需要root)

确实存在蛮力方法。它涉及搜索/ system和/ data文件系统中的所有文件,并删除每个找到的项目。免责声明:谨慎使用(首先在模拟器上测试)。

adb shell

# Switch to root
su -

# Search for all installed files using the fully-qualified app name
find /system /data -name \*com.sand.airdroid\* 

...出现一个文件列表(包括目录) - 对于每个文件,通过在前面加上rm -f来删除它:

rm -r /data/media/0/Android/data/com.sand.airdroid
rm -r /data/data/com.sand.airdroid
rm -r /data/app-lib/com.sand.airdroid-1
rm -r /data/app/com.sand.airdroid-1.apk
rm -r /data/dalvik-cache/data@[email protected]@classes.dex

# Run the find command again to ensure nothing was missed
find /system /data -name \*com.sand.airdroid\* 

# exit root
exit
# exit Android shell
exit

要允许Android清理其文件,请重新启动设备。

adb reboot

设备重新启动后,可以使用uninstall命令卸载应用程序以完成清理。

adb uninstall com.sand.airdroid

1
投票

“adb shell pm disable-user pkgname”将取消激活DeviceAdmin并冻结应用程序。即使您启用该应用,它也不会再次处于活动状态。

(在带有8.0奥利奥的三星Galaxy S7上测试过)


0
投票

如果设置为Admin,则无法直接卸载应用程序。首先,您必须禁用管理模式,然后才能卸载应用程序。要删除活动管理员,请先运行此命令

adb shell dpm remove-active-admin com.kiosk.example/com.kiosk.example.MyDeviceAdminReceiver 

(com.kiosk.example)是包名称替换为您自己的,MyDeviceAdminReceiver是接收者名称。当此命令成功时,您可以卸载应用程序。或运行此命令以卸载

adb uninstall com.kiosk.example

© www.soinside.com 2019 - 2024. All rights reserved.