]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wpadebug: Add activity to select method for QR Code scanning
authorAnurag Das <anurdas@codeaurora.org>
Fri, 23 Feb 2018 10:14:02 +0000 (15:44 +0530)
committerJouni Malinen <j@w1.fi>
Fri, 23 Feb 2018 13:37:49 +0000 (15:37 +0200)
Add QrCodeReadActivity that makes a decision to select between InputUri
and QrCodeScannerActivity depending on the availability of the camera in
the device.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
wpadebug/AndroidManifest.xml
wpadebug/src/w1/fi/wpadebug/QrCodeReadActivity.java [new file with mode: 0644]

index 6c7157af5022d0837365f32325dcc9d48d7aa8f5..3c8b9b9881597f59ae36852cf33109b9521f39d5 100644 (file)
                  android:label="Input URI"
                  android:parentActivityName="w1.fi.wpadebug.MainActivity">
        </activity>
+       <activity
+                 android:name="w1.fi.wpadebug.QrCodeReadActivity"
+                 android:label="Start Scan"
+                android:parentActivityName="w1.fi.wpadebug.MainActivity">
+       </activity>
        <activity android:name="w1.fi.wpadebug.WpaWebViewActivity"
                  android:label="WebView"
                  android:launchMode="singleTop"
diff --git a/wpadebug/src/w1/fi/wpadebug/QrCodeReadActivity.java b/wpadebug/src/w1/fi/wpadebug/QrCodeReadActivity.java
new file mode 100644 (file)
index 0000000..f21eccb
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * wpadebug - wpa_supplicant and Wi-Fi debugging app for Android
+ * Copyright (c) 2018, The Linux Foundation
+ *
+ * This software may be distributed under the terms of the BSD license.
+ * See README for more details.
+ */
+
+package w1.fi.wpadebug;
+
+import android.app.Activity;
+import android.util.Log;
+import android.content.Intent;
+import android.hardware.Camera;
+import android.os.Bundle;
+
+public class QrCodeReadActivity extends Activity {
+
+    private static final String TAG = "wpadebug";
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        int numberOfCameras = Camera.getNumberOfCameras();
+
+        if (numberOfCameras > 0) {
+            Log.e(TAG, "Number of cameras found: " + numberOfCameras);
+            Intent QrCodeScanIntent = new Intent(QrCodeReadActivity.this,
+                                                QrCodeScannerActivity.class);
+            QrCodeReadActivity.this.startActivity(QrCodeScanIntent);
+            finish();
+        } else {
+            Log.e(TAG, "No cameras found, input the QR Code");
+            Intent QrCodeInputIntent = new Intent(QrCodeReadActivity.this,
+                                                 InputUri.class);
+            QrCodeReadActivity.this.startActivity(QrCodeInputIntent);
+            finish();
+        }
+    }
+}