cordova.plugins.diagnostic 7.2.2 → 7.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # CHANGELOG
2
2
 
3
+ **v7.2.3**
4
+ * (android) bugfix: dynamically resolve BuildConfig class (and remove hard-coded example app package name) when determining isDebugBuild()
5
+
3
6
  **v7.2.2**
4
7
  * (ios & android) feat: add isDebugBuild()
5
8
  * fix: Separate isMobileDataEnabled() for Android vs isMobileDataAuthorized() for iOS.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "7.2.2",
2
+ "version": "7.2.3",
3
3
  "name": "cordova.plugins.diagnostic",
4
4
  "cordova_name": "Diagnostic",
5
5
  "description": "Cordova/Phonegap plugin to check the state of Location/WiFi/Camera/Bluetooth device settings.",
package/plugin.xml CHANGED
@@ -2,7 +2,7 @@
2
2
  <plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
3
3
  xmlns:android="http://schemas.android.com/apk/res/android"
4
4
  id="cordova.plugins.diagnostic"
5
- version="7.2.2">
5
+ version="7.2.3">
6
6
 
7
7
  <name>Diagnostic</name>
8
8
  <description>Cordova/Phonegap plugin to check the state of Location/WiFi/Camera/Bluetooth device settings.</description>
@@ -64,7 +64,8 @@ import android.view.accessibility.AccessibilityManager;
64
64
 
65
65
  import androidx.core.app.ActivityCompat;
66
66
 
67
- import cordova.plugins.diagnostic.example.BuildConfig;
67
+ import static android.content.Context.CONTEXT_INCLUDE_CODE;
68
+ import static android.content.Context.CONTEXT_IGNORE_SECURITY;
68
69
 
69
70
  /**
70
71
  * Diagnostic plugin implementation for Android
@@ -546,8 +547,11 @@ public class Diagnostic extends CordovaPlugin{
546
547
  return result;
547
548
  }
548
549
 
549
- private boolean isDebugBuild() {
550
- boolean result = BuildConfig.DEBUG;
550
+ private boolean isDebugBuild() throws Exception {
551
+ Context context = this.cordova.getActivity().getApplicationContext();
552
+ ClassLoader classLoader = context.createPackageContext(context.getPackageName(), CONTEXT_INCLUDE_CODE | CONTEXT_IGNORE_SECURITY).getClassLoader();
553
+ Class<?> buildConfigClass = classLoader.loadClass(context.getPackageName() + ".BuildConfig");
554
+ boolean result = buildConfigClass.getField("DEBUG").getBoolean(null);
551
555
  logDebug("Debug build: " + result);
552
556
  return result;
553
557
  }