am a19f0577: am 8ccf071a: Merge "Move default token handling into WindowManagerImpl" into lmp-mr1-dev
* commit 'a19f057792e21879f0f071f361c13bc9e41f6a9d': Move default token handling into WindowManagerImpl
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package android.accessibilityservice;
|
package android.accessibilityservice;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -27,6 +28,7 @@ import android.util.Log;
|
|||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.WindowManagerGlobal;
|
import android.view.WindowManagerGlobal;
|
||||||
|
import android.view.WindowManagerImpl;
|
||||||
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;
|
||||||
@@ -618,6 +620,23 @@ public abstract class AccessibilityService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getSystemService(@ServiceName @NonNull String name) {
|
||||||
|
if (getBaseContext() == null) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"System services not available to Activities before onCreate()");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Guarantee that we always return the same window manager instance.
|
||||||
|
if (WINDOW_SERVICE.equals(name)) {
|
||||||
|
if (mWindowManager == null) {
|
||||||
|
mWindowManager = (WindowManager) getBaseContext().getSystemService(name);
|
||||||
|
}
|
||||||
|
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.
|
||||||
@@ -645,8 +664,10 @@ public abstract class AccessibilityService extends Service {
|
|||||||
mConnectionId = connectionId;
|
mConnectionId = connectionId;
|
||||||
mWindowToken = windowToken;
|
mWindowToken = windowToken;
|
||||||
|
|
||||||
// Let the window manager know about our shiny new token.
|
// The client may have already obtained the window manager, so
|
||||||
WindowManagerGlobal.getInstance().setDefaultToken(mWindowToken);
|
// update the default token on whatever manager we gave them.
|
||||||
|
final WindowManagerImpl wm = (WindowManagerImpl) getSystemService(WINDOW_SERVICE);
|
||||||
|
wm.setDefaultToken(windowToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -118,9 +118,6 @@ public final class WindowManagerGlobal {
|
|||||||
|
|
||||||
private Runnable mSystemPropertyUpdater;
|
private Runnable mSystemPropertyUpdater;
|
||||||
|
|
||||||
/** Default token to apply to added views. */
|
|
||||||
private IBinder mDefaultToken;
|
|
||||||
|
|
||||||
private WindowManagerGlobal() {
|
private WindowManagerGlobal() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,17 +178,6 @@ 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();
|
||||||
@@ -239,10 +225,6 @@ public final class WindowManagerGlobal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wparams.token == null && mDefaultToken != null) {
|
|
||||||
wparams.token = mDefaultToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewRootImpl root;
|
ViewRootImpl root;
|
||||||
View panelParentView = null;
|
View panelParentView = null;
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package android.view;
|
package android.view;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
import android.os.IBinder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides low-level communication with the system window manager for
|
* Provides low-level communication with the system window manager for
|
||||||
* operations that are bound to a particular context, display or parent window.
|
* operations that are bound to a particular context, display or parent window.
|
||||||
@@ -47,6 +50,8 @@ public final class WindowManagerImpl implements WindowManager {
|
|||||||
private final Display mDisplay;
|
private final Display mDisplay;
|
||||||
private final Window mParentWindow;
|
private final Window mParentWindow;
|
||||||
|
|
||||||
|
private IBinder mDefaultToken;
|
||||||
|
|
||||||
public WindowManagerImpl(Display display) {
|
public WindowManagerImpl(Display display) {
|
||||||
this(display, null);
|
this(display, null);
|
||||||
}
|
}
|
||||||
@@ -64,16 +69,43 @@ public final class WindowManagerImpl implements WindowManager {
|
|||||||
return new WindowManagerImpl(display, mParentWindow);
|
return new WindowManagerImpl(display, mParentWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the window token to assign when none is specified by the client or
|
||||||
|
* available from the parent window.
|
||||||
|
*
|
||||||
|
* @param token The default token to assign.
|
||||||
|
*/
|
||||||
|
public void setDefaultToken(IBinder token) {
|
||||||
|
mDefaultToken = token;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addView(View view, ViewGroup.LayoutParams params) {
|
public void addView(@NonNull View view, @NonNull ViewGroup.LayoutParams params) {
|
||||||
|
applyDefaultToken(params);
|
||||||
mGlobal.addView(view, params, mDisplay, mParentWindow);
|
mGlobal.addView(view, params, mDisplay, mParentWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateViewLayout(View view, ViewGroup.LayoutParams params) {
|
public void updateViewLayout(@NonNull View view, @NonNull ViewGroup.LayoutParams params) {
|
||||||
|
applyDefaultToken(params);
|
||||||
mGlobal.updateViewLayout(view, params);
|
mGlobal.updateViewLayout(view, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void applyDefaultToken(@NonNull ViewGroup.LayoutParams params) {
|
||||||
|
// Only use the default token if we don't have a parent window.
|
||||||
|
if (mDefaultToken != null && mParentWindow == null) {
|
||||||
|
if (!(params instanceof WindowManager.LayoutParams)) {
|
||||||
|
throw new IllegalArgumentException("Params must be WindowManager.LayoutParams");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only use the default token if we don't already have a token.
|
||||||
|
final WindowManager.LayoutParams wparams = (WindowManager.LayoutParams) params;
|
||||||
|
if (wparams.token == null) {
|
||||||
|
wparams.token = mDefaultToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeView(View view) {
|
public void removeView(View view) {
|
||||||
mGlobal.removeView(view, false);
|
mGlobal.removeView(view, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user