Skip to content

Commit

Permalink
airgap viewmodel part adapted to usb and adb control
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry-Borodin committed Jan 6, 2024
1 parent 9699b1e commit d44d77e
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import java.time.Duration


class AirGapViewModel : ViewModel() {
Expand All @@ -37,11 +36,9 @@ class AirGapViewModel : ViewModel() {
)
val state: StateFlow<AirGapScreenState> = _state.asStateFlow()

//todo dmitry update adb and usb checks
var scope: CoroutineScope? = null

fun isAdbEnabled(context: Context): Boolean {
//todo dmitry check usb checks
private fun isAdbEnabled(context: Context): Boolean {
if (FeatureFlags.isEnabled(FeatureOption.SKIP_USB_CHECK)) return false

return Settings.Global.getInt(context.contentResolver,
Expand All @@ -66,6 +63,11 @@ class AirGapViewModel : ViewModel() {
_state.update { it.copy(wifiDisabled = (newState != false)) }
}
}
scope.launch {
networkExposedStateKeeper.usbDisconnected.collect { newState ->
_state.update { it.copy(isUsbDisconnected = (newState != false)) }
}
}
scope.launch {
while (true) {
val adbEnabled = isAdbEnabled(appContext)
Expand Down

0 comments on commit d44d77e

Please sign in to comment.