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

Commit 6ce17fb0 authored by Adrian Roos's avatar Adrian Roos Committed by Android (Google) Code Review
Browse files

Merge "FalsingLog: Fix false positive Log.wtfs" into nyc-mr2-dev

parents 99291e8f 64f87bad
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -84,6 +84,11 @@ public class FalsingLog {
        log("I", tag, s);
    }

    public static void wLogcat(String tag, String s) {
        Log.w(TAG, tag + "\t" + s);
        log("W", tag, s);
    }

    public static void w(String tag, String s) {
        if (LOGCAT) {
            Log.w(TAG, tag + "\t" + s);
@@ -133,7 +138,7 @@ public class FalsingLog {
        pw.println();
    }

    public static synchronized void wtf(String tag, String s) {
    public static synchronized void wtf(String tag, String s, Throwable here) {
        if (!ENABLED) {
            return;
        }
@@ -161,6 +166,6 @@ public class FalsingLog {
            Log.e(TAG, "Unable to write log, build must be debuggable.");
        }

        Log.wtf(TAG, tag + " " + s + "; " + fileMessage);
        Log.wtf(TAG, tag + " " + s + "; " + fileMessage, here);
    }
}
+37 −5
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ public class FalsingManager implements SensorEventListener {
    private boolean mSessionActive = false;
    private int mState = StatusBarState.SHADE;
    private boolean mScreenOn;
    private Runnable mPendingWtf;

    protected final ContentObserver mSettingsObserver = new ContentObserver(mHandler) {
        @Override
@@ -136,6 +137,7 @@ public class FalsingManager implements SensorEventListener {
    private void onSessionStart() {
        if (FalsingLog.ENABLED) {
            FalsingLog.i("onSessionStart", "classifierEnabled=" + isClassiferEnabled());
            clearPendingWtf();
        }
        mBouncerOn = false;
        mSessionActive = true;
@@ -172,13 +174,35 @@ public class FalsingManager implements SensorEventListener {
        if (FalsingLog.ENABLED) {
            // We're getting some false wtfs from touches that happen after the device went
            // to sleep. Only report missing sessions that happen when the device is interactive.
            if (!mSessionActive && mContext.getSystemService(PowerManager.class).isInteractive()) {
                FalsingLog.wtf("isFalseTouch", new StringBuilder()
            if (!mSessionActive && mContext.getSystemService(PowerManager.class).isInteractive()
                    && mPendingWtf == null) {
                int enabled = isEnabled() ? 1 : 0;
                int screenOn = mScreenOn ? 1 : 0;
                String state = StatusBarState.toShortString(mState);
                Throwable here = new Throwable("here");
                FalsingLog.wLogcat("isFalseTouch", new StringBuilder()
                        .append("Session is not active, yet there's a query for a false touch.")
                        .append(" enabled=").append(isEnabled() ? 1 : 0)
                        .append(" mScreenOn=").append(mScreenOn ? 1 : 0)
                        .append(" mState=").append(StatusBarState.toShortString(mState))
                        .append(" enabled=").append(enabled)
                        .append(" mScreenOn=").append(screenOn)
                        .append(" mState=").append(state)
                        .append(". Escalating to WTF if screen does not turn on soon.")
                        .toString());

                // Unfortunately we're also getting false positives for touches that happen right
                // after the screen turns on, but before that notification has made it to us.
                // Unfortunately there's no good way to catch that, except to wait and see if we get
                // the screen on notification soon.
                mPendingWtf = () -> FalsingLog.wtf("isFalseTouch", new StringBuilder()
                        .append("Session did not become active after query for a false touch.")
                        .append(" enabled=").append(enabled)
                        .append('/').append(isEnabled() ? 1 : 0)
                        .append(" mScreenOn=").append(screenOn)
                        .append('/').append(mScreenOn ? 1 : 0)
                        .append(" mState=").append(state)
                        .append('/').append(StatusBarState.toShortString(mState))
                        .append(". Look for warnings ~1000ms earlier to see root cause.")
                        .toString(), here);
                mHandler.postDelayed(mPendingWtf, 1000);
            }
        }
        if (mAccessibilityManager.isTouchExplorationEnabled()) {
@@ -189,6 +213,13 @@ public class FalsingManager implements SensorEventListener {
        return mHumanInteractionClassifier.isFalseTouch();
    }

    private void clearPendingWtf() {
        if (mPendingWtf != null) {
            mHandler.removeCallbacks(mPendingWtf);
            mPendingWtf = null;
        }
    }

    @Override
    public synchronized void onSensorChanged(SensorEvent event) {
        mDataCollector.onSensorChanged(event);
@@ -224,6 +255,7 @@ public class FalsingManager implements SensorEventListener {
            FalsingLog.i("onScreenTurningOn", new StringBuilder()
                    .append("from=").append(mScreenOn ? 1 : 0)
                    .toString());
            clearPendingWtf();
        }
        mScreenOn = true;
        if (sessionEntrypoint()) {