From: rtrimana Date: Thu, 21 Sep 2017 19:04:48 +0000 (-0700) Subject: Checking in LEDE GUI for device registration; this was ported from the implementation... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;ds=sidebyside;h=a914d58c0a70f99490f059733d903c8974d5aa91;p=iot2.git Checking in LEDE GUI for device registration; this was ported from the implementation by the UROP South Korean students (June-August 2017); now, works on the main LEDE router with the adjusted scripts (see the previous one commit). --- diff --git a/others/lede-gui/.gitignore b/others/lede-gui/.gitignore new file mode 100644 index 0000000..3543521 --- /dev/null +++ b/others/lede-gui/.gitignore @@ -0,0 +1 @@ +/build diff --git a/others/lede-gui/.gradle/3.3/taskArtifacts/fileHashes.bin b/others/lede-gui/.gradle/3.3/taskArtifacts/fileHashes.bin new file mode 100644 index 0000000..8a9ea4e Binary files /dev/null and b/others/lede-gui/.gradle/3.3/taskArtifacts/fileHashes.bin differ diff --git a/others/lede-gui/.gradle/3.3/taskArtifacts/fileSnapshots.bin b/others/lede-gui/.gradle/3.3/taskArtifacts/fileSnapshots.bin new file mode 100644 index 0000000..5832079 Binary files /dev/null and b/others/lede-gui/.gradle/3.3/taskArtifacts/fileSnapshots.bin differ diff --git a/others/lede-gui/.gradle/3.3/taskArtifacts/taskArtifacts.bin b/others/lede-gui/.gradle/3.3/taskArtifacts/taskArtifacts.bin new file mode 100644 index 0000000..399927f Binary files /dev/null and b/others/lede-gui/.gradle/3.3/taskArtifacts/taskArtifacts.bin differ diff --git a/others/lede-gui/.gradle/3.3/taskArtifacts/taskArtifacts.lock b/others/lede-gui/.gradle/3.3/taskArtifacts/taskArtifacts.lock new file mode 100644 index 0000000..a153485 Binary files /dev/null and b/others/lede-gui/.gradle/3.3/taskArtifacts/taskArtifacts.lock differ diff --git a/others/lede-gui/.gradle/3.3/tasks/_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.bin b/others/lede-gui/.gradle/3.3/tasks/_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.bin new file mode 100644 index 0000000..c182c8b Binary files /dev/null and b/others/lede-gui/.gradle/3.3/tasks/_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.bin differ diff --git a/others/lede-gui/.gradle/3.3/tasks/_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.lock b/others/lede-gui/.gradle/3.3/tasks/_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.lock new file mode 100644 index 0000000..627cc8a Binary files /dev/null and b/others/lede-gui/.gradle/3.3/tasks/_compileDebugJavaWithJavac/localClassSetAnalysis/localClassSetAnalysis.lock differ diff --git a/others/lede-gui/.gradle/3.3/tasks/_compileDebugJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.bin b/others/lede-gui/.gradle/3.3/tasks/_compileDebugJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.bin new file mode 100644 index 0000000..e08f809 Binary files /dev/null and b/others/lede-gui/.gradle/3.3/tasks/_compileDebugJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.bin differ diff --git a/others/lede-gui/.gradle/3.3/tasks/_compileDebugJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.lock b/others/lede-gui/.gradle/3.3/tasks/_compileDebugJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.lock new file mode 100644 index 0000000..067e9e4 Binary files /dev/null and b/others/lede-gui/.gradle/3.3/tasks/_compileDebugJavaWithJavac/localJarClasspathSnapshot/localJarClasspathSnapshot.lock differ diff --git a/others/lede-gui/.idea/compiler.xml b/others/lede-gui/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/others/lede-gui/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/copyright/profiles_settings.xml b/others/lede-gui/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..c7d1c5a --- /dev/null +++ b/others/lede-gui/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/gradle.xml b/others/lede-gui/.idea/gradle.xml new file mode 100644 index 0000000..47bd81f --- /dev/null +++ b/others/lede-gui/.idea/gradle.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/animated_vector_drawable_26_0_0_alpha1.xml b/others/lede-gui/.idea/libraries/animated_vector_drawable_26_0_0_alpha1.xml new file mode 100644 index 0000000..37594df --- /dev/null +++ b/others/lede-gui/.idea/libraries/animated_vector_drawable_26_0_0_alpha1.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/appcompat_v7_26_0_0_alpha1.xml b/others/lede-gui/.idea/libraries/appcompat_v7_26_0_0_alpha1.xml new file mode 100644 index 0000000..ff5b26d --- /dev/null +++ b/others/lede-gui/.idea/libraries/appcompat_v7_26_0_0_alpha1.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/constraint_layout_1_0_2.xml b/others/lede-gui/.idea/libraries/constraint_layout_1_0_2.xml new file mode 100644 index 0000000..83b382d --- /dev/null +++ b/others/lede-gui/.idea/libraries/constraint_layout_1_0_2.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/constraint_layout_solver_1_0_2.xml b/others/lede-gui/.idea/libraries/constraint_layout_solver_1_0_2.xml new file mode 100644 index 0000000..f71d1a6 --- /dev/null +++ b/others/lede-gui/.idea/libraries/constraint_layout_solver_1_0_2.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/design_26_0_0_alpha1.xml b/others/lede-gui/.idea/libraries/design_26_0_0_alpha1.xml new file mode 100644 index 0000000..ac70c61 --- /dev/null +++ b/others/lede-gui/.idea/libraries/design_26_0_0_alpha1.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/espresso_core_2_2_2.xml b/others/lede-gui/.idea/libraries/espresso_core_2_2_2.xml new file mode 100644 index 0000000..9113cc7 --- /dev/null +++ b/others/lede-gui/.idea/libraries/espresso_core_2_2_2.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/espresso_idling_resource_2_2_2.xml b/others/lede-gui/.idea/libraries/espresso_idling_resource_2_2_2.xml new file mode 100644 index 0000000..69cf85a --- /dev/null +++ b/others/lede-gui/.idea/libraries/espresso_idling_resource_2_2_2.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/exposed_instrumentation_api_publish_0_5.xml b/others/lede-gui/.idea/libraries/exposed_instrumentation_api_publish_0_5.xml new file mode 100644 index 0000000..de3e1d7 --- /dev/null +++ b/others/lede-gui/.idea/libraries/exposed_instrumentation_api_publish_0_5.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/hamcrest_core_1_3.xml b/others/lede-gui/.idea/libraries/hamcrest_core_1_3.xml new file mode 100644 index 0000000..157e3f3 --- /dev/null +++ b/others/lede-gui/.idea/libraries/hamcrest_core_1_3.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/hamcrest_integration_1_3.xml b/others/lede-gui/.idea/libraries/hamcrest_integration_1_3.xml new file mode 100644 index 0000000..58b2c4b --- /dev/null +++ b/others/lede-gui/.idea/libraries/hamcrest_integration_1_3.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/hamcrest_library_1_3.xml b/others/lede-gui/.idea/libraries/hamcrest_library_1_3.xml new file mode 100644 index 0000000..676cc63 --- /dev/null +++ b/others/lede-gui/.idea/libraries/hamcrest_library_1_3.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/iotinstaller.xml b/others/lede-gui/.idea/libraries/iotinstaller.xml new file mode 100644 index 0000000..80ad498 --- /dev/null +++ b/others/lede-gui/.idea/libraries/iotinstaller.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/javawriter_2_1_1.xml b/others/lede-gui/.idea/libraries/javawriter_2_1_1.xml new file mode 100644 index 0000000..a66fefb --- /dev/null +++ b/others/lede-gui/.idea/libraries/javawriter_2_1_1.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/javax_annotation_api_1_2.xml b/others/lede-gui/.idea/libraries/javax_annotation_api_1_2.xml new file mode 100644 index 0000000..811e73f --- /dev/null +++ b/others/lede-gui/.idea/libraries/javax_annotation_api_1_2.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/javax_inject_1.xml b/others/lede-gui/.idea/libraries/javax_inject_1.xml new file mode 100644 index 0000000..0d1d5fc --- /dev/null +++ b/others/lede-gui/.idea/libraries/javax_inject_1.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/jsch_0_1_54.xml b/others/lede-gui/.idea/libraries/jsch_0_1_54.xml new file mode 100644 index 0000000..803717f --- /dev/null +++ b/others/lede-gui/.idea/libraries/jsch_0_1_54.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/jsr305_2_0_1.xml b/others/lede-gui/.idea/libraries/jsr305_2_0_1.xml new file mode 100644 index 0000000..cdf9878 --- /dev/null +++ b/others/lede-gui/.idea/libraries/jsr305_2_0_1.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/junit_4_12.xml b/others/lede-gui/.idea/libraries/junit_4_12.xml new file mode 100644 index 0000000..305df30 --- /dev/null +++ b/others/lede-gui/.idea/libraries/junit_4_12.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/recyclerview_v7_26_0_0_alpha1.xml b/others/lede-gui/.idea/libraries/recyclerview_v7_26_0_0_alpha1.xml new file mode 100644 index 0000000..fb50ff2 --- /dev/null +++ b/others/lede-gui/.idea/libraries/recyclerview_v7_26_0_0_alpha1.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/rules_0_5.xml b/others/lede-gui/.idea/libraries/rules_0_5.xml new file mode 100644 index 0000000..91e07ed --- /dev/null +++ b/others/lede-gui/.idea/libraries/rules_0_5.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/runner_0_5.xml b/others/lede-gui/.idea/libraries/runner_0_5.xml new file mode 100644 index 0000000..4c2562f --- /dev/null +++ b/others/lede-gui/.idea/libraries/runner_0_5.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/support_annotations_26_0_0_alpha1.xml b/others/lede-gui/.idea/libraries/support_annotations_26_0_0_alpha1.xml new file mode 100644 index 0000000..44566c5 --- /dev/null +++ b/others/lede-gui/.idea/libraries/support_annotations_26_0_0_alpha1.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/support_compat_26_0_0_alpha1.xml b/others/lede-gui/.idea/libraries/support_compat_26_0_0_alpha1.xml new file mode 100644 index 0000000..5507d57 --- /dev/null +++ b/others/lede-gui/.idea/libraries/support_compat_26_0_0_alpha1.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/support_core_ui_26_0_0_alpha1.xml b/others/lede-gui/.idea/libraries/support_core_ui_26_0_0_alpha1.xml new file mode 100644 index 0000000..5ad1369 --- /dev/null +++ b/others/lede-gui/.idea/libraries/support_core_ui_26_0_0_alpha1.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/support_core_utils_26_0_0_alpha1.xml b/others/lede-gui/.idea/libraries/support_core_utils_26_0_0_alpha1.xml new file mode 100644 index 0000000..07958bb --- /dev/null +++ b/others/lede-gui/.idea/libraries/support_core_utils_26_0_0_alpha1.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/support_fragment_26_0_0_alpha1.xml b/others/lede-gui/.idea/libraries/support_fragment_26_0_0_alpha1.xml new file mode 100644 index 0000000..520ccd2 --- /dev/null +++ b/others/lede-gui/.idea/libraries/support_fragment_26_0_0_alpha1.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/support_media_compat_26_0_0_alpha1.xml b/others/lede-gui/.idea/libraries/support_media_compat_26_0_0_alpha1.xml new file mode 100644 index 0000000..cc2ac96 --- /dev/null +++ b/others/lede-gui/.idea/libraries/support_media_compat_26_0_0_alpha1.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/support_v4_26_0_0_alpha1.xml b/others/lede-gui/.idea/libraries/support_v4_26_0_0_alpha1.xml new file mode 100644 index 0000000..669a0bd --- /dev/null +++ b/others/lede-gui/.idea/libraries/support_v4_26_0_0_alpha1.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/support_vector_drawable_26_0_0_alpha1.xml b/others/lede-gui/.idea/libraries/support_vector_drawable_26_0_0_alpha1.xml new file mode 100644 index 0000000..dfe14f4 --- /dev/null +++ b/others/lede-gui/.idea/libraries/support_vector_drawable_26_0_0_alpha1.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/libraries/transition_26_0_0_alpha1.xml b/others/lede-gui/.idea/libraries/transition_26_0_0_alpha1.xml new file mode 100644 index 0000000..49ecf0a --- /dev/null +++ b/others/lede-gui/.idea/libraries/transition_26_0_0_alpha1.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/misc.xml b/others/lede-gui/.idea/misc.xml new file mode 100644 index 0000000..b0a270f --- /dev/null +++ b/others/lede-gui/.idea/misc.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/modules.xml b/others/lede-gui/.idea/modules.xml new file mode 100644 index 0000000..e45091c --- /dev/null +++ b/others/lede-gui/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/runConfigurations.xml b/others/lede-gui/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/others/lede-gui/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/others/lede-gui/.idea/workspace.xml b/others/lede-gui/.idea/workspace.xml new file mode 100644 index 0000000..9323b6a --- /dev/null +++ b/others/lede-gui/.idea/workspace.xml @@ -0,0 +1,2181 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1501629053988 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/build.gradle b/others/lede-gui/build.gradle new file mode 100644 index 0000000..f74784d --- /dev/null +++ b/others/lede-gui/build.gradle @@ -0,0 +1,49 @@ +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:2.3.3' + } +} + +allprojects { + repositories { + jcenter() + } +} + +apply plugin: 'com.android.application' + +android { + compileSdkVersion 26 + buildToolsVersion "26.0.0" + + defaultConfig { + applicationId "com.example.lede2" + minSdkVersion 15 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(include: ['*.jar'], dir: 'libs') + androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + exclude group: 'com.android.support', module: 'support-annotations' + }) + compile 'com.android.support:appcompat-v7:26.+' + compile 'com.android.support.constraint:constraint-layout:1.0.2' + compile 'com.android.support:design:26.0.0-alpha1' + testCompile 'junit:junit:4.12' +} diff --git a/others/lede-gui/gradle/wrapper/gradle-wrapper.jar b/others/lede-gui/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..13372ae Binary files /dev/null and b/others/lede-gui/gradle/wrapper/gradle-wrapper.jar differ diff --git a/others/lede-gui/gradle/wrapper/gradle-wrapper.properties b/others/lede-gui/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..b483d86 --- /dev/null +++ b/others/lede-gui/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Sep 20 13:44:40 PDT 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip diff --git a/others/lede-gui/gradlew b/others/lede-gui/gradlew new file mode 100644 index 0000000..9d82f78 --- /dev/null +++ b/others/lede-gui/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/others/lede-gui/gradlew.bat b/others/lede-gui/gradlew.bat new file mode 100644 index 0000000..aec9973 --- /dev/null +++ b/others/lede-gui/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/others/lede-gui/lede-gui.iml b/others/lede-gui/lede-gui.iml new file mode 100644 index 0000000..b56780f --- /dev/null +++ b/others/lede-gui/lede-gui.iml @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/libs/iotinstaller.jar b/others/lede-gui/libs/iotinstaller.jar new file mode 100644 index 0000000..1acf7be Binary files /dev/null and b/others/lede-gui/libs/iotinstaller.jar differ diff --git a/others/lede-gui/libs/jsch-0.1.54.jar b/others/lede-gui/libs/jsch-0.1.54.jar new file mode 100644 index 0000000..1372c8e Binary files /dev/null and b/others/lede-gui/libs/jsch-0.1.54.jar differ diff --git a/others/lede-gui/local.properties b/others/lede-gui/local.properties new file mode 100644 index 0000000..35ebc26 --- /dev/null +++ b/others/lede-gui/local.properties @@ -0,0 +1,11 @@ +## This file is automatically generated by Android Studio. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must *NOT* be checked into Version Control Systems, +# as it contains information specific to your local configuration. +# +# Location of the SDK. This is only used by Gradle. +# For customization when using a Version Control System, please read the +# header note. +#Wed Sep 20 12:05:53 PDT 2017 +sdk.dir=/home/rtrimana/Android/Sdk diff --git a/others/lede-gui/proguard-rules.pro b/others/lede-gui/proguard-rules.pro new file mode 100644 index 0000000..e01b6b6 --- /dev/null +++ b/others/lede-gui/proguard-rules.pro @@ -0,0 +1,25 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:\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 *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/others/lede-gui/src/androidTest/java/com/example/lede2/ExampleInstrumentedTest.java b/others/lede-gui/src/androidTest/java/com/example/lede2/ExampleInstrumentedTest.java new file mode 100644 index 0000000..26dadde --- /dev/null +++ b/others/lede-gui/src/androidTest/java/com/example/lede2/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.example.lede2; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumentation test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.example.lede2", appContext.getPackageName()); + } +} diff --git a/others/lede-gui/src/main/AndroidManifest.xml b/others/lede-gui/src/main/AndroidManifest.xml new file mode 100644 index 0000000..c8e7e6f --- /dev/null +++ b/others/lede-gui/src/main/AndroidManifest.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/others/lede-gui/src/main/java/com/example/lede2/ConfigActivity.java b/others/lede-gui/src/main/java/com/example/lede2/ConfigActivity.java new file mode 100644 index 0000000..de16fa9 --- /dev/null +++ b/others/lede-gui/src/main/java/com/example/lede2/ConfigActivity.java @@ -0,0 +1,74 @@ +package com.example.lede2; + +import android.content.Context; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; +import android.view.inputmethod.InputMethodManager; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Toast; + +import java.lang.*; + +public class ConfigActivity extends AppCompatActivity implements View.OnClickListener,View.OnFocusChangeListener { + + EditText ssid; + EditText pwd; + EditText ip; + EditText user; + Button save; + public static String RSSID = MainActivity.DEF_RSSID; + public static String RPWD = MainActivity.DEF_RPWD; + public static String ROUTERIP = MainActivity.DEF_ROUTERIP; + public static String ROUTERUSER = MainActivity.DEF_ROUTERUSER; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_config); + + ssid = (EditText) findViewById(R.id.ssid); + pwd = (EditText) findViewById(R.id.pwd); + ip = (EditText) findViewById(R.id.ip); + user = (EditText) findViewById(R.id.user); + save = (Button) findViewById(R.id.save); + + ssid.setOnFocusChangeListener(this); + pwd.setOnFocusChangeListener(this); + ip.setOnFocusChangeListener(this); + user.setOnFocusChangeListener(this); + save.setOnClickListener(this); + } + + @Override + public void onClick(View view) { + if (view == save) { + if (ssid.getText().toString().equals("") || pwd.getText().toString().equals("") || + ip.getText().toString().equals("") || user.getText().toString().equals("")) { + Toast t = Toast.makeText(this, R.string.blank, Toast.LENGTH_SHORT); + t.show(); + return; + } else { + RSSID = ssid.getText().toString(); + RPWD = pwd.getText().toString(); + ROUTERIP = ip.getText().toString(); + ROUTERUSER = user.getText().toString(); + finish(); + } + } + } + + + @Override + public void onFocusChange(View view, boolean hasFocus) {//function not to modify randomly generated password for newly registered device + InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + if (hasFocus) { + imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); + } else { + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + } + } + +} diff --git a/others/lede-gui/src/main/java/com/example/lede2/EnrollDeviceActivity.java b/others/lede-gui/src/main/java/com/example/lede2/EnrollDeviceActivity.java new file mode 100644 index 0000000..926870a --- /dev/null +++ b/others/lede-gui/src/main/java/com/example/lede2/EnrollDeviceActivity.java @@ -0,0 +1,163 @@ +package com.example.lede2; + +import android.content.Context; +import android.content.Intent; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; +import android.net.wifi.WifiInfo; +import android.net.wifi.WifiManager; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; +import android.view.inputmethod.InputMethodManager; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; +import android.util.Log; + +import java.util.Random; + +public class EnrollDeviceActivity extends AppCompatActivity implements View.OnClickListener, View.OnFocusChangeListener { + + private static final int REQUEST_RESULT = 1001; + Button done;//Done button in UI + Button wifi;//wifi button in UI + SSH ssh;//Connection object between Android & Router + Context context; + + TextView psk;//red letter in UI + String newpsk;//same as psk (different data type) + + EditText name;//device name newly registered in UI + String deviceName;//same as name(different data type) + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_enroll_device); + + ssh = new SSH(); + psk = (TextView) findViewById(R.id.add_psk); + done = (Button) findViewById(R.id.done); + wifi = (Button) findViewById(R.id.wifi); + name = (EditText) findViewById(R.id.name); + + done.setOnClickListener(this); + wifi.setOnClickListener(this); + name.setOnFocusChangeListener(this); + + //Make random password and show the password through EditText + newpsk = generateRandomPassword(); + psk.setText(newpsk); + // execute shell script (script's function -> change router password to newpsk) + ssh.execute("-ch " + newpsk); + try {//To execute asyntask in ssh object, we have to sleep main thread + Thread.sleep(1000); + } catch (Exception e) { + Log.d("SLEEP EXCEPTION", "SLEEP EXCEPTION occurs in onCreate method of EnrollDeviceActivity"); + } + } + + @Override + public void onFocusChange(View view, boolean hasFocus) {//function not to modify randomly generated password for newly registered device + InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + if (hasFocus) { + imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); + } else { + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + } + } + + boolean isNetworkAvailable() {//check whether wifi connection is or not + Context context = getApplicationContext(); + ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); + boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting(); + return isConnected; + } + + @Override + public void onClick(View v) { + if (v == done) { + //Users try to execute shell scripts by pushing button, + //but problem could occur(application stop) if user push the button without wifi connection + //As a result, below function have to be implemented. + if (isNetworkAvailable() == false) {//without wifi connection + Toast t = Toast.makeText(this, R.string.connect, Toast.LENGTH_SHORT); + t.show(); + startActivity(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK)); + } else {//with wifi connection + deviceName = name.getText().toString(); + if(deviceName.equals("")){ + Toast t = Toast.makeText(this, R.string.empty_name,Toast.LENGTH_SHORT); + t.show(); + return; + } + context = getApplicationContext(); + if (getWifiName(context).equals("\""+ ConfigActivity.RSSID +"\"")) {//if wifi name is LEDE2 + String networkPass = psk.getText().toString();//random password + ssh = new SSH(); + + // execute shell script (script's function -> Save contents(Mac,Ip,Key,Name) on hostapd-psk) + ssh.execute("-co " + networkPass + " " + deviceName +" "+ ConfigActivity.RPWD);//review!!!!!! + try {//To execute asyntask in ssh object, we have to sleep main thread + Thread.sleep(1000); + } catch (Exception e) { + Log.d("SLEEP EXCEPTION", "SLEEP EXCEPTION occurs in onClick method of EnrollDeviceActivity"); + } + finish();//Go back to the Main Activity + } else { //if name of wifi is not LEDE2 -> go to wifi configuration screen to change wifi type + Toast t = Toast.makeText(this, R.string.try_again, Toast.LENGTH_SHORT); + t.show(); + startActivity(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK)); + } + } + } else if (v == wifi) { + startActivity(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK)); + } + } + + /******************************************************************************************************************************************************************/ + //Detect you are connected to a specific network. + /******************************************************************************************************************************************************************/ + public String getWifiName(Context context) { + WifiManager manager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); + if (manager.isWifiEnabled()) { + WifiInfo wifiInfo = manager.getConnectionInfo(); + if (wifiInfo != null) { + NetworkInfo.DetailedState state = WifiInfo.getDetailedStateOf(wifiInfo.getSupplicantState()); + if (state == NetworkInfo.DetailedState.CONNECTED || state == NetworkInfo.DetailedState.OBTAINING_IPADDR) { + return wifiInfo.getSSID(); + } + } + } + return null; + } + + /******************************************************************************************************************************************************************/ + // Generate a random password and return it + /******************************************************************************************************************************************************************/ + public String generateRandomPassword() { + String password = new String(); + + StringBuffer rndpassword = new StringBuffer(); + Random rnd = new Random(); + int digitnum = 20; + // Generate random 20digit password with upper / lower case alphabet + numbers + // There are 10 int nums, 26 lower alphabets, 26 upper alphabets. Total 62 + // So 2/12 possiblity of int, 5/12 lower, 5/12 upper alphabets. + for (int i = 0; i < digitnum; i++) { + int rIndex = rnd.nextInt(12); + if (rIndex >= 0 && rIndex < 2) { // 0 - 9 + rndpassword.append((rnd.nextInt(10))); + } else if (rIndex >= 2 && rIndex < 7) { // a-z + rndpassword.append((char) ((int) (rnd.nextInt(26)) + 97)); + } else { // A-Z + rndpassword.append((char) ((int) (rnd.nextInt(26)) + 65)); + } + } + password = rndpassword.toString(); + return password; + } +} diff --git a/others/lede-gui/src/main/java/com/example/lede2/ListActivity.java b/others/lede-gui/src/main/java/com/example/lede2/ListActivity.java new file mode 100644 index 0000000..60bc1f8 --- /dev/null +++ b/others/lede-gui/src/main/java/com/example/lede2/ListActivity.java @@ -0,0 +1,87 @@ +package com.example.lede2; + +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.util.Log; +import android.util.SparseBooleanArray; +import android.view.View; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.ListView; + +import java.util.List; + +public class ListActivity extends AppCompatActivity implements View.OnClickListener { + + Button delete;//delete button in UI + Button selectAll;//select button in UI + ListView listview;//listview in UI + SSH ssh;//Connection object between Android & Router + List tmp;//data structure which has IoT device information already registered on LEDE2 + ArrayAdapter adapter;//adapter between tmp and listview + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_list); + + ssh = new SSH(); + try { + tmp = ssh.execute("-ln").get(); + Thread.sleep(1000);//To execute asyntask in ssh object, we have to sleep main thread + } catch (Exception e) { + } + + delete = (Button) findViewById(R.id.delete); + selectAll = (Button) findViewById(R.id.selectAll); + listview = (ListView) findViewById(R.id.listView1); + + adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_multiple_choice, tmp);//register tmp array to adapter + + delete.setOnClickListener(this); + selectAll.setOnClickListener(this); + listview.setAdapter(adapter); + } + + @Override + public void onClick(View v) { + if (v == delete) { + //SparseBooleanArray's data is Ture or False + SparseBooleanArray checkedItems = listview.getCheckedItemPositions();//to check which devices are checked in listview(check -> true, no check -> false) + int count = adapter.getCount();//number of items in listview + String command = "-dn "; //after, +'name ' + + for (int i = count - 1; i >= 0; i--) {//scan from back + //i : index of IoT device which will be removed in tmp array + if (checkedItems.get(i)) {//if check + String rmName = tmp.get(i).toString();//save the name of checked IoT device + command += rmName + " ";//complete command + //remove this information on the listview + tmp.remove(i); + } + } + try { + //delete IoT device information in the router by sending command line to router + ssh = new SSH(); + ssh.execute(command); + Thread.sleep(1000);//To execute asyntask in ssh object, we have to sleep main thread + } catch (Exception e) { + Log.d("SLEEP EXCEPTION", "SLEEP EXCEPTION occurs in onClick method of ListActivity"); + } + + //update + adapter.notifyDataSetChanged(); + + //delete checked mark in listview + listview.clearChoices(); + + } else if (v == selectAll) { + int count; + count = adapter.getCount(); + + for (int i = 0; i < count; i++) { + listview.setItemChecked(i, true); + } + } + } +} diff --git a/others/lede-gui/src/main/java/com/example/lede2/MainActivity.java b/others/lede-gui/src/main/java/com/example/lede2/MainActivity.java new file mode 100644 index 0000000..d4ee5ea --- /dev/null +++ b/others/lede-gui/src/main/java/com/example/lede2/MainActivity.java @@ -0,0 +1,100 @@ +package com.example.lede2; + +import android.content.Context; +import android.content.Intent; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; +import android.net.wifi.WifiManager; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; +import android.widget.Toast; + +import iotinstaller.IoTInstaller; + +public class MainActivity extends AppCompatActivity implements View.OnClickListener { + + Button registerButton; + Button listButton; + Button configButton; + TextView ssid; + protected static Context context; + protected static String DEF_RSSID; + protected static String DEF_RPWD; + protected static String DEF_ROUTERIP; + protected static String DEF_ROUTERUSER; + protected static String DEF_CHANGE_DEFAULT_SCRIPT; + protected static String DEF_CONNECT_DEVICE_SCRIPT; + protected static String DEF_REGISTER_DEVICE_SCRIPT; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + registerButton = (Button) findViewById(R.id.register); + listButton = (Button) findViewById(R.id.list); + configButton = (Button) findViewById(R.id.config); + ssid = (TextView)findViewById(R.id.ssid); + + registerButton.setOnClickListener(this); + listButton.setOnClickListener(this); + configButton.setOnClickListener(this); + + context = getApplicationContext(); + DEF_RSSID = context.getResources().getString(R.string.default_rssid); + DEF_RPWD = context.getResources().getString(R.string.default_rpwd); + DEF_ROUTERIP = context.getResources().getString(R.string.default_routerip); + DEF_ROUTERUSER = context.getResources().getString(R.string.default_routeruser); + DEF_CHANGE_DEFAULT_SCRIPT = context.getResources().getString(R.string.change_default_script); + DEF_CONNECT_DEVICE_SCRIPT = context.getResources().getString(R.string.connect_device_script); + DEF_REGISTER_DEVICE_SCRIPT = context.getResources().getString(R.string.register_device_script); + ssid.setText(DEF_RSSID); + } + + public void onClick(View v) { + + if(v == configButton){ + startActivityForResult(new Intent(this,ConfigActivity.class),1000); + } + + //Users try to execute shell scripts by pushing button, + //but problem could occur(application stop) if user push the button without wifi connection + //As a result, below function have to be implemented. + if (isNetworkAvailable() == false) {//without wifi connection + Toast t = Toast.makeText(this, R.string.connect, Toast.LENGTH_SHORT); + t.show(); + startActivity(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK)); + } else {//with wifi connection + if (v == registerButton) { + Log.d("CLICKING", "Clicking on register!"); + startActivity(new Intent(this, EnrollDeviceActivity.class)); + } else if (v == listButton) { + startActivity(new Intent(this, ListActivity.class)); + } + } + //IoTInstaller ioTInstaller = new IoTInstaller(); + //ioTInstaller.helpMessages(); + + } + + boolean isNetworkAvailable() {//check whether wifi connection is or not + Context context = getApplicationContext(); + ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); + boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting(); + return isConnected; + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + + if(requestCode == 1000){ + ssid.setText(ConfigActivity.RSSID); + } + } +} diff --git a/others/lede-gui/src/main/java/com/example/lede2/MySQLInterface.config b/others/lede-gui/src/main/java/com/example/lede2/MySQLInterface.config new file mode 100644 index 0000000..b809e59 --- /dev/null +++ b/others/lede-gui/src/main/java/com/example/lede2/MySQLInterface.config @@ -0,0 +1,7 @@ +# MySQLInterface configuration + +#HOST=128.195.204.105 +HOST=localhost +DATABASE=IoTMain +USERNAME=root +PASSWORD=1234 \ No newline at end of file diff --git a/others/lede-gui/src/main/java/com/example/lede2/SSH.java b/others/lede-gui/src/main/java/com/example/lede2/SSH.java new file mode 100644 index 0000000..203ba79 --- /dev/null +++ b/others/lede-gui/src/main/java/com/example/lede2/SSH.java @@ -0,0 +1,200 @@ +/** + * Created by Tak and Bowon on 17. 7. 21. + * SSH class can be used to make ssh connections and send command lines + */ + +package com.example.lede2; + +import android.content.Context; +import android.util.Log; +import android.os.AsyncTask; + +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.JSchException; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.ChannelExec; +import com.jcraft.jsch.Channel; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.String; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +//import android.provider.Settings; +//import android.support.v7.app.AppCompatActivity; +//import android.os.Bundle; +//import java.io.ByteArrayOutputStream; +//import java.util.Properties; +//import java.io.PrintStream; + +// AsyncTask input : command line +// AysncTask output : output from a command +public class SSH extends AsyncTask> { + + // variables used for connection + Session session; + Channel channel; + ChannelExec ce; + // in this project, we supposed we use fixed host, username, password + String host; + String username; + String password; + + // host, username, password initialize + @Override + protected void onPreExecute() { + super.onPreExecute(); + + host = ConfigActivity.ROUTERIP; + username = ConfigActivity.ROUTERUSER; + password = ConfigActivity.RPWD; + } + + /* + The functions below are mainly from : + https://stackoverflow.com/questions/25789245/how-to-get-jsch-shell-command-output-in-string + */ + + + // open the conenction using username, password, and hostname + public boolean open() throws JSchException { + + JSch jSch = new JSch(); + + session = jSch.getSession(username, host, 22); + java.util.Properties config = new java.util.Properties(); + config.put("StrictHostKeyChecking", "no"); // not recommended + session.setPassword(password); + session.setConfig(config); + + + Log.d("SSH CONNECT OPEN", "Connecting SSH to " + host + " - Please wait for few seconds... "); + session.connect(); + if (session.isConnected()) { + Log.d("SSH CONNECT", "router connected!"); + return true; + } else { + Log.d("SSH NOT CONNECT", "router NOT connected!"); + return false; + } + } + + // send a command + public void runCommand(String command) throws JSchException, IOException { + + if (!session.isConnected()) + throw new RuntimeException("Not connected to an open session. Call open() first!"); + + channel = session.openChannel("exec"); + ce = (ChannelExec) channel; + ce.setCommand(command); + ce.connect(); + Log.d("SSH RUN COMMAND", command); + } + + // get output from a command + private List getChannelOutput(Channel channel) throws IOException { + + byte[] buffer = new byte[1024]; + List output_lines = new ArrayList(); + try { + InputStream in = channel.getInputStream(); + String line = new String(); + while (true) { + while (in.available() > 0) { + int i = in.read(buffer, 0, 1024); + if (i < 0) { + break; + } + line = new String(buffer, 0, i); + // add the read line to the return value list. + output_lines = new ArrayList(Arrays.asList(line.split("\\n"))); + } + + if(line.contains("logout")) { + break; + } + if (channel.isClosed()) { + break; + } + try { + Thread.sleep(1000); + } catch (Exception ee){} + } + } catch(Exception e) { + Log.d("SSH READOUTPUT ERROR", "Error while reading channel output: "+ e); + } + + return output_lines; + } + + + /* + usage : + 0. params == "-ch " : change default password into + 1. params == "-co " : add device to the database and hostapd file + 2. params == "-dn " : delete devices by their names + 3. params == "-ln " : list devices' names + */ + @Override + protected List doInBackground(String... params) { + + List result_lines = new ArrayList(); + String cmd; + + if(params[0].substring(0,3).equals("-ch")) { // ./change_default_pw.sh -ch + cmd = MainActivity.DEF_CHANGE_DEFAULT_SCRIPT + " " + params[0]; + } else if(params[0].substring(0,3).equals("-co")) { // ./connect_device.sh -co + cmd = MainActivity.DEF_CONNECT_DEVICE_SCRIPT + " " + params[0]; + } else if(params[0].substring(0,3).equals("-dn")) { // ./register_device.sh -dn + cmd = MainActivity.DEF_REGISTER_DEVICE_SCRIPT + " " + params[0]; + } else if(params[0].substring(0,3).equals("-ln")) { // ./register_device.sh -ln + // below block is a little different from others cause it needs to get output from the router + try { + // try open the connection + if (!open()) { + Log.d("SSH CONNECTION CLOSE", "open failed."); + return null; + } + cmd = MainActivity.DEF_REGISTER_DEVICE_SCRIPT + " " + params[0]; + runCommand(cmd); + ce.setCommand(cmd); + ce.connect(); + result_lines = getChannelOutput(ce); + } catch (Exception e) { + } + channel.disconnect(); + + // only this block return meaningful value, which should be the names of devices. + return result_lines; + } else { + Log.d("SSH PARAM ERROR", "Wrong parameter used."); + return null; + } + + // now the command is set, so send it. + try { + // try open the connection + if (!open()) { + Log.d("SSH CONNECTION CLOSE", "open failed."); + return null; + } + runCommand(cmd); + ce.setCommand(cmd); + ce.connect(); + } catch (Exception e) { + } // done + + channel.disconnect(); + return null; + } + + /* + @Override + protected onPostExecute(Void param) { + Log.d("POST", "in post execute"); + } + */ +} diff --git a/others/lede-gui/src/main/res/drawable/background.png b/others/lede-gui/src/main/res/drawable/background.png new file mode 100644 index 0000000..7cfd6e8 Binary files /dev/null and b/others/lede-gui/src/main/res/drawable/background.png differ diff --git a/others/lede-gui/src/main/res/drawable/blueberry.jpg b/others/lede-gui/src/main/res/drawable/blueberry.jpg new file mode 100644 index 0000000..7430e24 Binary files /dev/null and b/others/lede-gui/src/main/res/drawable/blueberry.jpg differ diff --git a/others/lede-gui/src/main/res/drawable/bluename.png b/others/lede-gui/src/main/res/drawable/bluename.png new file mode 100644 index 0000000..cf08830 Binary files /dev/null and b/others/lede-gui/src/main/res/drawable/bluename.png differ diff --git a/others/lede-gui/src/main/res/drawable/config.png b/others/lede-gui/src/main/res/drawable/config.png new file mode 100644 index 0000000..09a18b3 Binary files /dev/null and b/others/lede-gui/src/main/res/drawable/config.png differ diff --git a/others/lede-gui/src/main/res/drawable/configuration.png b/others/lede-gui/src/main/res/drawable/configuration.png new file mode 100644 index 0000000..b03319f Binary files /dev/null and b/others/lede-gui/src/main/res/drawable/configuration.png differ diff --git a/others/lede-gui/src/main/res/drawable/empty.png b/others/lede-gui/src/main/res/drawable/empty.png new file mode 100644 index 0000000..5824084 Binary files /dev/null and b/others/lede-gui/src/main/res/drawable/empty.png differ diff --git a/others/lede-gui/src/main/res/drawable/orange.png b/others/lede-gui/src/main/res/drawable/orange.png new file mode 100644 index 0000000..cc8c7b6 Binary files /dev/null and b/others/lede-gui/src/main/res/drawable/orange.png differ diff --git a/others/lede-gui/src/main/res/drawable/pinkback.PNG b/others/lede-gui/src/main/res/drawable/pinkback.PNG new file mode 100644 index 0000000..41a6579 Binary files /dev/null and b/others/lede-gui/src/main/res/drawable/pinkback.PNG differ diff --git a/others/lede-gui/src/main/res/drawable/wifi.PNG b/others/lede-gui/src/main/res/drawable/wifi.PNG new file mode 100644 index 0000000..37016ca Binary files /dev/null and b/others/lede-gui/src/main/res/drawable/wifi.PNG differ diff --git a/others/lede-gui/src/main/res/drawable/wifibackground.png b/others/lede-gui/src/main/res/drawable/wifibackground.png new file mode 100644 index 0000000..ac623b8 Binary files /dev/null and b/others/lede-gui/src/main/res/drawable/wifibackground.png differ diff --git a/others/lede-gui/src/main/res/layout/activity_config.xml b/others/lede-gui/src/main/res/layout/activity_config.xml new file mode 100644 index 0000000..3e720a6 --- /dev/null +++ b/others/lede-gui/src/main/res/layout/activity_config.xml @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + +