|
@@ -12,6 +12,7 @@ import androidx.datastore.preferences.preferencesDataStore
|
|
|
import com.example.modifier.BuildConfig
|
|
import com.example.modifier.BuildConfig
|
|
|
import com.example.modifier.data.AppPreferences
|
|
import com.example.modifier.data.AppPreferences
|
|
|
import com.example.modifier.utils.getContext
|
|
import com.example.modifier.utils.getContext
|
|
|
|
|
+import com.example.modifier.utils.shellRun
|
|
|
import com.example.modifier.utils.uniqueId
|
|
import com.example.modifier.utils.uniqueId
|
|
|
import kotlinx.coroutines.CoroutineScope
|
|
import kotlinx.coroutines.CoroutineScope
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
import kotlinx.coroutines.Dispatchers
|
|
@@ -88,7 +89,15 @@ class AppPrefsRepo private constructor(private val context: Context) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// suspend fun stateFlow() = appPreferencesFlow.stateIn(CoroutineScope(coroutineContext))
|
|
|
|
|
|
|
+ // suspend fun stateFlow() = appPreferencesFlow.stateIn(CoroutineScope(coroutineContext))
|
|
|
|
|
+ suspend fun updateId() {
|
|
|
|
|
+ val serialNo = shellRun("getprop ro.serialno").first.trim()
|
|
|
|
|
+ if (serialNo.isNotBlank() && serialNo != appPrefs.value.id) {
|
|
|
|
|
+ context.appPreferencesDataStore.edit { preferences ->
|
|
|
|
|
+ preferences[PreferencesKeys.ID] = serialNo
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
suspend fun updateId(id: String) {
|
|
suspend fun updateId(id: String) {
|
|
|
context.appPreferencesDataStore.edit { preferences ->
|
|
context.appPreferencesDataStore.edit { preferences ->
|