aboutsummaryrefslogtreecommitdiffstats
path: root/wpadebug
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2013-05-11 18:01:46 (GMT)
committerJouni Malinen <j@w1.fi>2013-05-12 16:18:55 (GMT)
commit0db66360d8319e301a79b1669efeb6d13196eb53 (patch)
treed2fa69da08a7828bdd390ecb28fc2a5908b7677b /wpadebug
parent280cd8a9a2447524ca34c8e51c098c88d8d3c508 (diff)
downloadhostap-0db66360d8319e301a79b1669efeb6d13196eb53.zip
hostap-0db66360d8319e301a79b1669efeb6d13196eb53.tar.gz
hostap-0db66360d8319e301a79b1669efeb6d13196eb53.tar.bz2
wpadebug: Add a simple WebView activity
This provides a simple web browser that can be started and stopped from other apps or native applications. This activity can be started with the following command: am start -a android.action.MAIN -c android.intent.category.LAUNCHER \ -n w1.fi.wpadebug/.WpaWebViewActivity -e w1.fi.wpadebug.URL <URL> If <URL> is set to FINISH the activity is finished. Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wpadebug')
-rw-r--r--wpadebug/AndroidManifest.xml9
-rw-r--r--wpadebug/src/w1/fi/wpadebug/WpaWebViewActivity.java114
2 files changed, 123 insertions, 0 deletions
diff --git a/wpadebug/AndroidManifest.xml b/wpadebug/AndroidManifest.xml
index 56f80aa..e939d24 100644
--- a/wpadebug/AndroidManifest.xml
+++ b/wpadebug/AndroidManifest.xml
@@ -7,6 +7,7 @@
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
+ <uses-permission android:name="android.permission.INTERNET" />
<application android:label="wpadebug">
<activity android:name="w1.fi.wpadebug.MainActivity"
android:label="wpadebug">
@@ -44,5 +45,13 @@
android:label="Credential"
android:parentActivityName="w1.fi.wpadebug.WpaCredActivity">
</activity>
+ <activity android:name="w1.fi.wpadebug.WpaWebViewActivity"
+ android:label="WebView"
+ android:launchMode="singleTop"
+ android:noHistory="true">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ </intent-filter>
+ </activity>
</application>
</manifest>
diff --git a/wpadebug/src/w1/fi/wpadebug/WpaWebViewActivity.java b/wpadebug/src/w1/fi/wpadebug/WpaWebViewActivity.java
new file mode 100644
index 0000000..7046439
--- /dev/null
+++ b/wpadebug/src/w1/fi/wpadebug/WpaWebViewActivity.java
@@ -0,0 +1,114 @@
+/*
+ * wpadebug - wpa_supplicant and Wi-Fi debugging app for Android
+ * Copyright (c) 2013, Jouni Malinen <j@w1.fi>
+ *
+ * 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.content.Intent;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.Window;
+import android.webkit.WebChromeClient;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
+import android.widget.Toast;
+
+public class WpaWebViewActivity extends Activity
+{
+ private static final String TAG = "wpadebug";
+ private static final String EXTRA_MESSAGE = "w1.fi.wpadebug.URL";
+ private WebView mWebView;
+ final Activity activity = this;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ Log.d(TAG, "WpaWebViewActivity::onCreate");
+ super.onCreate(savedInstanceState);
+
+ Intent intent = getIntent();
+ String url = intent.getStringExtra(EXTRA_MESSAGE);
+ Log.d(TAG, "url=" + url);
+ if (url.equals("FINISH")) {
+ finish();
+ return;
+ }
+
+ mWebView = new WebView(this);
+ mWebView.getSettings().setJavaScriptEnabled(true);
+ mWebView.setWebViewClient(new WpaWebViewClient());
+
+ getWindow().requestFeature(Window.FEATURE_PROGRESS);
+
+ mWebView.setWebChromeClient(new WebChromeClient()
+ {
+ public void onProgressChanged(WebView view, int progress)
+ {
+ Log.d(TAG, "progress=" + progress);
+ activity.setProgress(progress * 1000);
+ }
+ });
+
+ setContentView(mWebView);
+
+ mWebView.loadUrl(url);
+ }
+
+ @Override
+ public void onResume()
+ {
+ Log.d(TAG, "WpaWebViewActivity::onResume");
+ super.onResume();
+ }
+
+ @Override
+ protected void onNewIntent(Intent intent)
+ {
+ Log.d(TAG, "WpaWebViewActivity::onNewIntent");
+ super.onNewIntent(intent);
+ String url = intent.getStringExtra(EXTRA_MESSAGE);
+ Log.d(TAG, "url=" + url);
+ setIntent(intent);
+ if (url.equals("FINISH")) {
+ finish();
+ return;
+ }
+ mWebView.loadUrl(url);
+ }
+
+ private class WpaWebViewClient extends WebViewClient {
+ @Override
+ public boolean shouldOverrideUrlLoading(WebView view, String url)
+ {
+ Log.d(TAG, "shouldOverrideUrlLoading: url=" + url);
+ Intent intent = getIntent();
+ intent.putExtra(EXTRA_MESSAGE, url);
+
+ view.loadUrl(url);
+ return true;
+ }
+
+ @Override
+ public void onPageFinished(WebView view, String url)
+ {
+ Log.d(TAG, "onPageFinished: url=" + url);
+ }
+
+ public void onReceivedError(WebView view, int errorCode,
+ String description, String failingUrl)
+ {
+ Log.d(TAG, "Failed to load page: errorCode=" +
+ errorCode + " description=" + description +
+ " URL=" + failingUrl);
+ Toast.makeText(activity, "Failed to load page: " +
+ description + " (URL=" + failingUrl + ")",
+ Toast.LENGTH_LONG).show();
+ }
+ }
+}