如何处理 Android 6 及更高版本的卸载意图?

How to handle uninstall intent on Android 6 and above?

背景

在我的“app manager”应用程序中,我处理了卸载意图,以便用户可以使用 root 在后台卸载应用程序。

问题

直到 Android 5.x ,一切顺利并且工作正常,但似乎从 Android 6 开始,事情发生了变化并且意图相同,即使日志say正在使用,不能被应用使用

我试过的

清单包括 activity 的此意向过滤器,因为它始终具有:

  <intent-filter>
    <action android:name="android.intent.action.DELETE"/>
    <action android:name="android.intent.action.UNINSTALL_PACKAGE"/>

    <category android:name="android.intent.category.DEFAULT"/>
    <data android:scheme="package"/>
  </intent-filter>

这是因为文档 here and here,它说这些是框架使用的内容。

我试着把动作分开,也试着看日志,但是和之前的日志一模一样。示例:

system_process I/ActivityManager: START u0 {act=android.intent.action.DELETE dat=package:me.scan.android.client flg=0x10800000 cmp=com.google.android.packageinstaller/com.android.packageinstaller.UninstallerActivity (has extras)} from uid 10078 on display 0

似乎框架已经决定了哪个应用程序将处理该意图。

问题

是否仍然可以处理卸载意图?即使有根?

根据 this commit, this was an intentional change first seen in the marshmallow-release branch 禁止拦截包卸载 UI。