Add support for checking app updates
This commit is contained in:
10
mobile/src/main/java/be/mygod/vpnhotspot/util/AppUpdate.kt
Normal file
10
mobile/src/main/java/be/mygod/vpnhotspot/util/AppUpdate.kt
Normal file
@@ -0,0 +1,10 @@
|
||||
package be.mygod.vpnhotspot.util
|
||||
|
||||
import android.app.Activity
|
||||
|
||||
interface AppUpdate {
|
||||
val downloaded: Boolean? get() = null
|
||||
val message: String? get() = null
|
||||
val stalenessDays: Int? get() = null
|
||||
fun updateForResult(activity: Activity, requestCode: Int): Unit = error("Update not supported")
|
||||
}
|
||||
@@ -24,6 +24,9 @@ import androidx.fragment.app.FragmentManager
|
||||
import be.mygod.vpnhotspot.App.Companion.app
|
||||
import be.mygod.vpnhotspot.net.MacAddressCompat
|
||||
import be.mygod.vpnhotspot.widget.SmartSnackbar
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
import java.io.FileNotFoundException
|
||||
@@ -32,6 +35,7 @@ import java.lang.invoke.MethodHandles
|
||||
import java.lang.reflect.InvocationHandler
|
||||
import java.lang.reflect.InvocationTargetException
|
||||
import java.lang.reflect.Method
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.InetAddress
|
||||
import java.net.NetworkInterface
|
||||
import java.net.SocketException
|
||||
@@ -66,6 +70,10 @@ fun Method.matchesCompat(name: String, args: Array<out Any?>?, vararg classes: C
|
||||
}
|
||||
} else matches(name, *classes)
|
||||
|
||||
fun HttpURLConnection.disconnectCompat() {
|
||||
if (Build.VERSION.SDK_INT < 26) GlobalScope.launch(Dispatchers.IO) { disconnect() } else disconnect()
|
||||
}
|
||||
|
||||
fun Context.ensureReceiverUnregistered(receiver: BroadcastReceiver) {
|
||||
try {
|
||||
unregisterReceiver(receiver)
|
||||
|
||||
Reference in New Issue
Block a user