Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8ebd7e1f authored by Rob Carr's avatar Rob Carr Committed by Android (Google) Code Review
Browse files

Merge "SurfaceControlViewHost: Add side-channel to SurfacePackage"

parents ce48a19f a3fc4405
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
/*
** 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();
}
+1 −0
Original line number Diff line number Diff line
@@ -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
+45 −2
Original line number Diff line number Diff line
@@ -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;
        }
+5 −0
Original line number Diff line number Diff line
@@ -10639,4 +10639,9 @@ public final class ViewRootImpl implements ViewParent,
    boolean wasRelayoutRequested() {
        return mRelayoutRequested;
    }

    void forceWmRelayout() {
       mForceNextWindowRelayout = true;
       scheduleTraversals();
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ public class WindowlessWindowManager implements IWindowSession {
        mHostInputToken = hostInputToken;
    }

    protected void setConfiguration(Configuration configuration) {
    public void setConfiguration(Configuration configuration) {
        mConfiguration.setTo(configuration);
    }