From 3a9c87d3b853c203b79b25b006df05c878097c7e Mon Sep 17 00:00:00 2001 From: Norman Breau Date: Fri, 14 Apr 2023 06:47:03 -0300 Subject: [PATCH 1/4] fix(test): Native test namespace refactor (#1595) --- test/androidx/app/build.gradle | 2 ++ test/androidx/app/src/main/AndroidManifest.xml | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/test/androidx/app/build.gradle b/test/androidx/app/build.gradle index c1eff500..05d93b91 100644 --- a/test/androidx/app/build.gradle +++ b/test/androidx/app/build.gradle @@ -24,6 +24,8 @@ android { compileSdkVersion cordovaConfig.COMPILE_SDK_VERSION buildToolsVersion cordovaConfig.BUILD_TOOLS_VERSION + namespace 'org.apache.cordova.unittests' + defaultConfig { applicationId "org.apache.cordova.unittests" minSdkVersion cordovaConfig.MIN_SDK_VERSION diff --git a/test/androidx/app/src/main/AndroidManifest.xml b/test/androidx/app/src/main/AndroidManifest.xml index a6ca5c41..a8abd7a5 100644 --- a/test/androidx/app/src/main/AndroidManifest.xml +++ b/test/androidx/app/src/main/AndroidManifest.xml @@ -17,8 +17,7 @@ specific language governing permissions and limitations under the License. --> - + Date: Fri, 14 Apr 2023 07:17:15 -0300 Subject: [PATCH 2/4] feat: bump default kotlin to version 1.7.21 (#1594) The rationale is based on the Gradle Compatibility Matrix: https://docs.gradle.org/current/userguide/compatibility.html 1.7.21 is the current latest version of the 1.7 Kotlin release. --- framework/cdv-gradle-config-defaults.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/cdv-gradle-config-defaults.json b/framework/cdv-gradle-config-defaults.json index 605b9989..6ccf469e 100644 --- a/framework/cdv-gradle-config-defaults.json +++ b/framework/cdv-gradle-config-defaults.json @@ -5,7 +5,7 @@ "GRADLE_VERSION": "7.6", "MIN_BUILD_TOOLS_VERSION": "33.0.2", "AGP_VERSION": "7.4.2", - "KOTLIN_VERSION": "1.5.21", + "KOTLIN_VERSION": "1.7.21", "ANDROIDX_APP_COMPAT_VERSION": "1.6.1", "ANDROIDX_WEBKIT_VERSION": "1.6.0", "ANDROIDX_CORE_SPLASHSCREEN_VERSION": "1.0.0", From 5b546a27e62ec9c5569353fff8661361236cdb95 Mon Sep 17 00:00:00 2001 From: Norman Breau Date: Fri, 14 Apr 2023 10:15:09 -0300 Subject: [PATCH 3/4] deprecate: CoreAndroid.getBuildConfigValue (#1597) --- .../src/org/apache/cordova/CoreAndroid.java | 29 +++++-------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/framework/src/org/apache/cordova/CoreAndroid.java b/framework/src/org/apache/cordova/CoreAndroid.java index 6ebdecb3..ea04ca4d 100755 --- a/framework/src/org/apache/cordova/CoreAndroid.java +++ b/framework/src/org/apache/cordova/CoreAndroid.java @@ -19,6 +19,8 @@ package org.apache.cordova; +import org.apache.cordova.BuildHelper; + import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -30,7 +32,6 @@ import android.content.IntentFilter; import android.telephony.TelephonyManager; import android.view.KeyEvent; -import java.lang.reflect.Field; import java.util.HashMap; /** @@ -376,35 +377,19 @@ public class CoreAndroid extends CordovaPlugin { } } - /* + /* * This needs to be implemented if you wish to use the Camera Plugin or other plugins * that read the Build Configuration. * * Thanks to Phil@Medtronic and Graham Borland for finding the answer and posting it to * StackOverflow. This is annoying as hell! * + * @deprecated Use {@link BuildHelper#getBuildConfigValue} instead. */ - + @Deprecated public static Object getBuildConfigValue(Context ctx, String key) { - try - { - Class clazz = Class.forName(ctx.getClass().getPackage().getName() + ".BuildConfig"); - Field field = clazz.getField(key); - return field.get(null); - } catch (ClassNotFoundException e) { - LOG.d(TAG, "Unable to get the BuildConfig, is this built with ANT?"); - e.printStackTrace(); - } catch (NoSuchFieldException e) { - LOG.d(TAG, key + " is not a valid field. Check your build.gradle"); - } catch (IllegalAccessException e) { - LOG.d(TAG, "Illegal Access Exception: Let's print a stack trace."); - e.printStackTrace(); - } catch (NullPointerException e) { - LOG.d(TAG, "Null Pointer Exception: Let's print a stack trace."); - e.printStackTrace(); - } - - return null; + LOG.w(TAG, "CoreAndroid.getBuildConfigValue is deprecated and will be removed in a future release. Use BuildHelper.getBuildConfigValue instead."); + return BuildHelper.getBuildConfigValue(ctx, key); } } From 7efe90faac3219b9991f6a6f622ba7d561b279cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=96=BB=E5=BF=97=E5=BC=BA?= Date: Fri, 14 Apr 2023 21:15:55 +0800 Subject: [PATCH 4/4] fix(BuildHelper): get package name from ApplicationInfo (#1575) --- framework/src/org/apache/cordova/BuildHelper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/framework/src/org/apache/cordova/BuildHelper.java b/framework/src/org/apache/cordova/BuildHelper.java index 94fe9612..2899ee2a 100644 --- a/framework/src/org/apache/cordova/BuildHelper.java +++ b/framework/src/org/apache/cordova/BuildHelper.java @@ -51,7 +51,8 @@ public class BuildHelper { { try { - Class clazz = Class.forName(ctx.getClass().getPackage().getName() + ".BuildConfig"); + String packageName = ctx.getApplicationInfo().packageName; + Class clazz = Class.forName(packageName + ".BuildConfig"); Field field = clazz.getField(key); return field.get(null); } catch (ClassNotFoundException e) {