SurfaceControlViewHost: Add side-channel to SurfacePackage
We add a control interface in to surface-package which allows the embedding process to dispatch events back to the embedded process. So far we support forwarding configuration changes, and dispatching a detach view hierarchy message. Bug: 213603716 Test: Existing tests pass Change-Id: I7d68628d845b5da687568ffa20529ce2a7772495
This commit is contained in:
28
core/java/android/view/ISurfaceControlViewHost.aidl
Normal file
28
core/java/android/view/ISurfaceControlViewHost.aidl
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
** Copyright 2021, The Android Open Source Project
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
package android.view;
|
||||
|
||||
import android.content.res.Configuration;
|
||||
|
||||
/**
|
||||
* API from content embedder back to embedded content in SurfaceControlViewHost
|
||||
* {@hide}
|
||||
*/
|
||||
oneway interface ISurfaceControlViewHost {
|
||||
void onConfigurationChanged(in Configuration newConfig);
|
||||
void onDispatchDetachedFromWindow();
|
||||
}
|
||||
@@ -73,6 +73,7 @@ per-file Inset*.aidl = file:/services/core/java/com/android/server/wm/OWNERS
|
||||
per-file IPinnedStackListener.aidl = file:/services/core/java/com/android/server/wm/OWNERS
|
||||
per-file IRecents*.aidl = file:/services/core/java/com/android/server/wm/OWNERS
|
||||
per-file IRemote*.aidl = file:/services/core/java/com/android/server/wm/OWNERS
|
||||
per-file ISurfaceControlViewHost*.aidl = file:/services/core/java/com/android/server/wm/OWNERS
|
||||
per-file IWindow*.aidl = file:/services/core/java/com/android/server/wm/OWNERS
|
||||
per-file RemoteAnimation*.java = file:/services/core/java/com/android/server/wm/OWNERS
|
||||
per-file RemoteAnimation*.aidl = file:/services/core/java/com/android/server/wm/OWNERS
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.TestApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.os.IBinder;
|
||||
import android.os.Parcel;
|
||||
@@ -45,6 +46,35 @@ public class SurfaceControlViewHost {
|
||||
private SurfaceControl mSurfaceControl;
|
||||
private IAccessibilityEmbeddedConnection mAccessibilityEmbeddedConnection;
|
||||
|
||||
private final class ISurfaceControlViewHostImpl extends ISurfaceControlViewHost.Stub {
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration configuration) {
|
||||
if (mViewRoot == null) {
|
||||
return;
|
||||
}
|
||||
mViewRoot.mHandler.post(() -> {
|
||||
if (mWm != null) {
|
||||
mWm.setConfiguration(configuration);
|
||||
}
|
||||
if (mViewRoot != null) {
|
||||
mViewRoot.forceWmRelayout();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDispatchDetachedFromWindow() {
|
||||
if (mViewRoot == null) {
|
||||
return;
|
||||
}
|
||||
mViewRoot.mHandler.post(() -> {
|
||||
release();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private ISurfaceControlViewHost mRemoteInterface = new ISurfaceControlViewHostImpl();
|
||||
|
||||
/**
|
||||
* Package encapsulating a Surface hierarchy which contains interactive view
|
||||
* elements. It's expected to get this object from
|
||||
@@ -71,12 +101,14 @@ public class SurfaceControlViewHost {
|
||||
private SurfaceControl mSurfaceControl;
|
||||
private final IAccessibilityEmbeddedConnection mAccessibilityEmbeddedConnection;
|
||||
private final IBinder mInputToken;
|
||||
private final ISurfaceControlViewHost mRemoteInterface;
|
||||
|
||||
SurfacePackage(SurfaceControl sc, IAccessibilityEmbeddedConnection connection,
|
||||
IBinder inputToken) {
|
||||
IBinder inputToken, ISurfaceControlViewHost ri) {
|
||||
mSurfaceControl = sc;
|
||||
mAccessibilityEmbeddedConnection = connection;
|
||||
mInputToken = inputToken;
|
||||
mRemoteInterface = ri;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,6 +129,7 @@ public class SurfaceControlViewHost {
|
||||
}
|
||||
mAccessibilityEmbeddedConnection = other.mAccessibilityEmbeddedConnection;
|
||||
mInputToken = other.mInputToken;
|
||||
mRemoteInterface = other.mRemoteInterface;
|
||||
}
|
||||
|
||||
private SurfacePackage(Parcel in) {
|
||||
@@ -105,6 +138,8 @@ public class SurfaceControlViewHost {
|
||||
mAccessibilityEmbeddedConnection = IAccessibilityEmbeddedConnection.Stub.asInterface(
|
||||
in.readStrongBinder());
|
||||
mInputToken = in.readStrongBinder();
|
||||
mRemoteInterface = ISurfaceControlViewHost.Stub.asInterface(
|
||||
in.readStrongBinder());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,6 +161,13 @@ public class SurfaceControlViewHost {
|
||||
return mAccessibilityEmbeddedConnection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public ISurfaceControlViewHost getRemoteInterface() {
|
||||
return mRemoteInterface;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
@@ -136,6 +178,7 @@ public class SurfaceControlViewHost {
|
||||
mSurfaceControl.writeToParcel(out, flags);
|
||||
out.writeStrongBinder(mAccessibilityEmbeddedConnection.asBinder());
|
||||
out.writeStrongBinder(mInputToken);
|
||||
out.writeStrongBinder(mRemoteInterface.asBinder());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,7 +274,7 @@ public class SurfaceControlViewHost {
|
||||
public @Nullable SurfacePackage getSurfacePackage() {
|
||||
if (mSurfaceControl != null && mAccessibilityEmbeddedConnection != null) {
|
||||
return new SurfacePackage(mSurfaceControl, mAccessibilityEmbeddedConnection,
|
||||
mViewRoot.getInputToken());
|
||||
mViewRoot.getInputToken(), mRemoteInterface);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -10639,4 +10639,9 @@ public final class ViewRootImpl implements ViewParent,
|
||||
boolean wasRelayoutRequested() {
|
||||
return mRelayoutRequested;
|
||||
}
|
||||
|
||||
void forceWmRelayout() {
|
||||
mForceNextWindowRelayout = true;
|
||||
scheduleTraversals();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class WindowlessWindowManager implements IWindowSession {
|
||||
mHostInputToken = hostInputToken;
|
||||
}
|
||||
|
||||
protected void setConfiguration(Configuration configuration) {
|
||||
public void setConfiguration(Configuration configuration) {
|
||||
mConfiguration.setTo(configuration);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user