Revert "Refrain from using reflection to parse numerical address"
This reverts commit 72851d4417.
See also: https://issuetracker.google.com/issues/123456213
This commit is contained in:
@@ -110,6 +110,7 @@ API light grey list:
|
|||||||
* [`Landroid/net/wifi/p2p/WifiP2pManager;->requestPersistentGroupInfo(Landroid/net/wifi/p2p/WifiP2pManager$Channel;Landroid/net/wifi/p2p/WifiP2pManager$PersistentGroupInfoListener;)V`](https://android.googlesource.com/platform/prebuilts/runtime/+/94fec32/appcompat/hiddenapi-light-greylist.txt#4412)
|
* [`Landroid/net/wifi/p2p/WifiP2pManager;->requestPersistentGroupInfo(Landroid/net/wifi/p2p/WifiP2pManager$Channel;Landroid/net/wifi/p2p/WifiP2pManager$PersistentGroupInfoListener;)V`](https://android.googlesource.com/platform/prebuilts/runtime/+/94fec32/appcompat/hiddenapi-light-greylist.txt#4412)
|
||||||
* [`Landroid/net/wifi/p2p/WifiP2pManager;->setWifiP2pChannels(Landroid/net/wifi/p2p/WifiP2pManager$Channel;IILandroid/net/wifi/p2p/WifiP2pManager$ActionListener;)V`](https://android.googlesource.com/platform/prebuilts/runtime/+/94fec32/appcompat/hiddenapi-light-greylist.txt#4416)
|
* [`Landroid/net/wifi/p2p/WifiP2pManager;->setWifiP2pChannels(Landroid/net/wifi/p2p/WifiP2pManager$Channel;IILandroid/net/wifi/p2p/WifiP2pManager$ActionListener;)V`](https://android.googlesource.com/platform/prebuilts/runtime/+/94fec32/appcompat/hiddenapi-light-greylist.txt#4416)
|
||||||
* [`Landroid/net/wifi/p2p/WifiP2pManager;->startWps(Landroid/net/wifi/p2p/WifiP2pManager$Channel;Landroid/net/wifi/WpsInfo;Landroid/net/wifi/p2p/WifiP2pManager$ActionListener;)V`](https://android.googlesource.com/platform/prebuilts/runtime/+/94fec32/appcompat/hiddenapi-light-greylist.txt#4417)
|
* [`Landroid/net/wifi/p2p/WifiP2pManager;->startWps(Landroid/net/wifi/p2p/WifiP2pManager$Channel;Landroid/net/wifi/WpsInfo;Landroid/net/wifi/p2p/WifiP2pManager$ActionListener;)V`](https://android.googlesource.com/platform/prebuilts/runtime/+/94fec32/appcompat/hiddenapi-light-greylist.txt#4417)
|
||||||
|
* [`Ljava/net/InetAddress;->parseNumericAddress(Ljava/lang/String;)Ljava/net/InetAddress;`](https://android.googlesource.com/platform/prebuilts/runtime/+/94fec32/appcompat/hiddenapi-light-greylist.txt#9800)
|
||||||
|
|
||||||
Unlisted private API:
|
Unlisted private API:
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ data class IpNeighbour(val ip: InetAddress, val dev: String, val lladdr: Long, v
|
|||||||
fun parse(line: String): List<IpNeighbour> {
|
fun parse(line: String): List<IpNeighbour> {
|
||||||
return try {
|
return try {
|
||||||
val match = parser.matchEntire(line)!!
|
val match = parser.matchEntire(line)!!
|
||||||
val ip = parseNumericAddress(match.groupValues[2])!! // by regex, ip is non-empty
|
val ip = parseNumericAddress(match.groupValues[2]) // by regex, ip is non-empty
|
||||||
val dev = match.groupValues[3] // by regex, dev is non-empty as well
|
val dev = match.groupValues[3] // by regex, dev is non-empty as well
|
||||||
var lladdr = checkLladdrNotLoopback(match.groupValues[5])
|
var lladdr = checkLladdrNotLoopback(match.groupValues[5])
|
||||||
// use ARP as fallback
|
// use ARP as fallback
|
||||||
if (lladdr.isEmpty()) lladdr = checkLladdrNotLoopback(arp()
|
if (lladdr.isEmpty()) lladdr = checkLladdrNotLoopback(arp()
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ object TrafficRecorder {
|
|||||||
val isReceive = columns[7] == ANYWHERE
|
val isReceive = columns[7] == ANYWHERE
|
||||||
val isSend = columns[8] == ANYWHERE
|
val isSend = columns[8] == ANYWHERE
|
||||||
check(isReceive != isSend) // this check might fail when the user performed an upgrade from 1.x
|
check(isReceive != isSend) // this check might fail when the user performed an upgrade from 1.x
|
||||||
val ip = parseNumericAddress(columns[if (isReceive) 8 else 7])!!
|
val ip = parseNumericAddress(columns[if (isReceive) 8 else 7])
|
||||||
val downstream = columns[if (isReceive) 6 else 5]
|
val downstream = columns[if (isReceive) 6 else 5]
|
||||||
val key = Pair(ip, downstream)
|
val key = Pair(ip, downstream)
|
||||||
val oldRecord = records[key] ?: continue@loop // assuming they're legacy old rules
|
val oldRecord = records[key] ?: continue@loop // assuming they're legacy old rules
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package be.mygod.vpnhotspot.util
|
|||||||
|
|
||||||
import android.content.*
|
import android.content.*
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.system.Os
|
|
||||||
import android.system.OsConstants
|
|
||||||
import android.text.Spannable
|
import android.text.Spannable
|
||||||
import android.text.SpannableString
|
import android.text.SpannableString
|
||||||
import android.text.SpannableStringBuilder
|
import android.text.SpannableStringBuilder
|
||||||
@@ -72,8 +70,12 @@ fun NetworkInterface.formatAddresses() = SpannableStringBuilder().apply {
|
|||||||
}
|
}
|
||||||
}.trimEnd()
|
}.trimEnd()
|
||||||
|
|
||||||
fun parseNumericAddress(address: String?): InetAddress? =
|
private val parseNumericAddress by lazy {
|
||||||
Os.inet_pton(OsConstants.AF_INET, address) ?: Os.inet_pton(OsConstants.AF_INET6, address)
|
InetAddress::class.java.getDeclaredMethod("parseNumericAddress", String::class.java).apply {
|
||||||
|
isAccessible = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fun parseNumericAddress(address: String) = parseNumericAddress.invoke(null, address) as InetAddress
|
||||||
|
|
||||||
fun Context.launchUrl(url: String) {
|
fun Context.launchUrl(url: String) {
|
||||||
if (app.hasTouch) try {
|
if (app.hasTouch) try {
|
||||||
|
|||||||
Reference in New Issue
Block a user