am 6a98dde8: am 9342b049: Merge "Use default token instead of wrapped window manager" into lmp-mr1-dev
* commit '6a98dde8dffac83283850afaec4400db9146a3e5':
Use default token instead of wrapped window manager
diff --git a/core/java/android/accessibilityservice/AccessibilityService.java b/core/java/android/accessibilityservice/AccessibilityService.java
index 1e1b33f..a9eaf29 100644
--- a/core/java/android/accessibilityservice/AccessibilityService.java
+++ b/core/java/android/accessibilityservice/AccessibilityService.java
@@ -24,11 +24,9 @@
import android.os.Message;
import android.os.RemoteException;
import android.util.Log;
-import android.view.Display;
import android.view.KeyEvent;
-import android.view.View;
-import android.view.ViewGroup;
import android.view.WindowManager;
+import android.view.WindowManagerGlobal;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityInteractionClient;
import android.view.accessibility.AccessibilityNodeInfo;
@@ -620,18 +618,6 @@
}
}
- @Override
- public Object getSystemService(String name) {
- if (Context.WINDOW_SERVICE.equals(name)) {
- if (mWindowManager == null) {
- WindowManager wrapped = (WindowManager) super.getSystemService(name);
- mWindowManager = new LocalWindowManager(wrapped);
- }
- return mWindowManager;
- }
- return super.getSystemService(name);
- }
-
/**
* Implement to return the implementation of the internal accessibility
* service interface.
@@ -658,6 +644,9 @@
public void init(int connectionId, IBinder windowToken) {
mConnectionId = connectionId;
mWindowToken = windowToken;
+
+ // Let the window manager know about our shiny new token.
+ WindowManagerGlobal.getInstance().setDefaultToken(mWindowToken);
}
@Override
@@ -812,53 +801,4 @@
}
}
}
-
- private class LocalWindowManager implements WindowManager {
- private final WindowManager mImpl;
-
- private LocalWindowManager(WindowManager impl) {
- mImpl = impl;
- }
-
- @Override
- public Display getDefaultDisplay() {
- return mImpl.getDefaultDisplay();
- }
-
- @Override
- public void addView(View view, ViewGroup.LayoutParams params) {
- if (!(params instanceof WindowManager.LayoutParams)) {
- throw new IllegalArgumentException("Params must be WindowManager.LayoutParams");
- }
- WindowManager.LayoutParams windowParams = (WindowManager.LayoutParams) params;
- if (windowParams.type == LayoutParams.TYPE_ACCESSIBILITY_OVERLAY
- && windowParams.token == null) {
- windowParams.token = mWindowToken;
- }
- mImpl.addView(view, params);
- }
-
- @Override
- public void updateViewLayout(View view, ViewGroup.LayoutParams params) {
- if (!(params instanceof WindowManager.LayoutParams)) {
- throw new IllegalArgumentException("Params must be WindowManager.LayoutParams");
- }
- WindowManager.LayoutParams windowParams = (WindowManager.LayoutParams) params;
- if (windowParams.type == LayoutParams.TYPE_ACCESSIBILITY_OVERLAY
- && windowParams.token == null) {
- windowParams.token = mWindowToken;
- }
- mImpl.updateViewLayout(view, params);
- }
-
- @Override
- public void removeViewImmediate(View view) {
- mImpl.removeViewImmediate(view);
- }
-
- @Override
- public void removeView(View view) {
- mImpl.removeView(view);
- }
- }
}
diff --git a/core/java/android/view/WindowManagerGlobal.java b/core/java/android/view/WindowManagerGlobal.java
index 5926d5f..82b1073 100644
--- a/core/java/android/view/WindowManagerGlobal.java
+++ b/core/java/android/view/WindowManagerGlobal.java
@@ -118,6 +118,9 @@
private Runnable mSystemPropertyUpdater;
+ /** Default token to apply to added views. */
+ private IBinder mDefaultToken;
+
private WindowManagerGlobal() {
}
@@ -169,6 +172,17 @@
}
}
+ /**
+ * Sets the default token to use in {@link #addView} when no parent window
+ * token is available and no token has been explicitly set in the view's
+ * layout params.
+ *
+ * @param token Default window token to apply to added views.
+ */
+ public void setDefaultToken(IBinder token) {
+ mDefaultToken = token;
+ }
+
public String[] getViewRootNames() {
synchronized (mLock) {
final int numRoots = mRoots.size();
@@ -216,6 +230,10 @@
}
}
+ if (wparams.token == null && mDefaultToken != null) {
+ wparams.token = mDefaultToken;
+ }
+
ViewRootImpl root;
View panelParentView = null;