Skip to content

Commit

Permalink
Fix getting hidden global settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Mygod committed Feb 29, 2024
1 parent cd8b302 commit 81ecda8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ Greylisted/blacklisted APIs or internal constants: (some constants are hardcoded
* (since API 29) `Landroid/net/wifi/p2p/WifiP2pConfig$Builder;->mNetworkName:Ljava/lang/String;,blocked`
* `Landroid/net/wifi/p2p/WifiP2pManager;->startWps(Landroid/net/wifi/p2p/WifiP2pManager$Channel;Landroid/net/wifi/WpsInfo;Landroid/net/wifi/p2p/WifiP2pManager$ActionListener;)V,unsupported`
* (prior to API 30) `Landroid/provider/Settings$Global;->SOFT_AP_TIMEOUT_ENABLED:Ljava/lang/String;,lo-prio,max-target-o`
* (since API 31) `Landroid/provider/Settings;->setInSystemServer()V,lo-prio,max-target-o`
* (prior to API 30) `Lcom/android/internal/R$array;->config_tether_bluetooth_regexs:I,max-target-q`
* (prior to API 30) `Lcom/android/internal/R$array;->config_tether_usb_regexs:I,max-target-q`
* (prior to API 30) `Lcom/android/internal/R$array;->config_tether_wifi_regexs:I,max-target-q`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.annotation.RequiresApi
import be.mygod.vpnhotspot.App.Companion.app
import be.mygod.vpnhotspot.R
import be.mygod.vpnhotspot.util.RootSession
import be.mygod.vpnhotspot.util.UnblockCentral
import be.mygod.vpnhotspot.widget.SmartSnackbar
import timber.log.Timber

Expand Down Expand Up @@ -74,6 +75,7 @@ object VpnFirewallManager {
return
}
val uid = Process.myUid()
UnblockCentral.Settings_setInSystemServer
val allowed = Settings.Global.getString(app.contentResolver, UIDS_ALLOWED_ON_RESTRICTED_NETWORKS)
?.splitToSequence(';')?.mapNotNull { it.toIntOrNull() }?.toMutableSet() ?: mutableSetOf()
if (!allowed.contains(uid)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.net.MacAddress
import android.net.wifi.SoftApConfiguration
import android.net.wifi.p2p.WifiP2pConfig
import android.provider.Settings
import androidx.annotation.RequiresApi
import org.lsposed.hiddenapibypass.HiddenApiBypass

Expand Down Expand Up @@ -40,4 +41,9 @@ object UnblockCentral {
val WifiP2pConfig_Builder_mNetworkName get() = init.let {
WifiP2pConfig.Builder::class.java.getDeclaredField("mNetworkName").apply { isAccessible = true }
}

val Settings_setInSystemServer by lazy {
init
Settings::class.java.getDeclaredMethod("setInSystemServer")(null)
}
}

0 comments on commit 81ecda8

Please sign in to comment.