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

Commit 694197a5 authored by Jiaming Liu's avatar Jiaming Liu Committed by Automerger Merge Worker
Browse files

Merge "Add error logs when none of the state conditions are satisfied" into...

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

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20405420



Change-Id: Ic2c0002d19de605fb848527e1db56abe30627471
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents d7ab244c 452cefc3
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.