summaryrefslogtreecommitdiffhomepage
path: root/ui/src/main/java/com/wireguard/android/fragment
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2020-11-16 15:45:19 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2020-11-16 15:45:19 +0530
commit4fae2d125577e17a457c26d66398ab6a498733b4 (patch)
tree7b7939493d751a581c5cbb1bdbc5384c05553eae /ui/src/main/java/com/wireguard/android/fragment
parenta300f269f154eddc244fe7fc3f8de556c6172993 (diff)
ui: show all apps with internet permission in exclusions list
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'ui/src/main/java/com/wireguard/android/fragment')
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt13
1 files changed, 6 insertions, 7 deletions
diff --git a/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt
index 7a51a757..2da8d5db 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt
+++ b/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt
@@ -4,8 +4,8 @@
*/
package com.wireguard.android.fragment
+import android.Manifest
import android.app.Dialog
-import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.Toast
@@ -40,12 +40,11 @@ class AppListDialogFragment : DialogFragment() {
try {
val applicationData: MutableList<ApplicationData> = ArrayList()
withContext(Dispatchers.IO) {
- val launcherIntent = Intent(Intent.ACTION_MAIN, null)
- launcherIntent.addCategory(Intent.CATEGORY_LAUNCHER)
- val resolveInfos = pm.queryIntentActivities(launcherIntent, 0)
- resolveInfos.forEach {
- val packageName = it.activityInfo.packageName
- val appData = ApplicationData(it.loadIcon(pm), it.loadLabel(pm).toString(), packageName, currentlySelectedApps.contains(packageName))
+ val packageInfos = pm.getPackagesHoldingPermissions(arrayOf(Manifest.permission.INTERNET), 0)
+ packageInfos.forEach {
+ val packageName = it.packageName
+ val appInfo = it.applicationInfo
+ val appData = ApplicationData(appInfo.loadIcon(pm), appInfo.loadLabel(pm).toString(), packageName, currentlySelectedApps.contains(packageName))
applicationData.add(appData)
appData.addOnPropertyChangedCallback(object : Observable.OnPropertyChangedCallback() {
override fun onPropertyChanged(sender: Observable?, propertyId: Int) {