Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2697445d authored by Jiaming Liu's avatar Jiaming Liu
Browse files

Add error logs when none of the state conditions are satisfied

Test: Adding logs. Existing tests pass.

Bug: 203971802

Change-Id: Idfea1e19c56d81a7bb74b291f4ac09ba072f62dd
parent 30053d58
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -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.