diff options
| author | David Samuelson <samuelsond@google.com> | 2022-01-28 05:30:43 +0000 |
|---|---|---|
| committer | David Samuelson <samuelsond@google.com> | 2022-02-01 20:38:07 +0000 |
| commit | 36764e48959bf3d2f17b7bbe1563a9c1f1aaabbd (patch) | |
| tree | c1ac7dec4a542db79f475a165602f96f1af0ff30 /core/java/android | |
| parent | 53fef98a25469d2ea669259c77ea13780e4a1292 (diff) | |
Introduce GameSession.onTransientSystemBarsVisibilityFromRevealGestureChanged(...)
Adds support for a GameSession to detect when the transient system bars
are revealed and hidden using the GameSession reveal gesture.
Test: Manual e2e testing
Bug: 210119966
Bug: 202414447
Bug: 202417255
CTS-Coverage-Bug: 206128693
Change-Id: I614f9aeae65d6be6e3262ef58011612062036b35
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/service/games/GameSession.java | 44 | ||||
| -rw-r--r-- | core/java/android/service/games/IGameSession.aidl | 1 |
2 files changed, 43 insertions, 2 deletions
diff --git a/core/java/android/service/games/GameSession.java b/core/java/android/service/games/GameSession.java index 9590933cf2da..e33f1801129b 100644 --- a/core/java/android/service/games/GameSession.java +++ b/core/java/android/service/games/GameSession.java @@ -84,6 +84,15 @@ public abstract class GameSession { } @Override + public void onTransientSystemBarVisibilityFromRevealGestureChanged( + boolean visibleDueToGesture) { + Handler.getMain().executeOrSendMessage(PooledLambda.obtainMessage( + GameSession::dispatchTransientSystemBarVisibilityFromRevealGestureChanged, + GameSession.this, + visibleDueToGesture)); + } + + @Override public void onTaskFocusChanged(boolean focused) { Handler.getMain().executeOrSendMessage(PooledLambda.obtainMessage( GameSession::moveToState, GameSession.this, @@ -109,6 +118,7 @@ public abstract class GameSession { } private LifecycleState mLifecycleState = LifecycleState.INITIALIZED; + private boolean mAreTransientInsetsVisibleDueToGesture = false; private IGameSessionController mGameSessionController; private int mTaskId; private GameSessionRootView mGameSessionRootView; @@ -138,11 +148,23 @@ public abstract class GameSession { } @Hide - void doDestroy() { + private void doDestroy() { mSurfaceControlViewHost.release(); moveToState(LifecycleState.DESTROYED); } + /** @hide */ + @VisibleForTesting + @MainThread + public void dispatchTransientSystemBarVisibilityFromRevealGestureChanged( + boolean visibleDueToGesture) { + boolean didValueChange = mAreTransientInsetsVisibleDueToGesture != visibleDueToGesture; + mAreTransientInsetsVisibleDueToGesture = visibleDueToGesture; + if (didValueChange) { + onTransientSystemBarVisibilityFromRevealGestureChanged(visibleDueToGesture); + } + } + /** * @hide */ @@ -252,7 +274,23 @@ public abstract class GameSession { * * @param focused True if the game task is focused, false if the game task is unfocused. */ - public void onGameTaskFocusChanged(boolean focused) {} + public void onGameTaskFocusChanged(boolean focused) { + } + + /** + * Called when the visibility of the transient system bars changed due to the user performing + * the reveal gesture. The reveal gesture is defined as a swipe to reveal the transient system + * bars that originates from the system bars. + * + * @param visibleDueToGesture if the transient bars triggered by the reveal gesture are visible. + * This is {@code true} when the transient system bars become visible + * due to user performing the reveal gesture. This is {@code false} + * when the transient system bars are hidden or become permanently + * visible. + */ + public void onTransientSystemBarVisibilityFromRevealGestureChanged( + boolean visibleDueToGesture) { + } /** * Sets the task overlay content to an explicit view. This view is placed directly into the game @@ -344,12 +382,14 @@ public abstract class GameSession { /** * Called when taking the screenshot failed. + * * @param statusCode Indicates the reason for failure. */ void onFailure(@ScreenshotFailureStatus int statusCode); /** * Called when taking the screenshot succeeded. + * * @param bitmap The screenshot. */ void onSuccess(@NonNull Bitmap bitmap); diff --git a/core/java/android/service/games/IGameSession.aidl b/core/java/android/service/games/IGameSession.aidl index 71da6302b63d..49c36c6a301c 100644 --- a/core/java/android/service/games/IGameSession.aidl +++ b/core/java/android/service/games/IGameSession.aidl @@ -21,5 +21,6 @@ package android.service.games; */ oneway interface IGameSession { void onDestroyed(); + void onTransientSystemBarVisibilityFromRevealGestureChanged(boolean visibleDueToGesture); void onTaskFocusChanged(boolean focused); } |
