summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWale Ogunwale <ogunwale@google.com>2015-06-05 16:55:33 -0700
committerWale Ogunwale <ogunwale@google.com>2015-06-06 11:26:33 -0700
commit26698514fbac587675221149aca98f3ea6414d55 (patch)
treeab85e311e5ccdd38730bf2f79d40c6d8247c4ae6
parent18d669dc597dc4997ee8d96f38cf138ae31a0cdf (diff)
downloadframeworks_base-26698514fbac587675221149aca98f3ea6414d55.zip
frameworks_base-26698514fbac587675221149aca98f3ea6414d55.tar.gz
frameworks_base-26698514fbac587675221149aca98f3ea6414d55.tar.bz2
Use DisplayAdjustments when creating display in ResourceManager
We were previous only taking the Configuration into account when creating Display objects in the ResourceManager. This led to the Display object not containing critical CompatibilityInfo. We now take the entire DisplayAdjustment into account. Bug: 21637615 Change-Id: Ide5ff49bfa12791ad17993764f312836216b1dd8
-rw-r--r--api/current.txt1
-rw-r--r--api/system-current.txt1
-rw-r--r--core/java/android/app/ActivityThread.java3
-rw-r--r--core/java/android/app/ContextImpl.java34
-rw-r--r--core/java/android/app/ResourcesManager.java20
-rw-r--r--core/java/android/hardware/display/DisplayManagerGlobal.java11
-rw-r--r--core/java/android/view/Display.java5
7 files changed, 39 insertions, 36 deletions
diff --git a/api/current.txt b/api/current.txt
index 481e651..d0ce1d9 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -34663,6 +34663,7 @@ package android.view {
field public static final int FLAG_ROUND = 16; // 0x10
field public static final int FLAG_SECURE = 2; // 0x2
field public static final int FLAG_SUPPORTS_PROTECTED_BUFFERS = 1; // 0x1
+ field public static final int INVALID_DISPLAY = -1; // 0xffffffff
field public static final int STATE_DOZE = 3; // 0x3
field public static final int STATE_DOZE_SUSPEND = 4; // 0x4
field public static final int STATE_OFF = 1; // 0x1
diff --git a/api/system-current.txt b/api/system-current.txt
index 32af01c..7d3f7c7 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -36928,6 +36928,7 @@ package android.view {
field public static final int FLAG_ROUND = 16; // 0x10
field public static final int FLAG_SECURE = 2; // 0x2
field public static final int FLAG_SUPPORTS_PROTECTED_BUFFERS = 1; // 0x1
+ field public static final int INVALID_DISPLAY = -1; // 0xffffffff
field public static final int STATE_DOZE = 3; // 0x3
field public static final int STATE_DOZE_SUSPEND = 4; // 0x4
field public static final int STATE_OFF = 1; // 0x1
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 2a98b6c..c18176d 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -2438,7 +2438,8 @@ public final class ActivityThread {
&& r.packageInfo.mPackageName.contains(pkgName)) {
for (int id : dm.getDisplayIds()) {
if (id != Display.DEFAULT_DISPLAY) {
- Display display = dm.getRealDisplay(id, r.overrideConfig);
+ Display display =
+ dm.getCompatibleDisplay(id, appContext.getDisplayAdjustments(id));
baseContext = appContext.createDisplayContext(display);
break;
}
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 3b1ccd2..829b098 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -1597,7 +1597,7 @@ class ContextImpl extends Context {
final boolean restricted = (flags & CONTEXT_RESTRICTED) == CONTEXT_RESTRICTED;
ContextImpl c = new ContextImpl(this, mMainThread, pi, mActivityToken,
new UserHandle(UserHandle.getUserId(application.uid)), restricted,
- mDisplay, null);
+ mDisplay, null, Display.INVALID_DISPLAY);
if (c.mResources != null) {
return c;
}
@@ -1620,14 +1620,14 @@ class ContextImpl extends Context {
final boolean restricted = (flags & CONTEXT_RESTRICTED) == CONTEXT_RESTRICTED;
if (packageName.equals("system") || packageName.equals("android")) {
return new ContextImpl(this, mMainThread, mPackageInfo, mActivityToken,
- user, restricted, mDisplay, null);
+ user, restricted, mDisplay, null, Display.INVALID_DISPLAY);
}
LoadedApk pi = mMainThread.getPackageInfo(packageName, mResources.getCompatibilityInfo(),
flags | CONTEXT_REGISTER_PACKAGE, user.getIdentifier());
if (pi != null) {
ContextImpl c = new ContextImpl(this, mMainThread, pi, mActivityToken,
- user, restricted, mDisplay, null);
+ user, restricted, mDisplay, null, Display.INVALID_DISPLAY);
if (c.mResources != null) {
return c;
}
@@ -1645,7 +1645,7 @@ class ContextImpl extends Context {
}
return new ContextImpl(this, mMainThread, mPackageInfo, mActivityToken,
- mUser, mRestricted, mDisplay, overrideConfiguration);
+ mUser, mRestricted, mDisplay, overrideConfiguration, Display.INVALID_DISPLAY);
}
@Override
@@ -1655,15 +1655,15 @@ class ContextImpl extends Context {
}
return new ContextImpl(this, mMainThread, mPackageInfo, mActivityToken,
- mUser, mRestricted, display, null);
+ mUser, mRestricted, display, null, Display.INVALID_DISPLAY);
}
Display getDisplay() {
if (mDisplay != null) {
return mDisplay;
}
- DisplayManager dm = getSystemService(DisplayManager.class);
- return dm.getDisplay(Display.DEFAULT_DISPLAY);
+ return ResourcesManager.getInstance().getAdjustedDisplay(
+ Display.DEFAULT_DISPLAY, mDisplayAdjustments);
}
private int getDisplayId() {
@@ -1708,7 +1708,7 @@ class ContextImpl extends Context {
static ContextImpl createSystemContext(ActivityThread mainThread) {
LoadedApk packageInfo = new LoadedApk(mainThread);
ContextImpl context = new ContextImpl(null, mainThread,
- packageInfo, null, null, false, null, null);
+ packageInfo, null, null, false, null, null, Display.INVALID_DISPLAY);
context.mResources.updateConfiguration(context.mResourcesManager.getConfiguration(),
context.mResourcesManager.getDisplayMetricsLocked());
return context;
@@ -1717,21 +1717,19 @@ class ContextImpl extends Context {
static ContextImpl createAppContext(ActivityThread mainThread, LoadedApk packageInfo) {
if (packageInfo == null) throw new IllegalArgumentException("packageInfo");
return new ContextImpl(null, mainThread,
- packageInfo, null, null, false, null, null);
+ packageInfo, null, null, false, null, null, Display.INVALID_DISPLAY);
}
static ContextImpl createActivityContext(ActivityThread mainThread,
LoadedApk packageInfo, int displayId, Configuration overrideConfiguration) {
if (packageInfo == null) throw new IllegalArgumentException("packageInfo");
- final Display display = ResourcesManager.getInstance().getAdjustedDisplay(
- displayId, overrideConfiguration);
- return new ContextImpl(null, mainThread, packageInfo, null, null, false, display,
- overrideConfiguration);
+ return new ContextImpl(null, mainThread, packageInfo, null, null, false,
+ null, overrideConfiguration, displayId);
}
private ContextImpl(ContextImpl container, ActivityThread mainThread,
LoadedApk packageInfo, IBinder activityToken, UserHandle user, boolean restricted,
- Display display, Configuration overrideConfiguration) {
+ Display display, Configuration overrideConfiguration, int createDisplayWithId) {
mOuterContext = this;
mMainThread = mainThread;
@@ -1745,9 +1743,10 @@ class ContextImpl extends Context {
mPackageInfo = packageInfo;
mResourcesManager = ResourcesManager.getInstance();
- mDisplay = display;
- final int displayId = getDisplayId();
+ final int displayId = (createDisplayWithId != Display.INVALID_DISPLAY)
+ ? createDisplayWithId : getDisplayId();
+
CompatibilityInfo compatInfo = null;
if (container != null) {
compatInfo = container.getDisplayAdjustments(displayId).getCompatibilityInfo();
@@ -1760,6 +1759,9 @@ class ContextImpl extends Context {
mDisplayAdjustments.setCompatibilityInfo(compatInfo);
mDisplayAdjustments.setConfiguration(overrideConfiguration);
+ mDisplay = (createDisplayWithId == Display.INVALID_DISPLAY) ? display
+ : ResourcesManager.getInstance().getAdjustedDisplay(displayId, mDisplayAdjustments);
+
Resources resources = packageInfo.getResources(mainThread);
if (resources != null) {
if (displayId != Display.DEFAULT_DISPLAY
diff --git a/core/java/android/app/ResourcesManager.java b/core/java/android/app/ResourcesManager.java
index 79797c9..2117597 100644
--- a/core/java/android/app/ResourcesManager.java
+++ b/core/java/android/app/ResourcesManager.java
@@ -31,6 +31,8 @@ import android.util.Log;
import android.util.Pair;
import android.util.Slog;
import android.view.Display;
+import android.view.DisplayAdjustments;
+
import java.lang.ref.WeakReference;
import java.util.Locale;
@@ -42,7 +44,7 @@ public class ResourcesManager {
private static ResourcesManager sResourcesManager;
private final ArrayMap<ResourcesKey, WeakReference<Resources> > mActiveResources =
new ArrayMap<>();
- private final ArrayMap<Pair<Integer, Configuration>, WeakReference<Display>> mDisplays =
+ private final ArrayMap<Pair<Integer, DisplayAdjustments>, WeakReference<Display>> mDisplays =
new ArrayMap<>();
CompatibilityInfo mResCompatibilityInfo;
@@ -68,7 +70,8 @@ public class ResourcesManager {
DisplayMetrics getDisplayMetricsLocked(int displayId) {
DisplayMetrics dm = new DisplayMetrics();
- final Display display = getAdjustedDisplay(displayId, Configuration.EMPTY);
+ final Display display =
+ getAdjustedDisplay(displayId, DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS);
if (display != null) {
display.getMetrics(dm);
} else {
@@ -113,12 +116,13 @@ public class ResourcesManager {
* available.
*
* @param displayId display Id.
- * @param overrideConfiguration override configurations.
+ * @param displayAdjustments display adjustments.
*/
- public Display getAdjustedDisplay(final int displayId, Configuration overrideConfiguration) {
- final Configuration configCopy = (overrideConfiguration != null)
- ? new Configuration(overrideConfiguration) : new Configuration();
- final Pair<Integer, Configuration> key = Pair.create(displayId, configCopy);
+ public Display getAdjustedDisplay(final int displayId, DisplayAdjustments displayAdjustments) {
+ final DisplayAdjustments displayAdjustmentsCopy = (displayAdjustments != null)
+ ? new DisplayAdjustments(displayAdjustments) : new DisplayAdjustments();
+ final Pair<Integer, DisplayAdjustments> key =
+ Pair.create(displayId, displayAdjustmentsCopy);
synchronized (this) {
WeakReference<Display> wd = mDisplays.get(key);
if (wd != null) {
@@ -132,7 +136,7 @@ public class ResourcesManager {
// may be null early in system startup
return null;
}
- final Display display = dm.getRealDisplay(displayId, key.second);
+ final Display display = dm.getCompatibleDisplay(displayId, key.second);
if (display != null) {
mDisplays.put(key, new WeakReference<>(display));
}
diff --git a/core/java/android/hardware/display/DisplayManagerGlobal.java b/core/java/android/hardware/display/DisplayManagerGlobal.java
index d9f9c1e..21ba7bd 100644
--- a/core/java/android/hardware/display/DisplayManagerGlobal.java
+++ b/core/java/android/hardware/display/DisplayManagerGlobal.java
@@ -192,17 +192,6 @@ public final class DisplayManagerGlobal {
return getCompatibleDisplay(displayId, DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS);
}
- /**
- * Gets information about a logical display without applying any compatibility metrics.
- *
- * @param displayId The logical display id.
- * @param configuration the configuration.
- * @return The display object, or null if there is no display with the given id.
- */
- public Display getRealDisplay(int displayId, Configuration configuration) {
- return getCompatibleDisplay(displayId, new DisplayAdjustments(configuration));
- }
-
public void registerDisplayListener(DisplayListener listener, Handler handler) {
if (listener == null) {
throw new IllegalArgumentException("listener must not be null");
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java
index 5a587fe..35c4192 100644
--- a/core/java/android/view/Display.java
+++ b/core/java/android/view/Display.java
@@ -89,6 +89,11 @@ public final class Display {
public static final int DEFAULT_DISPLAY = 0;
/**
+ * Invalid display id.
+ */
+ public static final int INVALID_DISPLAY = -1;
+
+ /**
* Display flag: Indicates that the display supports compositing content
* that is stored in protected graphics buffers.
* <p>