diff options
author | Wale Ogunwale <ogunwale@google.com> | 2015-02-15 20:20:06 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-02-15 20:20:08 +0000 |
commit | 421d6ad191563308d31594f53fee804c3d4d1f84 (patch) | |
tree | 4e37fccc18cacd0362ae4aef2b8cde9262aba375 /core/java/android/view | |
parent | 9f64d5c6c456863489ffb8583d611211e7c2f88f (diff) | |
parent | 7c72668f19d404b01412abc67937b1b5c660df71 (diff) | |
download | frameworks_base-421d6ad191563308d31594f53fee804c3d4d1f84.zip frameworks_base-421d6ad191563308d31594f53fee804c3d4d1f84.tar.gz frameworks_base-421d6ad191563308d31594f53fee804c3d4d1f84.tar.bz2 |
Merge "Adjust activity display metrics based on stack configuration."
Diffstat (limited to 'core/java/android/view')
-rw-r--r-- | core/java/android/view/Display.java | 2 | ||||
-rw-r--r-- | core/java/android/view/DisplayAdjustments.java | 30 | ||||
-rw-r--r-- | core/java/android/view/DisplayInfo.java | 28 | ||||
-rw-r--r-- | core/java/android/view/ViewRootImpl.java | 1 |
4 files changed, 32 insertions, 29 deletions
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java index cfb0297..71863b7 100644 --- a/core/java/android/view/Display.java +++ b/core/java/android/view/Display.java @@ -716,7 +716,7 @@ public final class Display { updateDisplayInfoLocked(); mDisplayInfo.getLogicalMetrics(outMetrics, CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, - mDisplayAdjustments.getActivityToken()); + mDisplayAdjustments.getConfiguration()); } } diff --git a/core/java/android/view/DisplayAdjustments.java b/core/java/android/view/DisplayAdjustments.java index 35fb504..272740f 100644 --- a/core/java/android/view/DisplayAdjustments.java +++ b/core/java/android/view/DisplayAdjustments.java @@ -17,7 +17,7 @@ package android.view; import android.content.res.CompatibilityInfo; -import android.os.IBinder; +import android.content.res.Configuration; import java.util.Objects; @@ -28,22 +28,18 @@ public class DisplayAdjustments { public static final DisplayAdjustments DEFAULT_DISPLAY_ADJUSTMENTS = new DisplayAdjustments(); private volatile CompatibilityInfo mCompatInfo = CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO; - private volatile IBinder mActivityToken; + private Configuration mConfiguration = Configuration.EMPTY; public DisplayAdjustments() { } - public DisplayAdjustments(IBinder token) { - mActivityToken = token; + public DisplayAdjustments(Configuration configuration) { + mConfiguration = configuration; } public DisplayAdjustments(DisplayAdjustments daj) { - this (daj.getCompatibilityInfo(), daj.getActivityToken()); - } - - public DisplayAdjustments(CompatibilityInfo compatInfo, IBinder token) { - setCompatibilityInfo(compatInfo); - mActivityToken = token; + setCompatibilityInfo(daj.mCompatInfo); + mConfiguration = daj.mConfiguration; } public void setCompatibilityInfo(CompatibilityInfo compatInfo) { @@ -63,16 +59,16 @@ public class DisplayAdjustments { return mCompatInfo; } - public void setActivityToken(IBinder token) { + public void setConfiguration(Configuration configuration) { if (this == DEFAULT_DISPLAY_ADJUSTMENTS) { throw new IllegalArgumentException( - "setActivityToken: Cannot modify DEFAULT_DISPLAY_ADJUSTMENTS"); + "setConfiguration: Cannot modify DEFAULT_DISPLAY_ADJUSTMENTS"); } - mActivityToken = token; + mConfiguration = configuration; } - public IBinder getActivityToken() { - return mActivityToken; + public Configuration getConfiguration() { + return mConfiguration; } @Override @@ -80,7 +76,7 @@ public class DisplayAdjustments { int hash = 17; hash = hash * 31 + mCompatInfo.hashCode(); if (DEVELOPMENT_RESOURCES_DEPEND_ON_ACTIVITY_TOKEN) { - hash = hash * 31 + (mActivityToken == null ? 0 : mActivityToken.hashCode()); + hash = hash * 31 + (mConfiguration == null ? 0 : mConfiguration.hashCode()); } return hash; } @@ -92,6 +88,6 @@ public class DisplayAdjustments { } DisplayAdjustments daj = (DisplayAdjustments)o; return Objects.equals(daj.mCompatInfo, mCompatInfo) && - Objects.equals(daj.mActivityToken, mActivityToken); + Objects.equals(daj.mConfiguration, mConfiguration); } } diff --git a/core/java/android/view/DisplayInfo.java b/core/java/android/view/DisplayInfo.java index 9feb681..ecf45b4 100644 --- a/core/java/android/view/DisplayInfo.java +++ b/core/java/android/view/DisplayInfo.java @@ -17,7 +17,7 @@ package android.view; import android.content.res.CompatibilityInfo; -import android.os.IBinder; +import android.content.res.Configuration; import android.os.Parcel; import android.os.Parcelable; import android.util.DisplayMetrics; @@ -401,16 +401,17 @@ public final class DisplayInfo implements Parcelable { public void getAppMetrics(DisplayMetrics outMetrics, DisplayAdjustments displayAdjustments) { getMetricsWithSize(outMetrics, displayAdjustments.getCompatibilityInfo(), - displayAdjustments.getActivityToken(), appWidth, appHeight); + displayAdjustments.getConfiguration(), appWidth, appHeight); } - public void getAppMetrics(DisplayMetrics outMetrics, CompatibilityInfo ci, IBinder token) { - getMetricsWithSize(outMetrics, ci, token, appWidth, appHeight); + public void getAppMetrics(DisplayMetrics outMetrics, CompatibilityInfo ci, + Configuration configuration) { + getMetricsWithSize(outMetrics, ci, configuration, appWidth, appHeight); } public void getLogicalMetrics(DisplayMetrics outMetrics, CompatibilityInfo compatInfo, - IBinder token) { - getMetricsWithSize(outMetrics, compatInfo, token, logicalWidth, logicalHeight); + Configuration configuration) { + getMetricsWithSize(outMetrics, compatInfo, configuration, logicalWidth, logicalHeight); } public int getNaturalWidth() { @@ -431,17 +432,24 @@ public final class DisplayInfo implements Parcelable { } private void getMetricsWithSize(DisplayMetrics outMetrics, CompatibilityInfo compatInfo, - IBinder token, int width, int height) { + Configuration configuration, int width, int height) { outMetrics.densityDpi = outMetrics.noncompatDensityDpi = logicalDensityDpi; - outMetrics.noncompatWidthPixels = outMetrics.widthPixels = width; - outMetrics.noncompatHeightPixels = outMetrics.heightPixels = height; - outMetrics.density = outMetrics.noncompatDensity = logicalDensityDpi * DisplayMetrics.DENSITY_DEFAULT_SCALE; outMetrics.scaledDensity = outMetrics.noncompatScaledDensity = outMetrics.density; outMetrics.xdpi = outMetrics.noncompatXdpi = physicalXDpi; outMetrics.ydpi = outMetrics.noncompatYdpi = physicalYDpi; + width = (configuration != null + && configuration.screenWidthDp != Configuration.SCREEN_WIDTH_DP_UNDEFINED) + ? (int)((configuration.screenWidthDp * outMetrics.density) + 0.5f) : width; + height = (configuration != null + && configuration.screenHeightDp != Configuration.SCREEN_HEIGHT_DP_UNDEFINED) + ? (int)((configuration.screenHeightDp * outMetrics.density) + 0.5f) : height; + + outMetrics.noncompatWidthPixels = outMetrics.widthPixels = width; + outMetrics.noncompatHeightPixels = outMetrics.heightPixels = height; + if (!compatInfo.equals(CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO)) { compatInfo.applyToDisplayMetrics(outMetrics); } diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index fb2a8d8..24fae8a 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -478,7 +478,6 @@ public final class ViewRootImpl implements ViewParent, CompatibilityInfo compatibilityInfo = mDisplayAdjustments.getCompatibilityInfo(); mTranslator = compatibilityInfo.getTranslator(); - mDisplayAdjustments.setActivityToken(attrs.token); // If the application owns the surface, don't enable hardware acceleration if (mSurfaceHolder == null) { |