summaryrefslogtreecommitdiff
path: root/core/java/android/view/SurfaceControlViewHost.java
diff options
context:
space:
mode:
authorRobert Carr <racarr@google.com>2020-03-12 12:39:24 -0700
committerRobert Carr <racarr@google.com>2020-03-12 13:14:42 -0700
commit271d9c76b6e701dce6b42a9b57ee9277685e6bda (patch)
tree5eff08ebaea42c36e46935dccb21bbf41c13a074 /core/java/android/view/SurfaceControlViewHost.java
parent19df52400ded34fb335d24e65aec33370bb49a9d (diff)
SurfaceControlViewHost: Respond to API feedback
API Council provided the following feedback: 1. Rename addView() to setView() 2. Add getView() Bug: 151311937 Test: Existing tests pass Change-Id: I26665c8bb8d0c10c5eb4228feb4ff13ee89f0d7b
Diffstat (limited to 'core/java/android/view/SurfaceControlViewHost.java')
-rw-r--r--core/java/android/view/SurfaceControlViewHost.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/core/java/android/view/SurfaceControlViewHost.java b/core/java/android/view/SurfaceControlViewHost.java
index a3b3f1f72310..41a384797521 100644
--- a/core/java/android/view/SurfaceControlViewHost.java
+++ b/core/java/android/view/SurfaceControlViewHost.java
@@ -26,6 +26,8 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.view.accessibility.IAccessibilityEmbeddedConnection;
+import java.util.Objects;
+
/**
* Utility class for adding a View hierarchy to a {@link SurfaceControl}. The View hierarchy
* will render in to a root SurfaceControl, and receive input based on the SurfaceControl's
@@ -159,7 +161,8 @@ public class SurfaceControlViewHost {
* @hide
*/
@TestApi
- public void addView(@NonNull View view, WindowManager.LayoutParams attrs) {
+ public void setView(@NonNull View view, @NonNull WindowManager.LayoutParams attrs) {
+ Objects.requireNonNull(view);
mViewRoot.setView(view, attrs, null);
}
@@ -172,11 +175,18 @@ public class SurfaceControlViewHost {
* @param width The width to layout the View within, in pixels.
* @param height The height to layout the View within, in pixels.
*/
- public void addView(@NonNull View view, int width, int height) {
+ public void setView(@NonNull View view, int width, int height) {
final WindowManager.LayoutParams lp =
new WindowManager.LayoutParams(width, height,
WindowManager.LayoutParams.TYPE_APPLICATION, 0, PixelFormat.TRANSPARENT);
- addView(view, lp);
+ setView(view, lp);
+ }
+
+ /**
+ * @return The view passed to setView, or null if none has been passed.
+ */
+ public @Nullable View getView() {
+ return mViewRoot.getView();
}
/**