Pass all package names for shared UID connections
This commit is contained in:
@@ -58,7 +58,7 @@ interface PlatformInterfaceWrapper : PlatformInterface {
|
|||||||
val owner = ConnectionOwner()
|
val owner = ConnectionOwner()
|
||||||
owner.userId = uid
|
owner.userId = uid
|
||||||
owner.userName = packages?.firstOrNull() ?: ""
|
owner.userName = packages?.firstOrNull() ?: ""
|
||||||
owner.androidPackageName = packages?.firstOrNull() ?: ""
|
owner.setAndroidPackageNames(StringArray(packages?.toList()?.iterator() ?: emptyList<String>().iterator()))
|
||||||
return owner
|
return owner
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("PlatformInterface", "getConnectionOwnerUid", e)
|
Log.e("PlatformInterface", "getConnectionOwnerUid", e)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import io.nekohasekai.libbox.Connection as LibboxConnection
|
|||||||
import io.nekohasekai.libbox.ProcessInfo as LibboxProcessInfo
|
import io.nekohasekai.libbox.ProcessInfo as LibboxProcessInfo
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
data class ProcessInfo(val processId: Long, val userId: Int, val userName: String, val processPath: String, val packageName: String) {
|
data class ProcessInfo(val processId: Long, val userId: Int, val userName: String, val processPath: String, val packageNames: List<String>) {
|
||||||
companion object {
|
companion object {
|
||||||
fun from(processInfo: LibboxProcessInfo?): ProcessInfo? {
|
fun from(processInfo: LibboxProcessInfo?): ProcessInfo? {
|
||||||
if (processInfo == null) return null
|
if (processInfo == null) return null
|
||||||
@@ -15,7 +15,7 @@ data class ProcessInfo(val processId: Long, val userId: Int, val userName: Strin
|
|||||||
userId = processInfo.userID,
|
userId = processInfo.userID,
|
||||||
userName = processInfo.userName ?: "",
|
userName = processInfo.userName ?: "",
|
||||||
processPath = processInfo.processPath ?: "",
|
processPath = processInfo.processPath ?: "",
|
||||||
packageName = processInfo.packageName ?: "",
|
packageNames = processInfo.packageNames()?.toList() ?: emptyList(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@ data class Connection(
|
|||||||
domain.contains(content, ignoreCase = true) ||
|
domain.contains(content, ignoreCase = true) ||
|
||||||
outbound.contains(content, ignoreCase = true) ||
|
outbound.contains(content, ignoreCase = true) ||
|
||||||
rule.contains(content, ignoreCase = true) ||
|
rule.contains(content, ignoreCase = true) ||
|
||||||
processInfo?.packageName?.contains(content, ignoreCase = true) == true
|
processInfo?.packageNames?.any { it.contains(content, ignoreCase = true) } == true
|
||||||
|
|
||||||
private fun performSearchType(type: String, value: String): Boolean = when (type) {
|
private fun performSearchType(type: String, value: String): Boolean = when (type) {
|
||||||
"network" -> network.equals(value, ignoreCase = true)
|
"network" -> network.equals(value, ignoreCase = true)
|
||||||
@@ -79,7 +79,7 @@ data class Connection(
|
|||||||
"rule" -> rule.contains(value, ignoreCase = true)
|
"rule" -> rule.contains(value, ignoreCase = true)
|
||||||
"protocol" -> protocolName.equals(value, ignoreCase = true)
|
"protocol" -> protocolName.equals(value, ignoreCase = true)
|
||||||
"user" -> user.contains(value, ignoreCase = true)
|
"user" -> user.contains(value, ignoreCase = true)
|
||||||
"package" -> processInfo?.packageName?.contains(value, ignoreCase = true) == true
|
"package" -> processInfo?.packageNames?.any { it.contains(value, ignoreCase = true) } == true
|
||||||
"chain" -> chain.any { it.contains(value, ignoreCase = true) }
|
"chain" -> chain.any { it.contains(value, ignoreCase = true) }
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ fun ConnectionDetailsScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
connection.processInfo?.let { processInfo ->
|
connection.processInfo?.let { processInfo ->
|
||||||
if (processInfo.packageName.isNotEmpty() ||
|
if (processInfo.packageNames.isNotEmpty() ||
|
||||||
processInfo.processPath.isNotEmpty() ||
|
processInfo.processPath.isNotEmpty() ||
|
||||||
processInfo.processId > 0
|
processInfo.processId > 0
|
||||||
) {
|
) {
|
||||||
@@ -282,10 +282,10 @@ fun ConnectionDetailsScreen(
|
|||||||
monospace = true,
|
monospace = true,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (processInfo.packageName.isNotEmpty()) {
|
if (processInfo.packageNames.isNotEmpty()) {
|
||||||
DetailRow(
|
DetailRow(
|
||||||
label = stringResource(R.string.connection_package_name),
|
label = stringResource(R.string.connection_package_name),
|
||||||
value = processInfo.packageName,
|
value = processInfo.packageNames.joinToString(", "),
|
||||||
monospace = true,
|
monospace = true,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ private fun rememberAppInfo(packageName: String): AppInfo? {
|
|||||||
@Composable
|
@Composable
|
||||||
fun ConnectionItem(connection: Connection, onClick: () -> Unit, onClose: () -> Unit, modifier: Modifier = Modifier) {
|
fun ConnectionItem(connection: Connection, onClick: () -> Unit, onClose: () -> Unit, modifier: Modifier = Modifier) {
|
||||||
var showContextMenu by remember { mutableStateOf(false) }
|
var showContextMenu by remember { mutableStateOf(false) }
|
||||||
val packageName = connection.processInfo?.packageName?.takeIf { it.isNotEmpty() }
|
val packageName = connection.processInfo?.packageNames?.firstOrNull()
|
||||||
val appInfo = packageName?.let { rememberAppInfo(it) }
|
val appInfo = packageName?.let { rememberAppInfo(it) }
|
||||||
|
|
||||||
Box(modifier = modifier) {
|
Box(modifier = modifier) {
|
||||||
|
|||||||
Reference in New Issue
Block a user