我正在尝试通过shell卸载一个应用程序,但是该应用程序正在作为设备管理员运行,因此shell> adb uninstall com.example.test
无法起作用。
我如何从shell中禁用设备管理员?
我正在尝试通过shell卸载一个应用程序,但是该应用程序正在作为设备管理员运行,因此shell> adb uninstall com.example.test
无法起作用。
我如何从shell中禁用设备管理员?
通常情况下,通过设备管理员屏幕取消管理访问权限,然后卸载应用程序。在以下示例中,我将假定已将Airdroid (com.sand.airdroid
)配置为设备管理员,并且要卸载该应用程序。因此,为了调整此示例,请将com.sand.airdroid
的实例替换为您自己的应用程序名称。
要访问设备管理员,请导航至:设置 → 安全 → 设备管理员。然后,取消选中应用程序以取消设置管理访问权限。
还可以使用shell打开此活动:
adb shell am start -S "com.android.settings/.Settings\$DeviceAdminSettingsActivity"
完成此操作后,可以正常卸载该活动:
adb uninstall com.sand.airdroid
确实存在一种暴力破解方法。它涉及在/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@app@com.sand.airdroid-1.apk@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
adb shell pm disable-user (package name)
命令可以停用 DeviceAdmin 并禁用该应用。即使您再次启用该应用程序,它也不会被激活。
如果应用程序被设置为管理员,您无法直接卸载它。首先,您需要禁用管理员模式,然后才能卸载应用程序。要删除活动管理员,首先运行此命令:
Original Answer翻译成"最初的回答"
adb shell dpm remove-active-admin com.kiosk.example/com.kiosk.example.MyDeviceAdminReceiver
(com.kiosk.example) 是包名,请将其替换为您自己的包名,而 MyDeviceAdminReceiver 是接收器名称。当此命令成功时,您可以卸载应用程序,或者运行此命令以卸载:
原始回答: "Original Answer"
adb uninstall com.kiosk.example
adb shell am start -S "'com.android.settings/.Settings\$DeviceAdminSettingsActivity'"
- MainActivity