Add error logs when none of the state conditions are satisfied

Test: Adding logs. Existing tests pass.

Bug: 203971802

Change-Id: Idfea1e19c56d81a7bb74b291f4ac09ba072f62dd
This commit is contained in:
Jiaming Liu
2022-11-08 02:05:33 +00:00
parent 30053d58f3
commit 2697445dcd

View File

@@ -395,6 +395,10 @@ public final class DeviceStateProviderImpl implements DeviceStateProvider,
break;
}
}
if (newState == INVALID_DEVICE_STATE) {
Slog.e(TAG, "No declared device states match any of the required conditions.");
dumpSensorValues();
}
if (newState != INVALID_DEVICE_STATE && newState != mLastReportedState) {
mLastReportedState = newState;
@@ -592,6 +596,19 @@ public final class DeviceStateProviderImpl implements DeviceStateProvider,
return null;
}
@GuardedBy("mLock")
private void dumpSensorValues() {
Slog.i(TAG, "Sensor values:");
for (Sensor sensor : mLatestSensorEvent.keySet()) {
SensorEvent sensorEvent = mLatestSensorEvent.get(sensor);
if (sensorEvent != null) {
Slog.i(TAG, sensor.getName() + ": " + Arrays.toString(sensorEvent.values));
} else {
Slog.i(TAG, sensor.getName() + ": null");
}
}
}
/**
* Tries to parse the provided file into a {@link DeviceStateConfig} object. Returns
* {@code null} if the file could not be successfully parsed.