summaryrefslogtreecommitdiffstats
path: root/tests/SslLoad
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-03 19:31:44 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-03 19:31:44 -0800
commit9066cfe9886ac131c34d59ed0e2d287b0e3c0087 (patch)
treed88beb88001f2482911e3d28e43833b50e4b4e97 /tests/SslLoad
parentd83a98f4ce9cfa908f5c54bbd70f03eec07e7553 (diff)
downloadframeworks_base-9066cfe9886ac131c34d59ed0e2d287b0e3c0087.zip
frameworks_base-9066cfe9886ac131c34d59ed0e2d287b0e3c0087.tar.gz
frameworks_base-9066cfe9886ac131c34d59ed0e2d287b0e3c0087.tar.bz2
auto import from //depot/cupcake/@135843
Diffstat (limited to 'tests/SslLoad')
-rw-r--r--tests/SslLoad/Android.mk10
-rw-r--r--tests/SslLoad/AndroidManifest.xml13
-rw-r--r--tests/SslLoad/src/com/android/sslload/SslLoad.java123
3 files changed, 146 insertions, 0 deletions
diff --git a/tests/SslLoad/Android.mk b/tests/SslLoad/Android.mk
new file mode 100644
index 0000000..f75be8d
--- /dev/null
+++ b/tests/SslLoad/Android.mk
@@ -0,0 +1,10 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_PACKAGE_NAME := SslLoad
+
+include $(BUILD_PACKAGE)
diff --git a/tests/SslLoad/AndroidManifest.xml b/tests/SslLoad/AndroidManifest.xml
new file mode 100644
index 0000000..497b1c7
--- /dev/null
+++ b/tests/SslLoad/AndroidManifest.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.sslload">
+ <uses-permission android:name="android.permission.INTERNET" />
+ <application>
+ <activity android:name="SslLoad" android:label="SSL Load">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
diff --git a/tests/SslLoad/src/com/android/sslload/SslLoad.java b/tests/SslLoad/src/com/android/sslload/SslLoad.java
new file mode 100644
index 0000000..9a08024
--- /dev/null
+++ b/tests/SslLoad/src/com/android/sslload/SslLoad.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.sslload;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Calendar;
+import java.util.Map;
+
+import android.app.Activity;
+import android.content.res.Resources;
+import android.media.MediaPlayer;
+import android.os.Handler;
+import android.os.Vibrator;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.TextView;
+import android.net.http.AndroidHttpClient;
+import android.util.Log;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.ResponseHandler;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.HttpResponse;
+
+public class SslLoad extends Activity implements OnClickListener, Runnable {
+
+ private static final String TAG = SslLoad.class.getSimpleName();
+
+ private Button button;
+ private boolean running = false;
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+
+ Thread requestThread = new Thread(this);
+ requestThread.setDaemon(true);
+ requestThread.start();
+
+ button = new Button(this);
+ button.setText("GO");
+ button.setOnClickListener(this);
+
+ setContentView(button);
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+
+ synchronized (this) {
+ running = false;
+ }
+ }
+
+ public void onClick(View v) {
+ synchronized (this) {
+ running = !running;
+ button.setText(running ? "STOP" : "GO");
+ if (running) {
+ this.notifyAll();
+ }
+ }
+ }
+
+ public void run() {
+ boolean error = false;
+ while (true) {
+ synchronized (this) {
+ while (!running) {
+ try {
+ this.wait();
+ } catch (InterruptedException e) { /* ignored */ }
+ }
+ }
+
+ AndroidHttpClient client = AndroidHttpClient.newInstance(
+ "Mozilla/5.001 (windows; U; NT4.0; en-us) Gecko/25250101");
+ try {
+ // Cert. is for "www.google.com", not "google.com".
+ String url = error ? "https://google.com/"
+ : "https://www.google.com";
+ client.execute(new HttpGet(url),
+ new ResponseHandler<Void>() {
+ public Void handleResponse(HttpResponse response) {
+ /* ignore */
+ return null;
+ }
+ });
+ Log.i(TAG, "Request succeeded.");
+ } catch (IOException e) {
+ Log.w(TAG, "Request failed.", e);
+ }
+
+ client.close();
+
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) { /* ignored */ }
+
+ error = !error;
+ }
+ }
+}