sharmadhiraj / installed_apps

Flutter plugin with utility methods related to installed apps on device.
https://pub.dev/packages/installed_apps
Apache License 2.0
25 stars 36 forks source link

excludeSystemApps seems broken #42

Open builtbybrayne opened 1 week ago

builtbybrayne commented 1 week ago

Previously worked fine (1.3.1) but now (1.5.2) hides apps like YouTube and Chrome.

I can still find them by setting excludeSystemApps=false. But then I have all the noise of the random system stuff.

What changed and how can I continue with the previous logic of including the user-facing system apps but excluding the under-the-hood apps?

builtbybrayne commented 1 week ago

I suspect this change may be related?

/android/src/main/kotlin/com/sharmadhiraj/installed_apps/InstalledAppsPlugin.kt

     private fun isSystemApp(packageManager: PackageManager, packageName: String): Boolean {
-        return packageManager.getLaunchIntentForPackage(packageName) == null
+        return try {
+            val ai = packageManager.getApplicationInfo(packageName, 0)
+            (ai.flags and ApplicationInfo.FLAG_SYSTEM) != 0
+        } catch (e: PackageManager.NameNotFoundException) {
+            e.printStackTrace()
+            false
+        }
      #}
builtbybrayne commented 1 week ago

Perhaps add an 'excludeUnlaunchable'?