|
|
@@ -22,17 +22,22 @@ import com.example.modifier.http.ktorClient
|
|
|
import com.example.modifier.service.ModifierService
|
|
|
import io.ktor.client.request.head
|
|
|
import kotlinx.coroutines.delay
|
|
|
-import kotlinx.coroutines.runBlocking
|
|
|
-import org.apache.commons.lang3.StringUtils
|
|
|
+import java.io.BufferedInputStream
|
|
|
+import java.io.ByteArrayOutputStream
|
|
|
import java.io.File
|
|
|
+import java.io.FileInputStream
|
|
|
+import java.io.IOException
|
|
|
+import java.net.InetAddress
|
|
|
+import java.net.NetworkInterface
|
|
|
import java.time.ZoneId
|
|
|
import java.time.ZonedDateTime
|
|
|
import java.time.format.DateTimeFormatter
|
|
|
+import java.util.Collections
|
|
|
import java.util.Locale
|
|
|
-import java.util.Objects
|
|
|
import java.util.UUID
|
|
|
import kotlin.system.exitProcess
|
|
|
|
|
|
+
|
|
|
const val systemTag = "$baseTag/System"
|
|
|
val uniqueId: String
|
|
|
@SuppressLint("HardwareIds")
|
|
|
@@ -269,4 +274,22 @@ fun restartSelf() {
|
|
|
val mgr = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
|
|
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent)
|
|
|
exitProcess(0)
|
|
|
+}
|
|
|
+
|
|
|
+fun getIPAddress(): List<String> {
|
|
|
+ return try {
|
|
|
+ NetworkInterface.getNetworkInterfaces().toList()
|
|
|
+ .flatMap { intf ->
|
|
|
+ intf.inetAddresses.toList()
|
|
|
+ .map {
|
|
|
+ it.hostAddress
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .filter {
|
|
|
+ it.matches(Regex("\\d+\\.\\d+\\.\\d+\\.\\d+")) && !it.startsWith("127.")
|
|
|
+ }
|
|
|
+ } catch (e: Exception) {
|
|
|
+ Log.e(systemTag, "Error getIPAddress", e)
|
|
|
+ emptyList()
|
|
|
+ }
|
|
|
}
|