Merge "SurfaceControlViewHost: Add side-channel to SurfacePackage"

This commit is contained in:
Rob Carr
2022-01-14 21:40:42 +00:00
committed by Android (Google) Code Review
5 changed files with 80 additions and 3 deletions

View 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();
}

View File

@@ -80,6 +80,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

View File

@@ -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;
}

View File

@@ -10639,4 +10639,9 @@ public final class ViewRootImpl implements ViewParent,
boolean wasRelayoutRequested() {
return mRelayoutRequested;
}
void forceWmRelayout() {
mForceNextWindowRelayout = true;
scheduleTraversals();
}
}

View File

@@ -87,7 +87,7 @@ public class WindowlessWindowManager implements IWindowSession {
mHostInputToken = hostInputToken;
}
protected void setConfiguration(Configuration configuration) {
public void setConfiguration(Configuration configuration) {
mConfiguration.setTo(configuration);
}