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

Commit 452cefc3 authored by Jiaming Liu's avatar Jiaming Liu Committed by Android (Google) Code Review
Browse files

Merge "Add error logs when none of the state conditions are satisfied" into tm-qpr-dev

parents b9613ed1 2697445d
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.