-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Android] virtual-device-app: Add usecase of the Doorlock/PowerSource…
… cluster (#29708) * virtual-device-app: Add powersource usecase Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> * virtual-device-app: Add doorlock usecase Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]> --------- Signed-off-by: Jaehoon You <[email protected]> Signed-off-by: Charles Kim <[email protected]>
- Loading branch information
1 parent
9e0c513
commit 4643010
Showing
5 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
...virtual/device/app/core/domain/usecase/matter/cluster/doorlock/GetLockStateFlowUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
19 changes: 19 additions & 0 deletions
19
...rtual/device/app/core/domain/usecase/matter/cluster/doorlock/SendLockAlarmEventUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...ter/virtual/device/app/core/domain/usecase/matter/cluster/doorlock/SetLockStateUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...evice/app/core/domain/usecase/matter/cluster/powersource/GetBatPercentRemainingUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
19 changes: 19 additions & 0 deletions
19
...evice/app/core/domain/usecase/matter/cluster/powersource/SetBatPercentRemainingUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |