From 9d431e1cc85b88afc1e06782e832e8453decdc95 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Mon, 17 Dec 2018 13:11:48 -0800 Subject: Enable views to be placed in windowless surfaces. For purposes of parcelling SurfaceControl to embed view hierarchies across processes. We also want these Surfaces to receive input, but we can't let the clients call setInputWindowInfo directly (or we could have issues with clients stealing focus, etc...) and so we provide a method blessInputSurface which has the WM configure a surface for input with a minimal and safe set of parameters. Test: WindowlessWmTests Bug: 111373437 Bug: 134365580 Change-Id: I45fde62ba9b810e783d62c4dd5442abd038734d5 --- core/java/android/view/WindowlessViewRoot.java | 41 ++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 core/java/android/view/WindowlessViewRoot.java (limited to 'core/java/android/view/WindowlessViewRoot.java') diff --git a/core/java/android/view/WindowlessViewRoot.java b/core/java/android/view/WindowlessViewRoot.java new file mode 100644 index 000000000000..75057a26afae --- /dev/null +++ b/core/java/android/view/WindowlessViewRoot.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2019 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.Resources; +import android.content.Context; +import android.view.SurfaceControl; +import android.view.View; + +/** + * Utility class for adding a view hierarchy to a SurfaceControl. + * + * See WindowlessWmTest for example usage. + * @hide + */ +public class WindowlessViewRoot { + ViewRootImpl mViewRoot; + WindowlessWindowManager mWm; + public WindowlessViewRoot(Context c, Display d, SurfaceControl rootSurface) { + mWm = new WindowlessWindowManager(c.getResources().getConfiguration(), rootSurface); + mViewRoot = new ViewRootImpl(c, d, mWm); + } + + public void addView(View view, WindowManager.LayoutParams attrs) { + mViewRoot.setView(view, attrs, null); + } +} -- cgit v1.2.3