Background
You can get a list of installed apps using PackageManager.getInstalledPackages.
And, you can reach the app-info screen of each app via :
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse("package:$appPackageName"))
startActivity(intent)
Example:
The problem
Thing is, I've noticed (after someone told me) that for some apps, you can't reach their app-info screen. Example of such package-names of those apps: "com.google.android.ext.services" ("Android Services Library") , "com.google.mainline.tememetry" ("Support components"), com.google.android.modulemetadata" (Main components") . Maybe more.
After reporting it to Google, I was told:
com.google.android.ext.services is mainline module, so Settings doesn't provide detail app info for it.
What I've tried
I've tried to look at various fields and functions of PackageInfo and ApplicationInfo.
I've found "isApex", but it seems to be always false, and the docs don't help about understanding what it is, at all ("Whether the package is an APEX package") . EDIT: it's always false if I check on API 30. On API 29 it's actually sometimes set to true. Reported here.
I've also found a private boolean field (that I can reach via reflection) called "coreApp" , and indeed it's sometimes true, but it's not always that when it's true, it means I can't reach it's app-info screen.
This is the code to get it:
fun isProbablyCoreApp(packageInfo: PackageInfo): Boolean {
return try {
val field = PackageInfo::class.java.getField("coreApp")
field.getBoolean(packageInfo)
} catch (e: Throwable) {
false
}
}
The questions
- What does it mean "mainline module" ? It's a part of the OS that gets updated on its own? Related to "project mainline" of Android 10 and above ?
- Why couldn't I reach its app-info? It's not a real app? But if not, how come it's listed as a part of the list of apps?
- Is there any way to detect that an installed app is in fact a module that you can't reach its app-info screen ? How does the UI of the OS filters out those apps from its list?
- Are there more cases of apps that I can't reach their app-info screen?
coreApp
is not the attribute that you are looking for. On my device,"com.google.android.modulemetadata"
has the value offalse
for thecoreApp
. – HectoMATCH_APEX
identifies the APEX files as well as non-APEX files. Unfortunately, the failure to display the app-info screen seems to be silent - at least nothing appears in logcat that I can discern. My opinion is that the the matters are related by that is just my unfounded opinion. – ScargetInstalledPackages
, but this doesn't bother me much. Thing is, it also has "com.google.android.documentsui", which we can reach its app-info just fine (it's the "Files" app). So I tried to checkisHidden
, and this app is the only one (for me) that returns false for it. I don't know which out of all apps fail to reach app-info, but out of the list I got fromgetInstalledModules
, seems those that do exist as installed apps (and hidden) - don't get to app-info. This includes the apps I've mentioned. – ChalybiteisHidden
as false. I think this is the right track. – Scar