From: rtrimana Date: Tue, 21 Feb 2017 01:01:52 +0000 (-0800) Subject: Migrating PhoneInterface (Irrigation and SpeakerLocator) from old to new Nexus 5X... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d070515f3c8da074210342cebfddbd5769cebe89;p=iot2.git Migrating PhoneInterface (Irrigation and SpeakerLocator) from old to new Nexus 5X phone --- diff --git a/benchmarks/other/PhoneInterface/Irrigation/.gitignore b/benchmarks/other/PhoneInterface/Irrigation/.gitignore new file mode 100644 index 0000000..c32a803 --- /dev/null +++ b/benchmarks/other/PhoneInterface/Irrigation/.gitignore @@ -0,0 +1,36 @@ +#built application files +*.apk +*.ap_ + +# files for the dex VM +*.dex + +# Java class files +*.class + +# generated files +bin/ +gen/ + +# Local configuration file (sdk path, etc) +local.properties + +# Windows thumbnail db +Thumbs.db + +# OSX files +.DS_Store + +# Eclipse project files +.classpath +.project + +# Android Studio +*.iml +.idea +#.idea/workspace.xml - remove # and delete .idea if it better suit your needs. +.gradle +build/ + +#NDK +obj/ diff --git a/benchmarks/other/PhoneInterface/Irrigation/Makefile b/benchmarks/other/PhoneInterface/Irrigation/Makefile new file mode 100644 index 0000000..5463f9f --- /dev/null +++ b/benchmarks/other/PhoneInterface/Irrigation/Makefile @@ -0,0 +1,14 @@ +BASE := ../../../.. + +include $(BASE)/common.mk + +all: + chmod +x gradlew + ./gradlew assembleDebug + +install: + adb -d install ./app/build/outputs/apk/app-debug.apk + +clean: + ./gradlew clean + diff --git a/benchmarks/other/PhoneInterface/Irrigation/app/.gitignore b/benchmarks/other/PhoneInterface/Irrigation/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/benchmarks/other/PhoneInterface/Irrigation/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/benchmarks/other/PhoneInterface/Irrigation/app/build.gradle b/benchmarks/other/PhoneInterface/Irrigation/app/build.gradle new file mode 100644 index 0000000..c0e0935 --- /dev/null +++ b/benchmarks/other/PhoneInterface/Irrigation/app/build.gradle @@ -0,0 +1,28 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 23 + buildToolsVersion "23.0.3" + useLibrary 'org.apache.http.legacy' + defaultConfig { + applicationId "com.example.xubin.irrigation" + minSdkVersion 15 + targetSdkVersion 23 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(include: ['*.jar'], dir: 'libs') + testCompile 'junit:junit:4.12' + compile 'com.android.support:appcompat-v7:23.3.0' + compile 'com.android.support:design:23.3.0' + compile files('libs/httpclient-android-4.3.3.jar') +} diff --git a/benchmarks/other/PhoneInterface/Irrigation/app/libs/httpclient-android-4.3.3.jar b/benchmarks/other/PhoneInterface/Irrigation/app/libs/httpclient-android-4.3.3.jar new file mode 100644 index 0000000..c59a729 Binary files /dev/null and b/benchmarks/other/PhoneInterface/Irrigation/app/libs/httpclient-android-4.3.3.jar differ diff --git a/benchmarks/other/PhoneInterface/Irrigation/app/proguard-rules.pro b/benchmarks/other/PhoneInterface/Irrigation/app/proguard-rules.pro new file mode 100644 index 0000000..8d3b83c --- /dev/null +++ b/benchmarks/other/PhoneInterface/Irrigation/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/xubin/Library/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/benchmarks/other/PhoneInterface/Irrigation/app/src/androidTest/java/com/example/xubin/irrigation/ApplicationTest.java b/benchmarks/other/PhoneInterface/Irrigation/app/src/androidTest/java/com/example/xubin/irrigation/ApplicationTest.java new file mode 100644 index 0000000..1f20d49 --- /dev/null +++ b/benchmarks/other/PhoneInterface/Irrigation/app/src/androidTest/java/com/example/xubin/irrigation/ApplicationTest.java @@ -0,0 +1,13 @@ +package com.example.xubin.irrigation; + +import android.app.Application; +import android.test.ApplicationTestCase; + +/** + * Testing Fundamentals + */ +public class ApplicationTest extends ApplicationTestCase { + public ApplicationTest() { + super(Application.class); + } +} \ No newline at end of file diff --git a/benchmarks/other/PhoneInterface/Irrigation/app/src/main/AndroidManifest.xml b/benchmarks/other/PhoneInterface/Irrigation/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..16b1023 --- /dev/null +++ b/benchmarks/other/PhoneInterface/Irrigation/app/src/main/AndroidManifest.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/benchmarks/other/PhoneInterface/Irrigation/app/src/main/assets/192.168.2.108.pem b/benchmarks/other/PhoneInterface/Irrigation/app/src/main/assets/192.168.2.108.pem new file mode 100644 index 0000000..d038f8a --- /dev/null +++ b/benchmarks/other/PhoneInterface/Irrigation/app/src/main/assets/192.168.2.108.pem @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDkzCCAnugAwIBAgIJAJEv9gf3BRGPMA0GCSqGSIb3DQEBCwUAMGAxCzAJBgNV +BAYTAlVTMQswCQYDVQQIDAJDQTEPMA0GA1UEBwwGSXJ2aW5lMQwwCgYDVQQKDANV +Q0kxDTALBgNVBAsMBEVFQ1MxFjAUBgNVBAMMDTE5Mi4xNjguMi4xMDgwHhcNMTYw +NTE2MjAzOTIzWhcNMTcwNTExMjAzOTIzWjBgMQswCQYDVQQGEwJVUzELMAkGA1UE +CAwCQ0ExDzANBgNVBAcMBklydmluZTEMMAoGA1UECgwDVUNJMQ0wCwYDVQQLDARF +RUNTMRYwFAYDVQQDDA0xOTIuMTY4LjIuMTA4MIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEA5azgPSycemBypBji0+dMvGUku8bCNxOI5t9rg3eTuDo/Sy1N +nQD58jluSsUWf74bBAayZjn0i0lnRWggKXqLJiPLXY1kXxV0TT0+SEynSNC408PV +8hZVYMd7pk6TqZw3MvDm2oHOKmpKW1bTBuNz6xpJhskckLyGM1QAQD9rvNrZII5a +knINejARv3aKRvSRkNaunulXJztY2kOJnpXlO+HvTG8+Dzr8BTKiVU7wu1RwWtUP +ha93eV+g0pbiJ/QUQ9mBScG1+iswOVA1HWnwEpV3GDJltGf1WTN4YsKRrXnfzwRf +gAmTI9SU6KugddHMCTD+/DBn4X4SPxAVc+eqywIDAQABo1AwTjAdBgNVHQ4EFgQU +oAvtU2TVp1KXB1ugGXIdt5zwmJcwHwYDVR0jBBgwFoAUoAvtU2TVp1KXB1ugGXId +t5zwmJcwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAbPa1JIGxmJmd +LQ3cM/nfLWn4BjkUFW7VSlsheL8zxt69uK6diwe3JFPNMHc4ZPey3N9KnlR5v/ax +qCVi4cdm9wA+20uRV3ay6FXNuCTK1YFpFfAJ8c/ZVX4megKLcnb1QHOiYRJIjUp+ +jr36Qvewf/bpRxHZMkmNGx2rQWRUPUUxOlT8mQnxQk+28/FlSLtSRPDNhfnHTahT +ujICes4XEq5/1fMhZKsjGo5JwzHp9KBg/RS1g7Q+gigPZZXCL8ml4pVBt3LYUGEA +7GQoNEL6eXkSvv5jzMwVUwniZmDL6VoHWMZtAHRlFsjT/KRGWBx05shBk2zRuloT +a9vK41EiSw== +-----END CERTIFICATE----- diff --git a/benchmarks/other/PhoneInterface/Irrigation/app/src/main/assets/192.168.2.191.pem b/benchmarks/other/PhoneInterface/Irrigation/app/src/main/assets/192.168.2.191.pem new file mode 100644 index 0000000..02dcba6 --- /dev/null +++ b/benchmarks/other/PhoneInterface/Irrigation/app/src/main/assets/192.168.2.191.pem @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDkzCCAnugAwIBAgIJAMzNAyNJVyYjMA0GCSqGSIb3DQEBCwUAMGAxCzAJBgNV +BAYTAlVTMQswCQYDVQQIDAJDQTEPMA0GA1UEBwwGSXJ2aW5lMQwwCgYDVQQKDANV +Q0kxDTALBgNVBAsMBEVFQ1MxFjAUBgNVBAMMDTE5Mi4xNjguMi4xOTEwHhcNMTYw +NTE3MTY0NTIzWhcNMTcwNTEyMTY0NTIzWjBgMQswCQYDVQQGEwJVUzELMAkGA1UE +CAwCQ0ExDzANBgNVBAcMBklydmluZTEMMAoGA1UECgwDVUNJMQ0wCwYDVQQLDARF +RUNTMRYwFAYDVQQDDA0xOTIuMTY4LjIuMTkxMIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEAwC8c83mhdfluocrTG2tMvwPR6GDiPuDLBAl1nHgmdttHdn1+ +IzaFoeXYa/96DROt7Sq5FiTao1zDsKuIoBulgmmlqwHbCdkbmA2nyk9on9g3KEGm +Q9K6r1IX4gwDnD050uPu3OE6ygDmActgHnlUc65NEgHOCZDztN+TIGCBDVYcAmqH +Ill0oPu2nsHpZBeRc0QoWW9cMBbyt5fFlIsYAV3BZjjU1UBx09R4etPLsO0V6+oV +UT/Vgq11/V5yPwsQdPw5PCFuwnzBeGEKmkPXtgrxZCwD0m9nCrezaALGAtXaI+yk +GkH2KbTDe1lizmL21IsFP1nFY28ux3reZ1obmQIDAQABo1AwTjAdBgNVHQ4EFgQU +O3aAOMYwJ33gMwC1TxpJkj8NU/4wHwYDVR0jBBgwFoAUO3aAOMYwJ33gMwC1TxpJ +kj8NU/4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAEJpPABRerq90 +rZKaI5aYR71j2zlzTmp0GpJ/SmuAXrn83m0B9JOVIK7sAVY99ugjWS+eJtjmDAJc +bb38OFu0hjH9U6W6TVTzNVVt5L6IMH6gMZTEVY61Yze3t+RHFXk2ggrxAgHnNVlo +M5r9Thw427UwHN2P+Du6guEurCJmT3Rw9rDYtHBjuef3Q6KjzuzGwsvLw+pRS5F0 +jlFQgtINvfoZlHmQvy+6jEQe7lyp1nmJPNH421CPpYrfflsIeuG35rHbH0IQ1NNv +aEzUbbvc0CKgIqEj9Spk3YFGMv7BZIcBviy3Jn7VWt57Xexm9hCEkzpkSiWAh/jB +YMuEz6aLJw== +-----END CERTIFICATE----- diff --git a/benchmarks/other/PhoneInterface/Irrigation/app/src/main/assets/192.168.2.192.pem b/benchmarks/other/PhoneInterface/Irrigation/app/src/main/assets/192.168.2.192.pem new file mode 100644 index 0000000..cfac11c --- /dev/null +++ b/benchmarks/other/PhoneInterface/Irrigation/app/src/main/assets/192.168.2.192.pem @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDkzCCAnugAwIBAgIJAKtV1MPWFk4tMA0GCSqGSIb3DQEBCwUAMGAxCzAJBgNV +BAYTAlVTMQswCQYDVQQIDAJDQTEPMA0GA1UEBwwGSXJ2aW5lMQwwCgYDVQQKDANV +Q0kxDTALBgNVBAsMBEVFQ1MxFjAUBgNVBAMMDTE5Mi4xNjguMi4xOTIwHhcNMTYw +NTE3MTY1NjE4WhcNMTcwNTEyMTY1NjE4WjBgMQswCQYDVQQGEwJVUzELMAkGA1UE +CAwCQ0ExDzANBgNVBAcMBklydmluZTEMMAoGA1UECgwDVUNJMQ0wCwYDVQQLDARF +RUNTMRYwFAYDVQQDDA0xOTIuMTY4LjIuMTkyMIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEAyRi5B1CRo2kVBxJOA+Z1PRqw/yeh7zU8x7Pak5Vg2T56hd12 +iUk3V2IrgWh5PYdhrs8ucf17gmsjA+k/kF2GIkzZVNKEakWg1ggqeUbWr/aRP0oO +10uUss4bcbghVoAKrJYZqJ7TjmQZWTcCFzpNzmAFWpcizVbQWF42p3tc7f3zsPk9 +rTOCTj6W2TJWCRHABkYfEExtf7T+JxG1cI/bY7YD/xLCtwykSBYrzDR0gtDxu7OD +in38jO++kTEhkbjUtxnwBzz1bjaiGIBMqt5sufODWqaU5QekFZQz5Ru04gBYRcd+ +jnHEI6SqAY8MkWtp7fo/vYxTK7iuflkbqBkFkQIDAQABo1AwTjAdBgNVHQ4EFgQU +/6CKy031CDWH+lrKn3BtHU+v2O0wHwYDVR0jBBgwFoAU/6CKy031CDWH+lrKn3Bt +HU+v2O0wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAkDQVG+AvrmBI +JGIGuAarNH/QeA7s4KI3B2BGvvSOOb9is1OuKrJ8TubTiEvbe9aGiKcqsZyt1abu +DvQ5GZh9m2aRIGb3ByDg5Qk8iipA/oIuFWexiqa8IoFS2cFu+4nM0CHsQBpdMRNX +tPWvV2CvQuzJRlALSucv4KOenzZmiiHBzBy1Bnbo6UFXl5DgYbOB+Mg82BlqenY5 +C2PpTEsrDmyy0A4IOnPQW9iRaNV7yC2i8T1bbFpSd95f64egb92hzGjf8os1r/5A +OpOccHlP6zFQ7MFCVcUzhKjrVrHFtj89Evag7KwVqFpMIwqRga9DtIaJlxYszPPn +m8woeEp1mA== +-----END CERTIFICATE----- diff --git a/benchmarks/other/PhoneInterface/Irrigation/app/src/main/assets/192.168.2.244.pem b/benchmarks/other/PhoneInterface/Irrigation/app/src/main/assets/192.168.2.244.pem new file mode 100644 index 0000000..cc471f9 --- /dev/null +++ b/benchmarks/other/PhoneInterface/Irrigation/app/src/main/assets/192.168.2.244.pem @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDkzCCAnugAwIBAgIJAJIi1p3z84ZfMA0GCSqGSIb3DQEBCwUAMGAxCzAJBgNV +BAYTAlVTMQswCQYDVQQIDAJDQTEPMA0GA1UEBwwGSXJ2aW5lMQwwCgYDVQQKDANV +Q0kxDTALBgNVBAsMBEVFQ1MxFjAUBgNVBAMMDTE5Mi4xNjguMi4yNDQwHhcNMTYw +NTE3MTY1ODQxWhcNMTcwNTEyMTY1ODQxWjBgMQswCQYDVQQGEwJVUzELMAkGA1UE +CAwCQ0ExDzANBgNVBAcMBklydmluZTEMMAoGA1UECgwDVUNJMQ0wCwYDVQQLDARF +RUNTMRYwFAYDVQQDDA0xOTIuMTY4LjIuMjQ0MIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEA36ufE9vlUNViOL24BSXGYjPrJMz0og55KFP+r9Z7QTz3uXuP +onTkHb4zwnjT7lDfe6Fc0h8mwLsXrgzRGnEa31ywrJS5U1GDN9dlO2x6IO0E5xd6 +wEE+47qSxZ2Kv8f1UfJWgi7Wtla6tkjBqq+Gwj8qodO82km+vkHgqbsEtfFoUlvm +KUfXdEkdigsSwxl2duCvZvDGWQ1j5k+Pr0oVJzTXiTWp0U1scQAtDccKDBzkIG7R +vJ6Ne8xhdaGxu+92bECPp52edOwbD7S5c3ayDr50qHW7Jff+Wd9LaXjpQDxIeMf4 +RUPlbLbpQ0qWEUk2phGUha1j/Tank6V5TKwM1wIDAQABo1AwTjAdBgNVHQ4EFgQU +6gIveONq1Pasrr1DKE92Qq9wpcAwHwYDVR0jBBgwFoAU6gIveONq1Pasrr1DKE92 +Qq9wpcAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAhy90ipsOXmeM +AqXEKc4YA6G9ew/99fYlBaML8qvDyojZDL6Ur7uB2X+eOhB60H/WHCTs0kaWYnnq +dGNfJnaV5ubQwrBOUfpmNdd5HQnxQXcdXev3CqMjz/Sdf9ckdoRkHnZNuqPCF2LO +CB4x9tAo0BPBpnWO5g6O9JEowUv1Zw+hjKudcv8qZXixxuamaDGALZfbG7EG5oK9 +nhpnpb77JBu9WFTRsJfrAXfVo9+s8M38nLOp76Jy9O9jGlUpmG72KTAnqmgOqRzT +C+X74eOUf02JV37kpPYLYnsKYjHqJRtBESgu/SE9CgHIMHbNkqUQTHoStBQxah7I +zb9fkDRHsQ== +-----END CERTIFICATE----- diff --git a/benchmarks/other/PhoneInterface/Irrigation/app/src/main/java/com/example/xubin/irrigation/Helper.java b/benchmarks/other/PhoneInterface/Irrigation/app/src/main/java/com/example/xubin/irrigation/Helper.java new file mode 100644 index 0000000..2ff9b49 --- /dev/null +++ b/benchmarks/other/PhoneInterface/Irrigation/app/src/main/java/com/example/xubin/irrigation/Helper.java @@ -0,0 +1,142 @@ +package com.example.xubin.irrigation; + +import android.util.Log; + +import org.apache.http.HttpResponse; +import org.apache.http.HttpVersion; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.conn.ClientConnectionManager; +import org.apache.http.conn.scheme.PlainSocketFactory; +import org.apache.http.conn.scheme.Scheme; +import org.apache.http.conn.scheme.SchemeRegistry; +import org.apache.http.conn.ssl.SSLSocketFactory; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; +import org.apache.http.params.BasicHttpParams; +import org.apache.http.params.CoreConnectionPNames; +import org.apache.http.params.CoreProtocolPNames; +import org.apache.http.params.HttpParams; +import org.apache.http.protocol.HTTP; +import org.json.JSONArray; +import org.json.JSONObject; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.BufferedInputStream; +import java.util.List; +import java.security.cert.CertificateFactory; +import java.security.cert.Certificate; +import java.security.cert.X509Certificate; +import java.security.KeyStore; + +/** + * Created by xubin on 4/26/16. + */ +public class Helper { + private static final int Driver_port = 8000; + private static final String Tag = "http"; + private static final String KEYEXT = ".pem"; + + HttpClient httpclient; + //Set up + void setConnection(String destIP) { + + httpclient = createClient(destIP); + } + + HttpClient createClient(String destIP) { + HttpParams params = new BasicHttpParams(); + params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); + params.setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, HTTP.DEFAULT_CONTENT_CHARSET); + params.setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true); + params.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 30 * 1000); + params.setParameter(CoreConnectionPNames.SO_TIMEOUT, 30 * 1000); + + SchemeRegistry schReg = new SchemeRegistry(); + schReg.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), Driver_port)); + schReg.register(new Scheme("https", newSslSocketFactory(destIP), 443)); + ClientConnectionManager conMgr = new ThreadSafeClientConnManager(params, schReg); + + return new DefaultHttpClient(conMgr, params); + } + + //Make http request + public void makeRequest(String destIP, List paramObjects, String methodName) { + String url = "https://"+ destIP + ":"+Driver_port+ "/"+methodName; + System.out.println("URL: " + url); + InputStream inputStream = null; + String result = ""; + try { + HttpPost httpPost = new HttpPost(url); + JSONArray params = new JSONArray(); + + JSONObject parent = new JSONObject(); + for (int i = 0; i < paramObjects.size(); i++) { + JSONObject content = new JSONObject(); + content.put("type", paramObjects.get(i).getClass().getName()); + content.put("value", paramObjects.get(i)); + params.put(i, content); + } + parent.put("params", params); + StringEntity se = new StringEntity(parent.toString()); + httpPost.setEntity(se); + httpPost.setHeader("Accept", "application/json"); + httpPost.setHeader("Content-type", "application/json"); + HttpResponse httpResponse = httpclient.execute(httpPost); + // 9. receive response as inputStream + inputStream = httpResponse.getEntity().getContent(); + + // 10. convert inputstream to string + if(inputStream != null) + result = convertInputStreamToString(inputStream); + else + result = "Did not work!"; + Log.v(Tag, result); + } catch (Exception ex) { + if (ex.getMessage() != null) { + Log.v(Tag, ex.getMessage()); + } + ex.printStackTrace(); + } + } + + private SSLSocketFactory newSslSocketFactory(String destIP) { + try { + // Load CAs from an InputStream + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + InputStream caInput = new + BufferedInputStream(MainActivity.context.getAssets().open(destIP + KEYEXT)); + Certificate ca; + try { + ca = cf.generateCertificate(caInput); + System.out.println("ca=" + ((X509Certificate) ca).getSubjectDN()); + } finally { + caInput.close(); + } + String keyStoreType = KeyStore.getDefaultType(); + KeyStore keyStore = KeyStore.getInstance(keyStoreType); + keyStore.load(null, null); + keyStore.setCertificateEntry("ca", ca); + SSLSocketFactory socketFactory = new SSLSocketFactory(keyStore); + return socketFactory; + } catch (Exception e) { + throw new AssertionError(e); + } + } + + private static String convertInputStreamToString(InputStream inputStream) throws IOException { + BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(inputStream)); + String line = ""; + String result = ""; + while((line = bufferedReader.readLine()) != null) + result += line; + + inputStream.close(); + return result; + + } +} diff --git a/benchmarks/other/PhoneInterface/Irrigation/app/src/main/java/com/example/xubin/irrigation/MainActivity.java b/benchmarks/other/PhoneInterface/Irrigation/app/src/main/java/com/example/xubin/irrigation/MainActivity.java new file mode 100644 index 0000000..65c7c34 --- /dev/null +++ b/benchmarks/other/PhoneInterface/Irrigation/app/src/main/java/com/example/xubin/irrigation/MainActivity.java @@ -0,0 +1,106 @@ +package com.example.xubin.irrigation; + +import android.os.AsyncTask; +import android.os.Bundle; +import android.support.design.widget.FloatingActionButton; +import android.support.design.widget.Snackbar; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.view.View; +import android.view.Menu; +import android.view.MenuItem; +import android.widget.Button; +import android.widget.EditText; +import android.content.Context; + +import java.util.ArrayList; +import java.util.List; + +public class MainActivity extends AppCompatActivity { + + private EditText gatewayIP; + private EditText inchesPerWeek; + private EditText weatherZipCode; + private EditText daysToWaterOn; + private EditText inchesPerMinute; + private Button submit_button; + protected static Context context; + private Helper helper = new Helper(); + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + context = getApplicationContext(); + gatewayIP = (EditText) findViewById(R.id.gatewayip); + inchesPerWeek = (EditText) findViewById(R.id.week); + weatherZipCode = (EditText) findViewById(R.id.zip); + daysToWaterOn = (EditText) findViewById(R.id.water); + inchesPerMinute = (EditText) findViewById(R.id.minute); + submit_button = (Button) findViewById(R.id.submit); + + submit_button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + List params = new ArrayList<>(); + params.add(Double.parseDouble(inchesPerWeek.getText().toString())); + params.add(Integer.parseInt(weatherZipCode.getText().toString())); + params.add(Integer.parseInt(daysToWaterOn.getText().toString())); + params.add(Double.parseDouble(inchesPerMinute.getText().toString())); + + String ip = gatewayIP.getText().toString(); + new MakeRequestTask(params).execute(ip, "getIrrigationInfo"); + + } + }); + FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) + .setAction("Action", null).show(); + } + }); + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } + private class MakeRequestTask extends AsyncTask{ + private List params; + public MakeRequestTask(List argus) { + this.params = argus; + } + @Override + protected Void doInBackground(String... argus) { + if (helper.httpclient == null) { + helper.setConnection(argus[0]); + } + + helper.makeRequest(argus[0],params, argus[1]); + + return null; + } + } +} diff --git a/benchmarks/other/PhoneInterface/Irrigation/app/src/main/res/layout/activity_main.xml b/benchmarks/other/PhoneInterface/Irrigation/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..0596703 --- /dev/null +++ b/benchmarks/other/PhoneInterface/Irrigation/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/benchmarks/other/PhoneInterface/Irrigation/app/src/main/res/layout/content_main.xml b/benchmarks/other/PhoneInterface/Irrigation/app/src/main/res/layout/content_main.xml new file mode 100644 index 0000000..f50e2d1 --- /dev/null +++ b/benchmarks/other/PhoneInterface/Irrigation/app/src/main/res/layout/content_main.xml @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + +