Target Android 13 on freedom as well
This commit is contained in:
@@ -115,12 +115,13 @@ class App : Application() {
|
||||
* https://android.googlesource.com/platform/frameworks/opt/net/wifi/+/53e0284/service/java/com/android/server/wifi/WifiSettingsStore.java#228
|
||||
*/
|
||||
inline fun <reified T> startServiceWithLocation(context: Context) {
|
||||
if (BuildConfig.TARGET_SDK >= 33 && Build.VERSION.SDK_INT >= 33 || if (Build.VERSION.SDK_INT >= 28) {
|
||||
location?.isLocationEnabled == true
|
||||
} else @Suppress("DEPRECATION") {
|
||||
Settings.Secure.getInt(context.contentResolver, Settings.Secure.LOCATION_MODE,
|
||||
Settings.Secure.LOCATION_MODE_OFF) != Settings.Secure.LOCATION_MODE_OFF
|
||||
}) ContextCompat.startForegroundService(context, Intent(context, T::class.java)) else try {
|
||||
val canStart = Build.VERSION.SDK_INT >= 33 || if (Build.VERSION.SDK_INT >= 28) {
|
||||
location?.isLocationEnabled == true
|
||||
} else @Suppress("DEPRECATION") {
|
||||
Settings.Secure.getInt(context.contentResolver, Settings.Secure.LOCATION_MODE,
|
||||
Settings.Secure.LOCATION_MODE_OFF) != Settings.Secure.LOCATION_MODE_OFF
|
||||
}
|
||||
if (canStart) ContextCompat.startForegroundService(context, Intent(context, T::class.java)) else try {
|
||||
context.startActivity(Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS))
|
||||
Toast.makeText(context, R.string.tethering_location_off, Toast.LENGTH_LONG).show()
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.net.NetworkInterface
|
||||
class LocalOnlyHotspotManager(private val parent: TetheringFragment) : Manager(), ServiceConnection {
|
||||
companion object {
|
||||
val permission = when {
|
||||
BuildConfig.TARGET_SDK >= 33 && Build.VERSION.SDK_INT >= 33 -> Manifest.permission.NEARBY_WIFI_DEVICES
|
||||
Build.VERSION.SDK_INT >= 33 -> Manifest.permission.NEARBY_WIFI_DEVICES
|
||||
Build.VERSION.SDK_INT >= 29 -> Manifest.permission.ACCESS_FINE_LOCATION
|
||||
else -> Manifest.permission.ACCESS_COARSE_LOCATION
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ class RepeaterManager(private val parent: TetheringFragment) : Manager(), Servic
|
||||
when (binder?.service?.status) {
|
||||
RepeaterService.Status.IDLE -> if (Build.VERSION.SDK_INT < 29) parent.requireContext().let { context ->
|
||||
ContextCompat.startForegroundService(context, Intent(context, RepeaterService::class.java))
|
||||
} else parent.startRepeater.launch(if (BuildConfig.TARGET_SDK >= 33 && Build.VERSION.SDK_INT >= 33) {
|
||||
} else parent.startRepeater.launch(if (Build.VERSION.SDK_INT >= 33) {
|
||||
Manifest.permission.NEARBY_WIFI_DEVICES
|
||||
} else Manifest.permission.ACCESS_FINE_LOCATION)
|
||||
RepeaterService.Status.ACTIVE -> binder.shutdown()
|
||||
|
||||
@@ -30,8 +30,7 @@ abstract class IpMonitor {
|
||||
var currentMode: Mode
|
||||
get() {
|
||||
// Completely restricted on Android 13: https://github.com/termux/termux-app/issues/2993#issuecomment-1250312777
|
||||
val isLegacy = Build.VERSION.SDK_INT < 33 && (Build.VERSION.SDK_INT < 30 || BuildConfig.TARGET_SDK < 30)
|
||||
val defaultMode = if (isLegacy) @Suppress("DEPRECATION") {
|
||||
val defaultMode = if (Build.VERSION.SDK_INT < 30) @Suppress("DEPRECATION") {
|
||||
Mode.Poll
|
||||
} else Mode.MonitorRoot
|
||||
return Mode.valueOf(app.pref.getString(KEY, defaultMode.toString()) ?: "")
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.net.wifi.SoftApConfiguration
|
||||
import android.net.wifi.p2p.WifiP2pConfig
|
||||
import androidx.annotation.RequiresApi
|
||||
import be.mygod.vpnhotspot.App.Companion.app
|
||||
import me.weishu.reflection.Reflection
|
||||
|
||||
/**
|
||||
* The central object for accessing all the useful blocked APIs. Thanks Google!
|
||||
@@ -20,7 +21,7 @@ object UnblockCentral {
|
||||
/**
|
||||
* Retrieve this property before doing dangerous shit.
|
||||
*/
|
||||
private val init by lazy { if (needInit) UnblockHelper(app.deviceStorage) }
|
||||
private val init by lazy { if (needInit) check(Reflection.unseal(app.deviceStorage) == 0) }
|
||||
|
||||
@RequiresApi(33)
|
||||
fun getCountryCode(clazz: Class<*>) = init.let { clazz.getDeclaredMethod("getCountryCode") }
|
||||
|
||||
Reference in New Issue
Block a user