summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tyler Lacey <tlacey@google.com> 2022-04-06 14:04:52 +0000
committer Tyler Lacey <tlacey@google.com> 2022-04-19 15:22:22 -0400
commit1f1f7c604f8fe97864ccc381db330efafc34206a (patch)
treef6e456b255bef4e3ae7eefc5e3fc7b5ba32edad2
parentb45b8bdc941f2a337ccb8e9d3b35929a93316a63 (diff)
Use Window Context for SurfaceControlViewHost.
This change is needed so that views will receive configuration changes via link View#onConfigurationChanged. Bug: 228343237 Test: Manual testing Change-Id: Iccc09babb910867e0cd8b21ed750d67e87b944f9
-rw-r--r--core/java/android/service/games/GameSessionService.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/core/java/android/service/games/GameSessionService.java b/core/java/android/service/games/GameSessionService.java
index df5bad5c53b2..52c8ec3d4018 100644
--- a/core/java/android/service/games/GameSessionService.java
+++ b/core/java/android/service/games/GameSessionService.java
@@ -21,6 +21,7 @@ import android.annotation.Nullable;
import android.annotation.SdkConstant;
import android.annotation.SystemApi;
import android.app.Service;
+import android.content.Context;
import android.content.Intent;
import android.hardware.display.DisplayManager;
import android.os.Binder;
@@ -28,6 +29,7 @@ import android.os.Handler;
import android.os.IBinder;
import android.view.Display;
import android.view.SurfaceControlViewHost;
+import android.view.WindowManager;
import com.android.internal.infra.AndroidFuture;
import com.android.internal.util.function.pooled.PooledLambda;
@@ -117,13 +119,18 @@ public abstract class GameSessionService extends Service {
}
IBinder hostToken = new Binder();
+
+ // Use a WindowContext so that views attached to the SurfaceControlViewHost will receive
+ // configuration changes (rather than always perceiving the global configuration).
+ final Context windowContext = createWindowContext(display,
+ WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY, /*options=*/ null);
SurfaceControlViewHost surfaceControlViewHost =
- new SurfaceControlViewHost(this, display, hostToken);
+ new SurfaceControlViewHost(windowContext, display, hostToken);
gameSession.attach(
gameSessionController,
createGameSessionRequest.getTaskId(),
- this,
+ windowContext,
surfaceControlViewHost,
gameSessionViewHostConfiguration.mWidthPx,
gameSessionViewHostConfiguration.mHeightPx);