Fix issue #5348948: Third Party app "Byki Turkish" shows...
...a tiny dialog (works fine in GB and HC)
I found two problems:
- When first binding an application, we were not correctly computing
the compat configuration.
- When retrieving the display metrics to hand to Resources, we were
using the one with compat applied. This is not right, because
Resources will apply the compat itself, so in some cases the compat
scaling was applied twice.
Change-Id: I22c9cfed9e271290c1a7544fa3ffa54a2e65daf9
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 99aae37..d2facdc 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -1478,7 +1478,7 @@
}
//Slog.i(TAG, "Resource: key=" + key + ", display metrics=" + metrics);
- DisplayMetrics metrics = getDisplayMetricsLocked(compInfo, false);
+ DisplayMetrics metrics = getDisplayMetricsLocked(null, false);
r = new Resources(assets, metrics, getConfiguration(), compInfo);
if (false) {
Slog.i(TAG, "Created app resources " + resDir + " " + r + ": "
@@ -3476,7 +3476,7 @@
return false;
}
int changes = mResConfiguration.updateFrom(config);
- DisplayMetrics dm = getDisplayMetricsLocked(compat, true);
+ DisplayMetrics dm = getDisplayMetricsLocked(null, true);
if (compat != null && (mResCompatibilityInfo == null ||
!mResCompatibilityInfo.equals(compat))) {
@@ -3517,7 +3517,20 @@
return changes != 0;
}
-
+
+ final Configuration applyCompatConfiguration() {
+ Configuration config = mConfiguration;
+ if (mCompatConfiguration == null) {
+ mCompatConfiguration = new Configuration();
+ }
+ mCompatConfiguration.setTo(mConfiguration);
+ if (mResCompatibilityInfo != null && !mResCompatibilityInfo.supportsScreen()) {
+ mResCompatibilityInfo.applyToConfiguration(mCompatConfiguration);
+ config = mCompatConfiguration;
+ }
+ return config;
+ }
+
final void handleConfigurationChanged(Configuration config, CompatibilityInfo compat) {
ArrayList<ComponentCallbacks2> callbacks = null;
@@ -3546,14 +3559,7 @@
return;
}
mConfiguration.updateFrom(config);
- if (mCompatConfiguration == null) {
- mCompatConfiguration = new Configuration();
- }
- mCompatConfiguration.setTo(mConfiguration);
- if (mResCompatibilityInfo != null && !mResCompatibilityInfo.supportsScreen()) {
- mResCompatibilityInfo.applyToConfiguration(mCompatConfiguration);
- config = mCompatConfiguration;
- }
+ config = applyCompatConfiguration();
callbacks = collectComponentCallbacksLocked(false, config);
}
@@ -3752,6 +3758,7 @@
* in AppBindData can be safely assumed to be up to date
*/
applyConfigurationToResourcesLocked(data.config, data.compatInfo);
+ applyCompatConfiguration();
data.info = getPackageInfoNoCheck(data.appInfo, data.compatInfo);