Merge "Ensure that autohide accounts for accessibilty timeout override" into tm-qpr-dev am: a2d33b1a11

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

Change-Id: I7e5858f1604a4e4e902dc77be96eb01cd3264921
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Winson Chung
2023-01-13 17:57:00 +00:00
committed by Automerger Merge Worker
2 changed files with 39 additions and 5 deletions

View File

@@ -1016,6 +1016,9 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
pw.println(" mOrientedHandleSamplingRegion: " + mOrientedHandleSamplingRegion);
mView.dump(pw);
mRegionSamplingHelper.dump(pw);
if (mAutoHideController != null) {
mAutoHideController.dump(pw);
}
}
// ----- CommandQueue Callbacks -----

View File

@@ -16,25 +16,35 @@
package com.android.systemui.statusbar.phone;
import static android.view.accessibility.AccessibilityManager.FLAG_CONTENT_CONTROLS;
import android.content.Context;
import android.os.Handler;
import android.os.RemoteException;
import android.util.Log;
import android.view.IWindowManager;
import android.view.MotionEvent;
import android.view.accessibility.AccessibilityManager;
import androidx.annotation.NonNull;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.statusbar.AutoHideUiElement;
import java.io.PrintWriter;
import javax.inject.Inject;
/** A controller to control all auto-hide things. Also see {@link AutoHideUiElement}. */
@SysUISingleton
public class AutoHideController {
private static final String TAG = "AutoHideController";
private static final long AUTO_HIDE_TIMEOUT_MS = 2250;
private static final int AUTO_HIDE_TIMEOUT_MS = 2250;
private static final int USER_AUTO_HIDE_TIMEOUT_MS = 350;
private final AccessibilityManager mAccessibilityManager;
private final IWindowManager mWindowManagerService;
private final Handler mHandler;
@@ -52,11 +62,12 @@ public class AutoHideController {
};
@Inject
public AutoHideController(Context context, @Main Handler handler,
public AutoHideController(Context context,
@Main Handler handler,
IWindowManager iWindowManager) {
mAccessibilityManager = context.getSystemService(AccessibilityManager.class);
mHandler = handler;
mWindowManagerService = iWindowManager;
mDisplayId = context.getDisplayId();
}
@@ -138,7 +149,12 @@ public class AutoHideController {
private void scheduleAutoHide() {
cancelAutoHide();
mHandler.postDelayed(mAutoHide, AUTO_HIDE_TIMEOUT_MS);
mHandler.postDelayed(mAutoHide, getAutoHideTimeout());
}
private int getAutoHideTimeout() {
return mAccessibilityManager.getRecommendedTimeoutMillis(AUTO_HIDE_TIMEOUT_MS,
FLAG_CONTENT_CONTROLS);
}
public void checkUserAutoHide(MotionEvent event) {
@@ -160,7 +176,13 @@ public class AutoHideController {
private void userAutoHide() {
cancelAutoHide();
mHandler.postDelayed(mAutoHide, 350); // longer than app gesture -> flag clear
// longer than app gesture -> flag clear
mHandler.postDelayed(mAutoHide, getUserAutoHideTimeout());
}
private int getUserAutoHideTimeout() {
return mAccessibilityManager.getRecommendedTimeoutMillis(USER_AUTO_HIDE_TIMEOUT_MS,
FLAG_CONTENT_CONTROLS);
}
private boolean isAnyTransientBarShown() {
@@ -175,6 +197,15 @@ public class AutoHideController {
return false;
}
public void dump(@NonNull PrintWriter pw) {
pw.println("AutoHideController:");
pw.println("\tmAutoHideSuspended=" + mAutoHideSuspended);
pw.println("\tisAnyTransientBarShown=" + isAnyTransientBarShown());
pw.println("\thasPendingAutoHide=" + mHandler.hasCallbacks(mAutoHide));
pw.println("\tgetAutoHideTimeout=" + getAutoHideTimeout());
pw.println("\tgetUserAutoHideTimeout=" + getUserAutoHideTimeout());
}
/**
* Injectable factory for creating a {@link AutoHideController}.
*/