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

Commit 347bb37f authored by Jason Chang's avatar Jason Chang Committed by Android (Google) Code Review
Browse files

Merge "Fix screen should not automatically leave one-handed mode when the...

Merge "Fix screen should not automatically leave one-handed mode when the TalkBack user is exploring"
parents 72ced073 0db51114
Loading
Loading
Loading
Loading
+27 −0
Original line number Original line Diff line number Diff line
@@ -32,6 +32,7 @@ import android.os.ServiceManager;
import android.os.SystemProperties;
import android.os.SystemProperties;
import android.provider.Settings;
import android.provider.Settings;
import android.util.Slog;
import android.util.Slog;
import android.view.accessibility.AccessibilityManager;


import androidx.annotation.NonNull;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Nullable;
@@ -75,6 +76,7 @@ public class OneHandedController implements OneHanded {
    private final Handler mMainHandler = new Handler(Looper.getMainLooper());
    private final Handler mMainHandler = new Handler(Looper.getMainLooper());


    private OneHandedDisplayAreaOrganizer mDisplayAreaOrganizer;
    private OneHandedDisplayAreaOrganizer mDisplayAreaOrganizer;
    private final AccessibilityManager mAccessibilityManager;


    /**
    /**
     * Handle rotation based on OnDisplayChangingListener callback
     * Handle rotation based on OnDisplayChangingListener callback
@@ -164,6 +166,26 @@ public class OneHandedController implements OneHanded {
                }
                }
            };
            };


    private AccessibilityManager.AccessibilityStateChangeListener
            mAccessibilityStateChangeListener =
            new AccessibilityManager.AccessibilityStateChangeListener() {
                @Override
                public void onAccessibilityStateChanged(boolean enabled) {
                    if (enabled) {
                        final int mOneHandedTimeout = OneHandedSettingsUtil
                                .getSettingsOneHandedModeTimeout(mContext.getContentResolver());
                        final int timeout = mAccessibilityManager
                                .getRecommendedTimeoutMillis(mOneHandedTimeout * 1000
                                        /* align with A11y timeout millis */,
                                        AccessibilityManager.FLAG_CONTENT_CONTROLS);
                        mTimeoutHandler.setTimeout(timeout / 1000);
                    } else {
                        mTimeoutHandler.setTimeout(OneHandedSettingsUtil
                                .getSettingsOneHandedModeTimeout(mContext.getContentResolver()));
                    }
                }
            };

    /**
    /**
     * Creates {@link OneHandedController}, returns {@code null} if the feature is not supported.
     * Creates {@link OneHandedController}, returns {@code null} if the feature is not supported.
     */
     */
@@ -239,6 +261,11 @@ public class OneHandedController implements OneHanded {
                        stopOneHanded(OneHandedEvents.EVENT_ONE_HANDED_TRIGGER_APP_TAPS_OUT);
                        stopOneHanded(OneHandedEvents.EVENT_ONE_HANDED_TRIGGER_APP_TAPS_OUT);
                    }
                    }
                });
                });

        mAccessibilityManager = (AccessibilityManager)
                context.getSystemService(Context.ACCESSIBILITY_SERVICE);
        mAccessibilityManager.addAccessibilityStateChangeListener(
                mAccessibilityStateChangeListener);
    }
    }


    /**
    /**