Start moving away from DisplayMetrics.DENSITY_DEVICE.
This puts in most of the infrastructure needed to allow us to
switch between different densities at run time. The main remaining
uses of the global are to initialize the Bitmap object (not sure
what to do about that since it doesn't have anything passed in
the constructor to get this information from), and being able to
load drawables if we need a different density than what was preloaded
by zygote.
Change-Id: Ifdbfd6b7a5c59e6aa22e63b95b78d96af3d96848
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 7011bc1..f8d01de 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -166,6 +166,7 @@
= new HashMap<IBinder, Service>();
AppBindData mBoundApplication;
Profiler mProfiler;
+ int mCurDefaultDisplayDpi;
Configuration mConfiguration;
Configuration mCompatConfiguration;
Configuration mResConfiguration;
@@ -1306,6 +1307,7 @@
break;
case CONFIGURATION_CHANGED:
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "configChanged");
+ mCurDefaultDisplayDpi = ((Configuration)msg.obj).densityDpi;
handleConfigurationChanged((Configuration)msg.obj, null);
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
break;
@@ -1539,14 +1541,15 @@
}
private Configuration mMainThreadConfig = new Configuration();
- Configuration applyConfigCompatMainThread(Configuration config, CompatibilityInfo compat) {
+ Configuration applyConfigCompatMainThread(int displayDensity, Configuration config,
+ CompatibilityInfo compat) {
if (config == null) {
return null;
}
if (compat != null && !compat.supportsScreen()) {
mMainThreadConfig.setTo(config);
config = mMainThreadConfig;
- compat.applyToConfiguration(config);
+ compat.applyToConfiguration(displayDensity, config);
}
return config;
}
@@ -3464,6 +3467,7 @@
// If there was a pending configuration change, execute it first.
if (changedConfig != null) {
+ mCurDefaultDisplayDpi = changedConfig.densityDpi;
handleConfigurationChanged(changedConfig, null);
}
@@ -3546,8 +3550,8 @@
for (ActivityClientRecord ar : mActivities.values()) {
Activity a = ar.activity;
if (a != null) {
- Configuration thisConfig = applyConfigCompatMainThread(newConfig,
- ar.packageInfo.mCompatibilityInfo.getIfNeeded());
+ Configuration thisConfig = applyConfigCompatMainThread(mCurDefaultDisplayDpi,
+ newConfig, ar.packageInfo.mCompatibilityInfo.getIfNeeded());
if (!ar.activity.mFinished && (allActivities || !ar.paused)) {
// If the activity is currently resumed, its configuration
// needs to change right now.
@@ -3691,14 +3695,14 @@
return changes != 0;
}
- final Configuration applyCompatConfiguration() {
+ final Configuration applyCompatConfiguration(int displayDensity) {
Configuration config = mConfiguration;
if (mCompatConfiguration == null) {
mCompatConfiguration = new Configuration();
}
mCompatConfiguration.setTo(mConfiguration);
if (mResCompatibilityInfo != null && !mResCompatibilityInfo.supportsScreen()) {
- mResCompatibilityInfo.applyToConfiguration(mCompatConfiguration);
+ mResCompatibilityInfo.applyToConfiguration(displayDensity, mCompatConfiguration);
config = mCompatConfiguration;
}
return config;
@@ -3713,6 +3717,7 @@
if (mPendingConfiguration != null) {
if (!mPendingConfiguration.isOtherSeqNewer(config)) {
config = mPendingConfiguration;
+ mCurDefaultDisplayDpi = config.densityDpi;
}
mPendingConfiguration = null;
}
@@ -3734,7 +3739,7 @@
}
configDiff = mConfiguration.diff(config);
mConfiguration.updateFrom(config);
- config = applyCompatConfiguration();
+ config = applyCompatConfiguration(mCurDefaultDisplayDpi);
callbacks = collectComponentCallbacksLocked(false, config);
}
@@ -3933,7 +3938,7 @@
// Persistent processes on low-memory devices do not get to
// use hardware accelerated drawing, since this can add too much
// overhead to the process.
- Display display = WindowManagerImpl.getDefault().getDefaultDisplay();
+ final Display display = WindowManagerImpl.getDefault().getDefaultDisplay();
if (!ActivityManager.isHighEndGfx(display)) {
HardwareRenderer.disable(false);
}
@@ -3970,7 +3975,8 @@
* in AppBindData can be safely assumed to be up to date
*/
applyConfigurationToResourcesLocked(data.config, data.compatInfo);
- applyCompatConfiguration();
+ mCurDefaultDisplayDpi = data.config.densityDpi;
+ applyCompatConfiguration(mCurDefaultDisplayDpi);
data.info = getPackageInfoNoCheck(data.appInfo, data.compatInfo);