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

Commit e519bad7 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move FaceDownDetector sensor config to background" into main

parents 845cbbbb 79379c19
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.provider.DeviceConfig;
import android.util.Slog;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.BackgroundThread;
import com.android.internal.util.FrameworkStatsLog;

import java.io.PrintWriter;
@@ -205,12 +206,13 @@ public class FaceDownDetector implements SensorEventListener {
        final boolean shouldBeActive = mInteractive && mIsEnabled && !sawRecentInteraction;
        if (mActive != shouldBeActive) {
            if (shouldBeActive) {
                BackgroundThread.getHandler().post(() -> {
                    mSensorManager.registerListener(
                            this,
                            mAccelerometer,
                            SensorManager.SENSOR_DELAY_NORMAL,
                        mSensorMaxLatencyMicros
                );
                            mSensorMaxLatencyMicros);
                });
                if (mPreviousResultType == SCREEN_OFF_RESULT) {
                    logScreenOff();
                }
@@ -219,7 +221,9 @@ public class FaceDownDetector implements SensorEventListener {
                    mPreviousResultType = SCREEN_OFF_RESULT;
                    mPreviousResultTime = currentTime;
                }
                BackgroundThread.getHandler().post(() -> {
                    mSensorManager.unregisterListener(this);
                });
                mFaceDown = false;
                mOnFlip.accept(false);
            }