diff options
| author | Jeff Brown <jeffbrown@google.com> | 2012-07-20 16:15:36 -0700 |
|---|---|---|
| committer | Jeff Brown <jeffbrown@google.com> | 2012-07-20 22:40:50 -0700 |
| commit | d32460c5b7bea7b06e345397fdbaca58d9732dcf (patch) | |
| tree | 9208131690107789c3112ba6b79ea703d51a3cee /core/java/android/view/Window.java | |
| parent | 23e7c35ab5d43242d35b1019ce1a50bfb495cd27 (diff) | |
Refactor local window manager implementation.
The objective of this refactoring is to remove the reliance on
WindowManager wrapper objects for compatibility mode and for
managing sub-windows.
Removed the WindowManager.isHardwareAccelerated() method since
it is never used.
Change-Id: I4840a6353121859a5e0c07d5cc307a437c595d63
Diffstat (limited to 'core/java/android/view/Window.java')
| -rw-r--r-- | core/java/android/view/Window.java | 112 |
1 files changed, 48 insertions, 64 deletions
diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java index ec4114e6a59d..f57f05677bbf 100644 --- a/core/java/android/view/Window.java +++ b/core/java/android/view/Window.java @@ -18,7 +18,6 @@ package android.view; import android.app.Application; import android.content.Context; -import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.content.res.TypedArray; import android.graphics.PixelFormat; @@ -27,7 +26,6 @@ import android.net.Uri; import android.os.Bundle; import android.os.IBinder; import android.os.SystemProperties; -import android.util.Slog; import android.view.accessibility.AccessibilityEvent; /** @@ -119,6 +117,8 @@ public abstract class Window { */ public static final int ID_ANDROID_CONTENT = com.android.internal.R.id.content; + private static final String PROPERTY_HARDWARE_UI = "persist.sys.ui.hw"; + private final Context mContext; private TypedArray mWindowStyle; @@ -126,6 +126,7 @@ public abstract class Window { private WindowManager mWindowManager; private IBinder mAppToken; private String mAppName; + private boolean mHardwareAccelerated; private Window mContainer; private Window mActiveChild; private boolean mIsActive = false; @@ -471,80 +472,63 @@ public abstract class Window { boolean hardwareAccelerated) { mAppToken = appToken; mAppName = appName; + mHardwareAccelerated = hardwareAccelerated + || SystemProperties.getBoolean(PROPERTY_HARDWARE_UI, false); if (wm == null) { wm = WindowManagerImpl.getDefault(); } - mWindowManager = new LocalWindowManager(wm, hardwareAccelerated); + mWindowManager = ((WindowManagerImpl)wm).makeLocal(this); } - static CompatibilityInfoHolder getCompatInfo(Context context) { - Application app = (Application)context.getApplicationContext(); - return app != null ? app.mLoadedApk.mCompatibilityInfo : new CompatibilityInfoHolder(); + CompatibilityInfoHolder getCompatibilityInfo() { + Application app = (Application)mContext.getApplicationContext(); + return app != null ? app.mLoadedApk.mCompatibilityInfo : null; } - private class LocalWindowManager extends WindowManagerImpl.CompatModeWrapper { - private static final String PROPERTY_HARDWARE_UI = "persist.sys.ui.hw"; - - private final boolean mHardwareAccelerated; - - LocalWindowManager(WindowManager wm, boolean hardwareAccelerated) { - super(wm, getCompatInfo(mContext)); - mHardwareAccelerated = hardwareAccelerated || - SystemProperties.getBoolean(PROPERTY_HARDWARE_UI, false); - } - - public boolean isHardwareAccelerated() { - return mHardwareAccelerated; - } - - public final void addView(View view, ViewGroup.LayoutParams params) { - // Let this throw an exception on a bad params. - WindowManager.LayoutParams wp = (WindowManager.LayoutParams)params; - CharSequence curTitle = wp.getTitle(); - if (wp.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW && - wp.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { - if (wp.token == null) { - View decor = peekDecorView(); - if (decor != null) { - wp.token = decor.getWindowToken(); - } + void adjustLayoutParamsForSubWindow(WindowManager.LayoutParams wp) { + CharSequence curTitle = wp.getTitle(); + if (wp.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW && + wp.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { + if (wp.token == null) { + View decor = peekDecorView(); + if (decor != null) { + wp.token = decor.getWindowToken(); } - if (curTitle == null || curTitle.length() == 0) { - String title; - if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA) { - title="Media"; - } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY) { - title="MediaOvr"; - } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) { - title="Panel"; - } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL) { - title="SubPanel"; - } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG) { - title="AtchDlg"; - } else { - title=Integer.toString(wp.type); - } - if (mAppName != null) { - title += ":" + mAppName; - } - wp.setTitle(title); - } - } else { - if (wp.token == null) { - wp.token = mContainer == null ? mAppToken : mContainer.mAppToken; + } + if (curTitle == null || curTitle.length() == 0) { + String title; + if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA) { + title="Media"; + } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY) { + title="MediaOvr"; + } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) { + title="Panel"; + } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL) { + title="SubPanel"; + } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG) { + title="AtchDlg"; + } else { + title=Integer.toString(wp.type); } - if ((curTitle == null || curTitle.length() == 0) - && mAppName != null) { - wp.setTitle(mAppName); + if (mAppName != null) { + title += ":" + mAppName; } - } - if (wp.packageName == null) { - wp.packageName = mContext.getPackageName(); + wp.setTitle(title); + } + } else { + if (wp.token == null) { + wp.token = mContainer == null ? mAppToken : mContainer.mAppToken; } - if (mHardwareAccelerated) { - wp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; + if ((curTitle == null || curTitle.length() == 0) + && mAppName != null) { + wp.setTitle(mAppName); } - super.addView(view, params); + } + if (wp.packageName == null) { + wp.packageName = mContext.getPackageName(); + } + if (mHardwareAccelerated) { + wp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; } } |
