@capgo/capacitor-document-scanner 8.3.2 → 8.3.4
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.
|
@@ -10,6 +10,7 @@ import android.graphics.ColorMatrix;
|
|
|
10
10
|
import android.graphics.ColorMatrixColorFilter;
|
|
11
11
|
import android.graphics.Paint;
|
|
12
12
|
import android.net.Uri;
|
|
13
|
+
import android.os.Build;
|
|
13
14
|
import android.util.Base64;
|
|
14
15
|
import androidx.activity.result.ActivityResult;
|
|
15
16
|
import androidx.activity.result.ActivityResultLauncher;
|
|
@@ -92,6 +93,16 @@ public class DocumentScannerPlugin extends Plugin {
|
|
|
92
93
|
return;
|
|
93
94
|
}
|
|
94
95
|
|
|
96
|
+
// Check if running on emulator
|
|
97
|
+
if (isRunningOnEmulator()) {
|
|
98
|
+
call.reject(
|
|
99
|
+
"Document scanner is not supported on Android emulators. " +
|
|
100
|
+
"The ML Kit Document Scanner requires a physical device with a hardware camera. " +
|
|
101
|
+
"Please test on a real Android device."
|
|
102
|
+
);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
95
106
|
Activity activity = getActivity();
|
|
96
107
|
if (activity == null) {
|
|
97
108
|
call.reject("Activity reference is unavailable.");
|
|
@@ -393,6 +404,33 @@ public class DocumentScannerPlugin extends Plugin {
|
|
|
393
404
|
}
|
|
394
405
|
}
|
|
395
406
|
|
|
407
|
+
/**
|
|
408
|
+
* Detects if the app is running on an Android emulator.
|
|
409
|
+
* Uses multiple heuristics to reliably detect emulator environments.
|
|
410
|
+
* @return true if running on an emulator, false otherwise
|
|
411
|
+
*/
|
|
412
|
+
private boolean isRunningOnEmulator() {
|
|
413
|
+
String model = Build.MODEL.toLowerCase(Locale.ROOT);
|
|
414
|
+
String product = Build.PRODUCT.toLowerCase(Locale.ROOT);
|
|
415
|
+
String fingerprint = Build.FINGERPRINT.toLowerCase(Locale.ROOT);
|
|
416
|
+
String manufacturer = Build.MANUFACTURER.toLowerCase(Locale.ROOT);
|
|
417
|
+
String brand = Build.BRAND.toLowerCase(Locale.ROOT);
|
|
418
|
+
String device = Build.DEVICE.toLowerCase(Locale.ROOT);
|
|
419
|
+
|
|
420
|
+
return (
|
|
421
|
+
fingerprint.startsWith("generic") ||
|
|
422
|
+
fingerprint.startsWith("unknown") ||
|
|
423
|
+
model.contains("google_sdk") ||
|
|
424
|
+
model.contains("emulator") ||
|
|
425
|
+
model.contains("android sdk built for x86") ||
|
|
426
|
+
manufacturer.contains("genymotion") ||
|
|
427
|
+
(brand.startsWith("generic") && device.startsWith("generic")) ||
|
|
428
|
+
"google_sdk".equals(product) ||
|
|
429
|
+
product.contains("sdk_gphone") ||
|
|
430
|
+
product.contains("emulator")
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
|
|
396
434
|
@PluginMethod
|
|
397
435
|
public void getPluginVersion(final PluginCall call) {
|
|
398
436
|
try {
|
|
@@ -3,7 +3,7 @@ import Foundation
|
|
|
3
3
|
|
|
4
4
|
@objc(DocumentScannerPlugin)
|
|
5
5
|
public class DocumentScannerPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
6
|
-
private let pluginVersion: String = "8.3.
|
|
6
|
+
private let pluginVersion: String = "8.3.4"
|
|
7
7
|
public let identifier = "DocumentScannerPlugin"
|
|
8
8
|
public let jsName = "DocumentScanner"
|
|
9
9
|
public let pluginMethods: [CAPPluginMethod] = [
|