aboutsummaryrefslogtreecommitdiff
path: root/wpadebug/src
diff options
context:
space:
mode:
Diffstat (limited to 'wpadebug/src')
-rw-r--r--wpadebug/src/w1/fi/wpadebug/CommandListActivity.java130
-rw-r--r--wpadebug/src/w1/fi/wpadebug/DisplayMessageActivity.java49
-rw-r--r--wpadebug/src/w1/fi/wpadebug/InputUri.java108
-rw-r--r--wpadebug/src/w1/fi/wpadebug/MainActivity.java209
-rw-r--r--wpadebug/src/w1/fi/wpadebug/QrCodeDisplayActivity.java109
-rw-r--r--wpadebug/src/w1/fi/wpadebug/QrCodeReadActivity.java40
-rw-r--r--wpadebug/src/w1/fi/wpadebug/QrCodeScannerActivity.java82
-rw-r--r--wpadebug/src/w1/fi/wpadebug/WifiReceiver.java95
-rw-r--r--wpadebug/src/w1/fi/wpadebug/WpaCommandListActivity.java112
-rw-r--r--wpadebug/src/w1/fi/wpadebug/WpaCredActivity.java263
-rw-r--r--wpadebug/src/w1/fi/wpadebug/WpaCredEditActivity.java55
-rw-r--r--wpadebug/src/w1/fi/wpadebug/WpaNfcActivity.java131
-rw-r--r--wpadebug/src/w1/fi/wpadebug/WpaWebViewActivity.java146
13 files changed, 0 insertions, 1529 deletions
diff --git a/wpadebug/src/w1/fi/wpadebug/CommandListActivity.java b/wpadebug/src/w1/fi/wpadebug/CommandListActivity.java
deleted file mode 100644
index 6d7ad4dd6678..000000000000
--- a/wpadebug/src/w1/fi/wpadebug/CommandListActivity.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * 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 java.util.ArrayList;
-import java.util.Scanner;
-import java.io.FileReader;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.io.InputStream;
-import java.io.IOException;
-
-import android.app.ListActivity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Parcelable;
-import android.view.View;
-import android.widget.ListView;
-import android.widget.ArrayAdapter;
-import android.widget.Toast;
-import android.text.method.ScrollingMovementMethod;
-import android.util.Log;
-
-class CmdList
-{
- String title;
- String command;
-
- public CmdList(String _title, String _command)
- {
- title = _title;
- command = _command;
- }
-
- @Override
- public String toString()
- {
- return title;
- }
-}
-
-public class CommandListActivity extends ListActivity
-{
- private static final String TAG = "wpadebug";
- private static final String cmdfile = "/data/local/wpadebug.cmds";
-
- private void read_commands(ArrayList<CmdList> list, Scanner in)
- {
- in.useDelimiter("@");
- while (in.hasNext()) {
- String title = in.next();
- String cmd = in.nextLine().substring(1);
- list.add(new CmdList(title, cmd));
- }
- in.close();
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
-
- ArrayList<CmdList> list = new ArrayList<CmdList>();
-
- FileReader in;
- try {
- in = new FileReader(cmdfile);
- read_commands(list, new Scanner(in));
- } catch (IOException e) {
- Toast.makeText(this, "Could not read " + cmdfile,
- Toast.LENGTH_SHORT).show();
- }
-
- InputStream inres;
- try {
- inres = getResources().openRawResource(R.raw.shell_commands);
- read_commands(list, new Scanner(inres));
- } catch (android.content.res.Resources.NotFoundException e) {
- Toast.makeText(this, "Could not read internal resource",
- Toast.LENGTH_SHORT).show();
- }
-
- ArrayAdapter<CmdList> listAdapter;
- listAdapter = new ArrayAdapter<CmdList>(this, android.R.layout.simple_list_item_1, list);
-
- setListAdapter(listAdapter);
- }
-
- @Override
- protected void onListItemClick(ListView l, View v, int position, long id)
- {
- CmdList item = (CmdList) getListAdapter().getItem(position);
- Toast.makeText(this, "Running: " + item.command,
- Toast.LENGTH_SHORT).show();
- String message = run(item.command);
- if (message == null)
- return;
- Intent intent = new Intent(this, DisplayMessageActivity.class);
- intent.putExtra(MainActivity.EXTRA_MESSAGE, message);
- startActivity(intent);
- }
-
- private String run(String cmd)
- {
- try {
- Process proc = Runtime.getRuntime().exec(new String[]{"/system/bin/mksh-su", "-c", cmd});
- BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
- StringBuffer output = new StringBuffer();
- int read;
- char[] buffer = new char[1024];
- while ((read = reader.read(buffer)) > 0)
- output.append(buffer, 0, read);
- reader.close();
- proc.waitFor();
- return output.toString();
- } catch (IOException e) {
- Toast.makeText(this, "Could not run command",
- Toast.LENGTH_LONG).show();
- return null;
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/wpadebug/src/w1/fi/wpadebug/DisplayMessageActivity.java b/wpadebug/src/w1/fi/wpadebug/DisplayMessageActivity.java
deleted file mode 100644
index 28ef85f39169..000000000000
--- a/wpadebug/src/w1/fi/wpadebug/DisplayMessageActivity.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.os.Bundle;
-import android.os.Parcelable;
-import android.view.MenuItem;
-import android.content.Intent;
-import android.widget.TextView;
-import android.text.method.ScrollingMovementMethod;
-import android.util.Log;
-
-public class DisplayMessageActivity extends Activity
-{
- private static final String TAG = "wpadebug";
-
- String byteArrayHex(byte[] a) {
- StringBuilder sb = new StringBuilder();
- for (byte b: a)
- sb.append(String.format("%02x", b));
- return sb.toString();
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- Log.d(TAG, "onCreate");
- super.onCreate(savedInstanceState);
-
- // Get the message from the intent
- Intent intent = getIntent();
- String action = intent.getAction();
- Log.d(TAG, "onCreate: action=" + action);
-
- String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
-
- TextView textView = new TextView(this);
- textView.setText(message);
- textView.setMovementMethod(new ScrollingMovementMethod());
- setContentView(textView);
- }
-}
diff --git a/wpadebug/src/w1/fi/wpadebug/InputUri.java b/wpadebug/src/w1/fi/wpadebug/InputUri.java
deleted file mode 100644
index ea1fa99d2a3e..000000000000
--- a/wpadebug/src/w1/fi/wpadebug/InputUri.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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.text.Editable;
-import android.text.TextWatcher;
-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);
-
- mEditText.addTextChangedListener(new TextWatcher() {
- @Override
- public void onTextChanged(CharSequence s, int start, int before,
- int count) {
- mUriText = mEditText.getText().toString();
- if (mUriText.startsWith("DPP:") &&
- mUriText.endsWith(";;")) {
- writeToFile(mUriText);
- finish();
- }
- }
-
- @Override
- public void beforeTextChanged(CharSequence s, int start,
- int count, int after) {
- }
-
- @Override
- public void afterTextChanged(Editable s) {
- }
- });
- }
-
- @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());
- }
- }
-}
diff --git a/wpadebug/src/w1/fi/wpadebug/MainActivity.java b/wpadebug/src/w1/fi/wpadebug/MainActivity.java
deleted file mode 100644
index 4c37b481f1bf..000000000000
--- a/wpadebug/src/w1/fi/wpadebug/MainActivity.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * 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 java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.io.IOException;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.os.Bundle;
-import android.view.View;
-import android.content.Intent;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.widget.EditText;
-import android.widget.Toast;
-import android.util.Log;
-import android.net.wifi.WifiManager;
-import android.net.wifi.WifiInfo;
-import android.net.wifi.WifiConfiguration;
-import android.nfc.NdefMessage;
-import android.nfc.NdefRecord;
-import android.nfc.NfcAdapter;
-
-public class MainActivity extends Activity
-{
- public final static String EXTRA_MESSAGE = "w1.fi.wpadebug.MESSAGE";
- private static final String TAG = "wpadebug";
-
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- }
-
- public void runCommands(View view)
- {
- Intent intent = new Intent(this, CommandListActivity.class);
- startActivity(intent);
- }
-
- public void runQrScan(View view)
- {
- Intent intent = new Intent(this, QrCodeScannerActivity.class);
- startActivity(intent);
- }
-
- public void runQrInput(View view)
- {
- Intent intent = new Intent(this, InputUri.class);
- startActivity(intent);
- }
-
- public void runQrDisplay(View view)
- {
- Intent intent = new Intent(this, QrCodeDisplayActivity.class);
- startActivity(intent);
- }
-
- public void runWpaCommands(View view)
- {
- Intent intent = new Intent(this, WpaCommandListActivity.class);
- startActivity(intent);
- }
-
- public void runWpaCredentials(View view)
- {
- Intent intent = new Intent(this, WpaCredActivity.class);
- startActivity(intent);
- }
-
- public void runWpaCliCmd(View view)
- {
- Intent intent = new Intent(this, DisplayMessageActivity.class);
- EditText editText = (EditText) findViewById(R.id.edit_cmd);
- String cmd = editText.getText().toString();
- if (cmd.trim().length() == 0) {
- show_alert("wpa_cli command", "Invalid command");
- return;
- }
- wpaCmd(view, cmd);
- }
-
- public void wpaLogLevelInfo(View view)
- {
- wpaCmd(view, "LOG_LEVEL INFO 1");
- }
-
- public void wpaLogLevelDebug(View view)
- {
- wpaCmd(view, "LOG_LEVEL DEBUG 1");
- }
-
- public void wpaLogLevelExcessive(View view)
- {
- wpaCmd(view, "LOG_LEVEL EXCESSIVE 1");
- }
-
- private void wpaCmd(View view, String cmd)
- {
- Intent intent = new Intent(this, DisplayMessageActivity.class);
- String message = run("wpa_cli " + cmd);
- if (message == null)
- return;
- intent.putExtra(EXTRA_MESSAGE, message);
- startActivity(intent);
- }
-
- private String run(String cmd)
- {
- try {
- Log.d(TAG, "Running external process: " + cmd);
- Process proc = Runtime.getRuntime().exec(new String[]{"/system/bin/mksh-su", "-c", cmd});
- BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
- StringBuffer output = new StringBuffer();
- int read;
- char[] buffer = new char[1024];
- while ((read = reader.read(buffer)) > 0)
- output.append(buffer, 0, read);
- reader.close();
- proc.waitFor();
- Log.d(TAG, "External process completed - exitValue " +
- proc.exitValue());
- return output.toString();
- } catch (IOException e) {
- show_alert("Could not run external program",
- "Execution of an external program failed. " +
- "Maybe mksh-su was not installed.");
- return null;
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
-
- private void show_alert(String title, String message)
- {
- AlertDialog.Builder alert = new AlertDialog.Builder(this);
- alert.setTitle(title);
- alert.setMessage(message);
- alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id)
- {
- }
- });
- alert.create().show();
- }
-
- public void wifiManagerInfo(View view)
- {
- Intent intent = new Intent(this, DisplayMessageActivity.class);
- WifiManager manager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
- String message = "WifiState: " + manager.getWifiState() + "\n" +
- "WifiEnabled: " + manager.isWifiEnabled() + "\n" +
- "pingSupplicant: " + manager.pingSupplicant() + "\n" +
- "DhcpInfo: " + manager.getDhcpInfo().toString() + "\n";
- intent.putExtra(EXTRA_MESSAGE, message);
- startActivity(intent);
- }
-
- public void wifiInfo(View view)
- {
- Intent intent = new Intent(this, DisplayMessageActivity.class);
- WifiManager manager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
- WifiInfo wifi = manager.getConnectionInfo();
- String message = wifi.toString() + "\n" + wifi.getSupplicantState();
- intent.putExtra(EXTRA_MESSAGE, message);
- startActivity(intent);
- }
-
- public void wifiConfiguredNetworks(View view)
- {
- Intent intent = new Intent(this, DisplayMessageActivity.class);
- WifiManager manager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
- StringBuilder sb = new StringBuilder();
- for (WifiConfiguration n: manager.getConfiguredNetworks())
- sb.append(n.toString() + "\n");
- intent.putExtra(EXTRA_MESSAGE, sb.toString());
- startActivity(intent);
- }
-
- public void nfcWpsHandoverRequest(View view)
- {
- NfcAdapter nfc;
- nfc = NfcAdapter.getDefaultAdapter(this);
- if (nfc == null) {
- Toast.makeText(this, "NFC is not available",
- Toast.LENGTH_LONG).show();
- return;
- }
-
- NdefMessage msg;
- msg = new NdefMessage(new NdefRecord[] {
- NdefRecord.createMime("application/vnd.wfa.wsc",
- new byte[0])
- });
-
- nfc.setNdefPushMessage(msg, this);
- Toast.makeText(this, "NFC push message (WSC) configured",
- Toast.LENGTH_LONG).show();
- }
-}
diff --git a/wpadebug/src/w1/fi/wpadebug/QrCodeDisplayActivity.java b/wpadebug/src/w1/fi/wpadebug/QrCodeDisplayActivity.java
deleted file mode 100644
index 10c9c0144fe4..000000000000
--- a/wpadebug/src/w1/fi/wpadebug/QrCodeDisplayActivity.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.graphics.Bitmap;
-import android.os.Bundle;
-import android.text.TextUtils;
-import android.util.Log;
-import android.widget.ImageView;
-
-import com.google.zxing.BarcodeFormat;
-import com.google.zxing.MultiFormatWriter;
-import com.google.zxing.WriterException;
-import com.google.zxing.common.BitMatrix;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-public class QrCodeDisplayActivity extends Activity {
-
- private static final String TAG = "wpadebug";
- private static final String FILE_NAME = "wpadebug_qrdata.txt";
- private ImageView imageView;
-
- // Below set of configs are used for QR code display window
- private final static int WHITE = 0xFFFFFFFF;
- private final static int BLACK = 0xFF000000;
- private final static int WIDTH = 400;
- private final static int HEIGHT = 400;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- // create imageview for this and attach to this activity.
- setContentView(R.layout.qrcode);
- imageView = (ImageView) findViewById(R.id.qrCode);
- String str = readFromFile(FILE_NAME);
-
- //Encode and launch qrcode now
- try {
- Bitmap bitmap = (TextUtils.isEmpty(str)) ? null : encodeAsBitmap(str);
- if (bitmap != null) {
- imageView.setImageBitmap(bitmap);
- } else {
- Log.e(TAG, "Failed to generate bitmap for uri=" + str);
- finish();
- }
- } catch (WriterException e) {
- e.printStackTrace();
- finish();
- }
- }
-
- private Bitmap encodeAsBitmap(String str) throws WriterException {
- BitMatrix result;
- try {
- result = new MultiFormatWriter().encode(str, BarcodeFormat.QR_CODE, WIDTH, HEIGHT, null);
- } catch (IllegalArgumentException iae) {
- // Unsupported format
- return null;
- }
-
- int width = result.getWidth();
- int height = result.getHeight();
- int[] pixels = new int[width * height];
- for (int y = 0; y < height; y++) {
- int offset = y * width;
- for (int x = 0; x < width; x++) {
- pixels[offset + x] = result.get(x, y) ? BLACK : WHITE;
- }
- }
-
- Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
- return bitmap;
- }
-
- private String readFromFile(String filePath) {
- try {
- FileInputStream fis = new FileInputStream(new File("/sdcard", filePath));
- BufferedReader br = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
- StringBuilder sb = new StringBuilder();
- String line;
- while(( line = br.readLine()) != null ) {
- sb.append( line );
- sb.append( '\n' );
- }
- return sb.toString();
- }
- catch (FileNotFoundException e) {
- Log.e(TAG, "File not found: " + e.toString());
- } catch (IOException e) {
- Log.e(TAG, "Can not read file: " + e.toString());
- }
-
- return null;
- }
-}
diff --git a/wpadebug/src/w1/fi/wpadebug/QrCodeReadActivity.java b/wpadebug/src/w1/fi/wpadebug/QrCodeReadActivity.java
deleted file mode 100644
index f21eccba8660..000000000000
--- a/wpadebug/src/w1/fi/wpadebug/QrCodeReadActivity.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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();
- }
- }
-}
diff --git a/wpadebug/src/w1/fi/wpadebug/QrCodeScannerActivity.java b/wpadebug/src/w1/fi/wpadebug/QrCodeScannerActivity.java
deleted file mode 100644
index 4b3591c725dc..000000000000
--- a/wpadebug/src/w1/fi/wpadebug/QrCodeScannerActivity.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.content.ActivityNotFoundException;
-import android.content.Intent;
-import android.os.Bundle;
-import android.util.Log;
-import android.widget.Toast;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-
-public class QrCodeScannerActivity extends Activity {
-
- private static final String TAG = "wpadebug";
- private static final String RESULT = "SCAN_RESULT";
- private static final String FILE_NAME = "wpadebug_qrdata.txt";
- private static final String ACTION = "com.google.zxing.client.android.SCAN";
-
- private static final int QRCODE = 1;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- Intent intent = new Intent();
- intent.setAction(ACTION);
- intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
- intent.putExtra("PROMPT_MESSAGE",
- "Place a QR Code inside the viewfinder rectangle to scan it.");
- try {
- startActivityForResult(intent, QRCODE);
- } catch (ActivityNotFoundException e) {
- Log.e(TAG, "No QR code scanner found with name=" + ACTION);
- Toast.makeText(QrCodeScannerActivity.this, "QR code scanner not found", Toast.LENGTH_SHORT).show();
- finish();
- }
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- Log.d(TAG, "onActivityResult: requestCode=" + requestCode + " resultCode=" + resultCode);
- if (requestCode == QRCODE && resultCode == RESULT_OK) {
- String contents = data.getStringExtra(RESULT);
- writeToFile(contents);
- Log.d(TAG, "onActivityResult: QRCODE RESULT_OK: " + contents);
- finishActivity(requestCode);
- finish();
- }
- }
-
- 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(data);
-
- myOutWriter.close();
-
- fOut.flush();
- fOut.close();
- }
- catch (IOException e)
- {
- Log.e(TAG, "File write failed: " + e.toString());
- }
- }
-}
diff --git a/wpadebug/src/w1/fi/wpadebug/WifiReceiver.java b/wpadebug/src/w1/fi/wpadebug/WifiReceiver.java
deleted file mode 100644
index d69e05d69ebb..000000000000
--- a/wpadebug/src/w1/fi/wpadebug/WifiReceiver.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.net.NetworkInfo;
-import android.net.wifi.SupplicantState;
-import android.net.wifi.WifiInfo;
-import android.os.Bundle;
-import android.util.Log;
-
-public class WifiReceiver extends BroadcastReceiver
-{
- private static final String TAG = "wpadebug";
-
- @Override
- public void onReceive(Context c, Intent intent)
- {
- String act = intent.getAction();
- Log.d(TAG, "Received broadcast intent: action=" + act);
-
- Bundle bundles = intent.getExtras();
- if (bundles == null)
- return;
-
- if (bundles.containsKey("bssid")) {
- String val;
- val = intent.getStringExtra("bssid");
- if (val != null)
- Log.d(TAG, " bssid: " + val);
- }
-
- if (bundles.containsKey("networkInfo")) {
- NetworkInfo info;
- info = (NetworkInfo) intent.getParcelableExtra("networkInfo");
- if (info != null)
- Log.d(TAG, " networkInfo: " + info);
- }
-
- if (bundles.containsKey("newRssi")) {
- int val;
- val = intent.getIntExtra("newRssi", -1);
- Log.d(TAG, " newRssi: " + val);
- }
-
- if (bundles.containsKey("newState")) {
- SupplicantState state;
- state = (SupplicantState) intent.getParcelableExtra("newState");
- if (state != null)
- Log.d(TAG, " newState: " + state);
- }
-
- if (bundles.containsKey("previous_wifi_state")) {
- int wifi_state;
- wifi_state = intent.getIntExtra("previous_wifi_state", -1);
- if (wifi_state != -1)
- Log.d(TAG, " previous_wifi_state: " + wifi_state);
- }
-
- if (bundles.containsKey("connected")) {
- boolean connected;
- connected = intent.getBooleanExtra("connected", false);
- Log.d(TAG, " connected: " + connected);
- }
-
- if (bundles.containsKey("supplicantError")) {
- int error;
- error = intent.getIntExtra("supplicantError", -1);
- if (error != -1)
- Log.d(TAG, " supplicantError: " + error);
- }
-
- if (bundles.containsKey("wifiInfo")) {
- WifiInfo info;
- info = (WifiInfo) intent.getParcelableExtra("wifiInfo");
- if (info != null)
- Log.d(TAG, " wifiInfo: " + info);
- }
-
- if (bundles.containsKey("wifi_state")) {
- int wifi_state;
- wifi_state = intent.getIntExtra("wifi_state", -1);
- if (wifi_state != -1)
- Log.d(TAG, " wifi_state: " + wifi_state);
- }
- }
-}
diff --git a/wpadebug/src/w1/fi/wpadebug/WpaCommandListActivity.java b/wpadebug/src/w1/fi/wpadebug/WpaCommandListActivity.java
deleted file mode 100644
index e089179340ee..000000000000
--- a/wpadebug/src/w1/fi/wpadebug/WpaCommandListActivity.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * 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 java.util.ArrayList;
-import java.util.Scanner;
-import java.io.FileReader;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.io.InputStream;
-import java.io.IOException;
-
-import android.app.ListActivity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Parcelable;
-import android.view.View;
-import android.widget.ListView;
-import android.widget.ArrayAdapter;
-import android.widget.Toast;
-import android.text.method.ScrollingMovementMethod;
-import android.util.Log;
-
-public class WpaCommandListActivity extends ListActivity
-{
- private static final String TAG = "wpadebug";
- private static final String cmdfile = "/data/local/wpadebug.wpacmds";
-
- private void read_commands(ArrayList<CmdList> list, Scanner in)
- {
- in.useDelimiter("@");
- while (in.hasNext()) {
- String title = in.next();
- String cmd = in.nextLine().substring(1);
- list.add(new CmdList(title, cmd));
- }
- in.close();
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
-
- ArrayList<CmdList> list = new ArrayList<CmdList>();
-
- FileReader in;
- try {
- in = new FileReader(cmdfile);
- read_commands(list, new Scanner(in));
- } catch (IOException e) {
- Toast.makeText(this, "Could not read " + cmdfile,
- Toast.LENGTH_SHORT).show();
- }
-
- InputStream inres;
- try {
- inres = getResources().openRawResource(R.raw.wpa_commands);
- read_commands(list, new Scanner(inres));
- } catch (android.content.res.Resources.NotFoundException e) {
- Toast.makeText(this, "Could not read internal resource",
- Toast.LENGTH_SHORT).show();
- }
-
- ArrayAdapter<CmdList> listAdapter;
- listAdapter = new ArrayAdapter<CmdList>(this, android.R.layout.simple_list_item_1, list);
-
- setListAdapter(listAdapter);
- }
-
- @Override
- protected void onListItemClick(ListView l, View v, int position, long id)
- {
- CmdList item = (CmdList) getListAdapter().getItem(position);
- Toast.makeText(this, "Running: " + item.command,
- Toast.LENGTH_SHORT).show();
- String message = run(item.command);
- if (message == null)
- return;
- Intent intent = new Intent(this, DisplayMessageActivity.class);
- intent.putExtra(MainActivity.EXTRA_MESSAGE, message);
- startActivity(intent);
- }
-
- private String run(String cmd)
- {
- try {
- Process proc = Runtime.getRuntime().exec(new String[]{"/system/bin/mksh-su", "-c", "wpa_cli " + cmd});
- BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
- StringBuffer output = new StringBuffer();
- int read;
- char[] buffer = new char[1024];
- while ((read = reader.read(buffer)) > 0)
- output.append(buffer, 0, read);
- reader.close();
- proc.waitFor();
- return output.toString();
- } catch (IOException e) {
- Toast.makeText(this, "Could not run command",
- Toast.LENGTH_LONG).show();
- return null;
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/wpadebug/src/w1/fi/wpadebug/WpaCredActivity.java b/wpadebug/src/w1/fi/wpadebug/WpaCredActivity.java
deleted file mode 100644
index 3902f0964d0a..000000000000
--- a/wpadebug/src/w1/fi/wpadebug/WpaCredActivity.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * 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 java.util.ArrayList;
-import java.util.ListIterator;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.io.InputStream;
-import java.io.IOException;
-
-import android.app.ListActivity;
-import android.app.ActionBar;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.View;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.widget.ListView;
-import android.widget.ArrayAdapter;
-import android.widget.Toast;
-import android.widget.AdapterView.AdapterContextMenuInfo;
-
-class Credential
-{
- int id;
- String realm;
- String username;
- String domain;
- String imsi;
-
- public Credential(String entry)
- {
- String fields[] = entry.split("\t");
- id = Integer.parseInt(fields[0]);
- if (fields.length > 1)
- realm = fields[1];
- else
- realm = "";
- if (fields.length > 2)
- username = fields[2];
- else
- username = "";
- if (fields.length > 3 && fields[3].length() > 0)
- domain = fields[3];
- else
- domain = null;
- if (fields.length > 4 && fields[4].length() > 0)
- imsi = fields[4];
- else
- imsi = null;
- }
-
- public Credential(int _id, String _username, String _realm, String _domain,
- String _imsi)
- {
- id = _id;
- username = _username;
- realm = _realm;
- domain = _domain;
- imsi = _imsi;
- }
-
-
- @Override
- public String toString()
- {
- String res = id + " - " + username + "@" + realm;
- if (domain != null)
- res += " (domain=" + domain + ")";
- if (imsi != null)
- res += " (imsi=" + imsi + ")";
- return res;
- }
-}
-
-public class WpaCredActivity extends ListActivity
-{
- private static final String TAG = "wpadebug";
- static final int CRED_EDIT_REQ = 0;
- private ArrayList<Credential> mList;
- private ArrayAdapter<Credential> mListAdapter;
-
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
-
- mList = new ArrayList<Credential>();
-
- String res = run("LIST_CREDS");
- if (res == null) {
- Toast.makeText(this, "Could not get credential list",
- Toast.LENGTH_LONG).show();
- finish();
- return;
- }
-
- String creds[] = res.split("\n");
- for (String cred: creds) {
- if (Character.isDigit(cred.charAt(0)))
- mList.add(new Credential(cred));
- }
-
- mListAdapter = new ArrayAdapter<Credential>(this, android.R.layout.simple_list_item_1, mList);
-
- setListAdapter(mListAdapter);
- registerForContextMenu(getListView());
-
- ActionBar abar = getActionBar();
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu)
- {
- menu.add(0, 0, 0, "Add credential");
- return true;
- }
-
- protected void onActivityResult(int requestCode, int resultCode,
- Intent data)
- {
- if (requestCode == CRED_EDIT_REQ) {
- if (resultCode != RESULT_OK)
- return;
-
- String username = data.getStringExtra("username");
-
- String realm = data.getStringExtra("realm");
-
- String domain = data.getStringExtra("domain");
- if (domain != null && domain.length() == 0)
- domain = null;
-
- String imsi = data.getStringExtra("imsi");
- if (imsi != null && imsi.length() == 0)
- imsi = null;
-
- String password = data.getStringExtra("password");
- if (password != null && password.length() == 0)
- password = null;
-
- String res = run("ADD_CRED");
- if (res == null || res.contains("FAIL")) {
- Toast.makeText(this, "Failed to add credential",
- Toast.LENGTH_LONG).show();
- return;
- }
-
- int id = -1;
- String lines[] = res.split("\n");
- for (String line: lines) {
- if (Character.isDigit(line.charAt(0))) {
- id = Integer.parseInt(line);
- break;
- }
- }
-
- if (id < 0) {
- Toast.makeText(this, "Failed to add credential (invalid id)",
- Toast.LENGTH_LONG).show();
- return;
- }
-
- if (!set_cred_quoted(id, "username", username) ||
- !set_cred_quoted(id, "realm", realm) ||
- (password != null &&
- !set_cred_quoted(id, "password", password)) ||
- (domain != null && !set_cred_quoted(id, "domain", domain)) ||
- (imsi != null && !set_cred_quoted(id, "imsi", imsi))) {
- run("REMOVE_CRED " + id);
- Toast.makeText(this, "Failed to set credential field",
- Toast.LENGTH_LONG).show();
- return;
- }
-
- mListAdapter.add(new Credential(id, username, realm, domain, imsi));
- }
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item)
- {
- if (item.getTitle().equals("Add credential")) {
- startActivityForResult(new Intent(this, WpaCredEditActivity.class),
- CRED_EDIT_REQ);
- return true;
- }
- return false;
- }
-
- public void onCreateContextMenu(android.view.ContextMenu menu, View v,
- android.view.ContextMenu.ContextMenuInfo menuInfo)
- {
- menu.add(0, v.getId(), 0, "Delete");
- }
-
- @Override
- public boolean onContextItemSelected(MenuItem item)
- {
- if (item.getTitle().equals("Delete")) {
- AdapterContextMenuInfo info =
- (AdapterContextMenuInfo) item.getMenuInfo();
- Credential cred = (Credential) getListAdapter().getItem(info.position);
- String res = run("REMOVE_CRED " + cred.id);
- if (res == null || !res.contains("OK")) {
- Toast.makeText(this, "Failed to delete credential",
- Toast.LENGTH_LONG).show();
- } else
- mListAdapter.remove(cred);
- return true;
- }
- return super.onContextItemSelected(item);
- }
-
- @Override
- protected void onListItemClick(ListView l, View v, int position, long id)
- {
- Credential item = (Credential) getListAdapter().getItem(position);
- Toast.makeText(this, "Credential selected: " + item,
- Toast.LENGTH_SHORT).show();
- }
-
- private String run(String cmd)
- {
- try {
- Process proc = Runtime.getRuntime().exec(new String[]{"/system/bin/mksh-su", "-c", "wpa_cli " + cmd});
- BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
- StringBuffer output = new StringBuffer();
- int read;
- char[] buffer = new char[1024];
- while ((read = reader.read(buffer)) > 0)
- output.append(buffer, 0, read);
- reader.close();
- proc.waitFor();
- return output.toString();
- } catch (IOException e) {
- Toast.makeText(this, "Could not run command",
- Toast.LENGTH_LONG).show();
- return null;
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
-
- private boolean set_cred(int id, String field, String value)
- {
- String res = run("SET_CRED " + id + " " + field + " " + value);
- return res != null && res.contains("OK");
- }
-
- private boolean set_cred_quoted(int id, String field, String value)
- {
- String value2 = "'\"" + value + "\"'";
- return set_cred(id, field, value2);
- }
-}
diff --git a/wpadebug/src/w1/fi/wpadebug/WpaCredEditActivity.java b/wpadebug/src/w1/fi/wpadebug/WpaCredEditActivity.java
deleted file mode 100644
index 3f846c7b4e82..000000000000
--- a/wpadebug/src/w1/fi/wpadebug/WpaCredEditActivity.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.os.Bundle;
-import android.view.View;
-import android.widget.EditText;
-
-public class WpaCredEditActivity extends Activity
-{
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.cred_edit);
- }
-
- public void credSave(View view)
- {
- Intent data = new Intent();
- EditText edit;
-
- edit = (EditText) findViewById(R.id.cred_edit_username);
- data.putExtra("username", edit.getText().toString());
-
- edit = (EditText) findViewById(R.id.cred_edit_realm);
- data.putExtra("realm", edit.getText().toString());
-
- edit = (EditText) findViewById(R.id.cred_edit_password);
- data.putExtra("password", edit.getText().toString());
-
- edit = (EditText) findViewById(R.id.cred_edit_domain);
- data.putExtra("domain", edit.getText().toString());
-
- edit = (EditText) findViewById(R.id.cred_edit_imsi);
- data.putExtra("imsi", edit.getText().toString());
-
- setResult(Activity.RESULT_OK, data);
- finish();
- }
-
- public void credCancel(View view)
- {
- setResult(Activity.RESULT_CANCELED);
- finish();
- }
-}
diff --git a/wpadebug/src/w1/fi/wpadebug/WpaNfcActivity.java b/wpadebug/src/w1/fi/wpadebug/WpaNfcActivity.java
deleted file mode 100644
index 6a1601723b6a..000000000000
--- a/wpadebug/src/w1/fi/wpadebug/WpaNfcActivity.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * 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 java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.io.IOException;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.os.Bundle;
-import android.os.Parcelable;
-import android.view.MenuItem;
-import android.content.Intent;
-import android.content.DialogInterface;
-import android.widget.TextView;
-import android.widget.Toast;
-import android.text.method.ScrollingMovementMethod;
-import android.util.Log;
-import android.nfc.NdefMessage;
-import android.nfc.NdefRecord;
-import android.nfc.NfcAdapter;
-
-public class WpaNfcActivity extends Activity
-{
- private static final String TAG = "wpadebug";
-
- String byteArrayHex(byte[] a) {
- StringBuilder sb = new StringBuilder();
- for (byte b: a)
- sb.append(String.format("%02x", b));
- return sb.toString();
- }
-
- private void show_alert(String title, String message)
- {
- AlertDialog.Builder alert = new AlertDialog.Builder(this);
- alert.setTitle(title);
- alert.setMessage(message);
- alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id)
- {
- finish();
- }
- });
- alert.create().show();
- }
-
- private String wpaCmd(String cmd)
- {
- try {
- Log.d(TAG, "Executing wpaCmd: " + cmd);
- Process proc = Runtime.getRuntime().exec(new String[]{"/system/bin/mksh-su", "-c", "wpa_cli " + cmd});
- BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
- StringBuffer output = new StringBuffer();
- int read;
- char[] buffer = new char[1024];
- while ((read = reader.read(buffer)) > 0)
- output.append(buffer, 0, read);
- reader.close();
- proc.waitFor();
- Log.d(TAG, "External process completed - exitValue " +
- proc.exitValue());
- return output.toString();
- } catch (IOException e) {
- show_alert("Could not run external program",
- "Execution of an external program failed. " +
- "Maybe mksh-su was not installed.");
- return null;
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
-
- public boolean report_tag_read(byte[] payload)
- {
- String res = wpaCmd("WPS_NFC_TAG_READ " + byteArrayHex(payload));
- if (res == null)
- return false;
- if (!res.contains("OK")) {
- Toast.makeText(this, "Failed to report WSC tag read to " +
- "wpa_supplicant", Toast.LENGTH_LONG).show();
- } else {
- Toast.makeText(this, "Reported WSC tag read to wpa_supplicant",
- Toast.LENGTH_LONG).show();
- }
- finish();
- return true;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
-
- Intent intent = getIntent();
- String action = intent.getAction();
- Log.d(TAG, "onCreate: action=" + action);
-
- if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) {
- Log.d(TAG, "NDEF discovered");
- Parcelable[] raw = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
- if (raw != null) {
- Log.d(TAG, "NDEF message count: " + raw.length);
- NdefMessage[] msgs = new NdefMessage[raw.length];
- for (int i = 0; i < raw.length; i++) {
- msgs[i] = (NdefMessage) raw[i];
- NdefRecord rec = msgs[i].getRecords()[0];
- Log.d(TAG, "MIME type: " + rec.toMimeType());
- byte[] a = rec.getPayload();
- Log.d(TAG, "NDEF record: " + byteArrayHex(a));
- if (rec.getTnf() == NdefRecord.TNF_MIME_MEDIA &&
- rec.toMimeType().equals("application/vnd/wfa.wsc")) {
- Log.d(TAG, "WSC tag read");
- }
-
- if (!report_tag_read(a))
- return;
- }
- }
- }
-
- finish();
- }
-}
diff --git a/wpadebug/src/w1/fi/wpadebug/WpaWebViewActivity.java b/wpadebug/src/w1/fi/wpadebug/WpaWebViewActivity.java
deleted file mode 100644
index a7c54fc680c9..000000000000
--- a/wpadebug/src/w1/fi/wpadebug/WpaWebViewActivity.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * 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.app.AlertDialog;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.res.Configuration;
-import android.net.http.SslError;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Window;
-import android.webkit.SslErrorHandler;
-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();
- }
-
- @Override
- public void onReceivedSslError(WebView view, SslErrorHandler handler,
- SslError error)
- {
- Log.d(TAG, "SSL error: " + error);
-
- final SslErrorHandler h = handler;
- AlertDialog.Builder alert = new AlertDialog.Builder(activity);
- alert.setTitle("SSL error - Continue?");
- alert.setMessage(error.toString())
- .setCancelable(false)
- .setPositiveButton("Yes", new DialogInterface.OnClickListener()
- {
- public void onClick(DialogInterface dialog, int id)
- {
- h.proceed();
- }
- })
- .setNegativeButton("No", new DialogInterface.OnClickListener()
- {
- public void onClick(DialogInterface dialog, int id)
- {
- h.cancel();
- }
- });
- alert.show();
- }
- }
-}