Android: Increase minimum API level to Android-23 / Android 6

There are certain APIs we need which cannot be used without this,
and in general it simplifies some code.

[ChangeLog][Android] Minimum Android version is now Android 6.0,
API level 23.

Change-Id: I72ca3b429bf48969e16e2bc6b99d9c4af993ea77
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2020-01-16 09:03:56 +01:00
parent b4e17a4864
commit 5f1afeacf6
7 changed files with 12 additions and 24 deletions

View File

@ -625,7 +625,7 @@ defineTest(qtConfOutput_prepareOptions) {
android_abis = armeabi-v7a,arm64-v8a,x86,x86_64 android_abis = armeabi-v7a,arm64-v8a,x86,x86_64
platform = $$eval(config.input.android-ndk-platform) platform = $$eval(config.input.android-ndk-platform)
isEmpty(platform): \ isEmpty(platform): \
platform = android-21 platform = android-23
$${currentConfig}.output.devicePro += \ $${currentConfig}.output.devicePro += \
"DEFAULT_ANDROID_SDK_ROOT = $$val_escape(sdk_root)" \ "DEFAULT_ANDROID_SDK_ROOT = $$val_escape(sdk_root)" \

View File

@ -1,6 +1,6 @@
API_VERSION_TO_USE = $$(ANDROID_API_VERSION) API_VERSION_TO_USE = $$(ANDROID_API_VERSION)
isEmpty(API_VERSION_TO_USE): API_VERSION_TO_USE = $$API_VERSION isEmpty(API_VERSION_TO_USE): API_VERSION_TO_USE = $$API_VERSION
isEmpty(API_VERSION_TO_USE): API_VERSION_TO_USE = android-21 isEmpty(API_VERSION_TO_USE): API_VERSION_TO_USE = android-23
ANDROID_JAR_FILE = $$ANDROID_SDK_ROOT/platforms/$$API_VERSION_TO_USE/android.jar ANDROID_JAR_FILE = $$ANDROID_SDK_ROOT/platforms/$$API_VERSION_TO_USE/android.jar
!exists($$ANDROID_JAR_FILE) { !exists($$ANDROID_JAR_FILE) {

View File

@ -673,7 +673,7 @@ public class ExtractStyle {
json.put("gradient",gradientStateClass.getField("mGradient").getInt(obj)); json.put("gradient",gradientStateClass.getField("mGradient").getInt(obj));
GradientDrawable.Orientation orientation=(Orientation) gradientStateClass.getField("mOrientation").get(obj); GradientDrawable.Orientation orientation=(Orientation) gradientStateClass.getField("mOrientation").get(obj);
json.put("orientation",orientation.name()); json.put("orientation",orientation.name());
int [] intArray=(int[]) gradientStateClass.getField((Build.VERSION.SDK_INT < 23) ? "mColors" : "mGradientColors").get(obj); int [] intArray=(int[]) gradientStateClass.getField("mGradientColors").get(obj);
if (intArray != null) if (intArray != null)
json.put("colors",getJsonArray(intArray, 0, intArray.length)); json.put("colors",getJsonArray(intArray, 0, intArray.length));
json.put("positions",getJsonArray((float[]) gradientStateClass.getField("mPositions").get(obj))); json.put("positions",getJsonArray((float[]) gradientStateClass.getField("mPositions").get(obj)));
@ -1089,9 +1089,7 @@ public class ExtractStyle {
{ {
try { try {
InsetDrawable d = (InsetDrawable)drawable; InsetDrawable d = (InsetDrawable)drawable;
// mInsetState changed to mState in Android 5.1 (22) Object mInsetStateObject = getAccessibleField(InsetDrawable.class, "mState").get(d);
Object mInsetStateObject = getAccessibleField(InsetDrawable.class, (Build.VERSION.SDK_INT > 21) ? "mState"
: "mInsetState").get(d);
Rect _padding = new Rect(); Rect _padding = new Rect();
boolean hasPadding = d.getPadding(_padding); boolean hasPadding = d.getPadding(_padding);
return getDrawable(getAccessibleField(mInsetStateObject.getClass(), "mDrawable").get(mInsetStateObject), filename, hasPadding ? _padding : null); return getDrawable(getAccessibleField(mInsetStateObject.getClass(), "mDrawable").get(mInsetStateObject), filename, hasPadding ? _padding : null);

View File

@ -704,14 +704,9 @@ public class QtNative
synchronized (m_mainActivityMutex) { synchronized (m_mainActivityMutex) {
Context context = getContext(); Context context = getContext();
try { try {
if (Build.VERSION.SDK_INT >= 23) { if (m_checkSelfPermissionMethod == null)
if (m_checkSelfPermissionMethod == null) m_checkSelfPermissionMethod = Context.class.getMethod("checkSelfPermission", String.class);
m_checkSelfPermissionMethod = Context.class.getMethod("checkSelfPermission", String.class); perm = (Integer)m_checkSelfPermissionMethod.invoke(context, permission);
perm = (Integer)m_checkSelfPermissionMethod.invoke(context, permission);
} else {
final PackageManager pm = context.getPackageManager();
perm = pm.checkPermission(permission, context.getApplicationContext().getPackageName());
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -93,13 +93,8 @@ public class QtActivity extends Activity
public QtActivity() public QtActivity()
{ {
m_loader = new QtActivityLoader(this); m_loader = new QtActivityLoader(this);
if (Build.VERSION.SDK_INT >= 21) { QT_ANDROID_THEMES = new String[] {"Theme_Holo_Light"};
QT_ANDROID_THEMES = new String[] {"Theme_Holo_Light"}; QT_ANDROID_DEFAULT_THEME = "Theme_Holo_Light";
QT_ANDROID_DEFAULT_THEME = "Theme_Holo_Light";
} else {
QT_ANDROID_THEMES = new String[] {"Theme_DeviceDefault_Light"};
QT_ANDROID_DEFAULT_THEME = "Theme_DeviceDefault_Light";
}
} }

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<manifest package="org.qtproject.example" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="-- %%INSERT_VERSION_NAME%% --" android:versionCode="-- %%INSERT_VERSION_CODE%% --" android:installLocation="auto"> <manifest package="org.qtproject.example" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="-- %%INSERT_VERSION_NAME%% --" android:versionCode="-- %%INSERT_VERSION_CODE%% --" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28"/> <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="28"/>
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application. <!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
Remove the comment if you do not require these default permissions. --> Remove the comment if you do not require these default permissions. -->

View File

@ -1425,8 +1425,8 @@ bool updateAndroidManifest(Options &options)
options.packageName = reader.attributes().value(QLatin1String("package")).toString(); options.packageName = reader.attributes().value(QLatin1String("package")).toString();
} else if (reader.name() == QLatin1String("uses-sdk")) { } else if (reader.name() == QLatin1String("uses-sdk")) {
if (reader.attributes().hasAttribute(QLatin1String("android:minSdkVersion"))) if (reader.attributes().hasAttribute(QLatin1String("android:minSdkVersion")))
if (reader.attributes().value(QLatin1String("android:minSdkVersion")).toInt() < 21) { if (reader.attributes().value(QLatin1String("android:minSdkVersion")).toInt() < 23) {
fprintf(stderr, "Invalid minSdkVersion version, minSdkVersion must be >= 21\n"); fprintf(stderr, "Invalid minSdkVersion version, minSdkVersion must be >= 23\n");
return false; return false;
} }
} else if ((reader.name() == QLatin1String("application") || } else if ((reader.name() == QLatin1String("application") ||