resolution support fix/improvement
    * adding compatibility menu
    * backup gravity
    * set expanable=true if the screen size is hvga * density.
    * added "supports any density" mode. I'll add sdk check later.
    * disallow to catch orientation change event if the app is not expandable. This
      was causing layout problem under non-expandable mode. I discussed this with Mike C
      and we agreed to do this approach for now. We'll revisit if this causes problem to
      a lot of applications.
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index d8bab56..ee8229d 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -129,7 +129,6 @@
     boolean mIsAnimating;
     
     private CompatibilityInfo mCompatibilityInfo;
-    private int[] mWindowLayoutParamsBackup = null;
 
     final View.AttachInfo mAttachInfo;
 
@@ -388,10 +387,11 @@
             if (mView == null) {
                 mView = view;
                 mWindowAttributes.copyFrom(attrs);
-                mCompatibilityInfo =
-                        mView.getContext().getResources().getCompatibilityInfo();
-                if (mCompatibilityInfo.mScalingRequired) {
-                    mWindowLayoutParamsBackup = new int[4];
+                mCompatibilityInfo = mView.getContext().getResources().getCompatibilityInfo();
+                boolean restore = false;
+                if (mCompatibilityInfo.mScalingRequired || !mCompatibilityInfo.mExpandable) {
+                    restore = true;
+                    mWindowAttributes.backup();
                 }
                 if (!mCompatibilityInfo.mExpandable) {
                     adjustWindowAttributesForCompatibleMode(mWindowAttributes);
@@ -420,6 +420,11 @@
                     unscheduleTraversals();
                     throw new RuntimeException("Adding window failed", e);
                 }
+
+                if (restore) {
+                    mWindowAttributes.restore();
+                }
+
                 if (mCompatibilityInfo.mScalingRequired) {
                     mAttachInfo.mContentInsets.scale(
                             mCompatibilityInfo.mApplicationInvertedScale);
@@ -1921,9 +1926,6 @@
         } else {
             didFinish = false;
         }
-        if (event != null && mCompatibilityInfo.mScalingRequired) {
-            event.scale(mCompatibilityInfo.mApplicationInvertedScale);
-        }
 
         if (DEBUG_TRACKBALL) Log.v(TAG, "Motion event:" + event);
 
@@ -2355,13 +2357,15 @@
         boolean restore = false;
         float appScale = mCompatibilityInfo.mApplicationScale;
         boolean scalingRequired = mCompatibilityInfo.mScalingRequired;
-        
         if (params != null && !mCompatibilityInfo.mExpandable) {
+            restore = true;
+            params.backup();
             adjustWindowAttributesForCompatibleMode(params);
         }
         if (params != null && scalingRequired) {
+            if (!restore) params.backup();
             restore = true;
-            params.scale(appScale, mWindowLayoutParamsBackup);
+            params.scale(appScale);
         }
         int relayoutResult = sWindowSession.relayout(
                 mWindow, params,
@@ -2370,7 +2374,7 @@
                 viewVisibility, insetsPending, mWinFrame,
                 mPendingContentInsets, mPendingVisibleInsets, mSurface);
         if (restore) {
-            params.restore(mWindowLayoutParamsBackup);
+            params.restore();
         }
         if (scalingRequired) {
             float invertedScale = mCompatibilityInfo.mApplicationInvertedScale;
@@ -2396,12 +2400,15 @@
             if (attrs.width == ViewGroup.LayoutParams.FILL_PARENT) {
                 attrs.width = metrics.widthPixels;
                 attrs.gravity |= Gravity.CENTER_HORIZONTAL;
+                mWindowAttributesChanged = attrs == mWindowAttributes;
             }
             if (attrs.height == ViewGroup.LayoutParams.FILL_PARENT) {
                 attrs.height = metrics.heightPixels;
+                attrs.gravity |= Gravity.TOP;
+                mWindowAttributesChanged = attrs == mWindowAttributes;
             }
             if (DEBUG_LAYOUT) {
-                Log.d(TAG, "Attributes fixed for compatibility : " + attrs);
+                Log.d(TAG, "Adjusted Attributes for compatibility : " + attrs);
             }
         }
     }