fix(android): stabilize motion sampling and gate pedometer command

This commit is contained in:
Ayaan Zaidi
2026-02-28 09:24:23 +05:30
committed by Ayaan Zaidi
parent 18e7938dfd
commit 1bc9da8f9e
7 changed files with 84 additions and 27 deletions

View File

@@ -25,7 +25,8 @@ class InvokeCommandRegistryTest {
locationEnabled = false,
smsAvailable = false,
voiceWakeEnabled = false,
motionAvailable = false,
motionActivityAvailable = false,
motionPedometerAvailable = false,
debugBuild = false,
),
)
@@ -52,7 +53,8 @@ class InvokeCommandRegistryTest {
locationEnabled = true,
smsAvailable = true,
voiceWakeEnabled = true,
motionAvailable = true,
motionActivityAvailable = true,
motionPedometerAvailable = true,
debugBuild = false,
),
)
@@ -79,7 +81,8 @@ class InvokeCommandRegistryTest {
locationEnabled = false,
smsAvailable = false,
voiceWakeEnabled = false,
motionAvailable = false,
motionActivityAvailable = false,
motionPedometerAvailable = false,
debugBuild = false,
),
)
@@ -117,7 +120,8 @@ class InvokeCommandRegistryTest {
locationEnabled = true,
smsAvailable = true,
voiceWakeEnabled = false,
motionAvailable = true,
motionActivityAvailable = true,
motionPedometerAvailable = true,
debugBuild = true,
),
)
@@ -145,4 +149,23 @@ class InvokeCommandRegistryTest {
assertTrue(commands.contains("debug.ed25519"))
assertTrue(commands.contains("app.update"))
}
@Test
fun advertisedCommands_onlyIncludesSupportedMotionCommands() {
val commands =
InvokeCommandRegistry.advertisedCommands(
NodeRuntimeFlags(
cameraEnabled = false,
locationEnabled = false,
smsAvailable = false,
voiceWakeEnabled = false,
motionActivityAvailable = true,
motionPedometerAvailable = false,
debugBuild = false,
),
)
assertTrue(commands.contains(OpenClawMotionCommand.Activity.rawValue))
assertFalse(commands.contains(OpenClawMotionCommand.Pedometer.rawValue))
}
}

View File

@@ -92,7 +92,8 @@ class MotionHandlerTest {
private class FakeMotionDataSource(
private val hasPermission: Boolean,
private val available: Boolean = true,
private val activityAvailable: Boolean = true,
private val pedometerAvailable: Boolean = true,
private val activityRecord: MotionActivityRecord =
MotionActivityRecord(
startISO = "2026-02-28T00:00:00Z",
@@ -117,7 +118,9 @@ private class FakeMotionDataSource(
private val activityError: Throwable? = null,
private val pedometerError: Throwable? = null,
) : MotionDataSource {
override fun isAvailable(context: Context): Boolean = available
override fun isActivityAvailable(context: Context): Boolean = activityAvailable
override fun isPedometerAvailable(context: Context): Boolean = pedometerAvailable
override fun hasPermission(context: Context): Boolean = hasPermission