summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@qt.io>2018-09-26 13:53:27 +0200
committerChristian Stromme <christian.stromme@qt.io>2018-10-08 11:14:01 +0000
commit52813712c4a93f4e0e9e8de47f4c7fc1d8838f29 (patch)
tree4c1b9465fa604182e895a7e228e31d765dea1a03
parent1170e707b7672642aadaf8103829a783713ae487 (diff)
Default to no style extraction on Android P when the target SDK is < 28
Applications with target SDK version lower then 28 running on a device with version greater or equal to 28 will cause compatibility warnings, so default to none when the extract_android_style value is set to default. Note that the new value "default" was introduced to allow this kind of changes in the future, i.e., selecting the best solution based on some simple heuristics. Adding a new value also keep compatibility and allows the user to explicitly set a value when needed. Task-number: QTBUG-69810 Change-Id: I68301716767870ce6de40e45742d9c5fc263ee25 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
-rw-r--r--src/android/java/src/org/qtproject/qt5/android/bindings/QtLoader.java20
-rw-r--r--src/android/templates/AndroidManifest.xml3
2 files changed, 18 insertions, 5 deletions
diff --git a/src/android/java/src/org/qtproject/qt5/android/bindings/QtLoader.java b/src/android/java/src/org/qtproject/qt5/android/bindings/QtLoader.java
index fc3d7e04ce..7826527918 100644
--- a/src/android/java/src/org/qtproject/qt5/android/bindings/QtLoader.java
+++ b/src/android/java/src/org/qtproject/qt5/android/bindings/QtLoader.java
@@ -46,6 +46,7 @@ import android.content.ServiceConnection;
import android.content.pm.ComponentInfo;
import android.content.pm.PackageInfo;
import android.content.res.AssetManager;
+import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
@@ -651,15 +652,26 @@ public abstract class QtLoader {
String themePath = m_context.getApplicationInfo().dataDir + "/qt-reserved-files/android-style/";
String stylePath = themePath + m_displayDensity + "/";
- String extractOption = "full";
+ String extractOption = "default";
if (m_contextInfo.metaData.containsKey("android.app.extract_android_style")) {
extractOption = m_contextInfo.metaData.getString("android.app.extract_android_style");
- if (!extractOption.equals("full") && !extractOption.equals("minimal") && !extractOption.equals("none")) {
- Log.e(QtApplication.QtTAG, "Invalid extract_android_style option \"" + extractOption + "\", defaulting to full");
- extractOption = "full";
+ if (!extractOption.equals("default") && !extractOption.equals("full") && !extractOption.equals("minimal") && !extractOption.equals("none")) {
+ Log.e(QtApplication.QtTAG, "Invalid extract_android_style option \"" + extractOption + "\", defaulting to \"default\"");
+ extractOption = "default";
}
}
+ // QTBUG-69810: The extraction code will trigger compatibility warnings on Android SDK version >= 28
+ // when the target SDK version is set to something lower then 28, so default to "none" and issue a warning
+ // if that is the case.
+ if (extractOption.equals("default")) {
+ final int targetSdkVersion = m_context.getApplicationInfo().targetSdkVersion;
+ if (targetSdkVersion < 28 && Build.VERSION.SDK_INT >= 28) {
+ Log.e(QtApplication.QtTAG, "extract_android_style option set to \"none\" when targetSdkVersion is less then 28");
+ extractOption = "none";
+ }
+ }
+
if (!(new File(stylePath)).exists() && !extractOption.equals("none")) {
loaderParams.putString(EXTRACT_STYLE_KEY, stylePath);
loaderParams.putBoolean(EXTRACT_STYLE_MINIMAL_KEY, extractOption.equals("minimal"));
diff --git a/src/android/templates/AndroidManifest.xml b/src/android/templates/AndroidManifest.xml
index c9eff264c4..44c2b519cf 100644
--- a/src/android/templates/AndroidManifest.xml
+++ b/src/android/templates/AndroidManifest.xml
@@ -57,11 +57,12 @@
<!-- extract android style -->
<!-- available android:values :
+ * default - In most cases this will be the same as "full", but it can also be something else if needed, e.g., for compatibility reasons
* full - useful QWidget & Quick Controls 1 apps
* minimal - useful for Quick Controls 2 apps, it is much faster than "full"
* none - useful for apps that don't use any of the above Qt modules
-->
- <meta-data android:name="android.app.extract_android_style" android:value="full"/>
+ <meta-data android:name="android.app.extract_android_style" android:value="default"/>
<!-- extract android style -->
</activity>