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;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -27,6 +28,7 @@ import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.WindowManager;
|
||||
import android.view.WindowManagerGlobal;
|
||||
import android.view.WindowManagerImpl;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityInteractionClient;
|
||||
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
|
||||
* service interface.
|
||||
@@ -645,8 +664,10 @@ public abstract class AccessibilityService extends Service {
|
||||
mConnectionId = connectionId;
|
||||
mWindowToken = windowToken;
|
||||
|
||||
// Let the window manager know about our shiny new token.
|
||||
WindowManagerGlobal.getInstance().setDefaultToken(mWindowToken);
|
||||
// The client may have already obtained the window manager, so
|
||||
// update the default token on whatever manager we gave them.
|
||||
final WindowManagerImpl wm = (WindowManagerImpl) getSystemService(WINDOW_SERVICE);
|
||||
wm.setDefaultToken(windowToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -118,9 +118,6 @@ public final class WindowManagerGlobal {
|
||||
|
||||
private Runnable mSystemPropertyUpdater;
|
||||
|
||||
/** Default token to apply to added views. */
|
||||
private IBinder mDefaultToken;
|
||||
|
||||
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() {
|
||||
synchronized (mLock) {
|
||||
final int numRoots = mRoots.size();
|
||||
@@ -239,10 +225,6 @@ public final class WindowManagerGlobal {
|
||||
}
|
||||
}
|
||||
|
||||
if (wparams.token == null && mDefaultToken != null) {
|
||||
wparams.token = mDefaultToken;
|
||||
}
|
||||
|
||||
ViewRootImpl root;
|
||||
View panelParentView = null;
|
||||
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
package android.view;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.os.IBinder;
|
||||
|
||||
/**
|
||||
* Provides low-level communication with the system window manager for
|
||||
* 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 Window mParentWindow;
|
||||
|
||||
private IBinder mDefaultToken;
|
||||
|
||||
public WindowManagerImpl(Display display) {
|
||||
this(display, null);
|
||||
}
|
||||
@@ -64,16 +69,43 @@ public final class WindowManagerImpl implements WindowManager {
|
||||
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
|
||||
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);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
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
|
||||
public void removeView(View view) {
|
||||
mGlobal.removeView(view, false);
|
||||
|
||||
Reference in New Issue
Block a user