Merge "Use default token instead of wrapped window manager" into lmp-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
9342b049b9
@@ -24,11 +24,9 @@ import android.os.Looper;
|
|||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Display;
|
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
import android.view.WindowManagerGlobal;
|
||||||
import android.view.accessibility.AccessibilityEvent;
|
import android.view.accessibility.AccessibilityEvent;
|
||||||
import android.view.accessibility.AccessibilityInteractionClient;
|
import android.view.accessibility.AccessibilityInteractionClient;
|
||||||
import android.view.accessibility.AccessibilityNodeInfo;
|
import android.view.accessibility.AccessibilityNodeInfo;
|
||||||
@@ -620,18 +618,6 @@ public abstract class AccessibilityService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@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
|
* Implement to return the implementation of the internal accessibility
|
||||||
* service interface.
|
* service interface.
|
||||||
@@ -658,6 +644,9 @@ public abstract class AccessibilityService extends Service {
|
|||||||
public void init(int connectionId, IBinder windowToken) {
|
public void init(int connectionId, IBinder windowToken) {
|
||||||
mConnectionId = connectionId;
|
mConnectionId = connectionId;
|
||||||
mWindowToken = windowToken;
|
mWindowToken = windowToken;
|
||||||
|
|
||||||
|
// Let the window manager know about our shiny new token.
|
||||||
|
WindowManagerGlobal.getInstance().setDefaultToken(mWindowToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -812,53 +801,4 @@ public abstract class AccessibilityService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,6 +118,9 @@ public final class WindowManagerGlobal {
|
|||||||
|
|
||||||
private Runnable mSystemPropertyUpdater;
|
private Runnable mSystemPropertyUpdater;
|
||||||
|
|
||||||
|
/** Default token to apply to added views. */
|
||||||
|
private IBinder mDefaultToken;
|
||||||
|
|
||||||
private WindowManagerGlobal() {
|
private WindowManagerGlobal() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,6 +172,17 @@ public final class WindowManagerGlobal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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() {
|
public String[] getViewRootNames() {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
final int numRoots = mRoots.size();
|
final int numRoots = mRoots.size();
|
||||||
@@ -216,6 +230,10 @@ public final class WindowManagerGlobal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wparams.token == null && mDefaultToken != null) {
|
||||||
|
wparams.token = mDefaultToken;
|
||||||
|
}
|
||||||
|
|
||||||
ViewRootImpl root;
|
ViewRootImpl root;
|
||||||
View panelParentView = null;
|
View panelParentView = null;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user