Skip to content

Commit

Permalink
[Android] virtual-device-app: Add usecase of the Doorlock/PowerSource…
Browse files Browse the repository at this point in the history
… cluster (project-chip#29708)

* virtual-device-app: Add powersource usecase

Signed-off-by: Jaehoon You <jaehoon.you@samsung.com>
Signed-off-by: Charles Kim <chulspro.kim@samsung.com>

* virtual-device-app: Add doorlock usecase

Signed-off-by: Jaehoon You <jaehoon.you@samsung.com>
Signed-off-by: Charles Kim <chulspro.kim@samsung.com>

---------

Signed-off-by: Jaehoon You <jaehoon.you@samsung.com>
Signed-off-by: Charles Kim <chulspro.kim@samsung.com>
  • Loading branch information
Jaehoon-You authored Oct 17, 2023
1 parent 462c79a commit b8c1cec
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.matter.virtual.device.app.core.domain.usecase.matter.cluster.doorlock

import com.matter.virtual.device.app.core.data.repository.cluster.DoorLockManagerRepository
import javax.inject.Inject
import kotlinx.coroutines.flow.StateFlow

class GetLockStateFlowUseCase
@Inject
constructor(private val doorLockManagerRepository: DoorLockManagerRepository) {

operator fun invoke(): StateFlow<Boolean> = doorLockManagerRepository.getLockStateFlow()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.matter.virtual.device.app.core.domain.usecase.matter.cluster.doorlock

import com.matter.virtual.device.app.core.common.di.IoDispatcher
import com.matter.virtual.device.app.core.data.repository.cluster.DoorLockManagerRepository
import com.matter.virtual.device.app.core.domain.NonParamCoroutineUseCase
import javax.inject.Inject
import kotlinx.coroutines.CoroutineDispatcher

class SendLockAlarmEventUseCase
@Inject
constructor(
private val doorLockManagerRepository: DoorLockManagerRepository,
@IoDispatcher dispatcher: CoroutineDispatcher
) : NonParamCoroutineUseCase<Unit>(dispatcher) {

override suspend fun execute() {
return doorLockManagerRepository.sendLockAlarmEvent()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.matter.virtual.device.app.core.domain.usecase.matter.cluster.doorlock

import com.matter.virtual.device.app.core.common.di.IoDispatcher
import com.matter.virtual.device.app.core.data.repository.cluster.DoorLockManagerRepository
import com.matter.virtual.device.app.core.domain.CoroutineUseCase
import javax.inject.Inject
import kotlinx.coroutines.CoroutineDispatcher

class SetLockStateUseCase
@Inject
constructor(
private val doorLockManagerRepository: DoorLockManagerRepository,
@IoDispatcher dispatcher: CoroutineDispatcher
) : CoroutineUseCase<Boolean, Unit>(dispatcher) {

override suspend fun execute(param: Boolean) {
doorLockManagerRepository.setLockState(param)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.matter.virtual.device.app.core.domain.usecase.matter.cluster.powersource

import com.matter.virtual.device.app.core.data.repository.cluster.PowerSourceManagerRepository
import javax.inject.Inject
import kotlinx.coroutines.flow.StateFlow

class GetBatPercentRemainingUseCase
@Inject
constructor(
private val powerSourceManagerRepository: PowerSourceManagerRepository,
) {
operator fun invoke(): StateFlow<Int> = powerSourceManagerRepository.getBatPercent()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.matter.virtual.device.app.core.domain.usecase.matter.cluster.powersource

import com.matter.virtual.device.app.core.common.di.IoDispatcher
import com.matter.virtual.device.app.core.data.repository.cluster.PowerSourceManagerRepository
import com.matter.virtual.device.app.core.domain.CoroutineUseCase
import javax.inject.Inject
import kotlinx.coroutines.CoroutineDispatcher

class SetBatPercentRemainingUseCase
@Inject
constructor(
private val powerSourceManagerRepository: PowerSourceManagerRepository,
@IoDispatcher dispatcher: CoroutineDispatcher
) : CoroutineUseCase<Int, Unit>(dispatcher) {

override suspend fun execute(param: Int) {
powerSourceManagerRepository.setBatPercentRemaining(param)
}
}

0 comments on commit b8c1cec

Please sign in to comment.