If your app relies on interactions with other apps to complete its use cases, it's useful to test how package visibility changes in Android 11 (API level 30) and higher affect your app.
This guide also gives some suggestions on how to test the behavior changes and helps you configure log messages to determine at a more granular level how your app might be affected.
Test the behavior changes
To test whether this behavior change affects your app, complete the following steps:
- Install Android Studio 3.6.1 or higher.
- Install the latest version of Gradle that Android Studio supports.
- Set your app's
targetSdkVersion
to30
or higher. - Don't include the
<queries>
element in your app's manifest file. - Call
getInstalledApplications()
orgetInstalledPackages()
. Both methods return a filtered list when they are successful. - See which features of your app aren't working.
- Introduce appropriate
<queries>
entries to fix those features.
Configure log messages for package filtering
To discover more details about how the default visibility of apps affects your app, you can enable log messages for package filtering. If you're developing a test app or debuggable app in Android Studio, the system log provides this capability for you. Otherwise, you can run the following command in a terminal window to enable it manually:
adb shell pm log-visibility --enable PACKAGE_NAME
Then, whenever packages are filtered out of a PackageManager
object's return
values, you see a message similar to the following in Logcat:
I/AppsFilter: interaction: PackageSetting{7654321 \ com.example.myapp/12345} -> PackageSetting{...} BLOCKED