Merge "Add testApi to query global keys."

This commit is contained in:
Philip Junker
2022-10-07 10:01:49 +00:00
committed by Android (Google) Code Review
8 changed files with 53 additions and 0 deletions

View File

@@ -2942,6 +2942,7 @@ package android.view {
public interface WindowManager extends android.view.ViewManager {
method public default int getDisplayImePolicy(int);
method public default void holdLock(android.os.IBinder, int);
method public default boolean isGlobalKey(int);
method public default boolean isTaskSnapshotSupported();
method public default void setDisplayImePolicy(int, int);
method public default void setShouldShowSystemDecors(int, boolean);

View File

@@ -985,4 +985,12 @@ interface IWindowManager
*/
oneway void captureDisplay(int displayId, in @nullable ScreenCapture.CaptureArgs captureArgs,
in ScreenCapture.ScreenCaptureListener listener);
/**
* Returns {@code true} if the key will be handled globally and not forwarded to all apps.
*
* @param keyCode the key code to check
* @return {@code true} if the key will be handled globally.
*/
boolean isGlobalKey(int keyCode);
}

View File

@@ -944,6 +944,18 @@ public interface WindowManager extends ViewManager {
return DISPLAY_IME_POLICY_FALLBACK_DISPLAY;
}
/**
* Returns {@code true} if the key will be handled globally and not forwarded to all apps.
*
* @param keyCode the key code to check
* @return {@code true} if the key will be handled globally.
* @hide
*/
@TestApi
default boolean isGlobalKey(int keyCode) {
return false;
}
/**
* <p>
* Returns whether cross-window blur is currently enabled. This affects both window blur behind

View File

@@ -282,6 +282,15 @@ public final class WindowManagerImpl implements WindowManager {
return DISPLAY_IME_POLICY_FALLBACK_DISPLAY;
}
@Override
public boolean isGlobalKey(int keyCode) {
try {
return WindowManagerGlobal.getWindowManagerService().isGlobalKey(keyCode);
} catch (RemoteException e) {
}
return false;
}
@Override
public WindowMetrics getCurrentWindowMetrics() {
final Context context = mParentWindow != null ? mParentWindow.getContext() : mContext;

View File

@@ -5493,6 +5493,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
effectId, always, reason);
}
@Override
public boolean isGlobalKey(int keyCode) {
return mGlobalKeyManager.shouldHandleGlobalKey(keyCode);
}
@Override
public boolean performHapticFeedback(int uid, String packageName, int effectId,
boolean always, String reason) {

View File

@@ -1188,4 +1188,12 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
* A new window on default display has been focused.
*/
default void onDefaultDisplayFocusChangedLw(WindowState newFocus) {}
/**
* Returns {@code true} if the key will be handled globally and not forwarded to all apps.
*
* @param keyCode the key code to check
* @return {@code true} if the key will be handled globally.
*/
boolean isGlobalKey(int keyCode);
}

View File

@@ -9355,4 +9355,9 @@ public class WindowManagerService extends IWindowManager.Stub
.setSourceCrop(mTmpRect)
.build();
}
@Override
public boolean isGlobalKey(int keyCode) {
return mPolicy.isGlobalKey(keyCode);
}
}

View File

@@ -338,4 +338,9 @@ class TestWindowManagerPolicy implements WindowManagerPolicy {
public boolean canDismissBootAnimation() {
return true;
}
@Override
public boolean isGlobalKey(int keyCode) {
return false;
}
}