How to handle uninstall intent on Android 6 and ab

2020-04-19 08:12发布

问题:

Background

On my "app manager" app, I handled uninstall intent so that users could uninstall apps in the background, using root.

The problem

Up to Android 5.x , all went well and worked fine, but it seems that starting from Android 6, things have changed and the same intent, even though the logs say is being used, cannot be used by the app.

What I've tried

The manifest includes this intent-filter for the activity, as it always had:

  <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>

This is because of the docs, here and here, it says that those are what the framework uses.

I tried to separate the actions, and I tried to look at the logs, but it's exactly the same logs as before. Example:

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

It seems as if the framework already decided which app would handle the intent.

The question

Is it possible to still handle uninstall-intent? Even with root?

回答1:

Per this commit, this was an intentional change first seen in the marshmallow-release branch to disallow intercepting the package uninstall UI.