summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2019-02-20 14:59:12 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-02-20 14:59:12 +0000
commitdb9c27cb7af8a2adae68e29f9543d9d901b4245e (patch)
tree655f90f45c945bd7f6a3ec943176c9fb2e580a61
parent72ed3736747e0b4712a9e33dfcfd6d9dfa6906ad (diff)
parent1761cfac39d5ee17f2e4f8eef485c38a08624533 (diff)
Merge "Public API for statically accessing global list of window views"
-rw-r--r--api/current.txt4
-rw-r--r--core/java/android/view/WindowManagerGlobal.java11
-rw-r--r--core/java/android/view/inspector/WindowInspector.java40
3 files changed, 55 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt
index 7ab447a2a554..cb79f5a80ed8 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -54020,6 +54020,10 @@ package android.view.inspector {
ctor public PropertyReader.PropertyTypeMismatchException(int, @NonNull String, @NonNull String);
}
+ public final class WindowInspector {
+ method @NonNull public static java.util.List<android.view.View> getGlobalWindowViews();
+ }
+
}
package android.view.textclassifier {
diff --git a/core/java/android/view/WindowManagerGlobal.java b/core/java/android/view/WindowManagerGlobal.java
index e3833c01eeaf..453c5e32a178 100644
--- a/core/java/android/view/WindowManagerGlobal.java
+++ b/core/java/android/view/WindowManagerGlobal.java
@@ -17,6 +17,7 @@
package android.view;
import android.animation.ValueAnimator;
+import android.annotation.NonNull;
import android.annotation.UnsupportedAppUsage;
import android.app.ActivityManager;
import android.content.ComponentCallbacks2;
@@ -269,6 +270,16 @@ public final class WindowManagerGlobal {
return views;
}
+ /**
+ * @return the list of all views attached to the global window manager
+ */
+ @NonNull
+ public ArrayList<View> getWindowViews() {
+ synchronized (mLock) {
+ return new ArrayList<>(mViews);
+ }
+ }
+
public View getWindowView(IBinder windowToken) {
synchronized (mLock) {
final int numViews = mViews.size();
diff --git a/core/java/android/view/inspector/WindowInspector.java b/core/java/android/view/inspector/WindowInspector.java
new file mode 100644
index 000000000000..69d004e860fd
--- /dev/null
+++ b/core/java/android/view/inspector/WindowInspector.java
@@ -0,0 +1,40 @@
+/*
+ * 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.inspector;
+
+import android.annotation.NonNull;
+import android.view.View;
+import android.view.WindowManagerGlobal;
+
+import java.util.List;
+
+/**
+ * Provides access to window inspection information.
+ */
+public final class WindowInspector {
+ private WindowInspector() {
+ // Non-instantiable.
+ }
+
+ /**
+ * @return the list of all window views attached to the current process
+ */
+ @NonNull
+ public static List<View> getGlobalWindowViews() {
+ return WindowManagerGlobal.getInstance().getWindowViews();
+ }
+}