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

Commit 4a0ad9ca 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 am: 694197a5

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



Change-Id: I42ad5ec4782e4bd83ae36f2224db701e5ba32010
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 9496aad9 694197a5
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.