summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-08-19 20:30:52 -0700
committerJeff Brown <jeffbrown@google.com>2012-08-19 22:42:08 -0700
commit98365d7663cbd82979a5700faf0050220b01084d (patch)
tree8a4ff3e0a8afd814ed29609b26aa1c6ade2367f6
parent848c2dc93b6795e171f3dd6f64ea0be65e2762ca (diff)
Refactor for multi-display support.
Split WindowManagerImpl into two parts, the WindowManager interface implementation remains where it is but the global communications with the window manager are now handled by the WindowManagerGlobal class. This change greatly simplifies the challenge of having separate WindowManager instances for each Context. Removed WindowManagerImpl.getDefault(). This represents the bulk of this change. Most of the usages of this method were either to perform global functions (now handled by WindowManagerGlobal) or to obtain the default display (now handled by DisplayManager). Explicitly associate each new window with a display and make the Display object available to the View hierarchy. Add stubs for some new display manager API features. Start to split apart the concepts of display id and layer stack. since they operate at different layers of abstraction. While it's true that each logical display uniquely corresponds to a surface flinger layer stack, it is not necessarily the case that they must use the same ids. Added Display.getLayerStack() and started using it in places where it was relatively easy to do. Change-Id: I29ed909114dec86807c4d3a5059c3fa0358bea61
-rw-r--r--api/current.txt10
-rw-r--r--core/java/android/app/Activity.java10
-rw-r--r--core/java/android/app/ActivityManager.java5
-rw-r--r--core/java/android/app/ActivityThread.java24
-rw-r--r--core/java/android/app/ContextImpl.java11
-rw-r--r--core/java/android/app/KeyguardManager.java5
-rw-r--r--core/java/android/app/WallpaperManager.java7
-rw-r--r--core/java/android/content/Context.java11
-rw-r--r--core/java/android/content/ContextWrapper.java7
-rw-r--r--core/java/android/hardware/display/DisplayManager.java176
-rw-r--r--core/java/android/inputmethodservice/InputMethodService.java3
-rw-r--r--core/java/android/service/dreams/DreamManagerService.java4
-rw-r--r--core/java/android/service/wallpaper/WallpaperService.java10
-rw-r--r--core/java/android/view/Choreographer.java3
-rw-r--r--core/java/android/view/Display.java37
-rw-r--r--core/java/android/view/IWindowSession.aidl8
-rw-r--r--core/java/android/view/Surface.java19
-rw-r--r--core/java/android/view/SurfaceView.java8
-rw-r--r--core/java/android/view/View.java17
-rw-r--r--core/java/android/view/ViewConfiguration.java5
-rw-r--r--core/java/android/view/ViewRootImpl.java136
-rw-r--r--core/java/android/view/Window.java14
-rw-r--r--core/java/android/view/WindowManagerGlobal.java516
-rw-r--r--core/java/android/view/WindowManagerImpl.java557
-rw-r--r--core/java/android/view/WindowManagerPolicy.java6
-rw-r--r--core/java/android/webkit/WebViewClassic.java6
-rw-r--r--core/java/android/widget/Toast.java5
-rw-r--r--core/java/com/android/internal/view/RotationPolicy.java7
-rw-r--r--core/jni/android_view_Surface.cpp10
-rw-r--r--core/res/res/values/public.xml1
-rwxr-xr-xcore/res/res/values/strings.xml5
-rw-r--r--packages/FakeOemFeatures/src/com/android/fakeoemfeatures/FakeApp.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/ImageWallpaper.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/SystemUIService.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/UniverseBackground.java7
-rw-r--r--packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java30
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java10
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java38
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java36
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java9
-rw-r--r--policy/src/com/android/internal/policy/impl/GlobalActions.java13
-rw-r--r--policy/src/com/android/internal/policy/impl/KeyguardViewManager.java6
-rw-r--r--policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java6
-rwxr-xr-xpolicy/src/com/android/internal/policy/impl/PhoneWindowManager.java21
-rw-r--r--services/java/com/android/server/power/DisplayPowerController.java5
-rw-r--r--services/java/com/android/server/power/ElectronBeam.java10
-rw-r--r--services/java/com/android/server/wm/ScreenRotationAnimation.java16
-rw-r--r--services/java/com/android/server/wm/StrictModeFlash.java4
-rw-r--r--services/java/com/android/server/wm/Watermark.java6
-rwxr-xr-xservices/java/com/android/server/wm/WindowManagerService.java56
-rw-r--r--services/java/com/android/server/wm/WindowStateAnimator.java30
-rw-r--r--test-runner/src/android/test/mock/MockContext.java7
-rw-r--r--tools/layoutlib/bridge/src/android/view/AttachInfo_Accessor.java7
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java7
57 files changed, 1101 insertions, 888 deletions
diff --git a/api/current.txt b/api/current.txt
index 8350200a107d..d6d1732fd970 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -9981,6 +9981,15 @@ package android.hardware {
package android.hardware.display {
public final class DisplayManager {
+ method public android.view.Display getDisplay(int, android.content.Context);
+ method public void registerDisplayListener(android.hardware.display.DisplayManager.DisplayListener, android.os.Handler);
+ method public void unregisterDisplayListener(android.hardware.display.DisplayManager.DisplayListener);
+ }
+
+ public static abstract interface DisplayManager.DisplayListener {
+ method public abstract void onDisplayAdded(int);
+ method public abstract void onDisplayChanged(int);
+ method public abstract void onDisplayRemoved(int);
}
}
@@ -24579,6 +24588,7 @@ package android.view {
method public final android.content.Context getContext();
method protected android.view.ContextMenu.ContextMenuInfo getContextMenuInfo();
method public static int getDefaultSize(int, int);
+ method public android.view.Display getDisplay();
method public final int[] getDrawableState();
method public android.graphics.Bitmap getDrawingCache();
method public android.graphics.Bitmap getDrawingCache(boolean);
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 77107eee1770..395a79cf3b8c 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -74,7 +74,7 @@ import android.view.ViewGroup.LayoutParams;
import android.view.ViewManager;
import android.view.Window;
import android.view.WindowManager;
-import android.view.WindowManagerImpl;
+import android.view.WindowManagerGlobal;
import android.view.accessibility.AccessibilityEvent;
import android.widget.AdapterView;
@@ -5018,7 +5018,9 @@ public class Activity extends ContextThemeWrapper
mEmbeddedID = id;
mLastNonConfigurationInstances = lastNonConfigurationInstances;
- mWindow.setWindowManager(null, mToken, mComponent.flattenToString(),
+ mWindow.setWindowManager(
+ (WindowManager)context.getSystemService(Context.WINDOW_SERVICE),
+ mToken, mComponent.flattenToString(),
(info.flags & ActivityInfo.FLAG_HARDWARE_ACCELERATED) != 0);
if (mParent != null) {
mWindow.setContainer(mParent.getWindow());
@@ -5065,7 +5067,7 @@ public class Activity extends ContextThemeWrapper
if (mStopped) {
mStopped = false;
if (mToken != null && mParent == null) {
- WindowManagerImpl.getDefault().setStoppedState(mToken, false);
+ WindowManagerGlobal.getInstance().setStoppedState(mToken, false);
}
synchronized (mManagedCursors) {
@@ -5165,7 +5167,7 @@ public class Activity extends ContextThemeWrapper
}
if (mToken != null && mParent == null) {
- WindowManagerImpl.getDefault().setStoppedState(mToken, true);
+ WindowManagerGlobal.getInstance().setStoppedState(mToken, true);
}
mFragments.dispatchStop();
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 2c6d5d989b2d..58e661698039 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -30,6 +30,7 @@ import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Point;
+import android.hardware.display.DisplayManager;
import android.os.Binder;
import android.os.Bundle;
import android.os.Debug;
@@ -366,7 +367,7 @@ public class ActivityManager {
* (which tends to consume a lot more RAM).
* @hide
*/
- static public boolean isHighEndGfx(Display display) {
+ static public boolean isHighEndGfx() {
MemInfoReader reader = new MemInfoReader();
reader.readMemInfo();
if (reader.getTotalSize() >= (512*1024*1024)) {
@@ -374,6 +375,8 @@ public class ActivityManager {
// we can afford the overhead of graphics acceleration.
return true;
}
+
+ Display display = DisplayManager.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY);
Point p = new Point();
display.getRealSize(p);
int pixels = p.x * p.y;
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 2cdb0864821d..a3880f3d8786 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -42,6 +42,7 @@ import android.database.sqlite.SQLiteDebug;
import android.database.sqlite.SQLiteDebug.DbStats;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.hardware.display.DisplayManager;
import android.net.IConnectivityManager;
import android.net.Proxy;
import android.net.ProxyProperties;
@@ -79,7 +80,7 @@ import android.view.ViewManager;
import android.view.ViewRootImpl;
import android.view.Window;
import android.view.WindowManager;
-import android.view.WindowManagerImpl;
+import android.view.WindowManagerGlobal;
import android.renderscript.RenderScript;
import com.android.internal.os.BinderInternal;
@@ -1055,7 +1056,7 @@ public final class ActivityThread {
@Override
public void dumpGfxInfo(FileDescriptor fd, String[] args) {
dumpGraphicsInfo(fd);
- WindowManagerImpl.getDefault().dumpGfxInfo(fd);
+ WindowManagerGlobal.getInstance().dumpGfxInfo(fd);
}
@Override
@@ -1569,7 +1570,7 @@ public final class ActivityThread {
CompatibilityInfoHolder cih = new CompatibilityInfoHolder();
cih.set(ci);
- Display d = WindowManagerImpl.getDefault().makeCompatible(cih).getDefaultDisplay();
+ Display d = displayManager.getCompatibleDisplay(Display.DEFAULT_DISPLAY, cih);
d.getMetrics(dm);
//Slog.i("foo", "New metrics: w=" + metrics.widthPixels + " h="
// + metrics.heightPixels + " den=" + metrics.density
@@ -2641,7 +2642,7 @@ public final class ActivityThread {
r.mPendingRemoveWindowManager.removeViewImmediate(r.mPendingRemoveWindow);
IBinder wtoken = r.mPendingRemoveWindow.getWindowToken();
if (wtoken != null) {
- WindowManagerImpl.getDefault().closeAll(wtoken,
+ WindowManagerGlobal.getInstance().closeAll(wtoken,
r.activity.getClass().getName(), "Activity");
}
}
@@ -3176,7 +3177,7 @@ public final class ActivityThread {
apk.mCompatibilityInfo.set(data.info);
}
handleConfigurationChanged(mConfiguration, data.info);
- WindowManagerImpl.getDefault().reportNewConfiguration(mConfiguration);
+ WindowManagerGlobal.getInstance().reportNewConfiguration(mConfiguration);
}
private void deliverResults(ActivityClientRecord r, List<ResultInfo> results) {
@@ -3365,7 +3366,7 @@ public final class ActivityThread {
}
}
if (wtoken != null && r.mPendingRemoveWindow == null) {
- WindowManagerImpl.getDefault().closeAll(wtoken,
+ WindowManagerGlobal.getInstance().closeAll(wtoken,
r.activity.getClass().getName(), "Activity");
}
r.activity.mDecor = null;
@@ -3377,7 +3378,7 @@ public final class ActivityThread {
// by the app will leak. Well we try to warning them a lot
// about leaking windows, because that is a bug, so if they are
// using this recreate facility then they get to live with leaks.
- WindowManagerImpl.getDefault().closeAll(token,
+ WindowManagerGlobal.getInstance().closeAll(token,
r.activity.getClass().getName(), "Activity");
}
@@ -3805,7 +3806,7 @@ public final class ActivityThread {
}
// Cleanup hardware accelerated stuff
- WindowManagerImpl.getDefault().trimLocalMemory();
+ WindowManagerGlobal.getInstance().trimLocalMemory();
freeTextLayoutCachesIfNeeded(configDiff);
@@ -3945,7 +3946,7 @@ public final class ActivityThread {
final void handleTrimMemory(int level) {
if (DEBUG_MEMORY_TRIM) Slog.v(TAG, "Trimming memory to level: " + level);
- final WindowManagerImpl windowManager = WindowManagerImpl.getDefault();
+ final WindowManagerGlobal windowManager = WindowManagerGlobal.getInstance();
windowManager.startTrimMemory(level);
ArrayList<ComponentCallbacks2> callbacks;
@@ -3958,7 +3959,7 @@ public final class ActivityThread {
callbacks.get(i).onTrimMemory(level);
}
- windowManager.endTrimMemory();
+ windowManager.endTrimMemory();
}
private void setupGraphicsSupport(LoadedApk info, File cacheDir) {
@@ -4011,8 +4012,7 @@ public final class ActivityThread {
// Persistent processes on low-memory devices do not get to
// use hardware accelerated drawing, since this can add too much
// overhead to the process.
- final Display display = WindowManagerImpl.getDefault().getDefaultDisplay();
- if (!ActivityManager.isHighEndGfx(display)) {
+ if (!ActivityManager.isHighEndGfx()) {
HardwareRenderer.disable(false);
}
}
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 08947a48c845..0543f0570cbd 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -95,7 +95,9 @@ import android.telephony.TelephonyManager;
import android.content.ClipboardManager;
import android.util.AndroidRuntimeException;
import android.util.Log;
+import android.view.CompatibilityInfoHolder;
import android.view.ContextThemeWrapper;
+import android.view.Display;
import android.view.WindowManagerImpl;
import android.view.accessibility.AccessibilityManager;
import android.view.inputmethod.InputMethodManager;
@@ -499,8 +501,8 @@ class ContextImpl extends Context {
registerService(WINDOW_SERVICE, new ServiceFetcher() {
public Object getService(ContextImpl ctx) {
- return WindowManagerImpl.getDefault().makeCompatible(
- ctx.mPackageInfo.mCompatibilityInfo);
+ return new WindowManagerImpl(ctx.getOuterContext(),
+ Display.DEFAULT_DISPLAY);
}});
registerService(USER_SERVICE, new ServiceFetcher() {
@@ -1609,6 +1611,11 @@ class ContextImpl extends Context {
return mRestricted;
}
+ @Override
+ public CompatibilityInfoHolder getCompatibilityInfo() {
+ return mPackageInfo.mCompatibilityInfo;
+ }
+
private File getDataDirFile() {
if (mPackageInfo != null) {
return mPackageInfo.getDataDirFile();
diff --git a/core/java/android/app/KeyguardManager.java b/core/java/android/app/KeyguardManager.java
index ef61af715dfa..22a21cdf829d 100644
--- a/core/java/android/app/KeyguardManager.java
+++ b/core/java/android/app/KeyguardManager.java
@@ -16,13 +16,12 @@
package android.app;
-import android.content.Context;
import android.os.Binder;
import android.os.RemoteException;
import android.os.IBinder;
-import android.os.ServiceManager;
import android.view.IWindowManager;
import android.view.IOnKeyguardExitResult;
+import android.view.WindowManagerGlobal;
/**
* Class that can be used to lock and unlock the keyboard. Get an instance of this
@@ -111,7 +110,7 @@ public class KeyguardManager {
KeyguardManager() {
- mWM = IWindowManager.Stub.asInterface(ServiceManager.getService(Context.WINDOW_SERVICE));
+ mWM = WindowManagerGlobal.getWindowManagerService();
}
/**
diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java
index 27843acf5bb1..1ad2e6dbefa0 100644
--- a/core/java/android/app/WallpaperManager.java
+++ b/core/java/android/app/WallpaperManager.java
@@ -43,6 +43,7 @@ import android.util.DisplayMetrics;
import android.util.Log;
import android.view.ViewRootImpl;
import android.view.WindowManager;
+import android.view.WindowManagerGlobal;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -689,7 +690,7 @@ public class WallpaperManager {
public void setWallpaperOffsets(IBinder windowToken, float xOffset, float yOffset) {
try {
//Log.v(TAG, "Sending new wallpaper offsets from app...");
- ViewRootImpl.getWindowSession(mContext.getMainLooper()).setWallpaperPosition(
+ WindowManagerGlobal.getWindowSession(mContext.getMainLooper()).setWallpaperPosition(
windowToken, xOffset, yOffset, mWallpaperXStep, mWallpaperYStep);
//Log.v(TAG, "...app returning after sending offsets!");
} catch (RemoteException e) {
@@ -727,7 +728,7 @@ public class WallpaperManager {
int x, int y, int z, Bundle extras) {
try {
//Log.v(TAG, "Sending new wallpaper offsets from app...");
- ViewRootImpl.getWindowSession(mContext.getMainLooper()).sendWallpaperCommand(
+ WindowManagerGlobal.getWindowSession(mContext.getMainLooper()).sendWallpaperCommand(
windowToken, action, x, y, z, extras, false);
//Log.v(TAG, "...app returning after sending offsets!");
} catch (RemoteException e) {
@@ -747,7 +748,7 @@ public class WallpaperManager {
*/
public void clearWallpaperOffsets(IBinder windowToken) {
try {
- ViewRootImpl.getWindowSession(mContext.getMainLooper()).setWallpaperPosition(
+ WindowManagerGlobal.getWindowSession(mContext.getMainLooper()).setWallpaperPosition(
windowToken, -1, -1, -1, -1);
} catch (RemoteException e) {
// Ignore.
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index a70bf6cb52ba..1460bf561c40 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -34,6 +34,7 @@ import android.os.Handler;
import android.os.Looper;
import android.os.UserHandle;
import android.util.AttributeSet;
+import android.view.CompatibilityInfoHolder;
import java.io.File;
import java.io.FileInputStream;
@@ -2464,6 +2465,16 @@ public abstract class Context {
public abstract Context createConfigurationContext(Configuration overrideConfiguration);
/**
+ * Gets the compatibility info holder for this context. This information
+ * is provided on a per-application basis and is used to simulate lower density
+ * display metrics for legacy applications.
+ *
+ * @return The compatibility info holder, or null if not required by the application.
+ * @hide
+ */
+ public abstract CompatibilityInfoHolder getCompatibilityInfo();
+
+ /**
* Indicates whether this Context is restricted.
*
* @return True if this Context is restricted, false otherwise.
diff --git a/core/java/android/content/ContextWrapper.java b/core/java/android/content/ContextWrapper.java
index 75842bec9989..3a137257dada 100644
--- a/core/java/android/content/ContextWrapper.java
+++ b/core/java/android/content/ContextWrapper.java
@@ -31,6 +31,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.UserHandle;
+import android.view.CompatibilityInfoHolder;
import java.io.File;
import java.io.FileInputStream;
@@ -543,4 +544,10 @@ public class ContextWrapper extends Context {
public boolean isRestricted() {
return mBase.isRestricted();
}
+
+ /** @hide */
+ @Override
+ public CompatibilityInfoHolder getCompatibilityInfo() {
+ return mBase.getCompatibilityInfo();
+ }
}
diff --git a/core/java/android/hardware/display/DisplayManager.java b/core/java/android/hardware/display/DisplayManager.java
index dc7971057b83..a73115c4324b 100644
--- a/core/java/android/hardware/display/DisplayManager.java
+++ b/core/java/android/hardware/display/DisplayManager.java
@@ -17,12 +17,20 @@
package android.hardware.display;
import android.content.Context;
+import android.os.Handler;
import android.os.IBinder;
+import android.os.Looper;
+import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Log;
+import android.util.SparseArray;
+import android.view.CompatibilityInfoHolder;
+import android.view.Display;
import android.view.DisplayInfo;
+import java.util.ArrayList;
+
/**
* Manages the properties, media routing and power state of attached displays.
* <p>
@@ -34,11 +42,22 @@ import android.view.DisplayInfo;
*/
public final class DisplayManager {
private static final String TAG = "DisplayManager";
+ private static final boolean DEBUG = false;
+
+ private static final int MSG_DISPLAY_ADDED = 1;
+ private static final int MSG_DISPLAY_REMOVED = 2;
+ private static final int MSG_DISPLAY_CHANGED = 3;
private static DisplayManager sInstance;
private final IDisplayManager mDm;
+ // Guarded by mDisplayLock
+ private final Object mDisplayLock = new Object();
+ private final ArrayList<DisplayListenerDelegate> mDisplayListeners =
+ new ArrayList<DisplayListenerDelegate>();
+
+
private DisplayManager(IDisplayManager dm) {
mDm = dm;
}
@@ -79,4 +98,161 @@ public final class DisplayManager {
return false;
}
}
+
+ /**
+ * Gets information about a logical display.
+ *
+ * The display metrics may be adjusted to provide compatibility
+ * for legacy applications.
+ *
+ * @param displayId The logical display id.
+ * @param applicationContext The application context from which to obtain
+ * compatible metrics.
+ * @return The display object.
+ */
+ public Display getDisplay(int displayId, Context applicationContext) {
+ if (applicationContext == null) {
+ throw new IllegalArgumentException("applicationContext must not be null");
+ }
+
+ CompatibilityInfoHolder cih = null;
+ if (displayId == Display.DEFAULT_DISPLAY) {
+ cih = applicationContext.getCompatibilityInfo();
+ }
+ return getCompatibleDisplay(displayId, cih);
+ }
+
+ /**
+ * Gets information about a logical display.
+ *
+ * The display metrics may be adjusted to provide compatibility
+ * for legacy applications.
+ *
+ * @param displayId The logical display id.
+ * @param cih The compatibility info, or null if none is required.
+ * @return The display object.
+ *
+ * @hide
+ */
+ public Display getCompatibleDisplay(int displayId, CompatibilityInfoHolder cih) {
+ return new Display(displayId, cih);
+ }
+
+ /**
+ * Gets information about a logical display without applying any compatibility metrics.
+ *
+ * @param displayId The logical display id.
+ * @return The display object.
+ *
+ * @hide
+ */
+ public Display getRealDisplay(int displayId) {
+ return getCompatibleDisplay(displayId, null);
+ }
+
+ /**
+ * Registers an display listener to receive notifications about when
+ * displays are added, removed or changed.
+ *
+ * @param listener The listener to register.
+ * @param handler The handler on which the listener should be invoked, or null
+ * if the listener should be invoked on the calling thread's looper.
+ *
+ * @see #unregisterDisplayListener
+ */
+ public void registerDisplayListener(DisplayListener listener, Handler handler) {
+ if (listener == null) {
+ throw new IllegalArgumentException("listener must not be null");
+ }
+
+ synchronized (mDisplayLock) {
+ int index = findDisplayListenerLocked(listener);
+ if (index < 0) {
+ mDisplayListeners.add(new DisplayListenerDelegate(listener, handler));
+ }
+ }
+ }
+
+ /**
+ * Unregisters an input device listener.
+ *
+ * @param listener The listener to unregister.
+ *
+ * @see #registerDisplayListener
+ */
+ public void unregisterDisplayListener(DisplayListener listener) {
+ if (listener == null) {
+ throw new IllegalArgumentException("listener must not be null");
+ }
+
+ synchronized (mDisplayLock) {
+ int index = findDisplayListenerLocked(listener);
+ if (index >= 0) {
+ DisplayListenerDelegate d = mDisplayListeners.get(index);
+ d.removeCallbacksAndMessages(null);
+ mDisplayListeners.remove(index);
+ }
+ }
+ }
+
+ private int findDisplayListenerLocked(DisplayListener listener) {
+ final int numListeners = mDisplayListeners.size();
+ for (int i = 0; i < numListeners; i++) {
+ if (mDisplayListeners.get(i).mListener == listener) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Listens for changes in available display devices.
+ */
+ public interface DisplayListener {
+ /**
+ * Called whenever a logical display has been added to the system.
+ * Use {@link DisplayManager#getDisplay} to get more information about the display.
+ *
+ * @param displayId The id of the logical display that was added.
+ */
+ void onDisplayAdded(int displayId);
+
+ /**
+ * Called whenever a logical display has been removed from the system.
+ *
+ * @param displayId The id of the logical display that was removed.
+ */
+ void onDisplayRemoved(int displayId);
+
+ /**
+ * Called whenever the properties of a logical display have changed.
+ *
+ * @param displayId The id of the logical display that changed.
+ */
+ void onDisplayChanged(int displayId);
+ }
+
+ private static final class DisplayListenerDelegate extends Handler {
+ public final DisplayListener mListener;
+
+ public DisplayListenerDelegate(DisplayListener listener, Handler handler) {
+ super(handler != null ? handler.getLooper() : Looper.myLooper());
+ mListener = listener;
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case MSG_DISPLAY_ADDED:
+ mListener.onDisplayAdded(msg.arg1);
+ break;
+ case MSG_DISPLAY_REMOVED:
+ mListener.onDisplayRemoved(msg.arg1);
+ break;
+ case MSG_DISPLAY_CHANGED:
+ mListener.onDisplayChanged(msg.arg1);
+ break;
+ }
+ }
+ }
}
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index a9de28987937..d5b9edcc5588 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -39,7 +39,6 @@ import android.text.method.MovementMethod;
import android.util.Log;
import android.util.PrintWriterPrinter;
import android.util.Printer;
-import android.view.Display;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -630,7 +629,7 @@ public class InputMethodService extends AbstractInputMethodService {
if (mWindow != null) {
throw new IllegalStateException("Must be called before onCreate()");
}
- if (ActivityManager.isHighEndGfx(new Display(Display.DEFAULT_DISPLAY, null))) {
+ if (ActivityManager.isHighEndGfx()) {
mHardwareAccelerated = true;
return true;
}
diff --git a/core/java/android/service/dreams/DreamManagerService.java b/core/java/android/service/dreams/DreamManagerService.java
index fc3f5011b431..5d6b17ee3c54 100644
--- a/core/java/android/service/dreams/DreamManagerService.java
+++ b/core/java/android/service/dreams/DreamManagerService.java
@@ -18,6 +18,7 @@ import android.provider.Settings;
import android.util.Slog;
import android.view.IWindowManager;
import android.view.WindowManager;
+import android.view.WindowManagerGlobal;
/**
*
@@ -44,8 +45,7 @@ public class DreamManagerService
public DreamManagerService(Context context) {
if (DEBUG) Slog.v(TAG, "DreamManagerService startup");
mContext = context;
- mIWindowManager = IWindowManager.Stub.asInterface(
- ServiceManager.getService(Context.WINDOW_SERVICE));
+ mIWindowManager = WindowManagerGlobal.getWindowManagerService();
}
private void checkPermission(String permission) {
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index b513915a82ed..efa8911e12c4 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -36,7 +36,6 @@ import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.PowerManager;
-import android.os.Process;
import android.os.RemoteException;
import android.util.Log;
import android.util.LogPrinter;
@@ -51,9 +50,8 @@ import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.View;
import android.view.ViewGroup;
-import android.view.ViewRootImpl;
import android.view.WindowManager;
-import android.view.WindowManagerImpl;
+import android.view.WindowManagerGlobal;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -674,8 +672,8 @@ public abstract class WallpaperService extends Service {
}
}
- redrawNeeded |= creating
- || (relayoutResult&WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0;
+ redrawNeeded |= creating || (relayoutResult
+ & WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME) != 0;
if (forceReport || creating || surfaceCreating
|| formatChanged || sizeChanged) {
@@ -762,7 +760,7 @@ public abstract class WallpaperService extends Service {
mWindowToken = wrapper.mWindowToken;
mSurfaceHolder.setSizeFromLayout();
mInitializing = true;
- mSession = ViewRootImpl.getWindowSession(getMainLooper());
+ mSession = WindowManagerGlobal.getWindowSession(getMainLooper());
mWindow.setSession(mSession);
diff --git a/core/java/android/view/Choreographer.java b/core/java/android/view/Choreographer.java
index 6288ce514a50..392d1f2dd19e 100644
--- a/core/java/android/view/Choreographer.java
+++ b/core/java/android/view/Choreographer.java
@@ -16,6 +16,7 @@
package android.view;
+import android.hardware.display.DisplayManager;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -165,7 +166,7 @@ public final class Choreographer {
mDisplayEventReceiver = USE_VSYNC ? new FrameDisplayEventReceiver(looper) : null;
mLastFrameTimeNanos = Long.MIN_VALUE;
- Display d = WindowManagerImpl.getDefault().getDefaultDisplay();
+ Display d = DisplayManager.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY);
mFrameIntervalNanos = (long)(1000000000 / d.getRefreshRate());
mCallbackQueues = new CallbackQueue[CALLBACK_LAST + 1];
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java
index 5409b3849ff2..18eba817ac95 100644
--- a/core/java/android/view/Display.java
+++ b/core/java/android/view/Display.java
@@ -67,20 +67,16 @@ public final class Display {
private int mCachedAppHeightCompat;
/**
- * The default Display id.
+ * The default Display id, which is the id of the built-in primary display
+ * assuming there is one.
*/
public static final int DEFAULT_DISPLAY = 0;
/**
- * Uninitialized display.
- * @hide
- */
- public static final int NO_DISPLAY = -1;
-
- /**
* Internal method to create a display.
* Applications should use {@link android.view.WindowManager#getDefaultDisplay()}
- * to get a display object for the default display.
+ * or {@link android.hardware.display.DisplayManager#getDisplay}
+ * to get a display object.
*
* @hide
*/
@@ -114,6 +110,31 @@ public final class Display {
}
/**
+ * Gets the display's layer stack.
+ *
+ * Each display has its own independent layer stack upon which surfaces
+ * are placed to be managed by surface flinger.
+ *
+ * @return The layer stack number.
+ * @hide
+ */
+ public int getLayerStack() {
+ // Note: This is the current convention but there is no requirement that
+ // the display id and layer stack id be the same.
+ return mDisplayId;
+ }
+
+ /**
+ * Gets the compatibility info used by this display instance.
+ *
+ * @return The compatibility info holder, or null if none is required.
+ * @hide
+ */
+ public CompatibilityInfoHolder getCompatibilityInfo() {
+ return mCompatibilityInfo;
+ }
+
+ /**
* Gets the size of the display, in pixels.
* <p>
* Note that this value should <em>not</em> be used for computing layouts,
diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl
index e93e4805a7a6..c5d925594164 100644
--- a/core/java/android/view/IWindowSession.aidl
+++ b/core/java/android/view/IWindowSession.aidl
@@ -59,8 +59,8 @@ interface IWindowSession {
* @param requestedWidth The width the window wants to be.
* @param requestedHeight The height the window wants to be.
* @param viewVisibility Window root view's visibility.
- * @param flags Request flags: {@link WindowManagerImpl#RELAYOUT_INSETS_PENDING},
- * {@link WindowManagerImpl#RELAYOUT_DEFER_SURFACE_DESTROY}.
+ * @param flags Request flags: {@link WindowManagerGlobal#RELAYOUT_INSETS_PENDING},
+ * {@link WindowManagerGlobal#RELAYOUT_DEFER_SURFACE_DESTROY}.
* @param outFrame Rect in which is placed the new position/size on
* screen.
* @param outContentInsets Rect in which is placed the offsets from
@@ -79,8 +79,8 @@ interface IWindowSession {
* was last displayed.
* @param outSurface Object in which is placed the new display surface.
*
- * @return int Result flags: {@link WindowManagerImpl#RELAYOUT_SHOW_FOCUS},
- * {@link WindowManagerImpl#RELAYOUT_FIRST_TIME}.
+ * @return int Result flags: {@link WindowManagerGlobal#RELAYOUT_SHOW_FOCUS},
+ * {@link WindowManagerGlobal#RELAYOUT_FIRST_TIME}.
*/
int relayout(IWindow window, int seq, in WindowManager.LayoutParams attrs,
int requestedWidth, int requestedHeight, int viewVisibility,
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java
index 5f5d1f297fac..517b5147977d 100644
--- a/core/java/android/view/Surface.java
+++ b/core/java/android/view/Surface.java
@@ -246,22 +246,9 @@ public class Surface implements Parcelable {
native private static void nativeClassInit();
static { nativeClassInit(); }
- /** create a surface @hide */
- public Surface(SurfaceSession s,
- int pid, int displayId, int w, int h, int format, int flags)
- throws OutOfResourcesException {
- checkHeadless();
-
- if (DEBUG_RELEASE) {
- mCreationStack = new Exception();
- }
- mCanvas = new CompatibleCanvas();
- init(s,pid,null,displayId,w,h,format,flags);
- }
-
/** create a surface with a name @hide */
public Surface(SurfaceSession s,
- int pid, String name, int displayId, int w, int h, int format, int flags)
+ int pid, String name, int layerStack, int w, int h, int format, int flags)
throws OutOfResourcesException {
checkHeadless();
@@ -269,7 +256,7 @@ public class Surface implements Parcelable {
mCreationStack = new Exception();
}
mCanvas = new CompatibleCanvas();
- init(s,pid,name,displayId,w,h,format,flags);
+ init(s, pid, name, layerStack, w, h, format, flags);
mName = name;
}
@@ -470,7 +457,7 @@ public class Surface implements Parcelable {
/** @hide */
public native void setWindowCrop(Rect crop);
/** @hide */
- public native void setDisplayId(int displayId);
+ public native void setLayerStack(int layerStack);
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index bf570c9b750e..fdf1c226b510 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -480,10 +480,10 @@ public class SurfaceView extends View {
relayoutResult = mSession.relayout(
mWindow, mWindow.mSeq, mLayout, mWidth, mHeight,
visible ? VISIBLE : GONE,
- WindowManagerImpl.RELAYOUT_DEFER_SURFACE_DESTROY,
+ WindowManagerGlobal.RELAYOUT_DEFER_SURFACE_DESTROY,
mWinFrame, mContentInsets,
mVisibleInsets, mConfiguration, mNewSurface);
- if ((relayoutResult&WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0) {
+ if ((relayoutResult & WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME) != 0) {
mReportDrawNeeded = true;
}
@@ -516,8 +516,8 @@ public class SurfaceView extends View {
SurfaceHolder.Callback callbacks[] = null;
- final boolean surfaceChanged =
- (relayoutResult&WindowManagerImpl.RELAYOUT_RES_SURFACE_CHANGED) != 0;
+ final boolean surfaceChanged = (relayoutResult
+ & WindowManagerGlobal.RELAYOUT_RES_SURFACE_CHANGED) != 0;
if (mSurfaceCreated && (surfaceChanged || (!visible && visibleChanged))) {
mSurfaceCreated = false;
if (mSurface.isValid()) {
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 1684a9effea8..b1f5e9e58d36 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -39,6 +39,7 @@ import android.graphics.Region;
import android.graphics.Shader;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
+import android.hardware.display.DisplayManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
@@ -7346,7 +7347,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
outRect.bottom -= insets.bottom;
return;
}
- Display d = WindowManagerImpl.getDefault().getDefaultDisplay();
+ Display d = DisplayManager.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY);
d.getRectSize(outRect);
}
@@ -11622,6 +11623,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
}
/**
+ * Gets the logical display to which the view's window has been attached.
+ *
+ * @return The logical display, or null if the view is not currently attached to a window.
+ */
+ public Display getDisplay() {
+ return mAttachInfo != null ? mAttachInfo.mDisplay : null;
+ }
+
+ /**
* Retrieve private session object this view hierarchy is using to
* communicate with the window manager.
* @return the session object to communicate with the window manager
@@ -17260,6 +17270,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
final IBinder mWindowToken;
+ final Display mDisplay;
+
final Callbacks mRootCallbacks;
HardwareCanvas mHardwareCanvas;
@@ -17519,11 +17531,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*
* @param handler the events handler the view must use
*/
- AttachInfo(IWindowSession session, IWindow window,
+ AttachInfo(IWindowSession session, IWindow window, Display display,
ViewRootImpl viewRootImpl, Handler handler, Callbacks effectPlayer) {
mSession = session;
mWindow = window;
mWindowToken = window.asBinder();
+ mDisplay = display;
mViewRootImpl = viewRootImpl;
mHandler = handler;
mRootCallbacks = effectPlayer;
diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java
index 3082976ec7ea..499075e1b6a1 100644
--- a/core/java/android/view/ViewConfiguration.java
+++ b/core/java/android/view/ViewConfiguration.java
@@ -279,7 +279,8 @@ public class ViewConfiguration {
mWindowTouchSlop = (int) (sizeAndDensity * WINDOW_TOUCH_SLOP + 0.5f);
// Size of the screen in bytes, in ARGB_8888 format
- final Display display = WindowManagerImpl.getDefault().getDefaultDisplay();
+ final WindowManager win = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
+ final Display display = win.getDefaultDisplay();
final Point size = new Point();
display.getRealSize(size);
mMaximumDrawingCacheSize = 4 * size.x * size.y;
@@ -288,7 +289,7 @@ public class ViewConfiguration {
mOverflingDistance = (int) (sizeAndDensity * OVERFLING_DISTANCE + 0.5f);
if (!sHasPermanentMenuKeySet) {
- IWindowManager wm = WindowManagerImpl.getWindowManagerService();
+ IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
try {
sHasPermanentMenuKey = !wm.hasSystemNavBar() && !wm.hasNavigationBar();
sHasPermanentMenuKeySet = true;
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 4918d5be4ed9..725d9b52507c 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -18,7 +18,6 @@ package android.view;
import android.Manifest;
import android.animation.LayoutTransition;
-import android.animation.ValueAnimator;
import android.app.ActivityManagerNative;
import android.content.ClipDescription;
import android.content.ComponentCallbacks;
@@ -88,7 +87,7 @@ import java.util.HashSet;
/**
* The top of a view hierarchy, implementing the needed protocol between View
* and the WindowManager. This is for the most part an internal implementation
- * detail of {@link WindowManagerImpl}.
+ * detail of {@link WindowManagerGlobal}.
*
* {@hide}
*/
@@ -126,11 +125,6 @@ public final class ViewRootImpl implements ViewParent,
*/
static final int MAX_TRACKBALL_DELAY = 250;
- static IWindowSession sWindowSession;
-
- static final Object mStaticInit = new Object();
- static boolean mInitialized = false;
-
static final ThreadLocal<RunQueue> sRunQueues = new ThreadLocal<RunQueue>();
static final ArrayList<Runnable> sFirstDrawHandlers = new ArrayList<Runnable>();
@@ -143,6 +137,9 @@ public final class ViewRootImpl implements ViewParent,
private static boolean sRenderThreadQueried = false;
private static final Object[] sRenderThreadQueryLock = new Object[0];
+ final IWindowSession mWindowSession;
+ final Display mDisplay;
+
long mLastTrackballTime = 0;
final TrackballAxis mTrackballAxisX = new TrackballAxis();
final TrackballAxis mTrackballAxisY = new TrackballAxis();
@@ -250,7 +247,7 @@ public final class ViewRootImpl implements ViewParent,
boolean mAdded;
boolean mAddedTouchMode;
- CompatibilityInfoHolder mCompatibilityInfo;
+ final CompatibilityInfoHolder mCompatibilityInfo;
// These are accessed by multiple threads.
final Rect mWinFrame; // frame given by window manager.
@@ -322,24 +319,6 @@ public final class ViewRootImpl implements ViewParent,
InputEventConsistencyVerifier.isInstrumentationEnabled() ?
new InputEventConsistencyVerifier(this, 0) : null;
- public static IWindowSession getWindowSession(Looper mainLooper) {
- synchronized (mStaticInit) {
- if (!mInitialized) {
- try {
- InputMethodManager imm = InputMethodManager.getInstance(mainLooper);
- IWindowManager windowManager = WindowManagerImpl.getWindowManagerService();
- sWindowSession = windowManager.openSession(
- imm.getClient(), imm.getInputContext());
- float animatorScale = windowManager.getAnimationScale(2);
- ValueAnimator.setDurationScale(animatorScale);
- mInitialized = true;
- } catch (RemoteException e) {
- }
- }
- return sWindowSession;
- }
- }
-
static final class SystemUiVisibilityInfo {
int seq;
int globalVisibility;
@@ -347,7 +326,7 @@ public final class ViewRootImpl implements ViewParent,
int localChanges;
}
- public ViewRootImpl(Context context) {
+ public ViewRootImpl(Context context, Display display) {
super();
if (MEASURE_LATENCY) {
@@ -359,7 +338,11 @@ public final class ViewRootImpl implements ViewParent,
// Initialize the statics when this class is first instantiated. This is
// done here instead of in the static block because Zygote does not
// allow the spawning of threads.
- getWindowSession(context.getMainLooper());
+ mWindowSession = WindowManagerGlobal.getWindowSession(context.getMainLooper());
+ mDisplay = display;
+
+ CompatibilityInfoHolder cih = display.getCompatibilityInfo();
+ mCompatibilityInfo = cih != null ? cih : new CompatibilityInfoHolder();
mThread = Thread.currentThread();
mLocation = new WindowLeaked(null);
@@ -383,7 +366,7 @@ public final class ViewRootImpl implements ViewParent,
new AccessibilityInteractionConnectionManager();
mAccessibilityManager.addAccessibilityStateChangeListener(
mAccessibilityInteractionConnectionManager);
- mAttachInfo = new View.AttachInfo(sWindowSession, mWindow, this, mHandler, this);
+ mAttachInfo = new View.AttachInfo(mWindowSession, mWindow, display, this, mHandler, this);
mViewConfiguration = ViewConfiguration.get(context);
mDensity = context.getResources().getDisplayMetrics().densityDpi;
mNoncompatDensity = context.getResources().getDisplayMetrics().noncompatDensityDpi;
@@ -460,9 +443,10 @@ public final class ViewRootImpl implements ViewParent,
* @hide
*/
static boolean isInTouchMode() {
- if (mInitialized) {
+ IWindowSession windowSession = WindowManagerGlobal.peekWindowSession();
+ if (windowSession != null) {
try {
- return sWindowSession.getInTouchMode();
+ return windowSession.getInTouchMode();
} catch (RemoteException e) {
}
}
@@ -541,8 +525,8 @@ public final class ViewRootImpl implements ViewParent,
mOrigWindowType = mWindowAttributes.type;
mAttachInfo.mRecomputeGlobalAttributes = true;
collectViewAttributes();
- res = sWindowSession.addToDisplay(mWindow, mSeq, mWindowAttributes,
- getHostVisibility(), Display.DEFAULT_DISPLAY,
+ res = mWindowSession.addToDisplay(mWindow, mSeq, mWindowAttributes,
+ getHostVisibility(), mDisplay.getDisplayId(),
mAttachInfo.mContentInsets, mInputChannel);
} catch (RemoteException e) {
mAdded = false;
@@ -565,7 +549,7 @@ public final class ViewRootImpl implements ViewParent,
mPendingContentInsets.set(mAttachInfo.mContentInsets);
mPendingVisibleInsets.set(0, 0, 0, 0);
if (DEBUG_LAYOUT) Log.v(TAG, "Added window " + mWindow);
- if (res < WindowManagerImpl.ADD_OKAY) {
+ if (res < WindowManagerGlobal.ADD_OKAY) {
mView = null;
mAttachInfo.mRootView = null;
mAdded = false;
@@ -573,33 +557,33 @@ public final class ViewRootImpl implements ViewParent,
unscheduleTraversals();
setAccessibilityFocus(null, null);
switch (res) {
- case WindowManagerImpl.ADD_BAD_APP_TOKEN:
- case WindowManagerImpl.ADD_BAD_SUBWINDOW_TOKEN:
- throw new WindowManagerImpl.BadTokenException(
+ case WindowManagerGlobal.ADD_BAD_APP_TOKEN:
+ case WindowManagerGlobal.ADD_BAD_SUBWINDOW_TOKEN:
+ throw new WindowManager.BadTokenException(
"Unable to add window -- token " + attrs.token
+ " is not valid; is your activity running?");
- case WindowManagerImpl.ADD_NOT_APP_TOKEN:
- throw new WindowManagerImpl.BadTokenException(
+ case WindowManagerGlobal.ADD_NOT_APP_TOKEN:
+ throw new WindowManager.BadTokenException(
"Unable to add window -- token " + attrs.token
+ " is not for an application");
- case WindowManagerImpl.ADD_APP_EXITING:
- throw new WindowManagerImpl.BadTokenException(
+ case WindowManagerGlobal.ADD_APP_EXITING:
+ throw new WindowManager.BadTokenException(
"Unable to add window -- app for token " + attrs.token
+ " is exiting");
- case WindowManagerImpl.ADD_DUPLICATE_ADD:
- throw new WindowManagerImpl.BadTokenException(
+ case WindowManagerGlobal.ADD_DUPLICATE_ADD:
+ throw new WindowManager.BadTokenException(
"Unable to add window -- window " + mWindow
+ " has already been added");
- case WindowManagerImpl.ADD_STARTING_NOT_NEEDED:
+ case WindowManagerGlobal.ADD_STARTING_NOT_NEEDED:
// Silently ignore -- we would have just removed it
// right away, anyway.
return;
- case WindowManagerImpl.ADD_MULTIPLE_SINGLETON:
- throw new WindowManagerImpl.BadTokenException(
+ case WindowManagerGlobal.ADD_MULTIPLE_SINGLETON:
+ throw new WindowManager.BadTokenException(
"Unable to add window " + mWindow +
" -- another window of this type already exists");
- case WindowManagerImpl.ADD_PERMISSION_DENIED:
- throw new WindowManagerImpl.BadTokenException(
+ case WindowManagerGlobal.ADD_PERMISSION_DENIED:
+ throw new WindowManager.BadTokenException(
"Unable to add window " + mWindow +
" -- permission denied for this window type");
}
@@ -622,8 +606,8 @@ public final class ViewRootImpl implements ViewParent,
}
view.assignParent(this);
- mAddedTouchMode = (res&WindowManagerImpl.ADD_FLAG_IN_TOUCH_MODE) != 0;
- mAppVisible = (res&WindowManagerImpl.ADD_FLAG_APP_VISIBLE) != 0;
+ mAddedTouchMode = (res & WindowManagerGlobal.ADD_FLAG_IN_TOUCH_MODE) != 0;
+ mAppVisible = (res & WindowManagerGlobal.ADD_FLAG_APP_VISIBLE) != 0;
if (mAccessibilityManager.isEnabled()) {
mAccessibilityInteractionConnectionManager.ensureConnection();
@@ -1164,9 +1148,8 @@ public final class ViewRootImpl implements ViewParent,
if (lp.type == WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL) {
// NOTE -- system code, won't try to do compat mode.
- Display disp = WindowManagerImpl.getDefault().getDefaultDisplay();
Point size = new Point();
- disp.getRealSize(size);
+ mDisplay.getRealSize(size);
desiredWindowWidth = size.x;
desiredWindowHeight = size.y;
} else {
@@ -1251,9 +1234,8 @@ public final class ViewRootImpl implements ViewParent,
if (lp.type == WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL) {
// NOTE -- system code, won't try to do compat mode.
- Display disp = WindowManagerImpl.getDefault().getDefaultDisplay();
Point size = new Point();
- disp.getRealSize(size);
+ mDisplay.getRealSize(size);
desiredWindowWidth = size.x;
desiredWindowHeight = size.y;
} else {
@@ -1502,7 +1484,7 @@ public final class ViewRootImpl implements ViewParent,
} catch (Surface.OutOfResourcesException e) {
Log.e(TAG, "OutOfResourcesException initializing HW surface", e);
try {
- if (!sWindowSession.outOfMemory(mWindow)) {
+ if (!mWindowSession.outOfMemory(mWindow)) {
Slog.w(TAG, "No processes killed for memory; killing self");
Process.killProcess(Process.myPid());
}
@@ -1535,7 +1517,7 @@ public final class ViewRootImpl implements ViewParent,
} catch (Surface.OutOfResourcesException e) {
Log.e(TAG, "OutOfResourcesException updating HW surface", e);
try {
- if (!sWindowSession.outOfMemory(mWindow)) {
+ if (!mWindowSession.outOfMemory(mWindow)) {
Slog.w(TAG, "No processes killed for memory; killing self");
Process.killProcess(Process.myPid());
}
@@ -1629,7 +1611,7 @@ public final class ViewRootImpl implements ViewParent,
if (!mStopped) {
boolean focusChangedDueToTouchMode = ensureTouchModeLocally(
- (relayoutResult&WindowManagerImpl.RELAYOUT_RES_IN_TOUCH_MODE) != 0);
+ (relayoutResult&WindowManagerGlobal.RELAYOUT_RES_IN_TOUCH_MODE) != 0);
if (focusChangedDueToTouchMode || mWidth != host.getMeasuredWidth()
|| mHeight != host.getMeasuredHeight() || contentInsetsChanged) {
int childWidthMeasureSpec = getRootMeasureSpec(mWidth, lp.width);
@@ -1726,7 +1708,7 @@ public final class ViewRootImpl implements ViewParent,
mPreviousTransparentRegion.set(mTransparentRegion);
// reconfigure window manager
try {
- sWindowSession.setTransparentRegion(mWindow, mTransparentRegion);
+ mWindowSession.setTransparentRegion(mWindow, mTransparentRegion);
} catch (RemoteException e) {
}
}
@@ -1775,7 +1757,7 @@ public final class ViewRootImpl implements ViewParent,
}
try {
- sWindowSession.setInsets(mWindow, insets.mTouchableInsets,
+ mWindowSession.setInsets(mWindow, insets.mTouchableInsets,
contentInsets, visibleInsets, touchableRegion);
} catch (RemoteException e) {
}
@@ -1800,7 +1782,7 @@ public final class ViewRootImpl implements ViewParent,
+ mRealFocusedView);
}
}
- if ((relayoutResult&WindowManagerImpl.RELAYOUT_RES_ANIMATING) != 0) {
+ if ((relayoutResult & WindowManagerGlobal.RELAYOUT_RES_ANIMATING) != 0) {
// The first time we relayout the window, if the system is
// doing window animations, we want to hold of on any future
// draws until the animation is done.
@@ -1831,7 +1813,7 @@ public final class ViewRootImpl implements ViewParent,
}
// Remember if we must report the next draw.
- if ((relayoutResult & WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0) {
+ if ((relayoutResult & WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME) != 0) {
mReportNextDraw = true;
}
@@ -2061,7 +2043,7 @@ public final class ViewRootImpl implements ViewParent,
}
}
try {
- sWindowSession.finishDrawing(mWindow);
+ mWindowSession.finishDrawing(mWindow);
} catch (RemoteException e) {
}
}
@@ -2217,7 +2199,7 @@ public final class ViewRootImpl implements ViewParent,
} catch (Surface.OutOfResourcesException e) {
Log.e(TAG, "OutOfResourcesException locking surface", e);
try {
- if (!sWindowSession.outOfMemory(mWindow)) {
+ if (!mWindowSession.outOfMemory(mWindow)) {
Slog.w(TAG, "No processes killed for memory; killing self");
Process.killProcess(Process.myPid());
}
@@ -2646,7 +2628,7 @@ public final class ViewRootImpl implements ViewParent,
mInputEventReceiver = null;
}
try {
- sWindowSession.remove(mWindow);
+ mWindowSession.remove(mWindow);
} catch (RemoteException e) {
}
@@ -2891,7 +2873,7 @@ public final class ViewRootImpl implements ViewParent,
} catch (Surface.OutOfResourcesException e) {
Log.e(TAG, "OutOfResourcesException locking surface", e);
try {
- if (!sWindowSession.outOfMemory(mWindow)) {
+ if (!mWindowSession.outOfMemory(mWindow)) {
Slog.w(TAG, "No processes killed for memory; killing self");
Process.killProcess(Process.myPid());
}
@@ -3036,7 +3018,7 @@ public final class ViewRootImpl implements ViewParent,
// tell the window manager
try {
- sWindowSession.setInTouchMode(inTouchMode);
+ mWindowSession.setInTouchMode(inTouchMode);
} catch (RemoteException e) {
throw new RuntimeException(e);
}
@@ -3750,10 +3732,10 @@ public final class ViewRootImpl implements ViewParent,
if (prevDragView != mCurrentDragView) {
try {
if (prevDragView != null) {
- sWindowSession.dragRecipientExited(mWindow);
+ mWindowSession.dragRecipientExited(mWindow);
}
if (mCurrentDragView != null) {
- sWindowSession.dragRecipientEntered(mWindow);
+ mWindowSession.dragRecipientEntered(mWindow);
}
} catch (RemoteException e) {
Slog.e(TAG, "Unable to note drag target change");
@@ -3765,7 +3747,7 @@ public final class ViewRootImpl implements ViewParent,
mDragDescription = null;
try {
Log.i(TAG, "Reporting drop result: " + result);
- sWindowSession.reportDropResult(mWindow, result);
+ mWindowSession.reportDropResult(mWindow, result);
} catch (RemoteException e) {
Log.e(TAG, "Unable to report drop result");
}
@@ -3867,11 +3849,11 @@ public final class ViewRootImpl implements ViewParent,
params.type = mOrigWindowType;
}
}
- int relayoutResult = sWindowSession.relayout(
+ int relayoutResult = mWindowSession.relayout(
mWindow, mSeq, params,
(int) (mView.getMeasuredWidth() * appScale + 0.5f),
(int) (mView.getMeasuredHeight() * appScale + 0.5f),
- viewVisibility, insetsPending ? WindowManagerImpl.RELAYOUT_INSETS_PENDING : 0,
+ viewVisibility, insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0,
mWinFrame, mPendingContentInsets, mPendingVisibleInsets,
mPendingConfiguration, mSurface);
//Log.d(TAG, "<<<<<< BACK FROM relayout");
@@ -3928,7 +3910,7 @@ public final class ViewRootImpl implements ViewParent,
*/
public boolean performHapticFeedback(int effectId, boolean always) {
try {
- return sWindowSession.performHapticFeedback(mWindow, effectId, always);
+ return mWindowSession.performHapticFeedback(mWindow, effectId, always);
} catch (RemoteException e) {
return false;
}
@@ -4007,8 +3989,8 @@ public final class ViewRootImpl implements ViewParent,
// animation info.
try {
if ((relayoutWindow(mWindowAttributes, viewVisibility, false)
- & WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0) {
- sWindowSession.finishDrawing(mWindow);
+ & WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME) != 0) {
+ mWindowSession.finishDrawing(mWindow);
}
} catch (RemoteException e) {
}
@@ -4726,9 +4708,11 @@ public final class ViewRootImpl implements ViewParent,
static class W extends IWindow.Stub {
private final WeakReference<ViewRootImpl> mViewAncestor;
+ private final IWindowSession mWindowSession;
W(ViewRootImpl viewAncestor) {
mViewAncestor = new WeakReference<ViewRootImpl>(viewAncestor);
+ mWindowSession = viewAncestor.mWindowSession;
}
public void resized(Rect frame, Rect contentInsets,
@@ -4827,7 +4811,7 @@ public final class ViewRootImpl implements ViewParent,
boolean sync) {
if (sync) {
try {
- sWindowSession.wallpaperOffsetsComplete(asBinder());
+ mWindowSession.wallpaperOffsetsComplete(asBinder());
} catch (RemoteException e) {
}
}
@@ -4837,7 +4821,7 @@ public final class ViewRootImpl implements ViewParent,
int z, Bundle extras, boolean sync) {
if (sync) {
try {
- sWindowSession.wallpaperCommandComplete(asBinder(), null);
+ mWindowSession.wallpaperCommandComplete(asBinder(), null);
} catch (RemoteException e) {
}
}
diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java
index f57f05677bbf..a24289523560 100644
--- a/core/java/android/view/Window.java
+++ b/core/java/android/view/Window.java
@@ -16,7 +16,6 @@
package android.view;
-import android.app.Application;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
@@ -455,7 +454,7 @@ public abstract class Window {
* display panels. This is <em>not</em> used for displaying the
* Window itself -- that must be done by the client.
*
- * @param wm The ViewManager for adding new windows.
+ * @param wm The window manager for adding new windows.
*/
public void setWindowManager(WindowManager wm, IBinder appToken, String appName) {
setWindowManager(wm, appToken, appName, false);
@@ -466,7 +465,7 @@ public abstract class Window {
* display panels. This is <em>not</em> used for displaying the
* Window itself -- that must be done by the client.
*
- * @param wm The ViewManager for adding new windows.
+ * @param wm The window manager for adding new windows.
*/
public void setWindowManager(WindowManager wm, IBinder appToken, String appName,
boolean hardwareAccelerated) {
@@ -475,14 +474,9 @@ public abstract class Window {
mHardwareAccelerated = hardwareAccelerated
|| SystemProperties.getBoolean(PROPERTY_HARDWARE_UI, false);
if (wm == null) {
- wm = WindowManagerImpl.getDefault();
+ wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
}
- mWindowManager = ((WindowManagerImpl)wm).makeLocal(this);
- }
-
- CompatibilityInfoHolder getCompatibilityInfo() {
- Application app = (Application)mContext.getApplicationContext();
- return app != null ? app.mLoadedApk.mCompatibilityInfo : null;
+ mWindowManager = ((WindowManagerImpl)wm).createLocalWindowManager(this);
}
void adjustLayoutParamsForSubWindow(WindowManager.LayoutParams wp) {
diff --git a/core/java/android/view/WindowManagerGlobal.java b/core/java/android/view/WindowManagerGlobal.java
new file mode 100644
index 000000000000..7855763c910c
--- /dev/null
+++ b/core/java/android/view/WindowManagerGlobal.java
@@ -0,0 +1,516 @@
+/*
+ * Copyright (C) 2012 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;
+
+import android.animation.ValueAnimator;
+import android.app.ActivityManager;
+import android.content.ComponentCallbacks2;
+import android.content.res.Configuration;
+import android.opengl.ManagedEGLContext;
+import android.os.IBinder;
+import android.os.Looper;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.os.SystemProperties;
+import android.util.AndroidRuntimeException;
+import android.util.Log;
+import android.view.inputmethod.InputMethodManager;
+
+import java.io.FileDescriptor;
+import java.io.FileOutputStream;
+import java.io.PrintWriter;
+
+/**
+ * Provides low-level communication with the system window manager for
+ * operations that are not associated with any particular context.
+ *
+ * This class is only used internally to implement global functions where
+ * the caller already knows the display and relevant compatibility information
+ * for the operation. For most purposes, you should use {@link WindowManager} instead
+ * since it is bound to a context.
+ *
+ * @see WindowManagerImpl
+ * @hide
+ */
+public final class WindowManagerGlobal {
+ private static final String TAG = "WindowManager";
+
+ /**
+ * The user is navigating with keys (not the touch screen), so
+ * navigational focus should be shown.
+ */
+ public static final int RELAYOUT_RES_IN_TOUCH_MODE = 0x1;
+
+ /**
+ * This is the first time the window is being drawn,
+ * so the client must call drawingFinished() when done
+ */
+ public static final int RELAYOUT_RES_FIRST_TIME = 0x2;
+
+ /**
+ * The window manager has changed the surface from the last call.
+ */
+ public static final int RELAYOUT_RES_SURFACE_CHANGED = 0x4;
+
+ /**
+ * The window manager is currently animating. It will call
+ * IWindow.doneAnimating() when done.
+ */
+ public static final int RELAYOUT_RES_ANIMATING = 0x8;
+
+ /**
+ * Flag for relayout: the client will be later giving
+ * internal insets; as a result, the window will not impact other window
+ * layouts until the insets are given.
+ */
+ public static final int RELAYOUT_INSETS_PENDING = 0x1;
+
+ /**
+ * Flag for relayout: the client may be currently using the current surface,
+ * so if it is to be destroyed as a part of the relayout the destroy must
+ * be deferred until later. The client will call performDeferredDestroy()
+ * when it is okay.
+ */
+ public static final int RELAYOUT_DEFER_SURFACE_DESTROY = 0x2;
+
+ public static final int ADD_FLAG_APP_VISIBLE = 0x2;
+ public static final int ADD_FLAG_IN_TOUCH_MODE = RELAYOUT_RES_IN_TOUCH_MODE;
+
+ public static final int ADD_OKAY = 0;
+ public static final int ADD_BAD_APP_TOKEN = -1;
+ public static final int ADD_BAD_SUBWINDOW_TOKEN = -2;
+ public static final int ADD_NOT_APP_TOKEN = -3;
+ public static final int ADD_APP_EXITING = -4;
+ public static final int ADD_DUPLICATE_ADD = -5;
+ public static final int ADD_STARTING_NOT_NEEDED = -6;
+ public static final int ADD_MULTIPLE_SINGLETON = -7;
+ public static final int ADD_PERMISSION_DENIED = -8;
+
+ private static WindowManagerGlobal sDefaultWindowManager;
+ private static IWindowManager sWindowManagerService;
+ private static IWindowSession sWindowSession;
+
+ private final Object mLock = new Object();
+
+ private View[] mViews;
+ private ViewRootImpl[] mRoots;
+ private WindowManager.LayoutParams[] mParams;
+ private boolean mNeedsEglTerminate;
+
+ private Runnable mSystemPropertyUpdater;
+
+ private WindowManagerGlobal() {
+ }
+
+ public static WindowManagerGlobal getInstance() {
+ synchronized (WindowManagerGlobal.class) {
+ if (sDefaultWindowManager == null) {
+ sDefaultWindowManager = new WindowManagerGlobal();
+ }
+ return sDefaultWindowManager;
+ }
+ }
+
+ public static IWindowManager getWindowManagerService() {
+ synchronized (WindowManagerGlobal.class) {
+ if (sWindowManagerService == null) {
+ sWindowManagerService = IWindowManager.Stub.asInterface(
+ ServiceManager.getService("window"));
+ }
+ return sWindowManagerService;
+ }
+ }
+
+ public static IWindowSession getWindowSession(Looper mainLooper) {
+ synchronized (WindowManagerGlobal.class) {
+ if (sWindowSession == null) {
+ try {
+ InputMethodManager imm = InputMethodManager.getInstance(mainLooper);
+ IWindowManager windowManager = getWindowManagerService();
+ sWindowSession = windowManager.openSession(
+ imm.getClient(), imm.getInputContext());
+ float animatorScale = windowManager.getAnimationScale(2);
+ ValueAnimator.setDurationScale(animatorScale);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to open window session", e);
+ }
+ }
+ return sWindowSession;
+ }
+ }
+
+ public static IWindowSession peekWindowSession() {
+ synchronized (WindowManagerGlobal.class) {
+ return sWindowSession;
+ }
+ }
+
+ public void addView(View view, ViewGroup.LayoutParams params,
+ Display display, Window parentWindow) {
+ if (view == null) {
+ throw new IllegalArgumentException("view must not be null");
+ }
+ if (display == null) {
+ throw new IllegalArgumentException("display must not be null");
+ }
+ if (!(params instanceof WindowManager.LayoutParams)) {
+ throw new IllegalArgumentException("Params must be WindowManager.LayoutParams");
+ }
+
+ final WindowManager.LayoutParams wparams = (WindowManager.LayoutParams)params;
+ if (parentWindow != null) {
+ parentWindow.adjustLayoutParamsForSubWindow(wparams);
+ }
+
+ ViewRootImpl root;
+ View panelParentView = null;
+
+ synchronized (mLock) {
+ // Start watching for system property changes.
+ if (mSystemPropertyUpdater == null) {
+ mSystemPropertyUpdater = new Runnable() {
+ @Override public void run() {
+ synchronized (mLock) {
+ for (ViewRootImpl root : mRoots) {
+ root.loadSystemProperties();
+ }
+ }
+ }
+ };
+ SystemProperties.addChangeCallback(mSystemPropertyUpdater);
+ }
+
+ int index = findViewLocked(view, false);
+ if (index >= 0) {
+ throw new IllegalStateException("View " + view
+ + " has already been added to the window manager.");
+ }
+
+ // If this is a panel window, then find the window it is being
+ // attached to for future reference.
+ if (wparams.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW &&
+ wparams.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) {
+ final int count = mViews != null ? mViews.length : 0;
+ for (int i=0; i<count; i++) {
+ if (mRoots[i].mWindow.asBinder() == wparams.token) {
+ panelParentView = mViews[i];
+ }
+ }
+ }
+
+ root = new ViewRootImpl(view.getContext(), display);
+
+ view.setLayoutParams(wparams);
+
+ if (mViews == null) {
+ index = 1;
+ mViews = new View[1];
+ mRoots = new ViewRootImpl[1];
+ mParams = new WindowManager.LayoutParams[1];
+ } else {
+ index = mViews.length + 1;
+ Object[] old = mViews;
+ mViews = new View[index];
+ System.arraycopy(old, 0, mViews, 0, index-1);
+ old = mRoots;
+ mRoots = new ViewRootImpl[index];
+ System.arraycopy(old, 0, mRoots, 0, index-1);
+ old = mParams;
+ mParams = new WindowManager.LayoutParams[index];
+ System.arraycopy(old, 0, mParams, 0, index-1);
+ }
+ index--;
+
+ mViews[index] = view;
+ mRoots[index] = root;
+ mParams[index] = wparams;
+ }
+
+ // do this last because it fires off messages to start doing things
+ root.setView(view, wparams, panelParentView);
+ }
+
+ public void updateViewLayout(View view, ViewGroup.LayoutParams params) {
+ if (view == null) {
+ throw new IllegalArgumentException("view must not be null");
+ }
+ if (!(params instanceof WindowManager.LayoutParams)) {
+ throw new IllegalArgumentException("Params must be WindowManager.LayoutParams");
+ }
+
+ final WindowManager.LayoutParams wparams = (WindowManager.LayoutParams)params;
+
+ view.setLayoutParams(wparams);
+
+ synchronized (mLock) {
+ int index = findViewLocked(view, true);
+ ViewRootImpl root = mRoots[index];
+ mParams[index] = wparams;
+ root.setLayoutParams(wparams, false);
+ }
+ }
+
+ public void removeView(View view, boolean immediate) {
+ if (view == null) {
+ throw new IllegalArgumentException("view must not be null");
+ }
+
+ synchronized (mLock) {
+ int index = findViewLocked(view, true);
+ View curView = removeViewLocked(index, immediate);
+ if (curView == view) {
+ return;
+ }
+
+ throw new IllegalStateException("Calling with view " + view
+ + " but the ViewAncestor is attached to " + curView);
+ }
+ }
+
+ public void closeAll(IBinder token, String who, String what) {
+ synchronized (mLock) {
+ if (mViews == null)
+ return;
+
+ int count = mViews.length;
+ //Log.i("foo", "Closing all windows of " + token);
+ for (int i=0; i<count; i++) {
+ //Log.i("foo", "@ " + i + " token " + mParams[i].token
+ // + " view " + mRoots[i].getView());
+ if (token == null || mParams[i].token == token) {
+ ViewRootImpl root = mRoots[i];
+
+ //Log.i("foo", "Force closing " + root);
+ if (who != null) {
+ WindowLeaked leak = new WindowLeaked(
+ what + " " + who + " has leaked window "
+ + root.getView() + " that was originally added here");
+ leak.setStackTrace(root.getLocation().getStackTrace());
+ Log.e(TAG, leak.getMessage(), leak);
+ }
+
+ removeViewLocked(i, false);
+ i--;
+ count--;
+ }
+ }
+ }
+ }
+
+ private View removeViewLocked(int index, boolean immediate) {
+ ViewRootImpl root = mRoots[index];
+ View view = root.getView();
+
+ if (view != null) {
+ InputMethodManager imm = InputMethodManager.getInstance(view.getContext());
+ if (imm != null) {
+ imm.windowDismissed(mViews[index].getWindowToken());
+ }
+ }
+ root.die(immediate);
+
+ final int count = mViews.length;
+
+ // remove it from the list
+ View[] tmpViews = new View[count-1];
+ removeItem(tmpViews, mViews, index);
+ mViews = tmpViews;
+
+ ViewRootImpl[] tmpRoots = new ViewRootImpl[count-1];
+ removeItem(tmpRoots, mRoots, index);
+ mRoots = tmpRoots;
+
+ WindowManager.LayoutParams[] tmpParams
+ = new WindowManager.LayoutParams[count-1];
+ removeItem(tmpParams, mParams, index);
+ mParams = tmpParams;
+
+ if (view != null) {
+ view.assignParent(null);
+ // func doesn't allow null... does it matter if we clear them?
+ //view.setLayoutParams(null);
+ }
+ return view;
+ }
+
+ private static void removeItem(Object[] dst, Object[] src, int index) {
+ if (dst.length > 0) {
+ if (index > 0) {
+ System.arraycopy(src, 0, dst, 0, index);
+ }
+ if (index < dst.length) {
+ System.arraycopy(src, index+1, dst, index, src.length-index-1);
+ }
+ }
+ }
+
+ private int findViewLocked(View view, boolean required) {
+ synchronized (mLock) {
+ if (mViews != null) {
+ final int count = mViews.length;
+ for (int i = 0; i < count; i++) {
+ if (mViews[i] == view) {
+ return i;
+ }
+ }
+ }
+ if (required) {
+ throw new IllegalArgumentException("View not attached to window manager");
+ }
+ return -1;
+ }
+ }
+
+ public void startTrimMemory(int level) {
+ if (HardwareRenderer.isAvailable()) {
+ // On low-end gfx devices we trim when memory is moderate;
+ // on high-end devices we do this when low.
+ if (level >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE
+ || (level >= ComponentCallbacks2.TRIM_MEMORY_MODERATE
+ && !ActivityManager.isHighEndGfx())) {
+ // Destroy all hardware surfaces and resources associated to
+ // known windows
+ synchronized (mLock) {
+ if (mViews == null) return;
+ int count = mViews.length;
+ for (int i = 0; i < count; i++) {
+ mRoots[i].terminateHardwareResources();
+ }
+ }
+ // Force a full memory flush
+ mNeedsEglTerminate = true;
+ HardwareRenderer.startTrimMemory(ComponentCallbacks2.TRIM_MEMORY_COMPLETE);
+ return;
+ }
+
+ HardwareRenderer.startTrimMemory(level);
+ }
+ }
+
+ public void endTrimMemory() {
+ HardwareRenderer.endTrimMemory();
+
+ if (mNeedsEglTerminate) {
+ ManagedEGLContext.doTerminate();
+ mNeedsEglTerminate = false;
+ }
+ }
+
+ public void trimLocalMemory() {
+ synchronized (mLock) {
+ if (mViews == null) return;
+ int count = mViews.length;
+ for (int i = 0; i < count; i++) {
+ mRoots[i].destroyHardwareLayers();
+ }
+ }
+ }
+
+ public void dumpGfxInfo(FileDescriptor fd) {
+ FileOutputStream fout = new FileOutputStream(fd);
+ PrintWriter pw = new PrintWriter(fout);
+ try {
+ synchronized (mLock) {
+ if (mViews != null) {
+ final int count = mViews.length;
+
+ pw.println("Profile data in ms:");
+
+ for (int i = 0; i < count; i++) {
+ ViewRootImpl root = mRoots[i];
+ String name = getWindowName(root);
+ pw.printf("\n\t%s", name);
+
+ HardwareRenderer renderer =
+ root.getView().mAttachInfo.mHardwareRenderer;
+ if (renderer != null) {
+ renderer.dumpGfxInfo(pw);
+ }
+ }
+
+ pw.println("\nView hierarchy:\n");
+
+ int viewsCount = 0;
+ int displayListsSize = 0;
+ int[] info = new int[2];
+
+ for (int i = 0; i < count; i++) {
+ ViewRootImpl root = mRoots[i];
+ root.dumpGfxInfo(info);
+
+ String name = getWindowName(root);
+ pw.printf(" %s\n %d views, %.2f kB of display lists",
+ name, info[0], info[1] / 1024.0f);
+ HardwareRenderer renderer =
+ root.getView().mAttachInfo.mHardwareRenderer;
+ if (renderer != null) {
+ pw.printf(", %d frames rendered", renderer.getFrameCount());
+ }
+ pw.printf("\n\n");
+
+ viewsCount += info[0];
+ displayListsSize += info[1];
+ }
+
+ pw.printf("\nTotal ViewRootImpl: %d\n", count);
+ pw.printf("Total Views: %d\n", viewsCount);
+ pw.printf("Total DisplayList: %.2f kB\n\n", displayListsSize / 1024.0f);
+ }
+ }
+ } finally {
+ pw.flush();
+ }
+ }
+
+ private static String getWindowName(ViewRootImpl root) {
+ return root.mWindowAttributes.getTitle() + "/" +
+ root.getClass().getName() + '@' + Integer.toHexString(root.hashCode());
+ }
+
+ public void setStoppedState(IBinder token, boolean stopped) {
+ synchronized (mLock) {
+ if (mViews != null) {
+ int count = mViews.length;
+ for (int i=0; i < count; i++) {
+ if (token == null || mParams[i].token == token) {
+ ViewRootImpl root = mRoots[i];
+ root.setStopped(stopped);
+ }
+ }
+ }
+ }
+ }
+
+ public void reportNewConfiguration(Configuration config) {
+ synchronized (mLock) {
+ if (mViews != null) {
+ int count = mViews.length;
+ config = new Configuration(config);
+ for (int i=0; i < count; i++) {
+ ViewRootImpl root = mRoots[i];
+ root.requestUpdateConfiguration(config);
+ }
+ }
+ }
+ }
+}
+
+final class WindowLeaked extends AndroidRuntimeException {
+ public WindowLeaked(String msg) {
+ super(msg);
+ }
+}
diff --git a/core/java/android/view/WindowManagerImpl.java b/core/java/android/view/WindowManagerImpl.java
index bd95cdb34ad6..bf061df19791 100644
--- a/core/java/android/view/WindowManagerImpl.java
+++ b/core/java/android/view/WindowManagerImpl.java
@@ -16,34 +16,20 @@
package android.view;
-import android.app.ActivityManager;
-import android.content.ComponentCallbacks2;
-import android.content.res.Configuration;
-import android.opengl.ManagedEGLContext;
-import android.os.IBinder;
-import android.os.ServiceManager;
-import android.os.SystemProperties;
-import android.util.AndroidRuntimeException;
-import android.util.Log;
-import android.view.inputmethod.InputMethodManager;
-
-import java.io.FileDescriptor;
-import java.io.FileOutputStream;
-import java.io.PrintWriter;
-
-final class WindowLeaked extends AndroidRuntimeException {
- public WindowLeaked(String msg) {
- super(msg);
- }
-}
+import android.content.Context;
+import android.hardware.display.DisplayManager;
/**
- * Low-level communication with the global system window manager. It implements
- * the ViewManager interface, allowing you to add any View subclass as a
- * top-level window on the screen. Additional window manager specific layout
- * parameters are defined for control over how windows are displayed.
- * It also implements the WindowManager interface, allowing you to control the
- * displays attached to the device.
+ * Provides low-level communication with the system window manager for
+ * operations that are bound to a particular context, display or parent window.
+ * Instances of this object are sensitive to the compatibility info associated
+ * with the running application.
+ *
+ * This object implements the {@link ViewManager} interface,
+ * allowing you to add any View subclass as a top-level window on the screen.
+ * Additional window manager specific layout parameters are defined for
+ * control over how windows are displayed. It also implements the {@link WindowManager}
+ * interface, allowing you to control the displays attached to the device.
*
* <p>Applications will not normally use WindowManager directly, instead relying
* on the higher-level facilities in {@link android.app.Activity} and
@@ -51,531 +37,58 @@ final class WindowLeaked extends AndroidRuntimeException {
*
* <p>Even for low-level window manager access, it is almost never correct to use
* this class. For example, {@link android.app.Activity#getWindowManager}
- * provides a ViewManager for adding windows that are associated with that
+ * provides a window manager for adding windows that are associated with that
* activity -- the window manager will not normally allow you to add arbitrary
* windows that are not associated with an activity.
- *
+ *
+ * @see WindowManager
+ * @see WindowManagerGlobal
* @hide
*/
-public class WindowManagerImpl implements WindowManager {
- private static final String TAG = "WindowManager";
-
- /**
- * The user is navigating with keys (not the touch screen), so
- * navigational focus should be shown.
- */
- public static final int RELAYOUT_RES_IN_TOUCH_MODE = 0x1;
-
- /**
- * This is the first time the window is being drawn,
- * so the client must call drawingFinished() when done
- */
- public static final int RELAYOUT_RES_FIRST_TIME = 0x2;
-
- /**
- * The window manager has changed the surface from the last call.
- */
- public static final int RELAYOUT_RES_SURFACE_CHANGED = 0x4;
-
- /**
- * The window manager is currently animating. It will call
- * IWindow.doneAnimating() when done.
- */
- public static final int RELAYOUT_RES_ANIMATING = 0x8;
-
- /**
- * Flag for relayout: the client will be later giving
- * internal insets; as a result, the window will not impact other window
- * layouts until the insets are given.
- */
- public static final int RELAYOUT_INSETS_PENDING = 0x1;
-
- /**
- * Flag for relayout: the client may be currently using the current surface,
- * so if it is to be destroyed as a part of the relayout the destroy must
- * be deferred until later. The client will call performDeferredDestroy()
- * when it is okay.
- */
- public static final int RELAYOUT_DEFER_SURFACE_DESTROY = 0x2;
-
- public static final int ADD_FLAG_APP_VISIBLE = 0x2;
- public static final int ADD_FLAG_IN_TOUCH_MODE = RELAYOUT_RES_IN_TOUCH_MODE;
-
- public static final int ADD_OKAY = 0;
- public static final int ADD_BAD_APP_TOKEN = -1;
- public static final int ADD_BAD_SUBWINDOW_TOKEN = -2;
- public static final int ADD_NOT_APP_TOKEN = -3;
- public static final int ADD_APP_EXITING = -4;
- public static final int ADD_DUPLICATE_ADD = -5;
- public static final int ADD_STARTING_NOT_NEEDED = -6;
- public static final int ADD_MULTIPLE_SINGLETON = -7;
- public static final int ADD_PERMISSION_DENIED = -8;
-
- private static WindowManagerImpl sDefaultWindowManager;
- private static IWindowManager sWindowManagerService;
-
- private final WindowManagerState mState;
+public final class WindowManagerImpl implements WindowManager {
+ private final WindowManagerGlobal mGlobal = WindowManagerGlobal.getInstance();
+ private final Context mContext;
+ private final Display mDisplay;
private final Window mParentWindow;
- private final CompatibilityInfoHolder mCompatibilityInfo;
- private final Display mDefaultDisplay;
- private WindowManagerImpl(WindowManagerState state, Window parentWindow,
- CompatibilityInfoHolder compatibilityInfo) {
- mState = state;
- mParentWindow = parentWindow;
- mCompatibilityInfo = compatibilityInfo;
- mDefaultDisplay = mState.getDefaultDisplay(mCompatibilityInfo);
+ public WindowManagerImpl(Context context, int displayId) {
+ mContext = context;
+ mDisplay = DisplayManager.getInstance().getDisplay(displayId, mContext);
+ mParentWindow = null;
}
- public static WindowManagerImpl getDefault() {
- synchronized (WindowManagerImpl.class) {
- if (sDefaultWindowManager == null) {
- sDefaultWindowManager = new WindowManagerImpl(
- new WindowManagerState(), null, null);
- }
- return sDefaultWindowManager;
- }
- }
-
- public static IWindowManager getWindowManagerService() {
- synchronized (WindowManagerImpl.class) {
- if (sWindowManagerService == null) {
- sWindowManagerService = IWindowManager.Stub.asInterface(
- ServiceManager.getService("window"));
- }
- return sWindowManagerService;
- }
- }
-
- public WindowManagerImpl makeLocal(Window parentWindow) {
- return new WindowManagerImpl(mState, parentWindow, parentWindow.getCompatibilityInfo());
+ private WindowManagerImpl(Context context, Display display, Window parentWindow) {
+ mContext = context;
+ mDisplay = display;
+ mParentWindow = parentWindow;
}
- public WindowManagerImpl makeCompatible(CompatibilityInfoHolder compatInfo) {
- if (compatInfo == mCompatibilityInfo) {
- return this;
- }
- if (compatInfo == null && mParentWindow == null) {
- return getDefault();
- }
- return new WindowManagerImpl(mState, mParentWindow, compatInfo);
+ public WindowManagerImpl createLocalWindowManager(Window parentWindow) {
+ return new WindowManagerImpl(mContext, mDisplay, parentWindow);
}
@Override
public void addView(View view, ViewGroup.LayoutParams params) {
- mState.addView(view, params, mParentWindow, mCompatibilityInfo);
+ mGlobal.addView(view, params, mDisplay, mParentWindow);
}
@Override
public void updateViewLayout(View view, ViewGroup.LayoutParams params) {
- mState.updateViewLayout(view, params);
+ mGlobal.updateViewLayout(view, params);
}
@Override
public void removeView(View view) {
- mState.removeView(view, false);
+ mGlobal.removeView(view, false);
}
@Override
public void removeViewImmediate(View view) {
- mState.removeView(view, true);
+ mGlobal.removeView(view, true);
}
@Override
public Display getDefaultDisplay() {
- return mDefaultDisplay;
- }
-
- public void closeAll(IBinder token, String who, String what) {
- mState.closeAll(token, who, what);
- }
-
- public void startTrimMemory(int level) {
- mState.startTrimMemory(level);
- }
-
- public void endTrimMemory() {
- mState.endTrimMemory();
- }
-
- public void trimLocalMemory() {
- mState.trimLocalMemory();
- }
-
- public void dumpGfxInfo(FileDescriptor fd) {
- mState.dumpGfxInfo(fd);
- }
-
- public void setStoppedState(IBinder token, boolean stopped) {
- mState.setStoppedState(token, stopped);
- }
-
- public void reportNewConfiguration(Configuration config) {
- mState.reportNewConfiguration(config);
- }
-
- static final class WindowManagerState {
- private final Display mDefaultDisplay;
-
- private View[] mViews;
- private ViewRootImpl[] mRoots;
- private WindowManager.LayoutParams[] mParams;
- private boolean mNeedsEglTerminate;
-
- private Runnable mSystemPropertyUpdater;
-
- public WindowManagerState() {
- mDefaultDisplay = new Display(Display.DEFAULT_DISPLAY, null);
- }
-
- public Display getDefaultDisplay(CompatibilityInfoHolder compatInfo) {
- if (compatInfo == null) {
- return mDefaultDisplay;
- }
- return new Display(Display.DEFAULT_DISPLAY, compatInfo);
- }
-
- public void addView(View view, ViewGroup.LayoutParams params, Window parentWindow,
- CompatibilityInfoHolder cih) {
- if (!(params instanceof WindowManager.LayoutParams)) {
- throw new IllegalArgumentException("Params must be WindowManager.LayoutParams");
- }
-
- final WindowManager.LayoutParams wparams = (WindowManager.LayoutParams)params;
- if (parentWindow != null) {
- parentWindow.adjustLayoutParamsForSubWindow(wparams);
- }
-
- ViewRootImpl root;
- View panelParentView = null;
-
- synchronized (this) {
- // Start watching for system property changes.
- if (mSystemPropertyUpdater == null) {
- mSystemPropertyUpdater = new Runnable() {
- @Override public void run() {
- synchronized (this) {
- synchronized (this) {
- for (ViewRootImpl root : mRoots) {
- root.loadSystemProperties();
- }
- }
- }
- }
- };
- SystemProperties.addChangeCallback(mSystemPropertyUpdater);
- }
-
- int index = findViewLocked(view, false);
- if (index >= 0) {
- throw new IllegalStateException("View " + view
- + " has already been added to the window manager.");
- }
-
- // If this is a panel window, then find the window it is being
- // attached to for future reference.
- if (wparams.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW &&
- wparams.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) {
- final int count = mViews != null ? mViews.length : 0;
- for (int i=0; i<count; i++) {
- if (mRoots[i].mWindow.asBinder() == wparams.token) {
- panelParentView = mViews[i];
- }
- }
- }
-
- root = new ViewRootImpl(view.getContext());
- if (cih == null) {
- root.mCompatibilityInfo = new CompatibilityInfoHolder();
- } else {
- root.mCompatibilityInfo = cih;
- }
-
- view.setLayoutParams(wparams);
-
- if (mViews == null) {
- index = 1;
- mViews = new View[1];
- mRoots = new ViewRootImpl[1];
- mParams = new WindowManager.LayoutParams[1];
- } else {
- index = mViews.length + 1;
- Object[] old = mViews;
- mViews = new View[index];
- System.arraycopy(old, 0, mViews, 0, index-1);
- old = mRoots;
- mRoots = new ViewRootImpl[index];
- System.arraycopy(old, 0, mRoots, 0, index-1);
- old = mParams;
- mParams = new WindowManager.LayoutParams[index];
- System.arraycopy(old, 0, mParams, 0, index-1);
- }
- index--;
-
- mViews[index] = view;
- mRoots[index] = root;
- mParams[index] = wparams;
- }
-
- // do this last because it fires off messages to start doing things
- root.setView(view, wparams, panelParentView);
- }
-
- public void updateViewLayout(View view, ViewGroup.LayoutParams params) {
- if (!(params instanceof WindowManager.LayoutParams)) {
- throw new IllegalArgumentException("Params must be WindowManager.LayoutParams");
- }
-
- final WindowManager.LayoutParams wparams = (WindowManager.LayoutParams)params;
-
- view.setLayoutParams(wparams);
-
- synchronized (this) {
- int index = findViewLocked(view, true);
- ViewRootImpl root = mRoots[index];
- mParams[index] = wparams;
- root.setLayoutParams(wparams, false);
- }
- }
-
- public void removeView(View view, boolean immediate) {
- synchronized (this) {
- int index = findViewLocked(view, true);
- View curView = removeViewLocked(index, immediate);
- if (curView == view) {
- return;
- }
-
- throw new IllegalStateException("Calling with view " + view
- + " but the ViewAncestor is attached to " + curView);
- }
- }
-
- public void closeAll(IBinder token, String who, String what) {
- synchronized (this) {
- if (mViews == null)
- return;
-
- int count = mViews.length;
- //Log.i("foo", "Closing all windows of " + token);
- for (int i=0; i<count; i++) {
- //Log.i("foo", "@ " + i + " token " + mParams[i].token
- // + " view " + mRoots[i].getView());
- if (token == null || mParams[i].token == token) {
- ViewRootImpl root = mRoots[i];
-
- //Log.i("foo", "Force closing " + root);
- if (who != null) {
- WindowLeaked leak = new WindowLeaked(
- what + " " + who + " has leaked window "
- + root.getView() + " that was originally added here");
- leak.setStackTrace(root.getLocation().getStackTrace());
- Log.e(TAG, leak.getMessage(), leak);
- }
-
- removeViewLocked(i, false);
- i--;
- count--;
- }
- }
- }
- }
-
- private View removeViewLocked(int index, boolean immediate) {
- ViewRootImpl root = mRoots[index];
- View view = root.getView();
-
- if (view != null) {
- InputMethodManager imm = InputMethodManager.getInstance(view.getContext());
- if (imm != null) {
- imm.windowDismissed(mViews[index].getWindowToken());
- }
- }
- root.die(immediate);
-
- final int count = mViews.length;
-
- // remove it from the list
- View[] tmpViews = new View[count-1];
- removeItem(tmpViews, mViews, index);
- mViews = tmpViews;
-
- ViewRootImpl[] tmpRoots = new ViewRootImpl[count-1];
- removeItem(tmpRoots, mRoots, index);
- mRoots = tmpRoots;
-
- WindowManager.LayoutParams[] tmpParams
- = new WindowManager.LayoutParams[count-1];
- removeItem(tmpParams, mParams, index);
- mParams = tmpParams;
-
- if (view != null) {
- view.assignParent(null);
- // func doesn't allow null... does it matter if we clear them?
- //view.setLayoutParams(null);
- }
- return view;
- }
-
- private static void removeItem(Object[] dst, Object[] src, int index) {
- if (dst.length > 0) {
- if (index > 0) {
- System.arraycopy(src, 0, dst, 0, index);
- }
- if (index < dst.length) {
- System.arraycopy(src, index+1, dst, index, src.length-index-1);
- }
- }
- }
-
- private int findViewLocked(View view, boolean required) {
- synchronized (this) {
- if (mViews != null) {
- final int count = mViews.length;
- for (int i = 0; i < count; i++) {
- if (mViews[i] == view) {
- return i;
- }
- }
- }
- if (required) {
- throw new IllegalArgumentException("View not attached to window manager");
- }
- return -1;
- }
- }
-
- public void startTrimMemory(int level) {
- if (HardwareRenderer.isAvailable()) {
- // On low-end gfx devices we trim when memory is moderate;
- // on high-end devices we do this when low.
- if (level >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE
- || (level >= ComponentCallbacks2.TRIM_MEMORY_MODERATE
- && !ActivityManager.isHighEndGfx(mDefaultDisplay))) {
- // Destroy all hardware surfaces and resources associated to
- // known windows
- synchronized (this) {
- if (mViews == null) return;
- int count = mViews.length;
- for (int i = 0; i < count; i++) {
- mRoots[i].terminateHardwareResources();
- }
- }
- // Force a full memory flush
- mNeedsEglTerminate = true;
- HardwareRenderer.startTrimMemory(ComponentCallbacks2.TRIM_MEMORY_COMPLETE);
- return;
- }
-
- HardwareRenderer.startTrimMemory(level);
- }
- }
-
- public void endTrimMemory() {
- HardwareRenderer.endTrimMemory();
-
- if (mNeedsEglTerminate) {
- ManagedEGLContext.doTerminate();
- mNeedsEglTerminate = false;
- }
- }
-
- public void trimLocalMemory() {
- synchronized (this) {
- if (mViews == null) return;
- int count = mViews.length;
- for (int i = 0; i < count; i++) {
- mRoots[i].destroyHardwareLayers();
- }
- }
- }
-
- public void dumpGfxInfo(FileDescriptor fd) {
- FileOutputStream fout = new FileOutputStream(fd);
- PrintWriter pw = new PrintWriter(fout);
- try {
- synchronized (this) {
- if (mViews != null) {
- final int count = mViews.length;
-
- pw.println("Profile data in ms:");
-
- for (int i = 0; i < count; i++) {
- ViewRootImpl root = mRoots[i];
- String name = getWindowName(root);
- pw.printf("\n\t%s", name);
-
- HardwareRenderer renderer =
- root.getView().mAttachInfo.mHardwareRenderer;
- if (renderer != null) {
- renderer.dumpGfxInfo(pw);
- }
- }
-
- pw.println("\nView hierarchy:\n");
-
- int viewsCount = 0;
- int displayListsSize = 0;
- int[] info = new int[2];
-
- for (int i = 0; i < count; i++) {
- ViewRootImpl root = mRoots[i];
- root.dumpGfxInfo(info);
-
- String name = getWindowName(root);
- pw.printf(" %s\n %d views, %.2f kB of display lists",
- name, info[0], info[1] / 1024.0f);
- HardwareRenderer renderer =
- root.getView().mAttachInfo.mHardwareRenderer;
- if (renderer != null) {
- pw.printf(", %d frames rendered", renderer.getFrameCount());
- }
- pw.printf("\n\n");
-
- viewsCount += info[0];
- displayListsSize += info[1];
- }
-
- pw.printf("\nTotal ViewRootImpl: %d\n", count);
- pw.printf("Total Views: %d\n", viewsCount);
- pw.printf("Total DisplayList: %.2f kB\n\n", displayListsSize / 1024.0f);
- }
- }
- } finally {
- pw.flush();
- }
- }
-
- private static String getWindowName(ViewRootImpl root) {
- return root.mWindowAttributes.getTitle() + "/" +
- root.getClass().getName() + '@' + Integer.toHexString(root.hashCode());
- }
-
- public void setStoppedState(IBinder token, boolean stopped) {
- synchronized (this) {
- if (mViews != null) {
- int count = mViews.length;
- for (int i=0; i < count; i++) {
- if (token == null || mParams[i].token == token) {
- ViewRootImpl root = mRoots[i];
- root.setStopped(stopped);
- }
- }
- }
- }
- }
-
- public void reportNewConfiguration(Configuration config) {
- synchronized (this) {
- if (mViews != null) {
- int count = mViews.length;
- config = new Configuration(config);
- for (int i=0; i < count; i++) {
- ViewRootImpl root = mRoots[i];
- root.requestUpdateConfiguration(config);
- }
- }
- }
- }
+ return mDisplay;
}
}
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index 7aa3bb4e8397..c0a4a6301d5f 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -487,9 +487,9 @@ public interface WindowManagerPolicy {
*
* @param attrs The window's LayoutParams.
*
- * @return {@link WindowManagerImpl#ADD_OKAY} if the add can proceed;
+ * @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed;
* else an error code, usually
- * {@link WindowManagerImpl#ADD_PERMISSION_DENIED}, to abort the add.
+ * {@link WindowManagerGlobal#ADD_PERMISSION_DENIED}, to abort the add.
*/
public int checkAddPermission(WindowManager.LayoutParams attrs);
@@ -662,7 +662,7 @@ public interface WindowManagerPolicy {
* @param win The window being added.
* @param attrs The window's LayoutParams.
*
- * @return {@link WindowManagerImpl#ADD_OKAY} if the add can proceed, else an
+ * @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed, else an
* error code to abort the add.
*/
public int prepareAddWindowLw(WindowState win,
diff --git a/core/java/android/webkit/WebViewClassic.java b/core/java/android/webkit/WebViewClassic.java
index 8d794923ead1..c816d5b50f37 100644
--- a/core/java/android/webkit/WebViewClassic.java
+++ b/core/java/android/webkit/WebViewClassic.java
@@ -7279,11 +7279,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
// nativeCreate sets mNativeClass to a non-zero value
String drawableDir = BrowserFrame.getRawResFilename(
BrowserFrame.DRAWABLEDIR, mContext);
- WindowManager windowManager =
- (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
- Display display = windowManager.getDefaultDisplay();
- nativeCreate(msg.arg1, drawableDir,
- ActivityManager.isHighEndGfx(display));
+ nativeCreate(msg.arg1, drawableDir, ActivityManager.isHighEndGfx());
if (mDelaySetPicture != null) {
setNewPicture(mDelaySetPicture, true);
mDelaySetPicture = null;
diff --git a/core/java/android/widget/Toast.java b/core/java/android/widget/Toast.java
index 7dcbc3e0f1ae..053ade7ced7c 100644
--- a/core/java/android/widget/Toast.java
+++ b/core/java/android/widget/Toast.java
@@ -30,7 +30,6 @@ import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
-import android.view.WindowManagerImpl;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
@@ -331,7 +330,7 @@ public class Toast {
View mView;
View mNextView;
- WindowManagerImpl mWM;
+ WindowManager mWM;
TN() {
// XXX This should be changed to use a Dialog, with a Theme.Toast
@@ -371,7 +370,7 @@ public class Toast {
// remove the old view if necessary
handleHide();
mView = mNextView;
- mWM = WindowManagerImpl.getDefault();
+ mWM = (WindowManager)mView.getContext().getSystemService(Context.WINDOW_SERVICE);
// We can resolve the Gravity here by using the Locale for getting
// the layout direction
final Configuration config = mView.getContext().getResources().getConfiguration();
diff --git a/core/java/com/android/internal/view/RotationPolicy.java b/core/java/com/android/internal/view/RotationPolicy.java
index af512a30cce9..98beadb5aaae 100644
--- a/core/java/com/android/internal/view/RotationPolicy.java
+++ b/core/java/com/android/internal/view/RotationPolicy.java
@@ -27,6 +27,7 @@ import android.provider.Settings;
import android.util.Log;
import android.view.IWindowManager;
import android.view.Surface;
+import android.view.WindowManagerGlobal;
/**
* Provides helper functions for configuring the display rotation policy.
@@ -79,8 +80,7 @@ public final class RotationPolicy {
@Override
public void run() {
try {
- IWindowManager wm = IWindowManager.Stub.asInterface(
- ServiceManager.getService(Context.WINDOW_SERVICE));
+ IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
if (enabled) {
wm.freezeRotation(-1);
} else {
@@ -107,8 +107,7 @@ public final class RotationPolicy {
@Override
public void run() {
try {
- IWindowManager wm = IWindowManager.Stub.asInterface(
- ServiceManager.getService(Context.WINDOW_SERVICE));
+ IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
if (enabled) {
wm.freezeRotation(Surface.ROTATION_0);
} else {
diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp
index 3ad6406ea383..bada3291dbe1 100644
--- a/core/jni/android_view_Surface.cpp
+++ b/core/jni/android_view_Surface.cpp
@@ -221,7 +221,7 @@ void setSurface(JNIEnv* env, jobject clazz, const sp<Surface>& surface)
static void Surface_init(
JNIEnv* env, jobject clazz,
jobject session,
- jint, jstring jname, jint dpy, jint w, jint h, jint format, jint flags)
+ jint, jstring jname, jint layerStack, jint w, jint h, jint format, jint flags)
{
if (session == NULL) {
doThrowNPE(env);
@@ -233,12 +233,12 @@ static void Surface_init(
sp<SurfaceControl> surface;
if (jname == NULL) {
- surface = client->createSurface(dpy, w, h, format, flags);
+ surface = client->createSurface(layerStack, w, h, format, flags);
} else {
const jchar* str = env->GetStringCritical(jname, 0);
const String8 name(str, env->GetStringLength(jname));
env->ReleaseStringCritical(jname, str);
- surface = client->createSurface(name, dpy, w, h, format, flags);
+ surface = client->createSurface(name, layerStack, w, h, format, flags);
}
if (surface == 0) {
@@ -717,7 +717,7 @@ static void Surface_setWindowCrop(JNIEnv* env, jobject thiz, jobject crop)
}
}
-static void Surface_setDisplayId(JNIEnv* env, jobject thiz, jint displayId)
+static void Surface_setLayerStack(JNIEnv* env, jobject thiz, jint layerStack)
{
const sp<SurfaceControl>& surface(getSurfaceControl(env, thiz));
if (surface == 0) return;
@@ -863,7 +863,7 @@ static JNINativeMethod gSurfaceMethods[] = {
{"writeToParcel", "(Landroid/os/Parcel;I)V", (void*)Surface_writeToParcel },
{"isConsumerRunningBehind", "()Z", (void*)Surface_isConsumerRunningBehind },
{"setWindowCrop", "(Landroid/graphics/Rect;)V", (void*)Surface_setWindowCrop },
- {"setDisplayId", "(I)V", (void*)Surface_setDisplayId },
+ {"setLayerStack", "(I)V", (void*)Surface_setLayerStack },
};
void nativeClassInit(JNIEnv* env, jclass clazz)
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 38a431fa0feb..0d190eec7e99 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -479,6 +479,7 @@
<java-symbol type="string" name="decline" />
<java-symbol type="string" name="default_text_encoding" />
<java-symbol type="string" name="description_target_unlock_tablet" />
+ <java-symbol type="string" name="display_manager_built_in_display" />
<java-symbol type="string" name="double_tap_toast" />
<java-symbol type="string" name="elapsed_time_short_format_h_mm_ss" />
<java-symbol type="string" name="elapsed_time_short_format_mm_ss" />
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 620a0027ddb9..b7ad1e9d707c 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -3639,4 +3639,9 @@
<!-- Content description of a MediaRouteButton for accessibility support -->
<string name="media_route_button_content_description">Media output</string>
+ <!-- Display manager service -->
+
+ <!-- Name of the built-in display. [CHAR LIMIT=50] -->
+ <string name="display_manager_built_in_display">Built-in Screen</string>
+
</resources>
diff --git a/packages/FakeOemFeatures/src/com/android/fakeoemfeatures/FakeApp.java b/packages/FakeOemFeatures/src/com/android/fakeoemfeatures/FakeApp.java
index 436e57976c98..f11b4994cb00 100644
--- a/packages/FakeOemFeatures/src/com/android/fakeoemfeatures/FakeApp.java
+++ b/packages/FakeOemFeatures/src/com/android/fakeoemfeatures/FakeApp.java
@@ -119,7 +119,7 @@ public class FakeApp extends Application {
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
| WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
- if (ActivityManager.isHighEndGfx(display)) {
+ if (ActivityManager.isHighEndGfx()) {
lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
}
lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
diff --git a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
index a72074ebd15b..2512c02643cf 100644
--- a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
+++ b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
@@ -74,10 +74,7 @@ public class ImageWallpaper extends WallpaperService {
//noinspection PointlessBooleanExpression,ConstantConditions
if (FIXED_SIZED_SURFACE && USE_OPENGL) {
if (!isEmulator()) {
- WindowManager windowManager =
- (WindowManager) getSystemService(Context.WINDOW_SERVICE);
- Display display = windowManager.getDefaultDisplay();
- mIsHwAccelerated = ActivityManager.isHighEndGfx(display);
+ mIsHwAccelerated = ActivityManager.isHighEndGfx();
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIService.java b/packages/SystemUI/src/com/android/systemui/SystemUIService.java
index 0a5749938aec..1bde94924457 100644
--- a/packages/SystemUI/src/com/android/systemui/SystemUIService.java
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIService.java
@@ -31,6 +31,7 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Slog;
import android.view.IWindowManager;
+import android.view.WindowManagerGlobal;
public class SystemUIService extends Service {
static final String TAG = "SystemUIService";
@@ -67,8 +68,7 @@ public class SystemUIService extends Service {
@Override
public void onCreate() {
// Pick status bar or system bar.
- IWindowManager wm = IWindowManager.Stub.asInterface(
- ServiceManager.getService(Context.WINDOW_SERVICE));
+ IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
try {
SERVICES[0] = wm.hasSystemNavBar()
? R.string.config_systemBarComponent
diff --git a/packages/SystemUI/src/com/android/systemui/UniverseBackground.java b/packages/SystemUI/src/com/android/systemui/UniverseBackground.java
index 4852a3e64fec..762875479360 100644
--- a/packages/SystemUI/src/com/android/systemui/UniverseBackground.java
+++ b/packages/SystemUI/src/com/android/systemui/UniverseBackground.java
@@ -33,6 +33,7 @@ import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewRootImpl;
import android.view.WindowManager;
+import android.view.WindowManagerGlobal;
import android.view.animation.Transformation;
import android.widget.FrameLayout;
@@ -96,7 +97,7 @@ public class UniverseBackground extends FrameLayout {
public UniverseBackground(Context context) {
super(context);
setBackgroundColor(0xff000000);
- mSession = ViewRootImpl.getWindowSession(context.getMainLooper());
+ mSession = WindowManagerGlobal.getWindowSession(context.getMainLooper());
mContent = View.inflate(context, R.layout.universe, null);
addView(mContent);
mContent.findViewById(R.id.close).setOnClickListener(new View.OnClickListener() {
@@ -155,7 +156,7 @@ public class UniverseBackground extends FrameLayout {
}
}
- public WindowManager.LayoutParams getLayoutParams(Display display) {
+ public WindowManager.LayoutParams getLayoutParams() {
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_UNIVERSE_BACKGROUND,
@@ -165,7 +166,7 @@ public class UniverseBackground extends FrameLayout {
| WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
PixelFormat.OPAQUE);
// this will allow the window to run in an overlay on devices that support this
- if (ActivityManager.isHighEndGfx(display)) {
+ if (ActivityManager.isHighEndGfx()) {
lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
}
lp.setTitle("UniverseBackground");
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
index d5a76bcece73..b407078f117e 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
@@ -49,6 +49,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
+import android.view.WindowManagerGlobal;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
@@ -488,9 +489,7 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
mChoreo = new Choreographer(this, mRecentsScrim, mRecentsContainer, mRecentsNoApps, this);
if (mRecentsScrim != null) {
- Display d = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE))
- .getDefaultDisplay();
- mHighEndGfx = ActivityManager.isHighEndGfx(d);
+ mHighEndGfx = ActivityManager.isHighEndGfx();
if (!mHighEndGfx) {
mRecentsScrim.setBackground(null);
} else if (mRecentsScrim.getBackground() instanceof BitmapDrawable) {
@@ -733,8 +732,7 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
if (mTransitionBg == null) {
mTransitionBg = (View) findViewById(R.id.recents_transition_background);
- IWindowManager wm = IWindowManager.Stub.asInterface(
- ServiceManager.getService(Context.WINDOW_SERVICE));
+ IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
try {
if (!wm.hasSystemNavBar()) {
FrameLayout.LayoutParams lp =
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 646f98ac8557..e9e043ef1ccf 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -61,9 +61,9 @@ import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
+import android.view.WindowManagerGlobal;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
-import android.view.WindowManagerImpl;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
@@ -127,17 +127,11 @@ public abstract class BaseStatusBar extends SystemUI implements
*/
protected abstract void createAndAddWindows();
+ protected WindowManager mWindowManager;
+ protected IWindowManager mWindowManagerService;
protected Display mDisplay;
- private IWindowManager mWindowManager;
- private boolean mDeviceProvisioned = false;
-
- public IWindowManager getWindowManager() {
- return mWindowManager;
- }
- public Display getDisplay() {
- return mDisplay;
- }
+ private boolean mDeviceProvisioned = false;
public IStatusBarService getStatusBarService() {
return mBarService;
@@ -189,17 +183,15 @@ public abstract class BaseStatusBar extends SystemUI implements
};
public void start() {
- mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE))
- .getDefaultDisplay();
+ mWindowManager = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
+ mWindowManagerService = WindowManagerGlobal.getWindowManagerService();
+ mDisplay = mWindowManager.getDefaultDisplay();
mProvisioningObserver.onChange(false); // set up
mContext.getContentResolver().registerContentObserver(
Settings.Secure.getUriFor(Settings.Secure.DEVICE_PROVISIONED), true,
mProvisioningObserver);
- mWindowManager = IWindowManager.Stub.asInterface(
- ServiceManager.getService(Context.WINDOW_SERVICE));
-
mBarService = IStatusBarService.Stub.asInterface(
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
@@ -436,7 +428,7 @@ public abstract class BaseStatusBar extends SystemUI implements
boolean firstScreenful = false;
if (mRecentsPanel != null) {
visible = mRecentsPanel.isShowing();
- WindowManagerImpl.getDefault().removeView(mRecentsPanel);
+ mWindowManager.removeView(mRecentsPanel);
if (visible) {
recentTasksList = mRecentsPanel.getRecentTasksList();
firstScreenful = mRecentsPanel.getFirstScreenful();
@@ -456,7 +448,7 @@ public abstract class BaseStatusBar extends SystemUI implements
WindowManager.LayoutParams lp = getRecentsLayoutParams(mRecentsPanel.getLayoutParams());
- WindowManagerImpl.getDefault().addView(mRecentsPanel, lp);
+ mWindowManager.addView(mRecentsPanel, lp);
mRecentsPanel.setBar(this);
if (visible) {
mRecentsPanel.show(true, false, recentTasksList, firstScreenful);
@@ -469,7 +461,7 @@ public abstract class BaseStatusBar extends SystemUI implements
boolean visible = false;
if (mSearchPanelView != null) {
visible = mSearchPanelView.isShowing();
- WindowManagerImpl.getDefault().removeView(mSearchPanelView);
+ mWindowManager.removeView(mSearchPanelView);
}
// Provide SearchPanel with a temporary parent to allow layout params to work.
@@ -482,7 +474,7 @@ public abstract class BaseStatusBar extends SystemUI implements
WindowManager.LayoutParams lp = getSearchLayoutParams(mSearchPanelView.getLayoutParams());
- WindowManagerImpl.getDefault().addView(mSearchPanelView, lp);
+ mWindowManager.addView(mSearchPanelView, lp);
mSearchPanelView.setBar(this);
if (visible) {
mSearchPanelView.show(true, false);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index 63c9b79d05cb..33973b6ec7c2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -18,13 +18,11 @@ package com.android.systemui.statusbar.phone;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
-import android.animation.ObjectAnimator;
import android.app.StatusBarManager;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.Rect;
-import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Message;
@@ -34,19 +32,14 @@ import android.util.Slog;
import android.view.animation.AccelerateInterpolator;
import android.view.Display;
import android.view.MotionEvent;
-import android.view.VelocityTracker;
import android.view.View;
-import android.view.ViewGroup;
import android.view.Surface;
-import android.view.Window;
import android.view.WindowManager;
-import android.view.WindowManagerImpl;
import android.widget.ImageView;
import android.widget.LinearLayout;
import java.io.FileDescriptor;
import java.io.PrintWriter;
-import java.lang.StringBuilder;
import com.android.internal.statusbar.IStatusBarService;
import com.android.systemui.R;
@@ -244,7 +237,8 @@ public class NavigationBarView extends LinearLayout {
} else {
return;
}
- WindowManagerImpl.getDefault().updateViewLayout(this, lp);
+ WindowManager wm = (WindowManager)getContext().getSystemService(Context.WINDOW_SERVICE);
+ wm.updateViewLayout(this, lp);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 49e476059852..288644197bde 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -60,9 +60,9 @@ import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewGroup;
+import android.view.WindowManagerGlobal;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
-import android.view.WindowManagerImpl;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
@@ -150,7 +150,6 @@ public class PhoneStatusBar extends BaseStatusBar {
int mIconHPadding = -1;
Display mDisplay;
- IWindowManager mWindowManager;
IDreamManager mDreamManager;
StatusBarWindowView mStatusBarWindow;
@@ -261,9 +260,6 @@ public class PhoneStatusBar extends BaseStatusBar {
mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay();
- mWindowManager = IWindowManager.Stub.asInterface(
- ServiceManager.getService(Context.WINDOW_SERVICE));
-
mDreamManager = IDreamManager.Stub.asInterface(
ServiceManager.checkService("dreams"));
@@ -332,7 +328,7 @@ public class PhoneStatusBar extends BaseStatusBar {
mSettingsPanel = (PanelView) mStatusBarWindow.findViewById(R.id.settings_panel);
mSettingsPanel.setOnTouchListener(clickStopper);
- if (!ActivityManager.isHighEndGfx(mDisplay)) {
+ if (!ActivityManager.isHighEndGfx()) {
mStatusBarWindow.setBackground(null);
mNotificationPanel.setBackground(new FastColorDrawable(context.getResources().getColor(
R.color.notification_panel_solid_background)));
@@ -352,7 +348,7 @@ public class PhoneStatusBar extends BaseStatusBar {
updateShowSearchHoldoff();
try {
- boolean showNav = mWindowManager.hasNavigationBar();
+ boolean showNav = mWindowManagerService.hasNavigationBar();
if (DEBUG) Slog.v(TAG, "hasNavigationBar=" + showNav);
if (showNav) {
mNavigationBarView =
@@ -474,7 +470,7 @@ public class PhoneStatusBar extends BaseStatusBar {
| WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM
| WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
(opaque ? PixelFormat.OPAQUE : PixelFormat.TRANSLUCENT));
- if (ActivityManager.isHighEndGfx(mDisplay)) {
+ if (ActivityManager.isHighEndGfx()) {
lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
} else {
lp.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND;
@@ -499,7 +495,7 @@ public class PhoneStatusBar extends BaseStatusBar {
| WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM
| WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
(opaque ? PixelFormat.OPAQUE : PixelFormat.TRANSLUCENT));
- if (ActivityManager.isHighEndGfx(mDisplay)) {
+ if (ActivityManager.isHighEndGfx()) {
lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
}
lp.gravity = Gravity.BOTTOM | Gravity.LEFT;
@@ -535,7 +531,7 @@ public class PhoneStatusBar extends BaseStatusBar {
WindowManager.LayoutParams lp =
(android.view.WindowManager.LayoutParams) mNavigationBarView.getLayoutParams();
lp.flags &= ~WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
- WindowManagerImpl.getDefault().updateViewLayout(mNavigationBarView, lp);
+ mWindowManager.updateViewLayout(mNavigationBarView, lp);
}
@Override
@@ -544,7 +540,7 @@ public class PhoneStatusBar extends BaseStatusBar {
WindowManager.LayoutParams lp =
(android.view.WindowManager.LayoutParams) mNavigationBarView.getLayoutParams();
lp.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
- WindowManagerImpl.getDefault().updateViewLayout(mNavigationBarView, lp);
+ mWindowManager.updateViewLayout(mNavigationBarView, lp);
}
protected int getStatusBarGravity() {
@@ -620,8 +616,7 @@ public class PhoneStatusBar extends BaseStatusBar {
prepareNavigationBarView();
- WindowManagerImpl.getDefault().addView(
- mNavigationBarView, getNavigationBarLayoutParams());
+ mWindowManager.addView(mNavigationBarView, getNavigationBarLayoutParams());
}
private void repositionNavigationBar() {
@@ -629,8 +624,7 @@ public class PhoneStatusBar extends BaseStatusBar {
prepareNavigationBarView();
- WindowManagerImpl.getDefault().updateViewLayout(
- mNavigationBarView, getNavigationBarLayoutParams());
+ mWindowManager.updateViewLayout(mNavigationBarView, getNavigationBarLayoutParams());
}
private WindowManager.LayoutParams getNavigationBarLayoutParams() {
@@ -644,7 +638,7 @@ public class PhoneStatusBar extends BaseStatusBar {
| WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
PixelFormat.OPAQUE);
// this will allow the navbar to run in an overlay on devices that support this
- if (ActivityManager.isHighEndGfx(mDisplay)) {
+ if (ActivityManager.isHighEndGfx()) {
lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
}
@@ -671,7 +665,7 @@ public class PhoneStatusBar extends BaseStatusBar {
lp.packageName = mContext.getPackageName();
lp.windowAnimations = R.style.Animation_StatusBar_IntruderAlert;
- WindowManagerImpl.getDefault().addView(mIntruderAlertView, lp);
+ mWindowManager.addView(mIntruderAlertView, lp);
}
public void addIcon(String slot, int index, int viewIndex, StatusBarIcon icon) {
@@ -1157,8 +1151,7 @@ public class PhoneStatusBar extends BaseStatusBar {
lp.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
lp.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
- final WindowManager wm = WindowManagerImpl.getDefault();
- wm.updateViewLayout(mStatusBarWindow, lp);
+ mWindowManager.updateViewLayout(mStatusBarWindow, lp);
// Updating the window layout will force an expensive traversal/redraw.
// Kick off the reveal animation after this is complete to avoid animation latency.
@@ -1231,8 +1224,7 @@ public class PhoneStatusBar extends BaseStatusBar {
lp.height = getStatusBarHeight();
lp.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
lp.flags &= ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
- final WindowManager wm = WindowManagerImpl.getDefault();
- wm.updateViewLayout(mStatusBarWindow, lp);
+ mWindowManager.updateViewLayout(mStatusBarWindow, lp);
if ((mDisabled & StatusBarManager.DISABLE_NOTIFICATION_ICONS) == 0) {
setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in);
@@ -1409,7 +1401,7 @@ public class PhoneStatusBar extends BaseStatusBar {
private void notifyUiVisibilityChanged() {
try {
- mWindowManager.statusBarVisibilityChanged(mSystemUiVisibility);
+ mWindowManagerService.statusBarVisibilityChanged(mSystemUiVisibility);
} catch (RemoteException ex) {
}
}
@@ -1615,7 +1607,7 @@ public class PhoneStatusBar extends BaseStatusBar {
lp.packageName = mContext.getPackageName();
makeStatusBarView();
- WindowManagerImpl.getDefault().addView(mStatusBarWindow, lp);
+ mWindowManager.addView(mStatusBarWindow, lp);
}
void setNotificationIconVisibility(boolean visible, int anim) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
index 2a96d6d679d3..6d474938349c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
@@ -140,7 +140,7 @@ public class PhoneStatusBarView extends PanelBar {
super.panelExpansionChanged(pv, frac);
if (mFadingPanel == pv
- && mScrimColor != 0 && ActivityManager.isHighEndGfx(mBar.mDisplay)) {
+ && mScrimColor != 0 && ActivityManager.isHighEndGfx()) {
// woo, special effects
final float k = (float)(1f-0.5f*(1f-Math.cos(3.14159f * Math.pow(1f-frac, 2.2f))));
// attenuate background color alpha by k
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java
index ddb43b8b6e0e..2924cc954454 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java
@@ -34,7 +34,6 @@ import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
-import android.view.WindowManagerImpl;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
index cbd883102707..84697e09979b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
@@ -53,7 +53,6 @@ import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
-import android.view.WindowManagerImpl;
import android.view.accessibility.AccessibilityEvent;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -124,8 +123,6 @@ public class TabletStatusBar extends BaseStatusBar implements
int mMenuNavIconWidth = -1;
private int mMaxNotificationIcons = 5;
- IWindowManager mWindowManager;
-
TabletStatusBarView mStatusBarView;
View mNotificationArea;
View mNotificationTrigger;
@@ -241,7 +238,7 @@ public class TabletStatusBar extends BaseStatusBar implements
lp.gravity = getStatusBarGravity();
lp.setTitle("SystemBar");
lp.packageName = mContext.getPackageName();
- WindowManagerImpl.getDefault().addView(sb, lp);
+ mWindowManager.addView(sb, lp);
}
protected void addPanelWindows() {
@@ -306,7 +303,7 @@ public class TabletStatusBar extends BaseStatusBar implements
lp.windowAnimations = com.android.internal.R.style.Animation; // == no animation
// lp.windowAnimations = com.android.internal.R.style.Animation_ZoomButtons; // simple fade
- WindowManagerImpl.getDefault().addView(mNotificationPanel, lp);
+ mWindowManager.addView(mNotificationPanel, lp);
// Recents Panel
mRecentTasksLoader = new RecentTasksLoader(context);
@@ -338,7 +335,7 @@ public class TabletStatusBar extends BaseStatusBar implements
lp.setTitle("InputMethodsPanel");
lp.windowAnimations = R.style.Animation_RecentPanel;
- WindowManagerImpl.getDefault().addView(mInputMethodsPanel, lp);
+ mWindowManager.addView(mInputMethodsPanel, lp);
// Compatibility mode selector panel
mCompatModePanel = (CompatModePanel) View.inflate(context,
@@ -361,7 +358,7 @@ public class TabletStatusBar extends BaseStatusBar implements
lp.setTitle("CompatModePanel");
lp.windowAnimations = android.R.style.Animation_Dialog;
- WindowManagerImpl.getDefault().addView(mCompatModePanel, lp);
+ mWindowManager.addView(mCompatModePanel, lp);
mRecentButton.setOnTouchListener(mRecentsPanel);
@@ -380,7 +377,7 @@ public class TabletStatusBar extends BaseStatusBar implements
private int getNotificationPanelHeight() {
final Resources res = mContext.getResources();
- final Display d = WindowManagerImpl.getDefault().getDefaultDisplay();
+ final Display d = mWindowManager.getDefaultDisplay();
final Point size = new Point();
d.getRealSize(size);
return Math.max(res.getDimensionPixelSize(R.dimen.notification_panel_min_height), size.y);
@@ -395,8 +392,7 @@ public class TabletStatusBar extends BaseStatusBar implements
protected void onConfigurationChanged(Configuration newConfig) {
loadDimens();
mNotificationPanelParams.height = getNotificationPanelHeight();
- WindowManagerImpl.getDefault().updateViewLayout(mNotificationPanel,
- mNotificationPanelParams);
+ mWindowManager.updateViewLayout(mNotificationPanel, mNotificationPanelParams);
mRecentsPanel.updateValuesFromResources();
mShowSearchHoldoff = mContext.getResources().getInteger(
R.integer.config_show_search_delay);
@@ -456,9 +452,6 @@ public class TabletStatusBar extends BaseStatusBar implements
protected View makeStatusBarView() {
final Context context = mContext;
- mWindowManager = IWindowManager.Stub.asInterface(
- ServiceManager.getService(Context.WINDOW_SERVICE));
-
loadDimens();
final TabletStatusBarView sb = (TabletStatusBarView)View.inflate(
@@ -470,7 +463,7 @@ public class TabletStatusBar extends BaseStatusBar implements
try {
// Sanity-check that someone hasn't set up the config wrong and asked for a navigation
// bar on a tablet that has only the system bar
- if (mWindowManager.hasNavigationBar()) {
+ if (mWindowManagerService.hasNavigationBar()) {
Slog.e(TAG, "Tablet device cannot show navigation bar and system bar");
}
} catch (RemoteException ex) {
@@ -648,7 +641,7 @@ public class TabletStatusBar extends BaseStatusBar implements
| WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM
| WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
(opaque ? PixelFormat.OPAQUE : PixelFormat.TRANSLUCENT));
- if (ActivityManager.isHighEndGfx(mDisplay)) {
+ if (ActivityManager.isHighEndGfx()) {
lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
} else {
lp.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND;
@@ -681,7 +674,7 @@ public class TabletStatusBar extends BaseStatusBar implements
WindowManager.LayoutParams lp =
(android.view.WindowManager.LayoutParams) mStatusBarView.getLayoutParams();
lp.flags &= ~WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
- WindowManagerImpl.getDefault().updateViewLayout(mStatusBarView, lp);
+ mWindowManager.updateViewLayout(mStatusBarView, lp);
}
@Override
@@ -690,7 +683,7 @@ public class TabletStatusBar extends BaseStatusBar implements
WindowManager.LayoutParams lp =
(android.view.WindowManager.LayoutParams) mStatusBarView.getLayoutParams();
lp.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
- WindowManagerImpl.getDefault().updateViewLayout(mStatusBarView, lp);
+ mWindowManager.updateViewLayout(mStatusBarView, lp);
}
public int getStatusBarHeight() {
@@ -712,8 +705,7 @@ public class TabletStatusBar extends BaseStatusBar implements
}
if (lp.height != height) {
lp.height = height;
- final WindowManager wm = WindowManagerImpl.getDefault();
- wm.updateViewLayout(mStatusBarView, lp);
+ mWindowManager.updateViewLayout(mStatusBarView, lp);
}
}
@@ -1068,7 +1060,7 @@ public class TabletStatusBar extends BaseStatusBar implements
private void notifyUiVisibilityChanged() {
try {
- mWindowManager.statusBarVisibilityChanged(mSystemUiVisibility);
+ mWindowManagerService.statusBarVisibilityChanged(mSystemUiVisibility);
} catch (RemoteException ex) {
}
}
@@ -1160,12 +1152,12 @@ public class TabletStatusBar extends BaseStatusBar implements
| WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
lp.windowAnimations = com.android.internal.R.style.Animation_ZoomButtons; // simple fade
- WindowManagerImpl.getDefault().addView(mCompatibilityHelpDialog, lp);
+ mWindowManager.addView(mCompatibilityHelpDialog, lp);
}
private void hideCompatibilityHelp() {
if (mCompatibilityHelpDialog != null) {
- WindowManagerImpl.getDefault().removeView(mCompatibilityHelpDialog);
+ mWindowManager.removeView(mCompatibilityHelpDialog);
mCompatibilityHelpDialog = null;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java
index d4ebe6d1f2a6..932b035509a5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java
@@ -35,7 +35,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
-import android.view.WindowManagerImpl;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.FrameLayout;
@@ -62,7 +61,8 @@ public class TabletTicker
private static final int ADVANCE_DELAY = 5000; // 5 seconds
- private Context mContext;
+ private final Context mContext;
+ private final WindowManager mWindowManager;
private ViewGroup mWindow;
private IBinder mCurrentKey;
@@ -83,6 +83,7 @@ public class TabletTicker
public TabletTicker(TabletStatusBar bar) {
mBar = bar;
mContext = bar.getContext();
+ mWindowManager = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
final Resources res = mContext.getResources();
mLargeIconHeight = res.getDimensionPixelSize(
android.R.dimen.notification_large_icon_height);
@@ -178,7 +179,7 @@ public class TabletTicker
if (mCurrentView != null) {
if (mWindow == null) {
mWindow = makeWindow();
- WindowManagerImpl.getDefault().addView(mWindow, mWindow.getLayoutParams());
+ mWindowManager.addView(mWindow, mWindow.getLayoutParams());
}
mWindow.addView(mCurrentView);
@@ -242,7 +243,7 @@ public class TabletTicker
public void endTransition(LayoutTransition transition, ViewGroup container,
View view, int transitionType) {
if (mWindowShouldClose) {
- WindowManagerImpl.getDefault().removeView(mWindow);
+ mWindowManager.removeView(mWindow);
mWindow = null;
mWindowShouldClose = false;
mBar.doneTicking();
diff --git a/policy/src/com/android/internal/policy/impl/GlobalActions.java b/policy/src/com/android/internal/policy/impl/GlobalActions.java
index a0e3e3c8d36e..fe23bffd3051 100644
--- a/policy/src/com/android/internal/policy/impl/GlobalActions.java
+++ b/policy/src/com/android/internal/policy/impl/GlobalActions.java
@@ -50,6 +50,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
+import android.view.WindowManagerGlobal;
import android.view.WindowManagerPolicy.WindowManagerFuncs;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
@@ -90,8 +91,6 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
private boolean mHasTelephony;
private boolean mHasVibrator;
- private IWindowManager mIWindowManager;
-
/**
* @param context everything needs a context :(
*/
@@ -300,7 +299,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
public void onPress() {
try {
ActivityManagerNative.getDefault().switchUser(user.id);
- getWindowManager().lockNow();
+ WindowManagerGlobal.getWindowManagerService().lockNow();
} catch (RemoteException re) {
Log.e(TAG, "Couldn't switch user " + re);
}
@@ -873,12 +872,4 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
mAirplaneState = on ? ToggleAction.State.On : ToggleAction.State.Off;
}
}
-
- private IWindowManager getWindowManager() {
- if (mIWindowManager == null) {
- IBinder b = ServiceManager.getService(Context.WINDOW_SERVICE);
- mIWindowManager = IWindowManager.Stub.asInterface(b);
- }
- return mIWindowManager;
- }
}
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java b/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java
index fb6ff24f0d50..d521c05b5a9c 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java
@@ -123,8 +123,7 @@ public class KeyguardViewManager implements KeyguardWindowController {
if (!mNeedsInput) {
flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
}
- if (ActivityManager.isHighEndGfx(((WindowManager)mContext.getSystemService(
- Context.WINDOW_SERVICE)).getDefaultDisplay())) {
+ if (ActivityManager.isHighEndGfx()) {
flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
}
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
@@ -132,8 +131,7 @@ public class KeyguardViewManager implements KeyguardWindowController {
flags, PixelFormat.TRANSLUCENT);
lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
lp.windowAnimations = com.android.internal.R.style.Animation_LockScreen;
- if (ActivityManager.isHighEndGfx(((WindowManager)mContext.getSystemService(
- Context.WINDOW_SERVICE)).getDefaultDisplay())) {
+ if (ActivityManager.isHighEndGfx()) {
lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
lp.privateFlags |=
WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED;
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
index 66ccdac21619..4d05a8737823 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
@@ -44,7 +44,7 @@ import android.telephony.TelephonyManager;
import android.util.EventLog;
import android.util.Log;
import android.view.KeyEvent;
-import android.view.WindowManagerImpl;
+import android.view.WindowManager;
import android.view.WindowManagerPolicy;
@@ -376,9 +376,9 @@ public class KeyguardViewMediator implements KeyguardViewCallback {
mKeyguardViewProperties
= new LockPatternKeyguardViewProperties(mLockPatternUtils, mUpdateMonitor);
+ WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
mKeyguardViewManager = new KeyguardViewManager(
- context, WindowManagerImpl.getDefault(), this,
- mKeyguardViewProperties, mUpdateMonitor);
+ context, wm, this, mKeyguardViewProperties, mUpdateMonitor);
mUserPresentIntent = new Intent(Intent.ACTION_USER_PRESENT);
mUserPresentIntent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 737df7fac22f..95a202cec293 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -82,6 +82,7 @@ import android.view.InputEventReceiver;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.MotionEvent;
+import android.view.WindowManagerGlobal;
import android.view.WindowOrientationListener;
import android.view.Surface;
import android.view.View;
@@ -132,7 +133,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_POINTER;
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR;
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;
import static android.view.WindowManager.LayoutParams.TYPE_BOOT_PROGRESS;
-import android.view.WindowManagerImpl;
import android.view.WindowManagerPolicy;
import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT;
import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_OPEN;
@@ -1172,7 +1172,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (type < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW
|| type > WindowManager.LayoutParams.LAST_SYSTEM_WINDOW) {
- return WindowManagerImpl.ADD_OKAY;
+ return WindowManagerGlobal.ADD_OKAY;
}
String permission = null;
switch (type) {
@@ -1199,10 +1199,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (permission != null) {
if (mContext.checkCallingOrSelfPermission(permission)
!= PackageManager.PERMISSION_GRANTED) {
- return WindowManagerImpl.ADD_PERMISSION_DENIED;
+ return WindowManagerGlobal.ADD_PERMISSION_DENIED;
}
}
- return WindowManagerImpl.ADD_OKAY;
+ return WindowManagerGlobal.ADD_OKAY;
}
public void adjustWindowParamsLw(WindowManager.LayoutParams attrs) {
@@ -1499,7 +1499,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// Only return the view if it was successfully added to the
// window manager... which we can tell by it having a parent.
return view.getParent() != null ? view : null;
- } catch (WindowManagerImpl.BadTokenException e) {
+ } catch (WindowManager.BadTokenException e) {
// ignore
Log.w(TAG, appToken + " already running, starting window not displayed");
} catch (RuntimeException e) {
@@ -1538,7 +1538,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
* @param win The window to be added
* @param attrs Information about the window to be added
*
- * @return If ok, WindowManagerImpl.ADD_OKAY. If too many singletons, WindowManagerImpl.ADD_MULTIPLE_SINGLETON
+ * @return If ok, WindowManagerImpl.ADD_OKAY. If too many singletons,
+ * WindowManagerImpl.ADD_MULTIPLE_SINGLETON
*/
public int prepareAddWindowLw(WindowState win, WindowManager.LayoutParams attrs) {
switch (attrs.type) {
@@ -1548,7 +1549,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
"PhoneWindowManager");
if (mStatusBar != null) {
if (mStatusBar.isAlive()) {
- return WindowManagerImpl.ADD_MULTIPLE_SINGLETON;
+ return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON;
}
}
mStatusBar = win;
@@ -1559,7 +1560,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
"PhoneWindowManager");
if (mNavigationBar != null) {
if (mNavigationBar.isAlive()) {
- return WindowManagerImpl.ADD_MULTIPLE_SINGLETON;
+ return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON;
}
}
mNavigationBar = win;
@@ -1582,12 +1583,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
break;
case TYPE_KEYGUARD:
if (mKeyguard != null) {
- return WindowManagerImpl.ADD_MULTIPLE_SINGLETON;
+ return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON;
}
mKeyguard = win;
break;
}
- return WindowManagerImpl.ADD_OKAY;
+ return WindowManagerGlobal.ADD_OKAY;
}
/** {@inheritDoc} */
diff --git a/services/java/com/android/server/power/DisplayPowerController.java b/services/java/com/android/server/power/DisplayPowerController.java
index f3183f83768d..1991cf177911 100644
--- a/services/java/com/android/server/power/DisplayPowerController.java
+++ b/services/java/com/android/server/power/DisplayPowerController.java
@@ -27,6 +27,7 @@ import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.hardware.SystemSensorManager;
+import android.hardware.display.DisplayManager;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.Looper;
@@ -35,6 +36,7 @@ import android.os.SystemClock;
import android.util.Slog;
import android.util.Spline;
import android.util.TimeUtils;
+import android.view.Display;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -428,7 +430,8 @@ final class DisplayPowerController {
private void initialize() {
final Executor executor = AsyncTask.THREAD_POOL_EXECUTOR;
- mPowerState = new DisplayPowerState(new ElectronBeam(),
+ Display display = DisplayManager.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY);
+ mPowerState = new DisplayPowerState(new ElectronBeam(display),
new PhotonicModulator(executor,
mLights.getLight(LightsService.LIGHT_ID_BACKLIGHT),
mSuspendBlocker));
diff --git a/services/java/com/android/server/power/ElectronBeam.java b/services/java/com/android/server/power/ElectronBeam.java
index 547214895fc9..2d242494add6 100644
--- a/services/java/com/android/server/power/ElectronBeam.java
+++ b/services/java/com/android/server/power/ElectronBeam.java
@@ -33,7 +33,6 @@ import android.view.Display;
import android.view.DisplayInfo;
import android.view.Surface;
import android.view.SurfaceSession;
-import android.view.WindowManagerImpl;
import java.io.PrintWriter;
import java.nio.ByteBuffer;
@@ -68,6 +67,7 @@ final class ElectronBeam {
private boolean mPrepared;
private boolean mWarmUp;
+ private final Display mDisplay;
private final DisplayInfo mDisplayInfo = new DisplayInfo();
private int mDisplayLayerStack; // layer stack associated with primary display
private int mDisplayRotation;
@@ -90,7 +90,8 @@ final class ElectronBeam {
private final FloatBuffer mVertexBuffer = createNativeFloatBuffer(8);
private final FloatBuffer mTexCoordBuffer = createNativeFloatBuffer(8);
- public ElectronBeam() {
+ public ElectronBeam(Display display) {
+ mDisplay = display;
}
/**
@@ -109,9 +110,8 @@ final class ElectronBeam {
mWarmUp = warmUp;
// Get the display size and adjust it for rotation.
- Display display = WindowManagerImpl.getDefault().getDefaultDisplay();
- display.getDisplayInfo(mDisplayInfo);
- mDisplayLayerStack = display.getDisplayId();
+ mDisplay.getDisplayInfo(mDisplayInfo);
+ mDisplayLayerStack = mDisplay.getLayerStack();
mDisplayRotation = mDisplayInfo.rotation;
if (mDisplayRotation == Surface.ROTATION_90
|| mDisplayRotation == Surface.ROTATION_270) {
diff --git a/services/java/com/android/server/wm/ScreenRotationAnimation.java b/services/java/com/android/server/wm/ScreenRotationAnimation.java
index 142c60d68852..7d85d895b219 100644
--- a/services/java/com/android/server/wm/ScreenRotationAnimation.java
+++ b/services/java/com/android/server/wm/ScreenRotationAnimation.java
@@ -42,6 +42,7 @@ class ScreenRotationAnimation {
static final int FREEZE_LAYER = WindowManagerService.TYPE_LAYER_MULTIPLIER * 200;
final Context mContext;
+ final Display mDisplay;
Surface mSurface;
BlackFrame mCustomBlackFrame;
BlackFrame mExitingBlackFrame;
@@ -186,9 +187,10 @@ class ScreenRotationAnimation {
pw.println();
}
- public ScreenRotationAnimation(Context context, SurfaceSession session,
+ public ScreenRotationAnimation(Context context, Display display, SurfaceSession session,
boolean inTransaction, int originalWidth, int originalHeight, int originalRotation) {
mContext = context;
+ mDisplay = display;
// Screenshot does NOT include rotation!
if (originalRotation == Surface.ROTATION_90
@@ -213,13 +215,13 @@ class ScreenRotationAnimation {
try {
try {
if (WindowManagerService.DEBUG_SURFACE_TRACE) {
- mSurface = new SurfaceTrace(session, 0, "FreezeSurface", Display.DEFAULT_DISPLAY,
- mWidth, mHeight,
- PixelFormat.OPAQUE, Surface.FX_SURFACE_SCREENSHOT | Surface.HIDDEN);
+ mSurface = new SurfaceTrace(session, 0, "FreezeSurface",
+ mDisplay.getLayerStack(), mWidth, mHeight,
+ PixelFormat.OPAQUE, Surface.FX_SURFACE_SCREENSHOT | Surface.HIDDEN);
} else {
- mSurface = new Surface(session, 0, "FreezeSurface", Display.DEFAULT_DISPLAY,
- mWidth, mHeight,
- PixelFormat.OPAQUE, Surface.FX_SURFACE_SCREENSHOT | Surface.HIDDEN);
+ mSurface = new Surface(session, 0, "FreezeSurface",
+ mDisplay.getLayerStack(), mWidth, mHeight,
+ PixelFormat.OPAQUE, Surface.FX_SURFACE_SCREENSHOT | Surface.HIDDEN);
}
if (!mSurface.isValid()) {
// Screenshot failed, punt.
diff --git a/services/java/com/android/server/wm/StrictModeFlash.java b/services/java/com/android/server/wm/StrictModeFlash.java
index 4b072c3319c6..775aa0f2e94c 100644
--- a/services/java/com/android/server/wm/StrictModeFlash.java
+++ b/services/java/com/android/server/wm/StrictModeFlash.java
@@ -22,8 +22,6 @@ import android.graphics.Color;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.Region;
-import android.util.DisplayMetrics;
-import android.util.Slog;
import android.view.Display;
import android.view.Surface;
import android.view.SurfaceSession;
@@ -39,7 +37,7 @@ class StrictModeFlash {
public StrictModeFlash(Display display, SurfaceSession session) {
try {
- mSurface = new Surface(session, 0, "StrictModeFlash", Display.DEFAULT_DISPLAY,
+ mSurface = new Surface(session, 0, "StrictModeFlash", display.getLayerStack(),
1, 1, PixelFormat.TRANSLUCENT, 0);
} catch (Surface.OutOfResourcesException e) {
return;
diff --git a/services/java/com/android/server/wm/Watermark.java b/services/java/com/android/server/wm/Watermark.java
index 12076d834c11..5901cc8834a9 100644
--- a/services/java/com/android/server/wm/Watermark.java
+++ b/services/java/com/android/server/wm/Watermark.java
@@ -35,6 +35,7 @@ import android.view.Surface.OutOfResourcesException;
* Displays a watermark on top of the window manager's windows.
*/
class Watermark {
+ final Display mDisplay;
final String[] mTokens;
final String mText;
final Paint mTextPaint;
@@ -50,7 +51,7 @@ class Watermark {
int mLastDH;
boolean mDrawNeeded;
- Watermark(DisplayMetrics dm, SurfaceSession session, String[] tokens) {
+ Watermark(Display display, DisplayMetrics dm, SurfaceSession session, String[] tokens) {
if (false) {
Log.i(WindowManagerService.TAG, "*********************** WATERMARK");
for (int i=0; i<tokens.length; i++) {
@@ -58,6 +59,7 @@ class Watermark {
}
}
+ mDisplay = display;
mTokens = tokens;
StringBuilder builder = new StringBuilder(32);
@@ -112,7 +114,7 @@ class Watermark {
try {
mSurface = new Surface(session, 0,
- "WatermarkSurface", Display.DEFAULT_DISPLAY,
+ "WatermarkSurface", mDisplay.getLayerStack(),
1, 1, PixelFormat.TRANSLUCENT, 0);
mSurface.setLayer(WindowManagerService.TYPE_LAYER_MULTIPLIER*100);
mSurface.setPosition(0, 0);
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index c1884dabb0bb..74fb08b6f69a 100755
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -127,7 +127,7 @@ import android.view.SurfaceSession;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
-import android.view.WindowManagerImpl;
+import android.view.WindowManagerGlobal;
import android.view.WindowManagerPolicy;
import android.view.WindowManager.LayoutParams;
import android.view.WindowManagerPolicy.FakeWindow;
@@ -2141,7 +2141,7 @@ public class WindowManagerService extends IWindowManager.Stub
WindowManager.LayoutParams attrs, int viewVisibility, int displayId,
Rect outContentInsets, InputChannel outInputChannel) {
int res = mPolicy.checkAddPermission(attrs);
- if (res != WindowManagerImpl.ADD_OKAY) {
+ if (res != WindowManagerGlobal.ADD_OKAY) {
return res;
}
@@ -2157,7 +2157,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (mWindowMap.containsKey(client.asBinder())) {
Slog.w(TAG, "Window " + client + " is already added");
- return WindowManagerImpl.ADD_DUPLICATE_ADD;
+ return WindowManagerGlobal.ADD_DUPLICATE_ADD;
}
if (attrs.type >= FIRST_SUB_WINDOW && attrs.type <= LAST_SUB_WINDOW) {
@@ -2165,13 +2165,13 @@ public class WindowManagerService extends IWindowManager.Stub
if (attachedWindow == null) {
Slog.w(TAG, "Attempted to add window with token that is not a window: "
+ attrs.token + ". Aborting.");
- return WindowManagerImpl.ADD_BAD_SUBWINDOW_TOKEN;
+ return WindowManagerGlobal.ADD_BAD_SUBWINDOW_TOKEN;
}
if (attachedWindow.mAttrs.type >= FIRST_SUB_WINDOW
&& attachedWindow.mAttrs.type <= LAST_SUB_WINDOW) {
Slog.w(TAG, "Attempted to add window with token that is a sub-window: "
+ attrs.token + ". Aborting.");
- return WindowManagerImpl.ADD_BAD_SUBWINDOW_TOKEN;
+ return WindowManagerGlobal.ADD_BAD_SUBWINDOW_TOKEN;
}
}
@@ -2182,22 +2182,22 @@ public class WindowManagerService extends IWindowManager.Stub
&& attrs.type <= LAST_APPLICATION_WINDOW) {
Slog.w(TAG, "Attempted to add application window with unknown token "
+ attrs.token + ". Aborting.");
- return WindowManagerImpl.ADD_BAD_APP_TOKEN;
+ return WindowManagerGlobal.ADD_BAD_APP_TOKEN;
}
if (attrs.type == TYPE_INPUT_METHOD) {
Slog.w(TAG, "Attempted to add input method window with unknown token "
+ attrs.token + ". Aborting.");
- return WindowManagerImpl.ADD_BAD_APP_TOKEN;
+ return WindowManagerGlobal.ADD_BAD_APP_TOKEN;
}
if (attrs.type == TYPE_WALLPAPER) {
Slog.w(TAG, "Attempted to add wallpaper window with unknown token "
+ attrs.token + ". Aborting.");
- return WindowManagerImpl.ADD_BAD_APP_TOKEN;
+ return WindowManagerGlobal.ADD_BAD_APP_TOKEN;
}
if (attrs.type == TYPE_DREAM) {
Slog.w(TAG, "Attempted to add Dream window with unknown token "
+ attrs.token + ". Aborting.");
- return WindowManagerImpl.ADD_BAD_APP_TOKEN;
+ return WindowManagerGlobal.ADD_BAD_APP_TOKEN;
}
token = new WindowToken(this, attrs.token, -1, false);
addToken = true;
@@ -2207,35 +2207,35 @@ public class WindowManagerService extends IWindowManager.Stub
if (atoken == null) {
Slog.w(TAG, "Attempted to add window with non-application token "
+ token + ". Aborting.");
- return WindowManagerImpl.ADD_NOT_APP_TOKEN;
+ return WindowManagerGlobal.ADD_NOT_APP_TOKEN;
} else if (atoken.removed) {
Slog.w(TAG, "Attempted to add window with exiting application token "
+ token + ". Aborting.");
- return WindowManagerImpl.ADD_APP_EXITING;
+ return WindowManagerGlobal.ADD_APP_EXITING;
}
if (attrs.type == TYPE_APPLICATION_STARTING && atoken.firstWindowDrawn) {
// No need for this guy!
if (localLOGV) Slog.v(
TAG, "**** NO NEED TO START: " + attrs.getTitle());
- return WindowManagerImpl.ADD_STARTING_NOT_NEEDED;
+ return WindowManagerGlobal.ADD_STARTING_NOT_NEEDED;
}
} else if (attrs.type == TYPE_INPUT_METHOD) {
if (token.windowType != TYPE_INPUT_METHOD) {
Slog.w(TAG, "Attempted to add input method window with bad token "
+ attrs.token + ". Aborting.");
- return WindowManagerImpl.ADD_BAD_APP_TOKEN;
+ return WindowManagerGlobal.ADD_BAD_APP_TOKEN;
}
} else if (attrs.type == TYPE_WALLPAPER) {
if (token.windowType != TYPE_WALLPAPER) {
Slog.w(TAG, "Attempted to add wallpaper window with bad token "
+ attrs.token + ". Aborting.");
- return WindowManagerImpl.ADD_BAD_APP_TOKEN;
+ return WindowManagerGlobal.ADD_BAD_APP_TOKEN;
}
} else if (attrs.type == TYPE_DREAM) {
if (token.windowType != TYPE_DREAM) {
Slog.w(TAG, "Attempted to add Dream window with bad token "
+ attrs.token + ". Aborting.");
- return WindowManagerImpl.ADD_BAD_APP_TOKEN;
+ return WindowManagerGlobal.ADD_BAD_APP_TOKEN;
}
}
@@ -2247,13 +2247,13 @@ public class WindowManagerService extends IWindowManager.Stub
// continue.
Slog.w(TAG, "Adding window client " + client.asBinder()
+ " that is dead, aborting.");
- return WindowManagerImpl.ADD_APP_EXITING;
+ return WindowManagerGlobal.ADD_APP_EXITING;
}
mPolicy.adjustWindowParamsLw(win.mAttrs);
res = mPolicy.prepareAddWindowLw(win, attrs);
- if (res != WindowManagerImpl.ADD_OKAY) {
+ if (res != WindowManagerGlobal.ADD_OKAY) {
return res;
}
@@ -2269,7 +2269,7 @@ public class WindowManagerService extends IWindowManager.Stub
// From now on, no exceptions or errors allowed!
- res = WindowManagerImpl.ADD_OKAY;
+ res = WindowManagerGlobal.ADD_OKAY;
origId = Binder.clearCallingIdentity();
@@ -2313,10 +2313,10 @@ public class WindowManagerService extends IWindowManager.Stub
mPolicy.getContentInsetHintLw(attrs, outContentInsets);
if (mInTouchMode) {
- res |= WindowManagerImpl.ADD_FLAG_IN_TOUCH_MODE;
+ res |= WindowManagerGlobal.ADD_FLAG_IN_TOUCH_MODE;
}
if (win.mAppToken == null || !win.mAppToken.clientHidden) {
- res |= WindowManagerImpl.ADD_FLAG_APP_VISIBLE;
+ res |= WindowManagerGlobal.ADD_FLAG_APP_VISIBLE;
}
mInputMonitor.setUpdateInputWindowsNeededLw();
@@ -2748,7 +2748,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
winAnimator.mSurfaceDestroyDeferred =
- (flags&WindowManagerImpl.RELAYOUT_DEFER_SURFACE_DESTROY) != 0;
+ (flags&WindowManagerGlobal.RELAYOUT_DEFER_SURFACE_DESTROY) != 0;
int attrChanges = 0;
int flagChanges = 0;
@@ -2967,7 +2967,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
mLayoutNeeded = true;
- win.mGivenInsetsPending = (flags&WindowManagerImpl.RELAYOUT_INSETS_PENDING) != 0;
+ win.mGivenInsetsPending = (flags&WindowManagerGlobal.RELAYOUT_INSETS_PENDING) != 0;
if (assignLayers) {
assignLayersLocked(win.getWindowList());
}
@@ -3010,10 +3010,10 @@ public class WindowManagerService extends IWindowManager.Stub
Binder.restoreCallingIdentity(origId);
- return (inTouchMode ? WindowManagerImpl.RELAYOUT_RES_IN_TOUCH_MODE : 0)
- | (toBeDisplayed ? WindowManagerImpl.RELAYOUT_RES_FIRST_TIME : 0)
- | (surfaceChanged ? WindowManagerImpl.RELAYOUT_RES_SURFACE_CHANGED : 0)
- | (animating ? WindowManagerImpl.RELAYOUT_RES_ANIMATING : 0);
+ return (inTouchMode ? WindowManagerGlobal.RELAYOUT_RES_IN_TOUCH_MODE : 0)
+ | (toBeDisplayed ? WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME : 0)
+ | (surfaceChanged ? WindowManagerGlobal.RELAYOUT_RES_SURFACE_CHANGED : 0)
+ | (animating ? WindowManagerGlobal.RELAYOUT_RES_ANIMATING : 0);
}
public void performDeferredDestroyWindow(Session session, IWindow client) {
@@ -9629,7 +9629,7 @@ public class WindowManagerService extends IWindowManager.Stub
// TODO(multidisplay): rotation on main screen only.
DisplayInfo displayInfo = getDefaultDisplayContent().getDisplayInfo();
- mAnimator.mScreenRotationAnimation = new ScreenRotationAnimation(mContext,
+ mAnimator.mScreenRotationAnimation = new ScreenRotationAnimation(mContext, mDisplay,
mFxSession, inTransaction, displayInfo.logicalWidth, displayInfo.logicalHeight,
mDisplay.getRotation());
}
@@ -9742,7 +9742,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (line != null) {
String[] toks = line.split("%");
if (toks != null && toks.length > 0) {
- mWatermark = new Watermark(mRealDisplayMetrics, mFxSession, toks);
+ mWatermark = new Watermark(mDisplay, mRealDisplayMetrics, mFxSession, toks);
}
}
} catch (FileNotFoundException e) {
diff --git a/services/java/com/android/server/wm/WindowStateAnimator.java b/services/java/com/android/server/wm/WindowStateAnimator.java
index d931426a3bed..899610fc86c1 100644
--- a/services/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/java/com/android/server/wm/WindowStateAnimator.java
@@ -474,24 +474,14 @@ class WindowStateAnimator {
private final Point mSize = new Point();
private final Rect mWindowCrop = new Rect();
private boolean mShown = false;
- private int mDisplayId;
- private String mName = "Not named";
+ private int mLayerStack;
+ private String mName;
public SurfaceTrace(SurfaceSession s,
- int pid, int displayId, int w, int h, int format, int flags) throws
- OutOfResourcesException {
- super(s, pid, displayId, w, h, format, flags);
- mSize.set(w, h);
- mDisplayId = displayId;
- Slog.v(SURFACE_TAG, "ctor: " + this + ". Called by "
- + Debug.getCallers(3));
- }
-
- public SurfaceTrace(SurfaceSession s,
- int pid, String name, int displayId, int w, int h, int format, int flags)
+ int pid, String name, int layerStack, int w, int h, int format, int flags)
throws OutOfResourcesException {
- super(s, pid, name, displayId, w, h, format, flags);
- mName = name;
+ super(s, pid, name, layerStack, w, h, format, flags);
+ mName = name != null ? name : "Not named";
mSize.set(w, h);
Slog.v(SURFACE_TAG, "ctor: " + this + ". Called by "
+ Debug.getCallers(3));
@@ -550,10 +540,10 @@ class WindowStateAnimator {
}
@Override
- public void setDisplayId(int displayId) {
- super.setDisplayId(displayId);
- mDisplayId = displayId;
- Slog.v(SURFACE_TAG, "setDisplayId: " + this + ". Called by " + Debug.getCallers(3));
+ public void setLayerStack(int layerStack) {
+ super.setLayerStack(layerStack);
+ mLayerStack = layerStack;
+ Slog.v(SURFACE_TAG, "setLayerStack: " + this + ". Called by " + Debug.getCallers(3));
}
@Override
@@ -597,7 +587,7 @@ class WindowStateAnimator {
@Override
public String toString() {
return "Surface " + Integer.toHexString(System.identityHashCode(this)) + " "
- + mName + " (" + mDisplayId + "): shown=" + mShown + " layer=" + mLayer
+ + mName + " (" + mLayerStack + "): shown=" + mShown + " layer=" + mLayer
+ " alpha=" + mSurfaceTraceAlpha + " " + mPosition.x + "," + mPosition.y
+ " " + mSize.x + "x" + mSize.y
+ " crop=" + mWindowCrop.toShortString();
diff --git a/test-runner/src/android/test/mock/MockContext.java b/test-runner/src/android/test/mock/MockContext.java
index 02d0b450f51d..12ad4feabd3e 100644
--- a/test-runner/src/android/test/mock/MockContext.java
+++ b/test-runner/src/android/test/mock/MockContext.java
@@ -39,6 +39,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.UserHandle;
+import android.view.CompatibilityInfoHolder;
import java.io.File;
import java.io.FileInputStream;
@@ -487,4 +488,10 @@ public class MockContext extends Context {
public boolean isRestricted() {
throw new UnsupportedOperationException();
}
+
+ /** @hide */
+ @Override
+ public CompatibilityInfoHolder getCompatibilityInfo() {
+ throw new UnsupportedOperationException();
+ }
}
diff --git a/tools/layoutlib/bridge/src/android/view/AttachInfo_Accessor.java b/tools/layoutlib/bridge/src/android/view/AttachInfo_Accessor.java
index 97d99695386f..4901f72b23d6 100644
--- a/tools/layoutlib/bridge/src/android/view/AttachInfo_Accessor.java
+++ b/tools/layoutlib/bridge/src/android/view/AttachInfo_Accessor.java
@@ -19,6 +19,7 @@ package android.view;
import com.android.layoutlib.bridge.android.BridgeWindow;
import com.android.layoutlib.bridge.android.BridgeWindowSession;
+import android.content.Context;
import android.os.Handler;
import android.view.View.AttachInfo;
@@ -28,8 +29,12 @@ import android.view.View.AttachInfo;
public class AttachInfo_Accessor {
public static void setAttachInfo(View view) {
+ Context context = view.getContext();
+ WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
+ Display display = wm.getDefaultDisplay();
+ ViewRootImpl root = new ViewRootImpl(context, display);
AttachInfo info = new AttachInfo(new BridgeWindowSession(), new BridgeWindow(),
- new ViewRootImpl(view.getContext()), new Handler(), null);
+ display, root, new Handler(), null);
info.mHasWindowFocus = true;
info.mWindowVisibility = View.VISIBLE;
info.mInTouchMode = false; // this is so that we can display selections.
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
index 943357a78bf1..3d45bff2e612 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
@@ -66,6 +66,7 @@ import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.BridgeInflater;
+import android.view.CompatibilityInfoHolder;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
@@ -1318,4 +1319,10 @@ public final class BridgeContext extends Context {
Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "OBB not supported", null);
return null;
}
+
+ @Override
+ public CompatibilityInfoHolder getCompatibilityInfo() {
+ // pass
+ return null;
+ }
}