aboutsummaryrefslogtreecommitdiffstats
path: root/wpadebug
diff options
context:
space:
mode:
authorAnurag Das <anurdas@codeaurora.org>2018-02-21 12:35:33 (GMT)
committerJouni Malinen <j@w1.fi>2018-02-22 12:42:05 (GMT)
commit8b244b00098fe57bdee4a88b5878de9ca72825c2 (patch)
treef519173b683f1c853f4cb34fcf4ac56a241373ea /wpadebug
parent0b851ec75228a7b2919c853ef89bdb67c6d4a2e3 (diff)
downloadhostap-8b244b00098fe57bdee4a88b5878de9ca72825c2.zip
hostap-8b244b00098fe57bdee4a88b5878de9ca72825c2.tar.gz
hostap-8b244b00098fe57bdee4a88b5878de9ca72825c2.tar.bz2
wpadebug: A dialog activity to input the URI from QR Code Scanner
This should help to read the URI from the QR Code Scanner's (USB HID devices instead of USB video device) that decodes the QR Code. This dialog box provisions the mechanism to enter the decoded URI code from such hardware devices. This dialog can be used with: am start -n w1.fi.wpadebug/w1.fi.wpadebug.InputUri Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
Diffstat (limited to 'wpadebug')
-rw-r--r--wpadebug/AndroidManifest.xml5
-rw-r--r--wpadebug/res/layout/input_uri.xml26
-rw-r--r--wpadebug/src/w1/fi/wpadebug/InputUri.java84
3 files changed, 115 insertions, 0 deletions
diff --git a/wpadebug/AndroidManifest.xml b/wpadebug/AndroidManifest.xml
index f72a653..6c7157a 100644
--- a/wpadebug/AndroidManifest.xml
+++ b/wpadebug/AndroidManifest.xml
@@ -54,6 +54,11 @@
android:label="QR Code Display"
android:parentActivityName="w1.fi.wpadebug.MainActivity">
</activity>
+ <activity
+ android:name="w1.fi.wpadebug.InputUri"
+ android:label="Input URI"
+ android:parentActivityName="w1.fi.wpadebug.MainActivity">
+ </activity>
<activity android:name="w1.fi.wpadebug.WpaWebViewActivity"
android:label="WebView"
android:launchMode="singleTop"
diff --git a/wpadebug/res/layout/input_uri.xml b/wpadebug/res/layout/input_uri.xml
new file mode 100644
index 0000000..ab391fb
--- /dev/null
+++ b/wpadebug/res/layout/input_uri.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="w1.fi.wpadebug.InputUri">
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:gravity="center"
+ android:orientation="vertical"
+ android:layout_margin="30dp"
+ android:layout_height="wrap_content">
+
+ <EditText
+ android:id="@+id/edit_uri"
+ android:layout_width="match_parent"
+ android:layout_height="130dp" />
+
+ <Button
+ android:id="@+id/submit_uri"
+ android:layout_width="wrap_content"
+ android:text="Submit"
+ android:layout_height="wrap_content" />
+ </LinearLayout>
+</LinearLayout>
diff --git a/wpadebug/src/w1/fi/wpadebug/InputUri.java b/wpadebug/src/w1/fi/wpadebug/InputUri.java
new file mode 100644
index 0000000..a7c5131
--- /dev/null
+++ b/wpadebug/src/w1/fi/wpadebug/InputUri.java
@@ -0,0 +1,84 @@
+/*
+ * 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.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.util.Log;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+
+public class InputUri extends Activity {
+
+ private EditText mEditText;
+ private Button mSubmitButton;
+ private String mUriText;
+ private static final String FILE_NAME = "wpadebug_qrdata.txt";
+ private static final String TAG = "wpadebug";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.input_uri);
+ mEditText = (EditText)findViewById(R.id.edit_uri);
+ mSubmitButton = (Button)findViewById(R.id.submit_uri);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ mSubmitButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ mUriText = mEditText.getText().toString();
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ writeToFile(mUriText);
+
+ InputUri.this.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ finish();
+ }
+ });
+ }
+ }).start();
+
+ }
+
+ });
+ }
+
+ public void writeToFile(String data)
+ {
+ File file = new File("/sdcard", FILE_NAME);
+ try
+ {
+ file.createNewFile();
+ FileOutputStream fOut = new FileOutputStream(file);
+ OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut);
+ myOutWriter.append(mUriText);
+ myOutWriter.close();
+
+ fOut.flush();
+ fOut.close();
+ }
+ catch (IOException e)
+ {
+ Log.e(TAG, "File write failed: " + e.toString());
+ }
+ }
+}