Skip to content

Commit

Permalink
ui: show all apps with internet permission in exclusions list
Browse files Browse the repository at this point in the history
Signed-off-by: Harsh Shandilya <[email protected]>
  • Loading branch information
proletarius101 authored and msfjarvis committed Nov 16, 2020
1 parent a300f26 commit fca3a68
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit fca3a68

Please sign in to comment.