diff --git a/.gitignore b/.gitignore
index 8448160..7d5d0a2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,36 @@ bin/*
gen/*
*.log
local.properties
+# Built application files
+*.apk
+*.ap_
+
+# Files for the Dalvik VM
+*.dex
+
+# Java class files
+*.class
+
+# Generated files
+bin/
+gen/
+
+# Gradle files
+.gradle/
+build/
+
+# Local configuration file (sdk path, etc)
+local.properties
+
+# Proguard folder generated by Eclipse
+proguard/
+
+# Log Files
+*.log
+
+# Android Studio Navigation editor temp files
+.navigation/
+.DS_Store
+.idea
+*.iml
+build.info
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..735eae8
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,72 @@
+# Change Log
+
+## [0.4.4](https://github.com/OpenSensing/funf-core-android/tree/0.4.4) (2015-12-20)
+[Full Changelog](https://github.com/OpenSensing/funf-core-android/compare/0.4.3...0.4.4)
+
+**Implemented enhancements:**
+
+- Support for Bluetooth identifier [\#12](https://github.com/OpenSensing/funf-core-android/issues/12)
+- Introduce JSON database file [\#11](https://github.com/OpenSensing/funf-core-android/issues/11)
+- Improve HTTP get [\#10](https://github.com/OpenSensing/funf-core-android/issues/10)
+- Communication of funf status [\#9](https://github.com/OpenSensing/funf-core-android/issues/9)
+- Geofencing to limit data collection [\#8](https://github.com/OpenSensing/funf-core-android/issues/8)
+- Bluetooth discoverability [\#1](https://github.com/OpenSensing/funf-core-android/issues/1)
+
+**Merged pull requests:**
+
+- Json db [\#7](https://github.com/OpenSensing/funf-core-android/pull/7) ([h0pbeat](https://github.com/h0pbeat))
+- Geofencing [\#6](https://github.com/OpenSensing/funf-core-android/pull/6) ([h0pbeat](https://github.com/h0pbeat))
+- Bluetooth Probe can be now configured to keep phone discoverable [\#5](https://github.com/OpenSensing/funf-core-android/pull/5) ([h0pbeat](https://github.com/h0pbeat))
+
+## [0.4.3](https://github.com/OpenSensing/funf-core-android/tree/0.4.3) (2015-10-16)
+[Full Changelog](https://github.com/OpenSensing/funf-core-android/compare/v0.5.0RC1...0.4.3)
+
+**Implemented enhancements:**
+
+- Add stub for exclusion of fields to Wifi probe [\#12](https://github.com/OpenSensing/funf-v4/issues/12)
+- Add stub for exclusion of fields to Bluetooth probe [\#11](https://github.com/OpenSensing/funf-v4/issues/11)
+- Add LGPL license file [\#10](https://github.com/OpenSensing/funf-v4/issues/10)
+- Include datapoint when Wifi scan starts, even if no devices are found [\#9](https://github.com/OpenSensing/funf-v4/issues/9)
+- Include datapoint when Bluetooth scan starts, even if no devices are found [\#8](https://github.com/OpenSensing/funf-v4/issues/8)
+- Change BT probe default duration to 60s [\#7](https://github.com/OpenSensing/funf-v4/issues/7)
+- Change file uploader to HttpClient [\#6](https://github.com/OpenSensing/funf-v4/issues/6)
+- Add changelog [\#4](https://github.com/OpenSensing/funf-v4/issues/4)
+- Option to compress archives \(using gzip\) [\#1](https://github.com/OpenSensing/funf-v4/issues/1)
+
+**Closed issues:**
+
+- Generate archive file extension based on the compression/encryption [\#15](https://github.com/OpenSensing/funf-v4/issues/15)
+
+**Merged pull requests:**
+
+- File uploader [\#14](https://github.com/OpenSensing/funf-v4/pull/14) ([h0pbeat](https://github.com/h0pbeat))
+- Added license file [\#13](https://github.com/OpenSensing/funf-v4/pull/13) ([h0pbeat](https://github.com/h0pbeat))
+- added changelog [\#5](https://github.com/OpenSensing/funf-v4/pull/5) ([h0pbeat](https://github.com/h0pbeat))
+- small cleaning and enhancements of the probes [\#3](https://github.com/OpenSensing/funf-v4/pull/3) ([h0pbeat](https://github.com/h0pbeat))
+- implemented gzip compression of the files, configurable in pipeline config [\#2](https://github.com/OpenSensing/funf-v4/pull/2) ([h0pbeat](https://github.com/h0pbeat))
+
+## [v0.5.0RC1](https://github.com/OpenSensing/funf-core-android/tree/v0.5.0RC1) (2013-09-19)
+[Full Changelog](https://github.com/OpenSensing/funf-core-android/compare/0.4.2...v0.5.0RC1)
+
+## [0.4.2](https://github.com/OpenSensing/funf-core-android/tree/0.4.2) (2013-04-10)
+[Full Changelog](https://github.com/OpenSensing/funf-core-android/compare/0.4.1...0.4.2)
+
+## [0.4.1](https://github.com/OpenSensing/funf-core-android/tree/0.4.1) (2013-04-06)
+[Full Changelog](https://github.com/OpenSensing/funf-core-android/compare/0.4.0...0.4.1)
+
+## [0.4.0](https://github.com/OpenSensing/funf-core-android/tree/0.4.0) (2013-03-27)
+[Full Changelog](https://github.com/OpenSensing/funf-core-android/compare/0.3.1...0.4.0)
+
+## [0.3.1](https://github.com/OpenSensing/funf-core-android/tree/0.3.1) (2012-04-03)
+[Full Changelog](https://github.com/OpenSensing/funf-core-android/compare/0.3.0...0.3.1)
+
+## [0.3.0](https://github.com/OpenSensing/funf-core-android/tree/0.3.0) (2011-11-03)
+[Full Changelog](https://github.com/OpenSensing/funf-core-android/compare/0.2.1...0.3.0)
+
+## [0.2.1](https://github.com/OpenSensing/funf-core-android/tree/0.2.1) (2011-10-07)
+[Full Changelog](https://github.com/OpenSensing/funf-core-android/compare/0.2.0...0.2.1)
+
+## [0.2.0](https://github.com/OpenSensing/funf-core-android/tree/0.2.0) (2011-10-05)
+
+
+\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 0000000..65c5ca8
--- /dev/null
+++ b/LICENSE.md
@@ -0,0 +1,165 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/README b/README
deleted file mode 100644
index 416c257..0000000
--- a/README
+++ /dev/null
@@ -1,17 +0,0 @@
-= Funf - Open Sensing Framework =
-
-== Building the project ==
-The Funf project can be used as an Android library, or can be packaged as a jar file.
-The typical method of using Funf is by using the Funf jar file. To build the funf jar
-file, use the 'release' target of the Ant build script. (Make sure you have ant 1.8.*
-or later installed.) Then, copy the jar file (bin/funf.jar) to the libs directory of your project.
-The Android build scripts (Command line Ant or in Eclipse) will take care of compiling
-the jar.
-
-If you think that you will be making frequent changes to the Funf library, you may
-want to integrate Funf as a library project.
-To use it as an Android library, add this project as a library dependency of your
-Android application project. See the following links for more details.
-http://developer.android.com/guide/developing/projects/projects-eclipse.html#ReferencingLibraryProject
-or
-http://developer.android.com/guide/developing/projects/projects-cmdline.html#ReferencingLibraryProject
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..077ea05
--- /dev/null
+++ b/README.md
@@ -0,0 +1,23 @@
+# Funf Open Sensing Framework
+Fork of the popular [Funf open sensing framework](https://github.com/funf-org/funf-core-android) which has been inactive for some years.
+Currently developed for and used in data collection projects at Google and at the Technical University of Denmark.
+
+For details about architecture design, documentation as well as scripts for processing collected data, see the original repo's [wiki](https://github.com/funf-org/funf-core-android/wiki).
+
+# Improvements
+Forked from Funf v0.4.2. See the [changelog](https://github.com/OpenSensing/funf-core-android/blob/master/CHANGELOG.md) for the full set of improvements over v0.4.2. Some of the more important ones include:
+* Geofencing
+* Gzipping of files before upload
+* Token based authentication
+* File storage in JSON format
+* Gradle integration
+
+# How to build
+Run ./gradlew assembleRelease in the project root to produce an .aar that you can use as a library in your Android app.
+
+# Usage
+Funf is meant to be used as a dependency for another Android app that can provide user interaction and data collection configuration. See original project for a [tutorial](https://github.com/funf-org/funf-core-android/wiki/WifiScannerTutorial) on this.
+
+
+
+
diff --git a/ant.properties b/ant.properties
deleted file mode 100644
index 0c276ff..0000000
--- a/ant.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-# This file is used to override default values used by the Ant build system.
-#
-# This file must be checked in Version Control Systems, as it is
-# integral to the build system of your project.
-
-# This file is only used by the Ant script.
-
-# You can use this to override default values such as
-# 'source.dir' for the location of your java source folder and
-# 'out.dir' for the location of your output folder.
-
-# You can also use it define how the release builds are signed by declaring
-# the following properties:
-# 'key.store' for the location of your keystore and
-# 'key.alias' for the name of the key to use.
-# The password will be asked during the build when you use the 'release' target.
-
-keystore=../funf.keystore
-keystore.alias=funf
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..6a5c233
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,15 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:1.3.0'
+ }
+}
+
+allprojects {
+ repositories {
+ jcenter()
+ }
+}
diff --git a/build.xml b/build.xml
deleted file mode 100644
index 30ee4ca..0000000
--- a/build.xml
+++ /dev/null
@@ -1,83 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/custom_rules.xml b/custom_rules.xml
deleted file mode 100644
index 8faf0ef..0000000
--- a/custom_rules.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/default.properties b/default.properties
deleted file mode 100644
index 62106dd..0000000
--- a/default.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "build.properties", and override values to adapt the script to your
-# project structure.
-
-android.library=true
-# Project target.
-target=android-7
diff --git a/funf_v4/build.gradle b/funf_v4/build.gradle
new file mode 100644
index 0000000..641e99d
--- /dev/null
+++ b/funf_v4/build.gradle
@@ -0,0 +1,84 @@
+apply plugin: 'com.android.library'
+
+android {
+ compileSdkVersion 17
+ buildToolsVersion "23.0.0"
+
+ defaultConfig {
+ minSdkVersion 8
+ targetSdkVersion 14
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
+ }
+ }
+
+ packagingOptions {
+ exclude 'META-INF/LICENSE'
+ exclude 'META-INF/NOTICE'
+ exclude 'META-INF/DEPENDENCIES'
+ }
+}
+
+dependencies {
+ compile files('libs/gson-2.1.jar')
+}
+
+
+def getVersionName = {->
+ println '*** getVersionName'
+ try {
+ def stdout = new ByteArrayOutputStream()
+ exec {
+ commandLine 'git', 'symbolic-ref', '--short', '-q', 'HEAD'
+ standardOutput = stdout
+ }
+
+ def stdout2 = new ByteArrayOutputStream()
+ exec {
+ commandLine 'git', 'log', '-1', '--format=%h'
+ standardOutput = stdout2
+ }
+
+ def stdout3 = new ByteArrayOutputStream()
+ exec {
+ commandLine 'git', 'describe', '--tags', '--abbrev=0'
+ standardOutput = stdout3
+ errorOutput = new ByteArrayOutputStream()
+ ignoreExitValue = true
+ }
+
+
+ def return_value = stdout3.toString().trim() + "-" +stdout.toString().trim() + "-" + stdout2.toString().trim()
+ println "return_value: "+return_value
+
+ def assetsDir = android.sourceSets.main.assets.srcDirs.toArray()[0]
+ println "assetsDir: "+assetsDir
+
+ def assetsDirObject = new File(assetsDir, '')
+
+ if (!assetsDirObject.exists()) {
+ assetsDirObject.mkdirs();
+ }
+
+ def buildInfoFile = new File(assetsDir, 'build.info').getAbsolutePath()
+ println "buildInfoFile: "+buildInfoFile
+
+ new File(buildInfoFile).write(return_value);
+
+ return return_value
+ }
+ catch (ignored) {
+ return null;
+ }
+
+}
+
+android {
+ defaultConfig {
+ versionName getVersionName()
+ }
+}
\ No newline at end of file
diff --git a/libs/gson-2.1-javadoc.jar b/funf_v4/libs/gson-2.1-javadoc.jar
similarity index 100%
rename from libs/gson-2.1-javadoc.jar
rename to funf_v4/libs/gson-2.1-javadoc.jar
diff --git a/libs/gson-2.1-sources.jar b/funf_v4/libs/gson-2.1-sources.jar
similarity index 100%
rename from libs/gson-2.1-sources.jar
rename to funf_v4/libs/gson-2.1-sources.jar
diff --git a/libs/gson-2.1.jar b/funf_v4/libs/gson-2.1.jar
similarity index 100%
rename from libs/gson-2.1.jar
rename to funf_v4/libs/gson-2.1.jar
diff --git a/funf_v4/lint.xml b/funf_v4/lint.xml
new file mode 100644
index 0000000..8423c0e
--- /dev/null
+++ b/funf_v4/lint.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/AndroidManifest.xml b/funf_v4/src/main/AndroidManifest.xml
similarity index 100%
rename from AndroidManifest.xml
rename to funf_v4/src/main/AndroidManifest.xml
diff --git a/src/com/google/gson/internal/bind/JsonTreeReader.java b/funf_v4/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java
similarity index 100%
rename from src/com/google/gson/internal/bind/JsonTreeReader.java
rename to funf_v4/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java
diff --git a/src/com/google/gson/internal/bind/JsonTreeWriter.java b/funf_v4/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java
similarity index 100%
rename from src/com/google/gson/internal/bind/JsonTreeWriter.java
rename to funf_v4/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java
diff --git a/src/edu/mit/media/funf/FunfManager.java b/funf_v4/src/main/java/edu/mit/media/funf/FunfManager.java
similarity index 91%
rename from src/edu/mit/media/funf/FunfManager.java
rename to funf_v4/src/main/java/edu/mit/media/funf/FunfManager.java
index 54eee78..d38270d 100644
--- a/src/edu/mit/media/funf/FunfManager.java
+++ b/funf_v4/src/main/java/edu/mit/media/funf/FunfManager.java
@@ -23,18 +23,6 @@
*/
package edu.mit.media.funf;
-import static edu.mit.media.funf.util.LogUtil.TAG;
-
-import java.lang.reflect.Type;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.Service;
@@ -63,6 +51,21 @@
import com.google.gson.JsonSerializer;
import com.google.gson.TypeAdapterFactory;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.lang.reflect.Type;
+import java.math.BigDecimal;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import edu.mit.media.funf.Schedule.BasicSchedule;
import edu.mit.media.funf.Schedule.DefaultSchedule;
import edu.mit.media.funf.config.ConfigUpdater;
@@ -88,9 +91,12 @@
import edu.mit.media.funf.storage.HttpArchive;
import edu.mit.media.funf.storage.RemoteFileArchive;
import edu.mit.media.funf.time.TimeUtil;
+import edu.mit.media.funf.util.IOUtil;
import edu.mit.media.funf.util.LogUtil;
import edu.mit.media.funf.util.StringUtil;
+import static edu.mit.media.funf.util.LogUtil.TAG;
+
public class FunfManager extends Service {
public static final String
@@ -109,7 +115,9 @@ public class FunfManager extends Service {
PROBE_ACTION_UNREGISTER = "unregister",
PROBE_ACTION_REGISTER_PASSIVE = "register-passive",
PROBE_ACTION_UNREGISTER_PASSIVE = "unregister-passive";
-
+
+ public static Context context = null;
+ public static FunfManager funfManager = null;
private Handler handler;
private JsonParser parser;
@@ -157,6 +165,8 @@ public void onCreate() {
this.disabledPipelines = new HashMap();
this.disabledPipelineNames = new HashSet(Arrays.asList(prefs.getString(DISABLED_PIPELINE_LIST, "").split(",")));
this.disabledPipelineNames.remove(""); // Remove the empty name, if no disabled pipelines exist
+ FunfManager.context = this;
+ funfManager = this;
reload();
}
@@ -210,7 +220,29 @@ public void run() {
registerPipeline(name, newPipeline); // Will unregister previous before running
}
}
-
+
+ public String getVersion() {
+ String version = "unknown";
+ BufferedReader reader = null;
+ try{
+ reader = new BufferedReader(new InputStreamReader(getAssets().open("build.info")));
+ version = reader.readLine().trim();
+ } catch (IOException e) {
+
+ }
+ finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException e) {
+
+ }
+ }
+ }
+
+ return version;
+ }
+
public JsonObject getPipelineConfig(String name) {
String configString = prefs.getString(name, null);
Bundle metadata = getMetadata();
@@ -456,7 +488,6 @@ public static SingletonTypeAdapterFactory getProbeFactory(Context context) {
public void registerPipeline(String name, Pipeline pipeline) {
synchronized (pipelines) {
- Log.d(LogUtil.TAG, "Registering pipeline: " + name);
unregisterPipeline(name);
pipelines.put(name, pipeline);
pipeline.onCreate(this);
@@ -710,7 +741,71 @@ private void cancelProbe(String probeConfig) {
scheduler.cancel(PROBE_TYPE, getComponenentUri(probeConfig, PROBE_ACTION_REGISTER_PASSIVE));
scheduler.cancel(PROBE_TYPE, getComponenentUri(probeConfig, PROBE_ACTION_UNREGISTER_PASSIVE));
}
-
+
+ public void setAuthToken(String url, String accessToken) {
+ URI uri = null;
+ try {
+ uri = new URI(url);
+ getSharedPreferences("funf_auth", MODE_PRIVATE).edit().putString(IOUtil.md5(uri.getHost()), accessToken).commit();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public String getAuthToken(String url) {
+ String authToken = "";
+ try {
+ URI uri = new URI(url);
+ authToken = getSharedPreferences("funf_auth", MODE_PRIVATE).getString(IOUtil.md5(uri.getHost()), "");
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+ return authToken;
+ }
+
+ public void authError() {
+ authError("unknown", "");
+ }
+
+ public void authError(String action, String accessToken) {
+ Log.i(TAG, "sending authError broadcast "+action);
+ Intent intent = new Intent(context.getPackageName() + "." + "AUTHENTICATION_ERROR");
+ intent.putExtra("action", action);
+ intent.putExtra("accessToken", accessToken);
+ sendBroadcast(intent);
+ }
+
+ public void broadcastDataCollectionStatus(Integer status) {
+ Intent intent = new Intent(context.getPackageName() + "." + "DATA_COLLECTION_STATUS");
+ intent.putExtra("status", status);
+ sendBroadcast(intent);
+ }
+
+ public void broadcastServerError(String action, String accessToken) {
+ Log.i(TAG, "sending serverError broadcast");
+ Intent intent = new Intent(context.getPackageName() + "." + "SERVER_ERROR");
+ intent.putExtra("action", action);
+ intent.putExtra("accessToken", accessToken);
+ sendBroadcast(intent);
+ }
+
+ public void setApplicationVersion(String version) {
+ try {
+ getSharedPreferences("funf_version", MODE_PRIVATE).edit().putString("application_version", version).commit();
+ } catch (NullPointerException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public String getApplicationVersion() {
+ try {
+ return getSharedPreferences("funf_version", MODE_PRIVATE).getString("application_version", "unknown");
+ } catch (NullPointerException e) {
+ e.printStackTrace();
+ return "unknown";
+ }
+ }
+
////////////////////////////////////////////////////
@@ -787,7 +882,7 @@ public void set(String type, Uri componentAndAction, Schedule schedule) {
}
}
-
+
// TODO: Feature to wait a certain amount of seconds after boot to begin
// TODO: Feature to prevent too many things from running at once, w/ random backoff times
@@ -812,4 +907,4 @@ public void set(String type, Uri componentAndAction, Schedule schedule) {
// This allows separate probes if required
// Allows creation of database services to be determined by pipeline
}
-}
+}
\ No newline at end of file
diff --git a/src/edu/mit/media/funf/Launcher.java b/funf_v4/src/main/java/edu/mit/media/funf/Launcher.java
similarity index 100%
rename from src/edu/mit/media/funf/Launcher.java
rename to funf_v4/src/main/java/edu/mit/media/funf/Launcher.java
diff --git a/src/edu/mit/media/funf/Schedule.java b/funf_v4/src/main/java/edu/mit/media/funf/Schedule.java
similarity index 100%
rename from src/edu/mit/media/funf/Schedule.java
rename to funf_v4/src/main/java/edu/mit/media/funf/Schedule.java
diff --git a/src/edu/mit/media/funf/config/ConfigUpdater.java b/funf_v4/src/main/java/edu/mit/media/funf/config/ConfigUpdater.java
similarity index 100%
rename from src/edu/mit/media/funf/config/ConfigUpdater.java
rename to funf_v4/src/main/java/edu/mit/media/funf/config/ConfigUpdater.java
diff --git a/src/edu/mit/media/funf/config/Configurable.java b/funf_v4/src/main/java/edu/mit/media/funf/config/Configurable.java
similarity index 100%
rename from src/edu/mit/media/funf/config/Configurable.java
rename to funf_v4/src/main/java/edu/mit/media/funf/config/Configurable.java
diff --git a/src/edu/mit/media/funf/config/ConfigurableTypeAdapterFactory.java b/funf_v4/src/main/java/edu/mit/media/funf/config/ConfigurableTypeAdapterFactory.java
similarity index 100%
rename from src/edu/mit/media/funf/config/ConfigurableTypeAdapterFactory.java
rename to funf_v4/src/main/java/edu/mit/media/funf/config/ConfigurableTypeAdapterFactory.java
diff --git a/src/edu/mit/media/funf/config/ContextInjectorTypeAdapaterFactory.java b/funf_v4/src/main/java/edu/mit/media/funf/config/ContextInjectorTypeAdapaterFactory.java
similarity index 100%
rename from src/edu/mit/media/funf/config/ContextInjectorTypeAdapaterFactory.java
rename to funf_v4/src/main/java/edu/mit/media/funf/config/ContextInjectorTypeAdapaterFactory.java
diff --git a/src/edu/mit/media/funf/config/DefaultRuntimeTypeAdapterFactory.java b/funf_v4/src/main/java/edu/mit/media/funf/config/DefaultRuntimeTypeAdapterFactory.java
similarity index 100%
rename from src/edu/mit/media/funf/config/DefaultRuntimeTypeAdapterFactory.java
rename to funf_v4/src/main/java/edu/mit/media/funf/config/DefaultRuntimeTypeAdapterFactory.java
diff --git a/src/edu/mit/media/funf/config/DefaultScheduleSerializer.java b/funf_v4/src/main/java/edu/mit/media/funf/config/DefaultScheduleSerializer.java
similarity index 100%
rename from src/edu/mit/media/funf/config/DefaultScheduleSerializer.java
rename to funf_v4/src/main/java/edu/mit/media/funf/config/DefaultScheduleSerializer.java
diff --git a/src/edu/mit/media/funf/config/HttpConfigUpdater.java b/funf_v4/src/main/java/edu/mit/media/funf/config/HttpConfigUpdater.java
similarity index 67%
rename from src/edu/mit/media/funf/config/HttpConfigUpdater.java
rename to funf_v4/src/main/java/edu/mit/media/funf/config/HttpConfigUpdater.java
index 4ed3f06..5bd6254 100644
--- a/src/edu/mit/media/funf/config/HttpConfigUpdater.java
+++ b/funf_v4/src/main/java/edu/mit/media/funf/config/HttpConfigUpdater.java
@@ -1,10 +1,15 @@
package edu.mit.media.funf.config;
+import android.util.Log;
+
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
+import edu.mit.media.funf.FunfManager;
+import edu.mit.media.funf.pipeline.BasicPipeline;
import edu.mit.media.funf.util.IOUtil;
+import edu.mit.media.funf.util.LogUtil;
/**
* ConfigUpdater which does an Http get to the given url.
@@ -18,9 +23,11 @@ public class HttpConfigUpdater extends ConfigUpdater {
@Override
public JsonObject getConfig() throws ConfigUpdateException {
try {
- String content = null;
- if (IOUtil.isValidUrl(url)) {
- content = IOUtil.httpGet(url, null);
+ String content = null;
+ String currentUrl = IOUtil.formatServerUrl(url, "");
+ Log.i(LogUtil.TAG, "Config url: " + currentUrl);
+ if (IOUtil.isValidUrl(currentUrl)) {
+ content = IOUtil.httpGet(currentUrl, null, BasicPipeline.ACTION_UPDATE, FunfManager.funfManager.getAuthToken(url));
}
if (content == null) {
throw new ConfigUpdateException("Unable to download configuration.");
diff --git a/src/edu/mit/media/funf/config/RuntimeTypeAdapterFactory.java b/funf_v4/src/main/java/edu/mit/media/funf/config/RuntimeTypeAdapterFactory.java
similarity index 100%
rename from src/edu/mit/media/funf/config/RuntimeTypeAdapterFactory.java
rename to funf_v4/src/main/java/edu/mit/media/funf/config/RuntimeTypeAdapterFactory.java
diff --git a/src/edu/mit/media/funf/config/SingletonTypeAdapterFactory.java b/funf_v4/src/main/java/edu/mit/media/funf/config/SingletonTypeAdapterFactory.java
similarity index 100%
rename from src/edu/mit/media/funf/config/SingletonTypeAdapterFactory.java
rename to funf_v4/src/main/java/edu/mit/media/funf/config/SingletonTypeAdapterFactory.java
diff --git a/src/edu/mit/media/funf/data/DataNormalizer.java b/funf_v4/src/main/java/edu/mit/media/funf/data/DataNormalizer.java
similarity index 100%
rename from src/edu/mit/media/funf/data/DataNormalizer.java
rename to funf_v4/src/main/java/edu/mit/media/funf/data/DataNormalizer.java
diff --git a/funf_v4/src/main/java/edu/mit/media/funf/data/Geofencer.java b/funf_v4/src/main/java/edu/mit/media/funf/data/Geofencer.java
new file mode 100644
index 0000000..a933bf3
--- /dev/null
+++ b/funf_v4/src/main/java/edu/mit/media/funf/data/Geofencer.java
@@ -0,0 +1,162 @@
+package edu.mit.media.funf.data;
+
+import android.content.SharedPreferences;
+import android.util.Log;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import edu.mit.media.funf.FunfManager;
+import edu.mit.media.funf.config.Configurable;
+import edu.mit.media.funf.json.IJsonObject;
+import edu.mit.media.funf.util.IOUtil;
+import edu.mit.media.funf.util.LogUtil;
+
+/**
+ * Created by arks on 10/16/15.
+ */
+public class Geofencer {
+
+ @Configurable
+ protected Integer version = 0;
+
+ @Configurable
+ protected List fences = new ArrayList();
+
+ @Configurable
+ protected Double minLocationAccuracy = 80.0;
+
+ @Configurable
+ protected Long minLocationFreshness = 1L;
+
+ @Configurable
+ protected Long timeWindow = 10L;
+
+
+ private Set acceptedLocationProbes =
+ new HashSet(Arrays.asList("edu.mit.media.funf.probe.builtin.LocationProbe", "edu.mit.media.funf.probe.builtin.SimpleLocationProbe"));
+
+
+
+ public Geofencer() {
+ Log.i(LogUtil.TAG, "Creating geofencer " + version);
+ }
+
+ public boolean shouldSaveData(String name, IJsonObject data) {
+ if (acceptedLocationProbes.contains(name)) {
+ updateVisits(name, data);
+ }
+
+ return checkFences(timestampToMillis(data.get("timestamp").getAsLong()));
+ }
+
+ public boolean shouldSaveData(Long timestamp) {
+ return checkFences(timestamp);
+ }
+
+ public boolean shouldFire(String name) {
+ if (acceptedLocationProbes.contains(name)) return true;
+ return shouldSaveData(System.currentTimeMillis());
+
+ }
+
+ private void updateVisits(String name, IJsonObject data) {
+
+ if (name.equals("edu.mit.media.funf.probe.builtin.LocationProbe")) {
+ Double accuracy = data.get("mAccuracy").getAsDouble();
+ Double lat = data.get("mLatitude").getAsDouble();
+ Double lon = data.get("mLongitude").getAsDouble();
+ Long timestamp = timestampToMillis(data.get("mTime").getAsLong());
+
+ //TODO discard mock locations
+ if (accuracy > minLocationAccuracy) return;
+ if ((System.currentTimeMillis()) > timestamp + minLocationFreshness*60*1000) return;
+
+ //TODO graceful error handling
+ for (JsonElement fence: fences) {
+ JsonObject fenceObject = fence.getAsJsonObject();
+ Double fenceLatitude = fenceObject.get("latitude").getAsDouble();
+ Double fenceLongitude = fenceObject.get("longitude").getAsDouble();
+ Double fenceRadius = fenceObject.get("radius").getAsDouble();
+
+ Double distance = haversine(lat, lon, fenceLatitude, fenceLongitude);
+
+ if (distance < fenceRadius) {
+ updateVisit(fenceLatitude, fenceLongitude, fenceRadius, timestamp);
+ }
+ }
+
+ }
+ }
+
+ private void updateVisit(Double fenceLatitude, Double fenceLongitude, Double fenceRadius, Long timestamp) {
+ String fenceID = fenceToString(fenceLatitude, fenceLongitude, fenceRadius);
+ SharedPreferences sharedPreferences = FunfManager.context.getSharedPreferences("funf_geofence", FunfManager.context.MODE_PRIVATE);
+
+ Long previousTimestamp = sharedPreferences.getLong(fenceID, 0);
+
+ if (timestamp > previousTimestamp) {
+ sharedPreferences.edit().putLong(fenceID, timestamp).commit();
+ }
+
+ }
+
+ private String fenceToString(Double fenceLatitude, Double fenceLongitude, Double fenceRadius) {
+ return IOUtil.md5(""+fenceLatitude + ";"+fenceLongitude+";"+fenceRadius);
+ }
+
+ private boolean checkFences(Long timestamp) {
+ //TODO in the future this should keep the last 24h or so of the fence history so we can
+ //put data from the past
+
+ if (fences.size() == 0) return true;
+
+ for (JsonElement fence: fences) {
+ JsonObject fenceObject = fence.getAsJsonObject();
+ Double fenceLatitude = fenceObject.get("latitude").getAsDouble();
+ Double fenceLongitude = fenceObject.get("longitude").getAsDouble();
+ Double fenceRadius = fenceObject.get("radius").getAsDouble();
+
+ String fenceID = fenceToString(fenceLatitude, fenceLongitude, fenceRadius);
+ SharedPreferences sharedPreferences = FunfManager.context.getSharedPreferences("funf_geofence", FunfManager.context.MODE_PRIVATE);
+ Long lastVisitTimestamp = sharedPreferences.getLong(fenceID, 0);
+
+ if ((timestamp < (lastVisitTimestamp + timeWindow*60*1000)) && (timestamp > (lastVisitTimestamp - timeWindow*60*1000)) ) return true;
+
+ }
+
+ return false;
+ }
+
+ public Integer getVersion() {
+ return this.version;
+ }
+
+ private Long timestampToMillis(Long timestamp) {
+ if (timestamp < 9999999999L) return timestamp*1000;
+ return timestamp;
+ }
+
+ private Double haversine(double lat1, double lon1, double lat2, double lon2) {
+ Double R = 6372.8; // In kilometers
+ Double dLat = Math.toRadians(lat2 - lat1);
+ Double dLon = Math.toRadians(lon2 - lon1);
+ lat1 = Math.toRadians(lat1);
+ lat2 = Math.toRadians(lat2);
+
+ Double a = Math.pow(Math.sin(dLat / 2),2) + Math.pow(Math.sin(dLon / 2),2) * Math.cos(lat1) * Math.cos(lat2);
+ Double c = 2 * Math.asin(Math.sqrt(a));
+ return R * c * 1000;
+ }
+
+ public List getFences() {
+ return this.fences;
+ }
+
+}
diff --git a/src/edu/mit/media/funf/json/BundleTypeAdapter.java b/funf_v4/src/main/java/edu/mit/media/funf/json/BundleTypeAdapter.java
similarity index 100%
rename from src/edu/mit/media/funf/json/BundleTypeAdapter.java
rename to funf_v4/src/main/java/edu/mit/media/funf/json/BundleTypeAdapter.java
diff --git a/src/edu/mit/media/funf/json/IJsonArray.java b/funf_v4/src/main/java/edu/mit/media/funf/json/IJsonArray.java
similarity index 100%
rename from src/edu/mit/media/funf/json/IJsonArray.java
rename to funf_v4/src/main/java/edu/mit/media/funf/json/IJsonArray.java
diff --git a/src/edu/mit/media/funf/json/IJsonObject.java b/funf_v4/src/main/java/edu/mit/media/funf/json/IJsonObject.java
similarity index 100%
rename from src/edu/mit/media/funf/json/IJsonObject.java
rename to funf_v4/src/main/java/edu/mit/media/funf/json/IJsonObject.java
diff --git a/src/edu/mit/media/funf/json/JsonUtils.java b/funf_v4/src/main/java/edu/mit/media/funf/json/JsonUtils.java
similarity index 100%
rename from src/edu/mit/media/funf/json/JsonUtils.java
rename to funf_v4/src/main/java/edu/mit/media/funf/json/JsonUtils.java
diff --git a/src/edu/mit/media/funf/math/FFT.java b/funf_v4/src/main/java/edu/mit/media/funf/math/FFT.java
similarity index 100%
rename from src/edu/mit/media/funf/math/FFT.java
rename to funf_v4/src/main/java/edu/mit/media/funf/math/FFT.java
diff --git a/src/edu/mit/media/funf/math/MFCC.java b/funf_v4/src/main/java/edu/mit/media/funf/math/MFCC.java
similarity index 100%
rename from src/edu/mit/media/funf/math/MFCC.java
rename to funf_v4/src/main/java/edu/mit/media/funf/math/MFCC.java
diff --git a/src/edu/mit/media/funf/math/Matrix.java b/funf_v4/src/main/java/edu/mit/media/funf/math/Matrix.java
similarity index 100%
rename from src/edu/mit/media/funf/math/Matrix.java
rename to funf_v4/src/main/java/edu/mit/media/funf/math/Matrix.java
diff --git a/src/edu/mit/media/funf/math/Window.java b/funf_v4/src/main/java/edu/mit/media/funf/math/Window.java
similarity index 100%
rename from src/edu/mit/media/funf/math/Window.java
rename to funf_v4/src/main/java/edu/mit/media/funf/math/Window.java
diff --git a/src/edu/mit/media/funf/pipeline/BasicPipeline.java b/funf_v4/src/main/java/edu/mit/media/funf/pipeline/BasicPipeline.java
similarity index 78%
rename from src/edu/mit/media/funf/pipeline/BasicPipeline.java
rename to funf_v4/src/main/java/edu/mit/media/funf/pipeline/BasicPipeline.java
index 8a3f03d..7325376 100644
--- a/src/edu/mit/media/funf/pipeline/BasicPipeline.java
+++ b/funf_v4/src/main/java/edu/mit/media/funf/pipeline/BasicPipeline.java
@@ -25,8 +25,11 @@
import java.util.List;
import java.util.Map;
+import android.app.Notification;
+import android.app.NotificationManager;
import android.content.ContentValues;
import android.content.Context;
+import android.content.Intent;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
@@ -44,17 +47,22 @@
import edu.mit.media.funf.config.ConfigUpdater;
import edu.mit.media.funf.config.Configurable;
import edu.mit.media.funf.config.RuntimeTypeAdapterFactory;
+import edu.mit.media.funf.data.Geofencer;
import edu.mit.media.funf.json.IJsonObject;
import edu.mit.media.funf.probe.Probe.DataListener;
import edu.mit.media.funf.probe.builtin.ProbeKeys;
+import edu.mit.media.funf.storage.DatabaseHelper;
import edu.mit.media.funf.storage.DefaultArchive;
import edu.mit.media.funf.storage.FileArchive;
+import edu.mit.media.funf.storage.JsonDatabaseHelper;
import edu.mit.media.funf.storage.NameValueDatabaseHelper;
import edu.mit.media.funf.storage.RemoteFileArchive;
import edu.mit.media.funf.storage.UploadService;
import edu.mit.media.funf.util.LogUtil;
import edu.mit.media.funf.util.StringUtil;
+import static edu.mit.media.funf.util.LogUtil.TAG;
+
public class BasicPipeline implements Pipeline, DataListener {
public static final String
@@ -84,13 +92,28 @@ public class BasicPipeline implements Pipeline, DataListener {
protected List data = new ArrayList();
@Configurable
- protected Map schedules = new HashMap();
+ protected Map schedules = new HashMap();
+
+ @Configurable
+ protected Geofencer geofence = new Geofencer();
+
+ @Configurable
+ protected boolean broadcastCollectionState = true;
+
+ @Configurable
+ protected String file_format = "sqlite"; //can be sqlite or json
private UploadService uploader;
-
+
+ public static BasicPipeline basicPipeline = null;
+
+ private Integer savingData = -1;
+
private boolean enabled;
private FunfManager manager;
- private SQLiteOpenHelper databaseHelper = null;
+ //private SQLiteOpenHelper databaseHelper = null;
+ //private JsonDatabaseHelper databaseHelper = null;
+ private DatabaseHelper databaseHelper = null;
private Looper looper;
private Handler handler;
private Handler.Callback callback = new Handler.Callback() {
@@ -128,39 +151,62 @@ public boolean handleMessage(Message msg) {
};
protected void reloadDbHelper(Context ctx) {
- this.databaseHelper = new NameValueDatabaseHelper(ctx, StringUtil.simpleFilesafe(name), version);
+ if (this.file_format.equals("json")) {
+ this.databaseHelper = new JsonDatabaseHelper(ctx, StringUtil.simpleFilesafe(name), version);
+ this.databaseHelper.init();
+ } else {
+ this.databaseHelper = new NameValueDatabaseHelper(ctx, StringUtil.simpleFilesafe(name), version);
+ this.databaseHelper.init();
+ }
+
}
protected void runArchive() {
- SQLiteDatabase db = databaseHelper.getWritableDatabase();
- // TODO: add check to make sure this is not empty
- File dbFile = new File(db.getPath());
- db.close();
+ File dbFile = new File(this.databaseHelper.getPath());
+ this.databaseHelper.finish();
if (archive.add(dbFile)) {
dbFile.delete();
}
reloadDbHelper(manager);
- databaseHelper.getWritableDatabase(); // Build new database
}
-
+
+ private void broadcastDataCollection() {
+ if (!broadcastCollectionState) return;
+
+ if (geofence.shouldSaveData(System.currentTimeMillis())) {
+ if (savingData != 1) {
+ savingData = 1;
+ manager.broadcastDataCollectionStatus(savingData);
+ }
+
+ } else {
+ if (savingData != 0) {
+ savingData = 0;
+ manager.broadcastDataCollectionStatus(savingData);
+ }
+ }
+ }
+
protected void writeData(String name, IJsonObject data) {
- SQLiteDatabase db = databaseHelper.getWritableDatabase();
+
+ broadcastDataCollection();
+ if (!geofence.shouldSaveData(name, data)) return;
+
final double timestamp = data.get(ProbeKeys.BaseProbeKeys.TIMESTAMP).getAsDouble();
- final String value = data.toString();
+ final IJsonObject value = data;
if (timestamp == 0L || name == null || value == null) {
Log.e(LogUtil.TAG, "Unable to save data. Not all required values specified. " + timestamp + " " + name + " - " + value);
+ //TODO custom exception
throw new SQLException("Not all required fields specified.");
}
- ContentValues cv = new ContentValues();
- cv.put(NameValueDatabaseHelper.COLUMN_NAME, name);
- cv.put(NameValueDatabaseHelper.COLUMN_VALUE, value);
- cv.put(NameValueDatabaseHelper.COLUMN_TIMESTAMP, timestamp);
- db.insertOrThrow(NameValueDatabaseHelper.DATA_TABLE.name, "", cv);
+
+ this.databaseHelper.insert(name, timestamp, value);
}
@Override
public void onCreate(FunfManager manager) {
+ basicPipeline = this;
if (archive == null) {
archive = new DefaultArchive(manager, name);
}
@@ -216,7 +262,6 @@ public void onRun(String action, JsonElement config) {
* @param config the configuration for the action
*/
protected void onBeforeRun(int action, JsonElement config) {
-
}
/**
@@ -237,9 +282,9 @@ protected FunfManager getFunfManager() {
}
- public SQLiteDatabase getDb() {
- return databaseHelper.getReadableDatabase();
- }
+ //public SQLiteDatabase getDb() {
+ // return databaseHelper.getReadableDatabase();
+ //}
public List getDataRequests() {
return data == null ? null : Collections.unmodifiableList(data);
@@ -325,14 +370,14 @@ public void setUploader(UploadService uploader) {
}
- public SQLiteOpenHelper getDatabaseHelper() {
- return databaseHelper;
- }
+ //public SQLiteOpenHelper getDatabaseHelper() {
+ // return databaseHelper;
+ //}
- public void setDatabaseHelper(SQLiteOpenHelper databaseHelper) {
- this.databaseHelper = databaseHelper;
- }
+ //public void setDatabaseHelper(SQLiteOpenHelper databaseHelper) {
+ // this.databaseHelper = databaseHelper;
+ //}
@Override
@@ -348,4 +393,12 @@ public void onDataCompleted(IJsonObject probeConfig, JsonElement checkpoint) {
// TODO Figure out what to do with continuations of probes, if anything
}
+
+ public List getFences() {
+ return this.geofence.getFences();
+ }
+
+ public Geofencer getGeofence() {
+ return this.geofence;
+ }
}
diff --git a/src/edu/mit/media/funf/pipeline/Pipeline.java b/funf_v4/src/main/java/edu/mit/media/funf/pipeline/Pipeline.java
similarity index 100%
rename from src/edu/mit/media/funf/pipeline/Pipeline.java
rename to funf_v4/src/main/java/edu/mit/media/funf/pipeline/Pipeline.java
diff --git a/src/edu/mit/media/funf/pipeline/PipelineFactory.java b/funf_v4/src/main/java/edu/mit/media/funf/pipeline/PipelineFactory.java
similarity index 100%
rename from src/edu/mit/media/funf/pipeline/PipelineFactory.java
rename to funf_v4/src/main/java/edu/mit/media/funf/pipeline/PipelineFactory.java
diff --git a/src/edu/mit/media/funf/probe/Probe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/Probe.java
similarity index 97%
rename from src/edu/mit/media/funf/probe/Probe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/Probe.java
index eab8ee4..a628219 100644
--- a/src/edu/mit/media/funf/probe/Probe.java
+++ b/funf_v4/src/main/java/edu/mit/media/funf/probe/Probe.java
@@ -41,6 +41,7 @@
import android.os.Looper;
import android.os.Message;
import android.os.PowerManager;
+import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -51,14 +52,17 @@
import edu.mit.media.funf.FunfManager;
import edu.mit.media.funf.Schedule.DefaultSchedule;
import edu.mit.media.funf.data.DataNormalizer;
+import edu.mit.media.funf.data.Geofencer;
import edu.mit.media.funf.json.BundleTypeAdapter;
import edu.mit.media.funf.json.IJsonObject;
import edu.mit.media.funf.json.JsonUtils;
+import edu.mit.media.funf.pipeline.BasicPipeline;
import edu.mit.media.funf.probe.builtin.ProbeKeys.BaseProbeKeys;
import edu.mit.media.funf.security.HashUtil;
import edu.mit.media.funf.security.HashUtil.HashingType;
import edu.mit.media.funf.time.TimeUtil;
import edu.mit.media.funf.util.LockUtil;
+import edu.mit.media.funf.util.LogUtil;
public interface Probe {
@@ -577,12 +581,20 @@ private void ensureLooperThreadExists() {
}
}
+ private boolean shouldFire() {
+ Geofencer geofence = null;
+ if (BasicPipeline.basicPipeline != null) geofence = BasicPipeline.basicPipeline.getGeofence();
+ if (geofence != null && !geofence.shouldFire(this.getClass().getName())) return false;
+ return true;
+ }
+
protected final void enable() {
ensureLooperThreadExists();
handler.sendMessage(handler.obtainMessage(ENABLE_MESSAGE));
}
protected final void start() {
+ if (!shouldFire()) return;
ensureLooperThreadExists();
handler.sendMessage(handler.obtainMessage(START_MESSAGE));
}
diff --git a/src/edu/mit/media/funf/probe/builtin/AccelerometerFeaturesProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/AccelerometerFeaturesProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/AccelerometerFeaturesProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/AccelerometerFeaturesProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/AccelerometerSensorProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/AccelerometerSensorProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/AccelerometerSensorProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/AccelerometerSensorProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/AccountsProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/AccountsProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/AccountsProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/AccountsProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/ActivityProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/ActivityProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/ActivityProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/ActivityProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/AndroidInfoProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/AndroidInfoProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/AndroidInfoProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/AndroidInfoProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/ApplicationsProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/ApplicationsProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/ApplicationsProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/ApplicationsProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/AudioFeaturesProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/AudioFeaturesProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/AudioFeaturesProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/AudioFeaturesProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/AudioMediaProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/AudioMediaProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/AudioMediaProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/AudioMediaProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/BatteryProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/BatteryProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/BatteryProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/BatteryProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/BluetoothProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/BluetoothProbe.java
similarity index 65%
rename from src/edu/mit/media/funf/probe/builtin/BluetoothProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/BluetoothProbe.java
index 6f04989..b325461 100644
--- a/src/edu/mit/media/funf/probe/builtin/BluetoothProbe.java
+++ b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/BluetoothProbe.java
@@ -34,6 +34,12 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.util.Log;
+
+import com.google.gson.ExclusionStrategy;
+import com.google.gson.FieldAttributes;
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+
import edu.mit.media.funf.Schedule;
import edu.mit.media.funf.config.Configurable;
import edu.mit.media.funf.probe.Probe.Base;
@@ -50,7 +56,16 @@
public class BluetoothProbe extends Base implements PassiveProbe {
@Configurable
- private BigDecimal maxScanTime = BigDecimal.valueOf(30.0);
+ private BigDecimal maxScanTime = BigDecimal.valueOf(60.0);
+
+ @Configurable
+ private boolean include_scan_started = true;
+
+ @Configurable
+ private boolean keepBluetoothVisible = false;
+
+ @Configurable
+ private String bluetooth_id = "";
private BluetoothAdapter adapter;
private BroadcastReceiver receiver = new BroadcastReceiver() {
@@ -58,7 +73,8 @@ public class BluetoothProbe extends Base implements PassiveProbe {
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if (action.equals(BluetoothDevice.ACTION_FOUND)) {
- sendData(getGson().toJsonTree(intent.getExtras()).getAsJsonObject());
+ Gson gson = getGsonBuilder().addSerializationExclusionStrategy(new BluetoothExclusionStrategy()).create();
+ sendData(gson.toJsonTree(intent.getExtras()).getAsJsonObject());
} else if (action.equals(BluetoothAdapter.ACTION_DISCOVERY_FINISHED)) {
stop();
}
@@ -78,11 +94,26 @@ public void onReceive(Context context, Intent intent) {
}
}
};
+
+ private JsonObject createScanStartedData() {
+ JsonObject data = new JsonObject();
+ JsonObject addressData = new JsonObject();
+ addressData.addProperty("mAddress", "00:00:00:00:00:00");
+ data.add("android.bluetooth.device.extra.DEVICE", addressData);
+ data.addProperty("android.bluetooth.device.extra.NAME", "DUMMY_SCAN_STARTED");
+ return data;
+ }
+
+ private void sendScanStartedData() {
+ JsonObject data = createScanStartedData();
+ sendData(data);
+ }
private boolean shouldDisableOnFinish = false; // Keeps track of previous bluetooth state
private void startDiscovery() {
if (adapter.isEnabled()) {
adapter.startDiscovery();
+ if (include_scan_started) sendScanStartedData();
} else {
shouldDisableOnFinish = true;
getContext().registerReceiver(stateChangedReceiver, new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED));
@@ -121,10 +152,32 @@ protected void onStop() {
if (adapter.isDiscovering()) {
adapter.cancelDiscovery();
}
+ if (!this.bluetooth_id.isEmpty()) {
+ setBluetoothId();
+ }
if (shouldDisableOnFinish) {
adapter.disable();
shouldDisableOnFinish = false;
}
+ if (keepBluetoothVisible) {
+ makeVisible();
+ }
+ }
+
+ private void makeVisible() {
+ if(adapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
+ Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
+ discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 0);
+ discoverableIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ this.getContext().startActivity(discoverableIntent);
+ }
+ }
+
+ private void setBluetoothId() {
+ if (this.bluetooth_id.isEmpty()) return;
+ String currentBluetoothName = adapter.getName();
+ if (currentBluetoothName.contains(this.bluetooth_id)) return;
+ adapter.setName(currentBluetoothName + "$" + this.bluetooth_id + "$");
}
@Override
@@ -135,6 +188,19 @@ protected void onDisable() {
Log.w(TAG, getClass().getName() + "Broadcast receiver not registered.", e);
}
}
-
+
+ public class BluetoothExclusionStrategy implements ExclusionStrategy {
+ public boolean shouldSkipClass(Class> cls) {
+ return false;
+ }
+ public boolean shouldSkipField(FieldAttributes f) {
+ String name = f.getName();
+ return (f.getDeclaringClass() == BluetoothDevice.class &&
+ (name.equals("XXX")
+ //here we can remove fields from the scan result if we want to
+ )
+ );
+ }
+ }
}
diff --git a/src/edu/mit/media/funf/probe/builtin/BrowserBookmarksProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/BrowserBookmarksProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/BrowserBookmarksProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/BrowserBookmarksProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/BrowserSearchesProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/BrowserSearchesProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/BrowserSearchesProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/BrowserSearchesProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/CallLogProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/CallLogProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/CallLogProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/CallLogProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/CellTowerProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/CellTowerProbe.java
similarity index 78%
rename from src/edu/mit/media/funf/probe/builtin/CellTowerProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/CellTowerProbe.java
index 7217d9e..4cc3afb 100644
--- a/src/edu/mit/media/funf/probe/builtin/CellTowerProbe.java
+++ b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/CellTowerProbe.java
@@ -55,10 +55,28 @@ private Bundle getData() {
GsmCellLocation gsmLocation = (GsmCellLocation) location;
gsmLocation.fillInNotifierBundle(data);
data.putInt(TYPE, TelephonyManager.PHONE_TYPE_GSM);
+ String networkOperator = manager.getNetworkOperator();
+ int mcc = 0;
+ int mnc = 0;
+ if (networkOperator != null && !networkOperator.isEmpty()) {
+ mcc = Integer.parseInt(networkOperator.substring(0, 3));
+ mnc = Integer.parseInt(networkOperator.substring(3));
+ }
+ data.putInt("mcc", mcc);
+ data.putInt("mnc", mnc);
} else if (location instanceof CdmaCellLocation) {
CdmaCellLocation cdmaLocation = (CdmaCellLocation) location;
cdmaLocation.fillInNotifierBundle(data);
data.putInt(TYPE, TelephonyManager.PHONE_TYPE_CDMA);
+ String networkOperator = manager.getNetworkOperator();
+ int mcc = 0;
+ int mnc = 0;
+ if (networkOperator != null && !networkOperator.isEmpty()) {
+ mcc = Integer.parseInt(networkOperator.substring(0, 3));
+ mnc = Integer.parseInt(networkOperator.substring(3));
+ }
+ data.putInt("mcc", mcc);
+ data.putInt("mnc", mnc);
} else {
data.putInt(TYPE, TelephonyManager.PHONE_TYPE_NONE);
}
diff --git a/src/edu/mit/media/funf/probe/builtin/ContactProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/ContactProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/ContactProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/ContactProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/ContentProviderProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/ContentProviderProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/ContentProviderProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/ContentProviderProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/DatedContentProviderProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/DatedContentProviderProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/DatedContentProviderProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/DatedContentProviderProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/GravitySensorProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/GravitySensorProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/GravitySensorProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/GravitySensorProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/GyroscopeSensorProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/GyroscopeSensorProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/GyroscopeSensorProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/GyroscopeSensorProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/HardwareInfoProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/HardwareInfoProbe.java
similarity index 95%
rename from src/edu/mit/media/funf/probe/builtin/HardwareInfoProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/HardwareInfoProbe.java
index ec5f1fa..0718b45 100644
--- a/src/edu/mit/media/funf/probe/builtin/HardwareInfoProbe.java
+++ b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/HardwareInfoProbe.java
@@ -31,9 +31,11 @@
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;
import edu.mit.media.funf.Schedule;
+import edu.mit.media.funf.probe.Probe;
import edu.mit.media.funf.probe.Probe.RequiredPermissions;
import edu.mit.media.funf.probe.builtin.ProbeKeys.HardwareInfoKeys;
+@Probe.DisplayName("Basic information about this device (e.g. brand, model, hardware ids)")
@Schedule.DefaultSchedule(interval=604800)
@RequiredPermissions({android.Manifest.permission.ACCESS_WIFI_STATE, android.Manifest.permission.BLUETOOTH, android.Manifest.permission.READ_PHONE_STATE})
public class HardwareInfoProbe extends ImpulseProbe implements HardwareInfoKeys {
diff --git a/src/edu/mit/media/funf/probe/builtin/ImageMediaProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/ImageMediaProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/ImageMediaProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/ImageMediaProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/ImpulseProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/ImpulseProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/ImpulseProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/ImpulseProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/LightSensorProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/LightSensorProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/LightSensorProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/LightSensorProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/LinearAccelerationSensorProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/LinearAccelerationSensorProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/LinearAccelerationSensorProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/LinearAccelerationSensorProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/LocationProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/LocationProbe.java
similarity index 95%
rename from src/edu/mit/media/funf/probe/builtin/LocationProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/LocationProbe.java
index 8a7b224..64180e9 100644
--- a/src/edu/mit/media/funf/probe/builtin/LocationProbe.java
+++ b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/LocationProbe.java
@@ -159,7 +159,13 @@ public boolean shouldSkipField(FieldAttributes f) {
|| name.equals("mLat2")
|| name.equals("mLon1")
|| name.equals("mLon2")
- || name.equals("mLon2")
+ || name.equals("mLon2")
+ || name.equals("mHasSpeed")
+ || name.equals("mHasAccuracy")
+ || name.equals("mHasAltitude")
+ || name.equals("mHasBearing")
+ || name.equals("mHasSpeed")
+ || name.equals("mElapsedRealtimeNanos")
)
);
}
diff --git a/src/edu/mit/media/funf/probe/builtin/MagneticFieldSensorProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/MagneticFieldSensorProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/MagneticFieldSensorProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/MagneticFieldSensorProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/OrientationSensorProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/OrientationSensorProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/OrientationSensorProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/OrientationSensorProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/PressureSensorProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/PressureSensorProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/PressureSensorProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/PressureSensorProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/ProbeKeys.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/ProbeKeys.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/ProbeKeys.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/ProbeKeys.java
diff --git a/src/edu/mit/media/funf/probe/builtin/ProcessStatisticsProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/ProcessStatisticsProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/ProcessStatisticsProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/ProcessStatisticsProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/ProximitySensorProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/ProximitySensorProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/ProximitySensorProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/ProximitySensorProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/RotationVectorSensorProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/RotationVectorSensorProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/RotationVectorSensorProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/RotationVectorSensorProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/RunningApplicationsProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/RunningApplicationsProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/RunningApplicationsProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/RunningApplicationsProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/ScreenProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/ScreenProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/ScreenProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/ScreenProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/SensorProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/SensorProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/SensorProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/SensorProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/ServicesProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/ServicesProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/ServicesProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/ServicesProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/SimpleLocationProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/SimpleLocationProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/SimpleLocationProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/SimpleLocationProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/SimpleProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/SimpleProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/SimpleProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/SimpleProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/SmsProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/SmsProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/SmsProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/SmsProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/TelephonyProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/TelephonyProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/TelephonyProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/TelephonyProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/TemperatureSensorProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/TemperatureSensorProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/TemperatureSensorProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/TemperatureSensorProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/TimeOffsetProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/TimeOffsetProbe.java
similarity index 97%
rename from src/edu/mit/media/funf/probe/builtin/TimeOffsetProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/TimeOffsetProbe.java
index 247703b..babcdc1 100644
--- a/src/edu/mit/media/funf/probe/builtin/TimeOffsetProbe.java
+++ b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/TimeOffsetProbe.java
@@ -37,6 +37,7 @@
import com.google.gson.JsonObject;
import edu.mit.media.funf.config.Configurable;
+import edu.mit.media.funf.probe.Probe;
import edu.mit.media.funf.probe.Probe.Base;
import edu.mit.media.funf.probe.builtin.ProbeKeys.TimeOffsetKeys;
import edu.mit.media.funf.time.NtpMessage;
@@ -49,6 +50,7 @@
* @author alangardner
*
*/
+@Probe.DisplayName("Status of time synchronization")
public class TimeOffsetProbe extends Base implements TimeOffsetKeys {
private static final BigDecimal SECONDS_1900_TO_1970 = new BigDecimal(2208988800L);
diff --git a/src/edu/mit/media/funf/probe/builtin/VideoMediaProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/VideoMediaProbe.java
similarity index 100%
rename from src/edu/mit/media/funf/probe/builtin/VideoMediaProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/VideoMediaProbe.java
diff --git a/src/edu/mit/media/funf/probe/builtin/WifiProbe.java b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/WifiProbe.java
similarity index 83%
rename from src/edu/mit/media/funf/probe/builtin/WifiProbe.java
rename to funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/WifiProbe.java
index 5007be5..f603910 100644
--- a/src/edu/mit/media/funf/probe/builtin/WifiProbe.java
+++ b/funf_v4/src/main/java/edu/mit/media/funf/probe/builtin/WifiProbe.java
@@ -25,8 +25,6 @@
-import java.util.List;
-
import android.Manifest;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -37,11 +35,16 @@
import android.net.wifi.WifiManager.WifiLock;
import android.util.Log;
+import com.google.gson.ExclusionStrategy;
+import com.google.gson.FieldAttributes;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
+import java.util.List;
+
import edu.mit.media.funf.Schedule;
+import edu.mit.media.funf.config.Configurable;
import edu.mit.media.funf.probe.Probe.Base;
import edu.mit.media.funf.probe.Probe.DisplayName;
import edu.mit.media.funf.probe.Probe.RequiredFeatures;
@@ -54,6 +57,9 @@
@DisplayName("Nearby Wifi Devices Probe")
public class WifiProbe extends Base {
+ @Configurable
+ private boolean include_scan_started = true;
+
public static final String TSF = "tsf";
private static final String LOCK_KEY = WifiProbe.class.getName();
@@ -68,7 +74,7 @@ public void onReceive(Context context, Intent intent) {
if (WifiManager.SCAN_RESULTS_AVAILABLE_ACTION.equals(intent.getAction())) {
List results = wifiManager.getScanResults();
if (results != null) {
- Gson gson = getGson();
+ Gson gson = getGsonBuilder().addSerializationExclusionStrategy(new WifiExclusionStrategy()).create();
for (ScanResult result : results) {
JsonObject data = gson.toJsonTree(result).getAsJsonObject();
if (data.has(TIMESTAMP)) {
@@ -174,14 +180,28 @@ private void releaseWifiLock() {
wifiLock = null;
}
}
-
+
+ private JsonObject createScanStartedData() {
+ JsonObject data = new JsonObject();
+ data.addProperty("BSSID", "00:00:00:00:00:00");
+ data.addProperty("SSID", "DUMMY_SCAN_STARTED");
+ return data;
+
+ }
+
+ private void sendScanStartedData() {
+ JsonObject data = createScanStartedData();
+ sendData(data);
+ }
+
private void runScan() {
numberOfAttempts += 1;
int state = wifiManager.getWifiState();
if (state == WifiManager.WIFI_STATE_ENABLED) {
boolean successfulStart = wifiManager.startScan();
- if (successfulStart) {
+ if (successfulStart) {
Log.i(LogUtil.TAG, "WIFI scan started succesfully");
+ if (include_scan_started) sendScanStartedData();
} else {
Log.e(LogUtil.TAG, "WIFI scan failed.");
}
@@ -196,4 +216,19 @@ private void runScan() {
}
}
+
+ public class WifiExclusionStrategy implements ExclusionStrategy {
+ public boolean shouldSkipClass(Class> cls) {
+ return false;
+ }
+ public boolean shouldSkipField(FieldAttributes f) {
+ String name = f.getName();
+ return (f.getDeclaringClass() == ScanResult.class &&
+ (name.equals("XXX")
+ //here we can remove fields from the scan result if we want to
+ )
+ );
+ }
+
+ }
}
diff --git a/src/edu/mit/media/funf/security/Base64Coder.java b/funf_v4/src/main/java/edu/mit/media/funf/security/Base64Coder.java
similarity index 100%
rename from src/edu/mit/media/funf/security/Base64Coder.java
rename to funf_v4/src/main/java/edu/mit/media/funf/security/Base64Coder.java
diff --git a/src/edu/mit/media/funf/security/HashUtil.java b/funf_v4/src/main/java/edu/mit/media/funf/security/HashUtil.java
similarity index 100%
rename from src/edu/mit/media/funf/security/HashUtil.java
rename to funf_v4/src/main/java/edu/mit/media/funf/security/HashUtil.java
diff --git a/src/edu/mit/media/funf/security/MD5.java b/funf_v4/src/main/java/edu/mit/media/funf/security/MD5.java
similarity index 100%
rename from src/edu/mit/media/funf/security/MD5.java
rename to funf_v4/src/main/java/edu/mit/media/funf/security/MD5.java
diff --git a/src/edu/mit/media/funf/security/RSAEncode.java b/funf_v4/src/main/java/edu/mit/media/funf/security/RSAEncode.java
similarity index 100%
rename from src/edu/mit/media/funf/security/RSAEncode.java
rename to funf_v4/src/main/java/edu/mit/media/funf/security/RSAEncode.java
diff --git a/src/edu/mit/media/funf/storage/BackedUpArchive.java b/funf_v4/src/main/java/edu/mit/media/funf/storage/BackedUpArchive.java
similarity index 100%
rename from src/edu/mit/media/funf/storage/BackedUpArchive.java
rename to funf_v4/src/main/java/edu/mit/media/funf/storage/BackedUpArchive.java
diff --git a/src/edu/mit/media/funf/storage/CompositeFileArchive.java b/funf_v4/src/main/java/edu/mit/media/funf/storage/CompositeFileArchive.java
similarity index 100%
rename from src/edu/mit/media/funf/storage/CompositeFileArchive.java
rename to funf_v4/src/main/java/edu/mit/media/funf/storage/CompositeFileArchive.java
diff --git a/funf_v4/src/main/java/edu/mit/media/funf/storage/DatabaseHelper.java b/funf_v4/src/main/java/edu/mit/media/funf/storage/DatabaseHelper.java
new file mode 100644
index 0000000..9afc96b
--- /dev/null
+++ b/funf_v4/src/main/java/edu/mit/media/funf/storage/DatabaseHelper.java
@@ -0,0 +1,24 @@
+package edu.mit.media.funf.storage;
+
+import android.content.Context;
+
+import edu.mit.media.funf.json.IJsonObject;
+
+/**
+ * Created by astopczynski on 10/27/15.
+ */
+public interface DatabaseHelper {
+
+ public static final String COLUMN_NAME = "name";
+ public static final String COLUMN_TIMESTAMP = "timestamp";
+ public static final String COLUMN_VALUE = "value";
+
+ public void init();
+
+ public String getPath();
+
+ public void finish();
+
+ public void insert(String name, double timestamp, IJsonObject value);
+
+}
diff --git a/src/edu/mit/media/funf/storage/DefaultArchive.java b/funf_v4/src/main/java/edu/mit/media/funf/storage/DefaultArchive.java
similarity index 89%
rename from src/edu/mit/media/funf/storage/DefaultArchive.java
rename to funf_v4/src/main/java/edu/mit/media/funf/storage/DefaultArchive.java
index afad56d..9774096 100644
--- a/src/edu/mit/media/funf/storage/DefaultArchive.java
+++ b/funf_v4/src/main/java/edu/mit/media/funf/storage/DefaultArchive.java
@@ -32,6 +32,8 @@
import javax.crypto.spec.PBEKeySpec;
import android.content.Context;
+import android.util.Log;
+
import edu.mit.media.funf.Schedule.DefaultSchedule;
import edu.mit.media.funf.config.Configurable;
import edu.mit.media.funf.security.Base64Coder;
@@ -67,6 +69,9 @@ public class DefaultArchive implements FileArchive {
@Configurable
protected String key;
+
+ @Configurable
+ protected Boolean compress = false;
protected Context context;
@@ -161,8 +166,8 @@ protected FileArchive getDelegateArchive() {
String rootSdCardPath = getPathOnSDCard();
FileArchive backupArchive = FileDirectoryArchive.getRollingFileArchive(new File(rootSdCardPath + "backup"));
FileArchive mainArchive = new CompositeFileArchive(
- getTimestampedDbFileArchive(new File(rootSdCardPath + "archive"), context, key),
- getTimestampedDbFileArchive(context.getDir("funf_" + getCleanedName() + "_archive", Context.MODE_PRIVATE), context, key)
+ getTimestampedDbFileArchive(new File(rootSdCardPath + "archive"), context, key, compress),
+ getTimestampedDbFileArchive(context.getDir("funf_" + getCleanedName() + "_archive", Context.MODE_PRIVATE), context, key, compress)
);
delegateArchive = new BackedUpArchive(mainArchive, backupArchive);
}
@@ -171,9 +176,18 @@ protected FileArchive getDelegateArchive() {
return delegateArchive;
}
- static FileDirectoryArchive getTimestampedDbFileArchive(File archiveDir, Context context, SecretKey encryptionKey) {
- NameGenerator nameGenerator = new CompositeNameGenerator(new SystemUniqueTimestampNameGenerator(context), new RequiredSuffixNameGenerator(".db"));
- FileCopier copier = (encryptionKey == null) ? new FileCopier.SimpleFileCopier() : new FileCopier.EncryptedFileCopier(encryptionKey, DES_ENCRYPTION);
+ static FileDirectoryArchive getTimestampedDbFileArchive(File archiveDir, Context context, SecretKey encryptionKey, Boolean compress) {
+ String suffix = ".db";
+ if (compress) suffix += ".gz";
+ if (encryptionKey != null) suffix += ".enc";
+ NameGenerator nameGenerator = new CompositeNameGenerator(new SystemUniqueTimestampNameGenerator(context), new RequiredSuffixNameGenerator(suffix));
+ FileCopier copier = null;
+ if (compress) {
+ copier = (encryptionKey == null) ? new FileCopier.CompressedFileCopier() : new FileCopier.CompressedEncryptedFileCopier(encryptionKey, DES_ENCRYPTION);
+ } else {
+ copier = (encryptionKey == null) ? new FileCopier.SimpleFileCopier() : new FileCopier.EncryptedFileCopier(encryptionKey, DES_ENCRYPTION);
+ }
+
return new FileDirectoryArchive(archiveDir, nameGenerator, copier, new DirectoryCleaner.KeepAll());
}
diff --git a/src/edu/mit/media/funf/storage/DirectoryCleaner.java b/funf_v4/src/main/java/edu/mit/media/funf/storage/DirectoryCleaner.java
similarity index 100%
rename from src/edu/mit/media/funf/storage/DirectoryCleaner.java
rename to funf_v4/src/main/java/edu/mit/media/funf/storage/DirectoryCleaner.java
diff --git a/src/edu/mit/media/funf/storage/FileArchive.java b/funf_v4/src/main/java/edu/mit/media/funf/storage/FileArchive.java
similarity index 100%
rename from src/edu/mit/media/funf/storage/FileArchive.java
rename to funf_v4/src/main/java/edu/mit/media/funf/storage/FileArchive.java
diff --git a/src/edu/mit/media/funf/storage/FileCopier.java b/funf_v4/src/main/java/edu/mit/media/funf/storage/FileCopier.java
similarity index 56%
rename from src/edu/mit/media/funf/storage/FileCopier.java
rename to funf_v4/src/main/java/edu/mit/media/funf/storage/FileCopier.java
index 9f48ae7..334597b 100644
--- a/src/edu/mit/media/funf/storage/FileCopier.java
+++ b/funf_v4/src/main/java/edu/mit/media/funf/storage/FileCopier.java
@@ -25,14 +25,18 @@
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.nio.channels.FileChannel;
+import java.util.zip.GZIPOutputStream;
import javax.crypto.Cipher;
import javax.crypto.CipherOutputStream;
@@ -136,14 +140,14 @@ public boolean copy(File sourceFile, File destinationFile) {
CipherOutputStream co = null;
try {
in = new FileInputStream(sourceFile);
- out = new FileOutputStream(destinationFile);
+ out = new FileOutputStream(destinationFile);
co = new CipherOutputStream(out, ecipher);
byte[] buf = new byte[128*4096];
- int len = 0;
- while ((len = in.read(buf)) > 0)
- {
- co.write(buf, 0, len);
- }
+ int len = 0;
+ while ((len = in.read(buf)) > 0)
+ {
+ co.write(buf, 0, len);
+ }
} catch (FileNotFoundException e) {
Log.e(TAG, "File not found", e);
return false;
@@ -160,4 +164,116 @@ public boolean copy(File sourceFile, File destinationFile) {
}
}
+
+ public static class CompressedEncryptedFileCopier implements FileCopier {
+ public static final String TAG = CompressedEncryptedFileCopier.class.getName();
+ private final SecretKey key;
+ private final String transformation;
+
+ public CompressedEncryptedFileCopier(SecretKey key, String transformation) {
+ this.key = key;
+ this.transformation = transformation;
+ }
+
+ private Cipher cipher; // Cache
+ protected Cipher getCipher() {
+ if (cipher == null) {
+ synchronized (this) {
+ if (cipher == null) {
+ try {
+ cipher = Cipher.getInstance(transformation);
+ cipher.init(Cipher.ENCRYPT_MODE, key);
+ } catch (Exception e) {
+ Log.e(TAG, "Error creating cipher", e);
+ }
+ }
+ }
+ }
+ return cipher;
+ }
+
+ @Override
+ public boolean copy(File sourceFile, File destinationFile) {
+ Log.i(TAG, "compressing + encrypting + copying " + sourceFile.getPath() + " to " + destinationFile.getPath());
+
+ Cipher ecipher = getCipher();
+ if (ecipher == null) {
+ return false;
+ }
+
+ InputStream in = null;
+ OutputStream out = null;
+ CipherOutputStream co = null;
+ GZIPOutputStream gzipOutputStream = null;
+ try {
+ in = new FileInputStream(sourceFile);
+ out = new FileOutputStream(destinationFile);
+ co = new CipherOutputStream(out, ecipher);
+ gzipOutputStream = new GZIPOutputStream(co);
+
+ byte[] buf = new byte[128*4096];
+ int len = 0;
+ while ((len = in.read(buf)) > 0) {
+ Log.i(TAG, "compressing...");
+ gzipOutputStream.write(buf, 0, len);
+ }
+ gzipOutputStream.finish();
+
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File not found", e);
+ return false;
+ } catch (IOException e) {
+ Log.e(TAG, "IOException", e);
+ return false;
+ } finally {
+ IOUtil.close(in);
+ IOUtil.close(co);
+ IOUtil.close(out);
+ }
+
+ Log.i(TAG, "done copy");
+ return true;
+ }
+ }
+
+ public static class CompressedFileCopier implements FileCopier {
+ public static final String TAG = CompressedFileCopier.class.getName();
+
+ @Override
+ public boolean copy(File sourceFile, File destinationFile) {
+ Log.i(TAG, "compressing + copying " + sourceFile.getPath() + " to " + destinationFile.getPath());
+
+
+ InputStream in = null;
+ OutputStream out = null;
+ GZIPOutputStream gzipOutputStream = null;
+ try {
+ in = new FileInputStream(sourceFile);
+ out = new FileOutputStream(destinationFile);
+ gzipOutputStream = new GZIPOutputStream(out);
+
+ byte[] buf = new byte[128*4096];
+ int len = 0;
+ while ((len = in.read(buf)) > 0) {
+ Log.i(TAG, "compressing...");
+ gzipOutputStream.write(buf, 0, len);
+ }
+
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File not found", e);
+ return false;
+ } catch (IOException e) {
+ Log.e(TAG, "IOException", e);
+ return false;
+ } finally {
+ IOUtil.close(in);
+ IOUtil.close(gzipOutputStream);
+ IOUtil.close(out);
+ }
+
+ Log.i(TAG, "done copy");
+ return true;
+ }
+ }
+
}
diff --git a/src/edu/mit/media/funf/storage/FileDirectoryArchive.java b/funf_v4/src/main/java/edu/mit/media/funf/storage/FileDirectoryArchive.java
similarity index 89%
rename from src/edu/mit/media/funf/storage/FileDirectoryArchive.java
rename to funf_v4/src/main/java/edu/mit/media/funf/storage/FileDirectoryArchive.java
index 82474bf..edb2d9b 100644
--- a/src/edu/mit/media/funf/storage/FileDirectoryArchive.java
+++ b/funf_v4/src/main/java/edu/mit/media/funf/storage/FileDirectoryArchive.java
@@ -54,14 +54,21 @@ public static FileDirectoryArchive getSimpleFileArchive(File archiveDir) {
}
public static FileDirectoryArchive getRollingFileArchive(File archiveDir) {
- return new FileDirectoryArchive(archiveDir, new NameGenerator.IdentityNameGenerator(), new FileCopier.SimpleFileCopier(), new DirectoryCleaner.KeepUnderPercentageOfDiskFree(0.5, 10000000));
+ return new FileDirectoryArchive(archiveDir, new NameGenerator.IdentityNameGenerator(), new FileCopier.SimpleFileCopier(), new DirectoryCleaner.KeepMostRecent(20));
}
@Override
public boolean add(File item) {
this.archiveDir.mkdirs();
- File archiveFile = new File(archiveDir, nameGenerator.generateName(item.getName()));
+ String filename = nameGenerator.generateName(item.getName());
+ String appendix = "";
+ File archiveFile = new File(archiveDir, filename);
+ while (archiveFile.exists()) {
+ appendix += "_";
+ filename = nameGenerator.generateName(appendix + item.getName());
+ archiveFile = new File(archiveDir, filename);
+ }
boolean result = fileCopier.copy(item, archiveFile);
cleaner.clean(archiveDir);
return result;
diff --git a/funf_v4/src/main/java/edu/mit/media/funf/storage/HttpArchive.java b/funf_v4/src/main/java/edu/mit/media/funf/storage/HttpArchive.java
new file mode 100644
index 0000000..e21ec08
--- /dev/null
+++ b/funf_v4/src/main/java/edu/mit/media/funf/storage/HttpArchive.java
@@ -0,0 +1,171 @@
+/**
+ *
+ * Funf: Open Sensing Framework
+ * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
+ * Acknowledgments: Alan Gardner
+ * Contact: nadav@media.mit.edu
+ *
+ * This file is part of Funf.
+ *
+ * Funf is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * Funf is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Funf. If not, see .
+ *
+ */
+package edu.mit.media.funf.storage;
+
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.net.NetworkInfo.State;
+import android.util.Log;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.InputStreamEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import edu.mit.media.funf.FunfManager;
+import edu.mit.media.funf.Schedule.DefaultSchedule;
+import edu.mit.media.funf.config.Configurable;
+import edu.mit.media.funf.pipeline.BasicPipeline;
+import edu.mit.media.funf.util.IOUtil;
+import edu.mit.media.funf.util.LogUtil;
+
+/**
+ * Archives a file to the url specified using POST HTTP method.
+ *
+ */
+@DefaultSchedule(interval=21600) // 6h
+public class HttpArchive implements RemoteFileArchive {
+
+ @Configurable
+ private String url;
+
+ @Configurable
+ private boolean wifiOnly = false;
+
+ private Context context;
+
+ @SuppressWarnings("unused")
+ private String mimeType;
+
+ public HttpArchive() {
+
+ }
+
+ public HttpArchive(Context context, final String uploadUrl) {
+ this(context, uploadUrl, "application/x-binary");
+ }
+
+ public HttpArchive(Context context, final String uploadUrl, final String mimeType) {
+ this.url = uploadUrl;
+ this.mimeType = mimeType;
+ this.context = context;
+ }
+
+ public void setContext(Context context) {
+ this.context = context;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public boolean isAvailable() {
+ assert context != null;
+ ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo netInfo = connectivityManager.getActiveNetworkInfo();
+ if (!wifiOnly && netInfo != null && netInfo.isConnectedOrConnecting()) {
+ return true;
+ } else if (wifiOnly) {
+ State wifiInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState();
+ if (State.CONNECTED.equals(wifiInfo) || State.CONNECTING.equals(wifiInfo)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public String getId() {
+ return url;
+ }
+
+
+
+ public boolean add(File file) {
+ String currentUrl = IOUtil.formatServerUrl(url, file.getName());
+ Log.i(LogUtil.TAG, "UPLOADER: "+currentUrl + " "+IOUtil.isValidUrl(currentUrl));
+ return IOUtil.isValidUrl(currentUrl) ? uploadFile(file, currentUrl,FunfManager.funfManager.getAuthToken(url)) : false;
+ }
+
+ /**
+ * Based on funf v3 from OpenSensing
+ * @param file
+ * @param uploadurl
+ * @return
+ */
+ public static boolean uploadFile(File file,String uploadurl,String accessToken) {
+ if (uploadurl == null) return false;
+ if (uploadurl.equals("")) return false;
+ HttpClient httpClient = new DefaultHttpClient() ;
+ HttpPost httpPost;
+ try {
+ httpPost = new HttpPost(new URI(uploadurl));
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ return false;
+ }
+
+ InputStreamEntity reqEntity = null;
+ HttpResponse response = null;
+ try {
+ reqEntity = new InputStreamEntity(new FileInputStream(file), -1);
+ reqEntity.setContentType("binary/octet-stream");
+ reqEntity.setChunked(true); // Send in multiple parts if needed
+ httpPost.setEntity(reqEntity);
+ response = httpClient.execute(httpPost);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ return false;
+ } catch (IOException e) {
+ e.printStackTrace();
+ return false;
+ }
+ if (response == null) {
+ return false;
+ }
+ if (response.getStatusLine().getStatusCode() == 200) {
+ return true;
+ }
+ if (response.getStatusLine().getStatusCode() == 401) {
+ //Auth error
+ Log.i(LogUtil.TAG, "Auth Error "+response.getStatusLine().getStatusCode());
+ FunfManager.funfManager.authError(BasicPipeline.ACTION_UPLOAD, accessToken);
+ }
+ if (response.getStatusLine().getStatusCode() == 500) {
+ //Server error
+ FunfManager.funfManager.broadcastServerError("SERVER_ERROR", accessToken);
+ }
+
+
+ return false;
+ }
+}
diff --git a/funf_v4/src/main/java/edu/mit/media/funf/storage/JsonDatabaseHelper.java b/funf_v4/src/main/java/edu/mit/media/funf/storage/JsonDatabaseHelper.java
new file mode 100644
index 0000000..525ab8f
--- /dev/null
+++ b/funf_v4/src/main/java/edu/mit/media/funf/storage/JsonDatabaseHelper.java
@@ -0,0 +1,146 @@
+package edu.mit.media.funf.storage;
+
+import com.google.gson.JsonObject;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.TimeZone;
+
+import edu.mit.media.funf.FunfManager;
+import edu.mit.media.funf.json.IJsonObject;
+
+/**
+ * Created by astopczynski on 10/26/15.
+ */
+public class JsonDatabaseHelper implements DatabaseHelper{
+
+ public static final String COLUMN_TIME_OFFSET = "time_offset";
+
+
+ Context context;
+ String databaseName;
+ String tempFileName;
+ static FileOutputStream fos = null;
+ private FileOutputStream tempFos = null;
+
+ public JsonDatabaseHelper(Context context, String name, int version) {
+ this.context = context;
+ this.databaseName = name;
+ this.tempFileName = this.databaseName + "_temp";
+ }
+
+ public void init() {
+ this.createDatabaseFile();
+ }
+
+ private void createDatabaseFile() {
+ try {
+ fos = this.context.openFileOutput(this.databaseName, Context.MODE_APPEND);
+
+ JsonObject dataObject = new JsonObject();
+ dataObject.addProperty("ANDROID_ID",
+ Settings.Secure.getString(
+ this.context.getContentResolver(), Settings.Secure.ANDROID_ID
+ ));
+ dataObject.addProperty(this.COLUMN_TIME_OFFSET,
+ TimeZone.getDefault().getOffset(System.currentTimeMillis()) / 1000 / 60);
+
+ try {
+ dataObject.addProperty("FUNF_VERSION", FunfManager.funfManager.getVersion());
+ } catch (NullPointerException e) {}
+
+ try {
+ dataObject.addProperty("APPLICATION_VERSION", FunfManager.funfManager.getApplicationVersion());
+ } catch (NullPointerException e) {}
+
+ fos.write((dataObject.toString() + "\n").getBytes());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ public void insert(String name, double timestamp, IJsonObject value) {
+ if (fos == null) {
+ createDatabaseFile();
+ }
+ JsonObject dataObject = null;
+ try {
+ dataObject = new JsonObject();
+ dataObject.addProperty(this.COLUMN_NAME, name);
+ dataObject.addProperty(this.COLUMN_TIMESTAMP, timestamp);
+ dataObject.add(this.COLUMN_VALUE, value);
+ fos.write((dataObject.toString() + "\n").getBytes());
+ } catch (IOException e) {
+ e.printStackTrace();
+ insertIntoTemp(dataObject);
+ }
+ }
+
+ private void createTempFile() {
+ try {
+ tempFos = this.context.openFileOutput(this.tempFileName, Context.MODE_APPEND);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void finalizeTempFile() {
+ try {
+ if (tempFos != null) tempFos.close();
+ (new File(this.tempFileName)).delete();
+ } catch (IOException e) {
+ }
+
+ }
+
+ private void copyFromTempFile() {
+ try {
+ FileInputStream tempFis = this.context.openFileInput(this.tempFileName);
+ BufferedReader bufferedReader = new BufferedReader(
+ new InputStreamReader(tempFis, "UTF-8"));
+ while (true) {
+ String line = bufferedReader.readLine();
+ if (line == null) break;
+ fos.write((line + "\n").getBytes());
+ }
+
+ } catch (IOException e) {
+ }
+ }
+
+ private void insertIntoTemp(JsonObject dataObject) {
+ createTempFile();
+ try {
+ if (dataObject != null) {
+ tempFos.write((dataObject.toString() + "\n").getBytes());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void finish() {
+ try {
+ if (fos != null) {
+ copyFromTempFile();
+ finalizeTempFile();
+ fos.close();
+ }
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public String getPath() {
+ return this.context.getFileStreamPath(this.databaseName).getPath();
+ }
+}
diff --git a/src/edu/mit/media/funf/storage/NameValueDatabaseHelper.java b/funf_v4/src/main/java/edu/mit/media/funf/storage/NameValueDatabaseHelper.java
similarity index 81%
rename from src/edu/mit/media/funf/storage/NameValueDatabaseHelper.java
rename to funf_v4/src/main/java/edu/mit/media/funf/storage/NameValueDatabaseHelper.java
index d1fd52c..7dd4f9c 100644
--- a/src/edu/mit/media/funf/storage/NameValueDatabaseHelper.java
+++ b/funf_v4/src/main/java/edu/mit/media/funf/storage/NameValueDatabaseHelper.java
@@ -29,20 +29,22 @@
import java.util.Locale;
import java.util.UUID;
+import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
+
+import edu.mit.media.funf.json.IJsonObject;
+import edu.mit.media.funf.probe.builtin.ProbeKeys;
import edu.mit.media.funf.time.TimeUtil;
import edu.mit.media.funf.util.StringUtil;
import edu.mit.media.funf.util.UuidUtil;
-public class NameValueDatabaseHelper extends SQLiteOpenHelper {
+public class NameValueDatabaseHelper extends SQLiteOpenHelper implements DatabaseHelper {
public static final int CURRENT_VERSION = 1;
- public static final String COLUMN_NAME = "name";
- public static final String COLUMN_TIMESTAMP = "timestamp";
- public static final String COLUMN_VALUE = "value";
+
public static final Table DATA_TABLE = new Table("data",
Arrays.asList(new Column(COLUMN_NAME, "TEXT"), // ACTION from data broadcast
new Column(COLUMN_TIMESTAMP, "FLOAT"), // TIMESTAMP in data broadcast
@@ -84,8 +86,35 @@ public void onCreate(SQLiteDatabase db) {
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// Nothing yet
- }
-
+ }
+
+ @Override
+ public void init() {
+ this.getWritableDatabase();
+ }
+
+ @Override
+ public String getPath() {
+ return this.getWritableDatabase().getPath();
+ }
+
+ @Override
+ public void insert(String name, double timestamp, IJsonObject value) {
+ SQLiteDatabase db = this.getWritableDatabase();
+ final String valueString = value.toString();
+ ContentValues cv = new ContentValues();
+ cv.put(NameValueDatabaseHelper.COLUMN_NAME, name);
+ cv.put(NameValueDatabaseHelper.COLUMN_VALUE, valueString);
+ cv.put(NameValueDatabaseHelper.COLUMN_TIMESTAMP, timestamp);
+ db.insertOrThrow(NameValueDatabaseHelper.DATA_TABLE.name, "", cv);
+
+ }
+
+ @Override
+ public void finish() {
+ this.getWritableDatabase().close();
+ }
+
// TODO: Consider moving these to an external utils class
/**
* Immutable Table Definition
diff --git a/src/edu/mit/media/funf/storage/RemoteFileArchive.java b/funf_v4/src/main/java/edu/mit/media/funf/storage/RemoteFileArchive.java
similarity index 100%
rename from src/edu/mit/media/funf/storage/RemoteFileArchive.java
rename to funf_v4/src/main/java/edu/mit/media/funf/storage/RemoteFileArchive.java
diff --git a/src/edu/mit/media/funf/storage/UploadService.java b/funf_v4/src/main/java/edu/mit/media/funf/storage/UploadService.java
similarity index 96%
rename from src/edu/mit/media/funf/storage/UploadService.java
rename to funf_v4/src/main/java/edu/mit/media/funf/storage/UploadService.java
index 8e7cb72..5240a2e 100644
--- a/src/edu/mit/media/funf/storage/UploadService.java
+++ b/funf_v4/src/main/java/edu/mit/media/funf/storage/UploadService.java
@@ -95,6 +95,8 @@ public void stop() {
public void run(final FileArchive archive, final RemoteFileArchive remoteArchive) {
Log.i(LogUtil.TAG, "Running upload...");
+ remoteArchiveFailures = new HashMap();
+ fileFailures = new HashMap();
if (archive != null && remoteArchive != null) {
if (lock == null) {
lock = LockUtil.getWakeLock(context);
@@ -145,7 +147,7 @@ protected void runArchive(FileArchive archive, RemoteFileArchive remoteArchive,
}
} else {
Log.i(LogUtil.TAG, "Canceling upload. Remote archive '" + remoteArchive.getId()
- + "' is not currently available.");
+ + "' is not currently available. " + numRemoteFailures);
filesToUpload.remove(file);
}
}
diff --git a/src/edu/mit/media/funf/time/DecimalTimeUnit.java b/funf_v4/src/main/java/edu/mit/media/funf/time/DecimalTimeUnit.java
similarity index 100%
rename from src/edu/mit/media/funf/time/DecimalTimeUnit.java
rename to funf_v4/src/main/java/edu/mit/media/funf/time/DecimalTimeUnit.java
diff --git a/src/edu/mit/media/funf/time/NtpMessage.java b/funf_v4/src/main/java/edu/mit/media/funf/time/NtpMessage.java
similarity index 100%
rename from src/edu/mit/media/funf/time/NtpMessage.java
rename to funf_v4/src/main/java/edu/mit/media/funf/time/NtpMessage.java
diff --git a/src/edu/mit/media/funf/time/TimeUnit.java b/funf_v4/src/main/java/edu/mit/media/funf/time/TimeUnit.java
similarity index 100%
rename from src/edu/mit/media/funf/time/TimeUnit.java
rename to funf_v4/src/main/java/edu/mit/media/funf/time/TimeUnit.java
diff --git a/src/edu/mit/media/funf/time/TimeUtil.java b/funf_v4/src/main/java/edu/mit/media/funf/time/TimeUtil.java
similarity index 100%
rename from src/edu/mit/media/funf/time/TimeUtil.java
rename to funf_v4/src/main/java/edu/mit/media/funf/time/TimeUtil.java
diff --git a/src/edu/mit/media/funf/util/AnnotationUtil.java b/funf_v4/src/main/java/edu/mit/media/funf/util/AnnotationUtil.java
similarity index 100%
rename from src/edu/mit/media/funf/util/AnnotationUtil.java
rename to funf_v4/src/main/java/edu/mit/media/funf/util/AnnotationUtil.java
diff --git a/src/edu/mit/media/funf/util/ArrayUtil.java b/funf_v4/src/main/java/edu/mit/media/funf/util/ArrayUtil.java
similarity index 100%
rename from src/edu/mit/media/funf/util/ArrayUtil.java
rename to funf_v4/src/main/java/edu/mit/media/funf/util/ArrayUtil.java
diff --git a/src/edu/mit/media/funf/util/AsyncSharedPrefs.java b/funf_v4/src/main/java/edu/mit/media/funf/util/AsyncSharedPrefs.java
similarity index 100%
rename from src/edu/mit/media/funf/util/AsyncSharedPrefs.java
rename to funf_v4/src/main/java/edu/mit/media/funf/util/AsyncSharedPrefs.java
diff --git a/src/edu/mit/media/funf/util/BundleUtil.java b/funf_v4/src/main/java/edu/mit/media/funf/util/BundleUtil.java
similarity index 100%
rename from src/edu/mit/media/funf/util/BundleUtil.java
rename to funf_v4/src/main/java/edu/mit/media/funf/util/BundleUtil.java
diff --git a/src/edu/mit/media/funf/util/EqualsUtil.java b/funf_v4/src/main/java/edu/mit/media/funf/util/EqualsUtil.java
similarity index 100%
rename from src/edu/mit/media/funf/util/EqualsUtil.java
rename to funf_v4/src/main/java/edu/mit/media/funf/util/EqualsUtil.java
diff --git a/src/edu/mit/media/funf/util/FileUtil.java b/funf_v4/src/main/java/edu/mit/media/funf/util/FileUtil.java
similarity index 100%
rename from src/edu/mit/media/funf/util/FileUtil.java
rename to funf_v4/src/main/java/edu/mit/media/funf/util/FileUtil.java
diff --git a/src/edu/mit/media/funf/util/HashCodeUtil.java b/funf_v4/src/main/java/edu/mit/media/funf/util/HashCodeUtil.java
similarity index 100%
rename from src/edu/mit/media/funf/util/HashCodeUtil.java
rename to funf_v4/src/main/java/edu/mit/media/funf/util/HashCodeUtil.java
diff --git a/src/edu/mit/media/funf/util/IOUtil.java b/funf_v4/src/main/java/edu/mit/media/funf/util/IOUtil.java
similarity index 53%
rename from src/edu/mit/media/funf/util/IOUtil.java
rename to funf_v4/src/main/java/edu/mit/media/funf/util/IOUtil.java
index 6d4ecb3..3067ddc 100644
--- a/src/edu/mit/media/funf/util/IOUtil.java
+++ b/funf_v4/src/main/java/edu/mit/media/funf/util/IOUtil.java
@@ -44,24 +44,27 @@
*/
package edu.mit.media.funf.util;
-import static edu.mit.media.funf.util.LogUtil.TAG;
+import android.content.Context;
+import android.util.Log;
+import android.util.Patterns;
+
+import org.apache.http.params.HttpParams;
+import java.io.BufferedInputStream;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.ResponseHandler;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.BasicResponseHandler;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.params.HttpParams;
-
-import android.net.Uri;
-import android.util.Log;
+import edu.mit.media.funf.FunfManager;
public class IOUtil {
@@ -78,28 +81,36 @@ public static String inputStreamToString(InputStream is, String encoding) throws
} while (read>=0);
return out.toString();
}
-
- public static String httpGet(String uri,HttpParams params){
- String responseBody=null;
- HttpClient httpclient = new DefaultHttpClient();
- StringBuilder uriBuilder = new StringBuilder(uri);
- HttpGet httpget = new HttpGet(uriBuilder.toString());
- if (params != null) {
- httpget.setParams(params);
- }
- ResponseHandler responseHandler = new BasicResponseHandler();
- try {
- responseBody = httpclient.execute(httpget, responseHandler);
- } catch (ClientProtocolException e) {
- Log.e(TAG, "HttpGet Error: ", e);
- responseBody=null;
+
+ public static String httpGet(String uri,HttpParams params,String action,String accessToken) {
+ //params are deprecated
+
+ HttpURLConnection urlConnection = null;
+ int responseCode = 0;
+ try {
+ URL url = new URL(uri);
+ urlConnection = (HttpURLConnection) url.openConnection();
+ responseCode = urlConnection.getResponseCode();
+ InputStream in = new BufferedInputStream(urlConnection.getInputStream());
+ String returnValue = inputStreamToString(in, "UTF-8");
+ return returnValue;
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
} catch (IOException e) {
- Log.e(TAG, "HttpGet Error: ", e);
- responseBody=null;
- } finally{
- httpclient.getConnectionManager().shutdown();
+ e.printStackTrace();
+ if (responseCode == 401) FunfManager.funfManager.authError(action, accessToken);
+ if (responseCode == 500) FunfManager.funfManager.broadcastServerError("SERVER_ERROR", accessToken);
}
- return responseBody;
+ finally {
+ if (urlConnection != null) {
+ urlConnection.disconnect();
+ }
+ }
+ return null;
+ }
+
+ public static String httpGet(String uri,HttpParams params){
+ return httpGet(uri,params,"unknown","");
}
/**
@@ -120,19 +131,51 @@ public static boolean close(Closeable stream) {
public static boolean isValidUrl(String url) {
Log.d(LogUtil.TAG, "Validating url");
- boolean isValidUrl = false;
- if (url != null && !url.trim().equals("")) {
- try {
- Uri test = Uri.parse(url);
- isValidUrl = test.getScheme() != null
- && test.getScheme().startsWith("http")
- && test.getHost() != null
- && !test.getHost().trim().equals("");
- } catch (Exception e) {
- Log.d(LogUtil.TAG, "Not valid", e);
- }
- }
+ boolean isValidUrl = Patterns.WEB_URL.matcher(url).matches();
Log.d(LogUtil.TAG, "Valid url? " + isValidUrl);
return isValidUrl;
}
+
+ public static String formatServerUrl(String uploadurl, String filename) {
+
+ URI uri = null;
+ String accessToken = "";
+ try {
+ uri = new URI(uploadurl);
+ accessToken = FunfManager.context.getSharedPreferences("funf_auth", Context.MODE_PRIVATE).getString(md5(uri.getHost()), "");
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+
+ String formattedUploadUrl = uploadurl;
+ formattedUploadUrl = formattedUploadUrl.replace("$FILENAME$", filename);
+ formattedUploadUrl = formattedUploadUrl.replace("$ACCESS_TOKEN$", accessToken);
+
+ return formattedUploadUrl;
+ }
+
+ public static final String md5(final String s) {
+ try {
+ // Create MD5 Hash
+ MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
+ digest.update(s.getBytes());
+ byte messageDigest[] = digest.digest();
+
+ // Create Hex String
+ StringBuffer hexString = new StringBuffer();
+ for (int i = 0; i < messageDigest.length; i++) {
+ String h = Integer.toHexString(0xFF & messageDigest[i]);
+ while (h.length() < 2)
+ h = "0" + h;
+ hexString.append(h);
+ }
+ return hexString.toString();
+
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ e.printStackTrace();
+ }
+ return "";
+ }
}
diff --git a/src/edu/mit/media/funf/util/LockUtil.java b/funf_v4/src/main/java/edu/mit/media/funf/util/LockUtil.java
similarity index 100%
rename from src/edu/mit/media/funf/util/LockUtil.java
rename to funf_v4/src/main/java/edu/mit/media/funf/util/LockUtil.java
diff --git a/src/edu/mit/media/funf/util/LogUtil.java b/funf_v4/src/main/java/edu/mit/media/funf/util/LogUtil.java
similarity index 100%
rename from src/edu/mit/media/funf/util/LogUtil.java
rename to funf_v4/src/main/java/edu/mit/media/funf/util/LogUtil.java
diff --git a/src/edu/mit/media/funf/util/NameGenerator.java b/funf_v4/src/main/java/edu/mit/media/funf/util/NameGenerator.java
similarity index 100%
rename from src/edu/mit/media/funf/util/NameGenerator.java
rename to funf_v4/src/main/java/edu/mit/media/funf/util/NameGenerator.java
diff --git a/src/edu/mit/media/funf/util/StringUtil.java b/funf_v4/src/main/java/edu/mit/media/funf/util/StringUtil.java
similarity index 100%
rename from src/edu/mit/media/funf/util/StringUtil.java
rename to funf_v4/src/main/java/edu/mit/media/funf/util/StringUtil.java
diff --git a/src/edu/mit/media/funf/util/UuidUtil.java b/funf_v4/src/main/java/edu/mit/media/funf/util/UuidUtil.java
similarity index 100%
rename from src/edu/mit/media/funf/util/UuidUtil.java
rename to funf_v4/src/main/java/edu/mit/media/funf/util/UuidUtil.java
diff --git a/res/values/strings.xml b/funf_v4/src/main/res/values/strings.xml
similarity index 100%
rename from res/values/strings.xml
rename to funf_v4/src/main/res/values/strings.xml
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..0c71e76
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Apr 10 15:27:10 PDT 2013
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,164 @@
+#!/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
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# 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\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+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"`
+
+ # 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/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/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/import-summary.txt b/import-summary.txt
new file mode 100644
index 0000000..c936ca9
--- /dev/null
+++ b/import-summary.txt
@@ -0,0 +1,124 @@
+ECLIPSE ANDROID PROJECT IMPORT SUMMARY
+======================================
+
+Ignored Files:
+--------------
+The following files were *not* copied into the new Gradle project; you
+should evaluate whether these are still needed in your project and if
+so manually move them:
+
+* .DS_Store
+* .gitignore
+* README
+* ant.properties
+* build.xml
+* custom_rules.xml
+* default.properties
+* proguard-project.txt
+* proguard.cfg
+* test/
+* test/.classpath
+* test/.gitignore
+* test/.project
+* test/AndroidManifest.xml
+* test/ant.properties
+* test/build.xml
+* test/default.properties
+* test/local.properties
+* test/old/
+* test/old/AccountsProbeTest.java
+* test/old/ActivityProbeTest.java
+* test/old/AndroidInfoProbeTest.java
+* test/old/ApplicationsProbeTest.java
+* test/old/AudioFilesProbeTest.java
+* test/old/BatteryProbeTest.java
+* test/old/BluetoothProbeTest.java
+* test/old/BrowserBookmarksProbeTest.java
+* test/old/BrowserSearchesProbeTest.java
+* test/old/CallLogProbeTest.java
+* test/old/CellProbeTest.java
+* test/old/ContactProbeTest.java
+* test/old/GravitySensorProbeTest.java
+* test/old/HardwareInfoProbeTest.java
+* test/old/ImagesProbeTest.java
+* test/old/LightSensorProbeTest.java
+* test/old/LocationProbeTest.java
+* test/old/ProbeUtilsTest.java
+* test/old/ProcessStatisticsProbeTest.java
+* test/old/RunningApplicationsProbeTest.java
+* test/old/SMSProbeTest.java
+* test/old/ServicesProbeTest.java
+* test/old/TelephonyProbeTest.java
+* test/old/TemperatureSensorProbeTest.java
+* test/old/TimeOffsetProbeTest.java
+* test/old/VideosProbeTest.java
+* test/old/WifiProbeTest.java
+* test/proguard-project.txt
+* test/proguard.cfg
+* test/project.properties
+* test/res/
+* test/res/.gitignore
+* test/src/
+* test/src/edu/
+* test/src/edu/mit/
+* test/src/edu/mit/media/
+* test/src/edu/mit/media/funf/
+* test/src/edu/mit/media/funf/AsyncSharedPrefsTest.java
+* test/src/edu/mit/media/funf/FunfManagerTest.java
+* test/src/edu/mit/media/funf/TestPipeline.java
+* test/src/edu/mit/media/funf/config/
+* test/src/edu/mit/media/funf/config/TestConfigurableParsing.java
+* test/src/edu/mit/media/funf/pipeline/
+* test/src/edu/mit/media/funf/pipeline/BasicPipelineTest.java
+* test/src/edu/mit/media/funf/probe/
+* test/src/edu/mit/media/funf/probe/AnnotationsTest.java
+* test/src/edu/mit/media/funf/probe/ProbeTest.java
+* test/src/edu/mit/media/funf/probe/ProbeTestCase.java
+* test/src/edu/mit/media/funf/probe/builtin/
+* test/src/edu/mit/media/funf/probe/builtin/ContactProbeTest.java
+* test/src/edu/mit/media/funf/probe/builtin/RunningApplicationsProbeTest.java
+* test/src/edu/mit/media/funf/probe/builtin/ServicesProbeTest.java
+* test/src/edu/mit/media/funf/probe/builtin/TelephonyProbeTest.java
+* test/src/edu/mit/media/funf/probe/builtin/TestAllBuiltinProbes.java
+* test/src/edu/mit/media/funf/probe/builtin/TestLocationProbes.java
+* test/src/edu/mit/media/funf/storage/
+* test/src/edu/mit/media/funf/storage/DefaultArchiveTest.java
+* test/src/edu/mit/media/funf/storage/PrefsWriteSpeedTest.java
+* test/src/edu/mit/media/funf/tests/
+* test/src/edu/mit/media/funf/tests/ExampleService.java
+* test/src/edu/mit/media/funf/tests/SensorTest.java
+
+Moved Files:
+------------
+Android Gradle projects use a different directory structure than ADT
+Eclipse projects. Here's how the projects were restructured:
+
+* AndroidManifest.xml => app/src/main/AndroidManifest.xml
+* libs/gson-2.1-javadoc.jar => app/libs/gson-2.1-javadoc.jar
+* libs/gson-2.1-sources.jar => app/libs/gson-2.1-sources.jar
+* libs/gson-2.1.jar => app/libs/gson-2.1.jar
+* lint.xml => app/lint.xml
+* res/ => app/src/main/res/
+* src/ => app/src/main/java/
+* src/.DS_Store => app/src/main/resources/.DS_Store
+* src/com/.DS_Store => app/src/main/resources/com/.DS_Store
+* src/edu/.DS_Store => app/src/main/resources/edu/.DS_Store
+* src/edu/mit/.DS_Store => app/src/main/resources/edu/mit/.DS_Store
+* src/edu/mit/media/.DS_Store => app/src/main/resources/edu/mit/media/.DS_Store
+* src/edu/mit/media/funf/.DS_Store => app/src/main/resources/edu/mit/media/funf/.DS_Store
+* src/edu/mit/media/funf/probe/.DS_Store => app/src/main/resources/edu/mit/media/funf/probe/.DS_Store
+
+Next Steps:
+-----------
+You can now build the project. The Gradle project needs network
+connectivity to download dependencies.
+
+Bugs:
+-----
+If for some reason your project does not build, and you determine that
+it is due to a bug or limitation of the Eclipse to Gradle importer,
+please file a bug at http://b.android.com with category
+Component-Tools.
+
+(This import summary is for your information only, and can be deleted
+after import once you are satisfied with the results.)
diff --git a/libs/GSON_LICENSE b/libs/GSON_LICENSE
deleted file mode 100644
index 892eaed..0000000
--- a/libs/GSON_LICENSE
+++ /dev/null
@@ -1,203 +0,0 @@
-Google Gson
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright 2008-2011 Google Inc.
-
- 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.
diff --git a/libs/gson-2.1.jar.orig b/libs/gson-2.1.jar.orig
deleted file mode 100644
index b85f091..0000000
Binary files a/libs/gson-2.1.jar.orig and /dev/null differ
diff --git a/lint.xml b/lint.xml
deleted file mode 100644
index ee0eead..0000000
--- a/lint.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/proguard-project.txt b/proguard-project.txt
deleted file mode 100644
index af94546..0000000
--- a/proguard-project.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-# To enable ProGuard in your project, edit project.properties
-# to define the proguard.config property as described in that file.
-#
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in ${sdk.dir}/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the ProGuard
-# include property in project.properties.
-#
-# 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 *;
-#}
--dontoptimize
\ No newline at end of file
diff --git a/proguard.cfg b/proguard.cfg
deleted file mode 100644
index b1cdf17..0000000
--- a/proguard.cfg
+++ /dev/null
@@ -1,40 +0,0 @@
--optimizationpasses 5
--dontusemixedcaseclassnames
--dontskipnonpubliclibraryclasses
--dontpreverify
--verbose
--optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-
--keep public class * extends android.app.Activity
--keep public class * extends android.app.Application
--keep public class * extends android.app.Service
--keep public class * extends android.content.BroadcastReceiver
--keep public class * extends android.content.ContentProvider
--keep public class * extends android.app.backup.BackupAgentHelper
--keep public class * extends android.preference.Preference
--keep public class com.android.vending.licensing.ILicensingService
-
--keepclasseswithmembernames class * {
- native ;
-}
-
--keepclasseswithmembers class * {
- public (android.content.Context, android.util.AttributeSet);
-}
-
--keepclasseswithmembers class * {
- public (android.content.Context, android.util.AttributeSet, int);
-}
-
--keepclassmembers class * extends android.app.Activity {
- public void *(android.view.View);
-}
-
--keepclassmembers enum * {
- public static **[] values();
- public static ** valueOf(java.lang.String);
-}
-
--keep class * implements android.os.Parcelable {
- public static final android.os.Parcelable$Creator *;
-}
diff --git a/project.properties b/project.properties
deleted file mode 100644
index 0e58ae1..0000000
--- a/project.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-
-android.library=true
-# Project target.
-target=android-17
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..4b8cafa
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1 @@
+include ':funf_v4'
diff --git a/src/edu/mit/media/funf/probe/.DS_Store b/src/edu/mit/media/funf/probe/.DS_Store
deleted file mode 100644
index 60f632c..0000000
Binary files a/src/edu/mit/media/funf/probe/.DS_Store and /dev/null differ
diff --git a/src/edu/mit/media/funf/storage/HttpArchive.java b/src/edu/mit/media/funf/storage/HttpArchive.java
deleted file mode 100644
index 9a497af..0000000
--- a/src/edu/mit/media/funf/storage/HttpArchive.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/**
- *
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- *
- */
-package edu.mit.media.funf.storage;
-
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.HttpURLConnection;
-import java.net.URL;
-
-import android.content.Context;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.net.NetworkInfo.State;
-import android.util.Log;
-import edu.mit.media.funf.Schedule.DefaultSchedule;
-import edu.mit.media.funf.config.Configurable;
-import edu.mit.media.funf.util.IOUtil;
-import edu.mit.media.funf.util.LogUtil;
-
-/**
- * Archives a file to the url specified using POST HTTP method.
- *
- */
-@DefaultSchedule(interval=21600) // 6h
-public class HttpArchive implements RemoteFileArchive {
-
- @Configurable
- private String url;
-
- @Configurable
- private boolean wifiOnly = false;
-
- private Context context;
-
- @SuppressWarnings("unused")
- private String mimeType;
-
- public HttpArchive() {
-
- }
-
- public HttpArchive(Context context, final String uploadUrl) {
- this(context, uploadUrl, "application/x-binary");
- }
-
- public HttpArchive(Context context, final String uploadUrl, final String mimeType) {
- this.url = uploadUrl;
- this.mimeType = mimeType;
- }
-
- public void setContext(Context context) {
- this.context = context;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public boolean isAvailable() {
- assert context != null;
- ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo netInfo = connectivityManager.getActiveNetworkInfo();
- if (!wifiOnly && netInfo != null && netInfo.isConnectedOrConnecting()) {
- return true;
- } else if (wifiOnly) {
- State wifiInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState();
- if (State.CONNECTED.equals(wifiInfo) || State.CONNECTING.equals(wifiInfo)) {
- return true;
- }
- }
- return false;
- }
-
- public String getId() {
- return url;
- }
-
-
-
- public boolean add(File file) {
- /*
- HttpClient httpclient = new DefaultHttpClient();
- try {
- httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
- HttpPost httppost = new HttpPost(uploadUrl);
-
- httppost.setEntity(new FileEntity(file, mimeType));
-
- Log.i(TAG, "executing request " + httppost.getRequestLine());
- HttpResponse response = httpclient.execute(httppost);
-
- HttpEntity resEntity = response.getEntity();
- if (resEntity == null) {
- Log.i(TAG, "Null response entity.");
- return false;
- }
- Log.i(TAG, "Response " + response.getStatusLine().getStatusCode() + ": "
- + IOUtils.inputStreamToString(resEntity.getContent(), "UTF-8"));
- } catch (ClientProtocolException e) {
- Log.e(TAG, e.getLocalizedMessage());
- e.printStackTrace();
- return false;
- } catch (IOException e) {
- Log.e(TAG, e.getLocalizedMessage());
- e.printStackTrace();
- return false;
- } finally {
- httpclient.getConnectionManager().shutdown();
- }
- return true;
- */
- return IOUtil.isValidUrl(url) ? uploadFile(file, url) : false;
- }
-
- /**
- * Copied (and slightly modified) from Friends and Family
- * @param file
- * @param uploadurl
- * @return
- */
- public static boolean uploadFile(File file,String uploadurl) {
- HttpURLConnection conn = null;
- DataOutputStream dos = null;
- //DataInputStream inStream = null;
-
- String lineEnd = "\r\n";
- String twoHyphens = "--";
- String boundary = "*****";
-
-
- int bytesRead, bytesAvailable, bufferSize;
- byte[] buffer;
- int maxBufferSize = 64*1024; //old value 1024*1024
-
- boolean isSuccess = true;
- try
- {
- //------------------ CLIENT REQUEST
- FileInputStream fileInputStream = null;
- //Log.i("FNF","UploadService Runnable: 1");
- try {
- fileInputStream = new FileInputStream(file);
- }catch (FileNotFoundException e) {
- e.printStackTrace();
- Log.e(LogUtil.TAG, "file not found");
- }
- // open a URL connection to the Servlet
- URL url = new URL(uploadurl);
- // Open a HTTP connection to the URL
- conn = (HttpURLConnection) url.openConnection();
- // Allow Inputs
- conn.setDoInput(true);
- // Allow Outputs
- conn.setDoOutput(true);
- // Don't use a cached copy.
- conn.setUseCaches(false);
- // set timeout
- conn.setConnectTimeout(60000);
- conn.setReadTimeout(60000);
- // Use a post method.
- conn.setRequestMethod("POST");
- conn.setRequestProperty("Connection", "Keep-Alive");
- conn.setRequestProperty("Content-Type", "multipart/form-data;boundary="+boundary);
-
- dos = new DataOutputStream( conn.getOutputStream() );
- dos.writeBytes(twoHyphens + boundary + lineEnd);
- dos.writeBytes("Content-Disposition: form-data; name=\"uploadedfile\";filename=\"" + file.getName() +"\"" + lineEnd);
- dos.writeBytes(lineEnd);
-
- //Log.i("FNF","UploadService Runnable:Headers are written");
-
- // create a buffer of maximum size
- bytesAvailable = fileInputStream.available();
- bufferSize = Math.min(bytesAvailable, maxBufferSize);
- buffer = new byte[bufferSize];
-
- // read file and write it into form...
- bytesRead = fileInputStream.read(buffer, 0, bufferSize);
- while (bytesRead > 0)
- {
- dos.write(buffer, 0, bufferSize);
- bytesAvailable = fileInputStream.available();
- bufferSize = Math.min(bytesAvailable, maxBufferSize);
- bytesRead = fileInputStream.read(buffer, 0, bufferSize);
- }
-
- // send multipart form data necesssary after file data...
- dos.writeBytes(lineEnd);
- dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
-
- // close streams
- //Log.i("FNF","UploadService Runnable:File is written");
- fileInputStream.close();
- dos.flush();
- dos.close();
- }
- catch (Exception e)
- {
- Log.e("FNF", "UploadService Runnable:Client Request error", e);
- isSuccess = false;
- }
-
- //------------------ read the SERVER RESPONSE
- try {
- if (conn.getResponseCode() != 200) {
- isSuccess = false;
- }
- } catch (IOException e) {
- Log.e("FNF", "Connection error", e);
- isSuccess = false;
- }
-
- return isSuccess;
- }
-}
diff --git a/test/.classpath b/test/.classpath
deleted file mode 100644
index ff4f2a3..0000000
--- a/test/.classpath
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/test/.gitignore b/test/.gitignore
deleted file mode 100644
index 862bb42..0000000
--- a/test/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-bin/*
-gen/*
-*.log
\ No newline at end of file
diff --git a/test/.project b/test/.project
deleted file mode 100644
index b380917..0000000
--- a/test/.project
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
- funf-old-test
-
-
-
-
-
- com.android.ide.eclipse.adt.ResourceManagerBuilder
-
-
-
-
- com.android.ide.eclipse.adt.PreCompilerBuilder
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- com.android.ide.eclipse.adt.ApkBuilder
-
-
-
-
-
- com.android.ide.eclipse.adt.AndroidNature
- org.eclipse.jdt.core.javanature
-
-
-
- funf_src
- 2
- _android_funf_3022c7/src
-
-
-
diff --git a/test/AndroidManifest.xml b/test/AndroidManifest.xml
deleted file mode 100644
index 0b018b6..0000000
--- a/test/AndroidManifest.xml
+++ /dev/null
@@ -1,110 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/test/ant.properties b/test/ant.properties
deleted file mode 100644
index da0e730..0000000
--- a/test/ant.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-# This file is used to override default values used by the Ant build system.
-#
-# This file must be checked in Version Control Systems, as it is
-# integral to the build system of your project.
-
-# This file is only used by the Ant script.
-
-# You can use this to override default values such as
-# 'source.dir' for the location of your java source folder and
-# 'out.dir' for the location of your output folder.
-
-# You can also use it define how the release builds are signed by declaring
-# the following properties:
-# 'key.store' for the location of your keystore and
-# 'key.alias' for the name of the key to use.
-# The password will be asked during the build when you use the 'release' target.
-
-tested.project.dir=../
diff --git a/test/build.xml b/test/build.xml
deleted file mode 100644
index f619669..0000000
--- a/test/build.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/test/default.properties b/test/default.properties
deleted file mode 100644
index 372b115..0000000
--- a/test/default.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-android.library=true
-android.library.reference.1=..
-# Project target.
-target=android-7
diff --git a/test/local.properties b/test/local.properties
deleted file mode 100644
index e6c6c17..0000000
--- a/test/local.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must *NOT* be checked in Version Control Systems,
-# as it contains information specific to your local configuration.
-
-# location of the SDK. This is only used by Ant
-# For customization when using a Version Control System, please read the
-# header note.
-sdk.dir=/usr/local/Cellar/android-sdk/r21
diff --git a/test/old/AccountsProbeTest.java b/test/old/AccountsProbeTest.java
deleted file mode 100644
index 9b74cb2..0000000
--- a/test/old/AccountsProbeTest.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package edu.mit.media.funf.probe.builtin;
-
-import android.os.Bundle;
-import android.util.Log;
-
-import com.google.gson.Gson;
-
-import edu.mit.media.funf.probe.ProbeTestCase;
-import edu.mit.media.funf.probe.Probe.Parameter;
-import edu.mit.media.funf.tests.JsonUtils;
-
-public class AccountsProbeTest extends ProbeTestCase {
-
- public AccountsProbeTest() {
- super(AccountsProbe.class);
- }
-
- public void testData() {
- Bundle params = new Bundle();
- params.putLong(Parameter.Builtin.PERIOD.name, 10L);
- startProbe(params);
-
- Bundle data = getData(10);
- Gson gson = JsonUtils.getGson();
- Log.i(TAG, "ServicesProbe DATA: " + gson.toJson(data));
- }
-}
diff --git a/test/old/ActivityProbeTest.java b/test/old/ActivityProbeTest.java
deleted file mode 100644
index 19b7fec..0000000
--- a/test/old/ActivityProbeTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import java.util.List;
-
-import android.os.Bundle;
-import android.util.Log;
-import edu.mit.media.funf.probe.Probe;
-import edu.mit.media.funf.probe.ProbeTestCase;
-import edu.mit.media.funf.probe.Probe.Parameter;
-
-public class ActivityProbeTest extends ProbeTestCase {
-
- public ActivityProbeTest() {
- super(ActivityProbe.class);
- }
-
-
-
- @Override
- protected List> getProbesAffected() {
- List> list = super.getProbesAffected();
- list.add(AccelerometerSensorProbe.class);
- return list;
- }
-
-
-
- public void testData() throws InterruptedException {
- Bundle params = new Bundle();
- params.putLong(Parameter.Builtin.DURATION.name, 10L);
- params.putLong(Parameter.Builtin.PERIOD.name, 0L);
- startProbe(params);
- Bundle data = getData(30);
- assertTrue(data.containsKey(ActivityProbe.TOTAL_INTERVALS));
- assertTrue(data.containsKey(ActivityProbe.LOW_ACTIVITY_INTERVALS));
- assertTrue(data.containsKey(ActivityProbe.HIGH_ACTIVITY_INTERVALS));
- Log.i(TAG,"T: " + data.getInt(ActivityProbe.TOTAL_INTERVALS) + " L:" + data.getInt(ActivityProbe.LOW_ACTIVITY_INTERVALS) + " H:" + data.getInt(ActivityProbe.HIGH_ACTIVITY_INTERVALS));
- Thread.sleep(4000);
- }
-
- public void testWithAccelerometerBroadcast() throws InterruptedException {
-
- Bundle params = new Bundle();
- params.putLong(Parameter.Builtin.DURATION.name, 4L);
- params.putLong(Parameter.Builtin.PERIOD.name, 0L);
-
- startProbe(AccelerometerSensorProbe.class, params);
- params.putLong(Parameter.Builtin.DURATION.name, 2L);
- startProbe(params);
-
- Bundle data = getData(20);
- assertTrue(data.containsKey(ActivityProbe.TOTAL_INTERVALS));
- assertTrue(data.containsKey(ActivityProbe.LOW_ACTIVITY_INTERVALS));
- assertTrue(data.containsKey(ActivityProbe.HIGH_ACTIVITY_INTERVALS));
- }
-}
diff --git a/test/old/AndroidInfoProbeTest.java b/test/old/AndroidInfoProbeTest.java
deleted file mode 100644
index 48b2cfd..0000000
--- a/test/old/AndroidInfoProbeTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import edu.mit.media.funf.probe.ProbeTestCase;
-import android.os.Bundle;
-
-public class AndroidInfoProbeTest extends ProbeTestCase {
-
- public AndroidInfoProbeTest() {
- super(AndroidInfoProbe.class);
- }
-
- public void testData() {
- Bundle params = new Bundle();
- startProbe(params);
- Bundle data = getData(5);
- String[] keysToCheck = new String[] {
- "FIRMWARE_VERSION",
- "BUILD_NUMBER",
- "SDK",
- };
- for (String key : keysToCheck) {
- assertNotNull(data.get(key));
- System.out.println(key + ": " + String.valueOf(data.get(key)));
- }
- }
-
-}
diff --git a/test/old/ApplicationsProbeTest.java b/test/old/ApplicationsProbeTest.java
deleted file mode 100644
index 288feea..0000000
--- a/test/old/ApplicationsProbeTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import edu.mit.media.funf.probe.Probe;
-import edu.mit.media.funf.probe.ProbeTestCase;
-import android.os.Bundle;
-
-public class ApplicationsProbeTest extends ProbeTestCase {
-
- public ApplicationsProbeTest() {
- super(ApplicationsProbe.class);
- }
-
- public void testProbe() {
- Bundle params = new Bundle();
- startProbe(params);
- Bundle data = getData(2);
- assertNotNull(data.get("INSTALLED_APPLICATIONS"));
- assertNotNull(data.get("UNINSTALLED_APPLICATIONS"));
- }
-
- public void testRunOnceProbe() {
- Bundle params = new Bundle();
- params.putLong(Probe.Parameter.Builtin.PERIOD.name, 0L);
- startProbe(params);
- Bundle data = getData(2);
- assertNotNull(data.get("INSTALLED_APPLICATIONS"));
- assertNotNull(data.get("UNINSTALLED_APPLICATIONS"));
- shouldNotReturnData(5);
- }
-}
diff --git a/test/old/AudioFilesProbeTest.java b/test/old/AudioFilesProbeTest.java
deleted file mode 100644
index dd66e3e..0000000
--- a/test/old/AudioFilesProbeTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import java.util.ArrayList;
-
-import android.os.Bundle;
-import android.os.Parcelable;
-import android.util.Log;
-import edu.mit.media.funf.probe.ProbeTestCase;
-import edu.mit.media.funf.probe.Probe.Parameter;
-
-public class AudioFilesProbeTest extends ProbeTestCase {
-
- public AudioFilesProbeTest() {
- super(AudioFilesProbe.class);
- }
-
- public void testData() throws InterruptedException {
- Bundle params = new Bundle();
- params.putLong(Parameter.Builtin.PERIOD.name, 0L);
- startProbe(params);
- Bundle data = getData(10);
- ArrayList audioFiles = data.getParcelableArrayList(AudioFilesProbe.AUDIO_FILES);
- assertNotNull(audioFiles);
- assertTrue(audioFiles.size() > 0);
- Log.i(TAG, "Audio files: " + audioFiles.size());
-
- // Running again should return an empty result
- startProbe(params);
- data = getData(10);
- audioFiles = data.getParcelableArrayList(AudioFilesProbe.AUDIO_FILES);
- assertNotNull(audioFiles);
- Log.i(TAG, "Audio files: " + audioFiles.size());
- assertTrue(audioFiles.isEmpty());
- }
-
-}
diff --git a/test/old/BatteryProbeTest.java b/test/old/BatteryProbeTest.java
deleted file mode 100644
index 333573b..0000000
--- a/test/old/BatteryProbeTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import edu.mit.media.funf.probe.ProbeTestCase;
-import android.os.BatteryManager;
-import android.os.Bundle;
-
-public class BatteryProbeTest extends ProbeTestCase {
-
- public BatteryProbeTest() {
- super(BatteryProbe.class);
- }
-
- public void testProbe() {
- Bundle params = new Bundle();
- startProbe(params);
- Bundle data = getData(20);
- assertNotNull(data.get(BatteryManager.EXTRA_LEVEL));
- }
-
-}
diff --git a/test/old/BluetoothProbeTest.java b/test/old/BluetoothProbeTest.java
deleted file mode 100644
index 0bf0148..0000000
--- a/test/old/BluetoothProbeTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import edu.mit.media.funf.probe.ProbeTestCase;
-import android.os.Bundle;
-
-public class BluetoothProbeTest extends ProbeTestCase {
-
- public BluetoothProbeTest() {
- super(BluetoothProbe.class);
- }
-
- public void testBluetoothProbe() {
- Bundle params = new Bundle();
- startProbe(params);
- Bundle data = getData(20);
- assertNotNull(data.get("DEVICES"));
- }
-}
diff --git a/test/old/BrowserBookmarksProbeTest.java b/test/old/BrowserBookmarksProbeTest.java
deleted file mode 100644
index c138ed9..0000000
--- a/test/old/BrowserBookmarksProbeTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import android.os.Bundle;
-import edu.mit.media.funf.probe.ProbeTestCase;
-import edu.mit.media.funf.probe.Probe.Parameter;
-import edu.mit.media.funf.probe.builtin.ProbeKeys.BaseProbeKeys;
-import edu.mit.media.funf.probe.builtin.ProbeKeys.BrowserBookmarksKeys;
-
-public class BrowserBookmarksProbeTest extends ProbeTestCase {
-
- public BrowserBookmarksProbeTest() {
- super(BrowserBookmarksProbe.class);
- }
-
- public void testProbe() {
- Bundle params = new Bundle();
- params.putLong(Parameter.Builtin.PERIOD.name, 0L);
- startProbe(params);
- Bundle data = getData(5);
- assertNotNull(data.get(BaseProbeKeys.TIMESTAMP));
- assertNotNull(data.get(BrowserBookmarksKeys.BOOKMARKS));
- }
-
-}
diff --git a/test/old/BrowserSearchesProbeTest.java b/test/old/BrowserSearchesProbeTest.java
deleted file mode 100644
index bff5dec..0000000
--- a/test/old/BrowserSearchesProbeTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import android.os.Bundle;
-import edu.mit.media.funf.probe.ProbeTestCase;
-import edu.mit.media.funf.probe.Probe.Parameter;
-import edu.mit.media.funf.probe.builtin.ProbeKeys.BaseProbeKeys;
-import edu.mit.media.funf.probe.builtin.ProbeKeys.BrowserSearchesKeys;
-
-public class BrowserSearchesProbeTest extends ProbeTestCase {
-
- public BrowserSearchesProbeTest() {
- super(BrowserSearchesProbe.class);
- }
-
- public void testProbe() {
- Bundle params = new Bundle();
- params.putLong(Parameter.Builtin.PERIOD.name, 0L);
- startProbe(params);
- Bundle data = getData(10);
- assertNotNull(data.get(BaseProbeKeys.TIMESTAMP));
- assertNotNull(data.get(BrowserSearchesKeys.SEARCHES));
- }
-
-}
diff --git a/test/old/CallLogProbeTest.java b/test/old/CallLogProbeTest.java
deleted file mode 100644
index 14ec0bd..0000000
--- a/test/old/CallLogProbeTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import android.os.Bundle;
-import edu.mit.media.funf.probe.ProbeTestCase;
-import edu.mit.media.funf.probe.Probe.Parameter;
-import edu.mit.media.funf.probe.builtin.ProbeKeys.BaseProbeKeys;
-import edu.mit.media.funf.probe.builtin.ProbeKeys.CallLogKeys;
-
-public class CallLogProbeTest extends ProbeTestCase {
-
- public CallLogProbeTest() {
- super(CallLogProbe.class);
- }
-
- public void testProbe() {
- Bundle params = new Bundle();
- params.putLong(Parameter.Builtin.PERIOD.name, 0L);
- startProbe(params);
- Bundle data = getData(10);
- assertNotNull(data.get(BaseProbeKeys.TIMESTAMP));
- assertNotNull(data.get(CallLogKeys.CALLS));
- }
-
-}
diff --git a/test/old/CellProbeTest.java b/test/old/CellProbeTest.java
deleted file mode 100644
index f9ed498..0000000
--- a/test/old/CellProbeTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import android.os.Bundle;
-import edu.mit.media.funf.Utils;
-import edu.mit.media.funf.probe.ProbeTestCase;
-import edu.mit.media.funf.probe.Probe.Parameter;
-import edu.mit.media.funf.probe.builtin.ProbeKeys.BaseProbeKeys;
-
-public class CellProbeTest extends ProbeTestCase {
-
- public CellProbeTest() {
- super(CellProbe.class);
- }
-
- public void testProbe() {
- Bundle params = new Bundle();
- params.putLong(Parameter.Builtin.PERIOD.name, 0L);
- startProbe(params);
- Bundle data = getData(5);
- assertNotNull(data.get(BaseProbeKeys.TIMESTAMP));
- System.out.println(Utils.join(Utils.getValues(data).keySet(), ", "));
- }
-
-}
diff --git a/test/old/ContactProbeTest.java b/test/old/ContactProbeTest.java
deleted file mode 100644
index af7ff6a..0000000
--- a/test/old/ContactProbeTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import java.util.ArrayList;
-
-import junit.framework.AssertionFailedError;
-import android.os.Bundle;
-import android.os.Parcelable;
-import android.provider.ContactsContract.Data;
-import android.util.Log;
-import edu.mit.media.funf.Utils;
-import edu.mit.media.funf.probe.ProbeTestCase;
-import edu.mit.media.funf.probe.Probe.Parameter;
-import edu.mit.media.funf.probe.builtin.ProbeKeys.BaseProbeKeys;
-
-public class ContactProbeTest extends ProbeTestCase {
-
- public ContactProbeTest() {
- super(ContactProbe.class);
- }
-
- public void testProbe() {
- Bundle params = new Bundle();
- params.putLong(Parameter.Builtin.PERIOD.name, 0L);
- params.putBoolean(ContactProbe.FULL_PARAM.getName(), true);
- startProbe(params);
- Bundle data = getData(30);
- assertNotNull(data.get(BaseProbeKeys.TIMESTAMP));
- ArrayList contactData = data.getParcelableArrayList(ContactProbe.CONTACT_DATA);
- assertNotNull(contactData);
- int count = 1;
- while(data != null) {
- try {
- data = getData(5);
- count ++;
- } catch (AssertionFailedError e) {
- assertTrue(contactData.size() > 0);
- Log.i("ContactProbeTest", "Contact keys: " + Utils.join(Utils.getValues(data).keySet(), ", "));
- for (Parcelable dataRow : contactData) {
- Bundle b = (Bundle)dataRow;
- Log.i("ContactProbeTest", "Data keys: " + b.getString(Data.MIMETYPE) + ":" + String.valueOf(b.get(Data.DATA1)) + " - Others: " + Utils.join(Utils.getValues(b).keySet(), ", "));
- }
- data = null;
- }
- }
- Log.i("ContactProbeTest", "Count: " + String.valueOf(count));
- }
-
- public void testFullParameter() {
- // Run a full scan
- Bundle params = new Bundle();
- params.putLong(Parameter.Builtin.PERIOD.name, 0L);
- params.putBoolean(ContactProbe.FULL_PARAM.getName(), true);
- startProbe(params);
- Bundle data = getData(30);
- boolean hasAtLeastTwo = false;
- while (data != null) {
- // Get the rest of the data
- try {
- data = getData(5);
- hasAtLeastTwo = true;
- } catch (AssertionFailedError e) {
- data = null;
- }
- }
- assertTrue(hasAtLeastTwo);
-
- // Run a non-full scan
- params.putBoolean(ContactProbe.FULL_PARAM.getName(), false);
- startProbe(params);
- try {
- data = getData(30); // Unfortunately we have to wait, since full scans take a while to return anything
- ArrayList contactData = data.getParcelableArrayList(ContactProbe.CONTACT_DATA);
- Log.i(TAG, "Data: " + (contactData == null ? "" : contactData.size()));
- fail("Should not get any contacts for a non-full scan after a full scan");
- } catch (AssertionFailedError e) {
- // Success
- }
- }
-
-}
diff --git a/test/old/GravitySensorProbeTest.java b/test/old/GravitySensorProbeTest.java
deleted file mode 100644
index c85f8f4..0000000
--- a/test/old/GravitySensorProbeTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import android.os.Bundle;
-import edu.mit.media.funf.probe.ProbeTestCase;
-import edu.mit.media.funf.probe.Probe.Parameter;
-
-public class GravitySensorProbeTest extends ProbeTestCase {
-
- public GravitySensorProbeTest() {
- super(GravitySensorProbe.class);
- }
-
-
- public void testData() throws InterruptedException {
- Bundle params = new Bundle();
- params.putLong(Parameter.Builtin.DURATION.name, 3L);
- params.putLong(Parameter.Builtin.PERIOD.name, 10L);
- startProbe(params);
- for (int i=0; i<3; i++) {
- Bundle data = getData(10);
- assertTrue(data.containsKey("SENSOR"));
- assertTrue(data.containsKey("EVENT_TIMESTAMP"));
- assertTrue(data.containsKey("ACCURACY"));
- assertTrue(data.containsKey("X"));
- assertTrue(data.containsKey("Y"));
- assertTrue(data.containsKey("Z"));
- assertTrue(data.containsKey("TIMESTAMP"));
- long[] eventTimestamp = data.getLongArray("EVENT_TIMESTAMP");
- int[] accuracy = data.getIntArray("ACCURACY");
- float[] x = data.getFloatArray("X");
- float[] y = data.getFloatArray("Y");
- float[] z = data.getFloatArray("Z");
- int numEvents = eventTimestamp.length;
- assertEquals(numEvents, accuracy.length);
- assertEquals(numEvents, x.length);
- assertEquals(numEvents, y.length);
- assertEquals(numEvents, z.length);
-// System.out.println("@" + data.getLong("TIMESTAMP") + " - " +
-// "X:" + data.getFloat("X") +
-// "Y:" + data.getFloat("Y") +
-// "Z:" + data.getFloat("Z")
-// );
- }
- }
-
-
-}
diff --git a/test/old/HardwareInfoProbeTest.java b/test/old/HardwareInfoProbeTest.java
deleted file mode 100644
index 5665af8..0000000
--- a/test/old/HardwareInfoProbeTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import android.os.Bundle;
-import android.util.Log;
-import edu.mit.media.funf.probe.ProbeTestCase;
-
-public class HardwareInfoProbeTest extends ProbeTestCase {
-
- public HardwareInfoProbeTest() {
- super(HardwareInfoProbe.class);
- }
-
- public void testData() {
- Bundle params = new Bundle();
- startProbe(params);
- Bundle data = getData(5);
- String[] keysToCheck = new String[] {
- "WIFI_MAC",
- "ANDROID_ID",
- //"BLUETOOTH_MAC", Does not exist on some phones (Cliq)
- "BRAND",
- "MODEL",
- "DEVICE_ID"
- };
- Log.i(TAG, String.valueOf(data));
- for (String key : keysToCheck) {
- assertNotNull("Key does not exist: " + key, data.getString(key));
- System.out.println(key + ": " + data.getString(key));
- }
- }
-
-}
diff --git a/test/old/ImagesProbeTest.java b/test/old/ImagesProbeTest.java
deleted file mode 100644
index 106232f..0000000
--- a/test/old/ImagesProbeTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import java.util.ArrayList;
-
-import android.os.Bundle;
-import android.os.Parcelable;
-import android.util.Log;
-import edu.mit.media.funf.probe.ProbeTestCase;
-import edu.mit.media.funf.probe.Probe.Parameter;
-
-public class ImagesProbeTest extends ProbeTestCase {
-
- public ImagesProbeTest() {
- super(ImagesProbe.class);
- }
-
- public void testData() throws InterruptedException {
- Log.i("edu.mit.media.funf.probe.builtin.ImagesProbe", "___________________START_________________");
- Bundle params = new Bundle();
- params.putLong(Parameter.Builtin.PERIOD.name, 0L);
- startProbe(params);
- Bundle data = getData(20);
- ArrayList images = data.getParcelableArrayList(ImagesProbe.IMAGES);
- assertNotNull(images);
- assertTrue(images.size() > 0);
-
- Thread.sleep(5000L);
- clearData();
-
- // Running again should return an empty result
- startProbe(params);
- data = getData(10);
- images = data.getParcelableArrayList(ImagesProbe.IMAGES);
- assertNotNull(images);
- Log.i(TAG, "Number of images: " + images.size());
- assertTrue(images.isEmpty());
- }
-
-}
diff --git a/test/old/LightSensorProbeTest.java b/test/old/LightSensorProbeTest.java
deleted file mode 100644
index cd402de..0000000
--- a/test/old/LightSensorProbeTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import android.os.Bundle;
-import edu.mit.media.funf.probe.ProbeTestCase;
-import edu.mit.media.funf.probe.Probe.Parameter;
-
-public class LightSensorProbeTest extends ProbeTestCase {
-
- public LightSensorProbeTest() {
- super(LightSensorProbe.class);
- }
-
-
- public void testData() throws InterruptedException {
- Bundle params = new Bundle();
- params.putLong(Parameter.Builtin.DURATION.name, 10L);
- params.putLong(Parameter.Builtin.PERIOD.name, 10L);
- startProbe(params);
-
- Bundle data = getData(10);
- assertTrue(data.containsKey("SENSOR"));
- assertTrue(data.containsKey("EVENT_TIMESTAMP"));
- assertTrue(data.containsKey("ACCURACY"));
- assertTrue(data.containsKey("LUX"));
- assertTrue(data.containsKey("TIMESTAMP"));
- long[] eventTimestamp = data.getLongArray("EVENT_TIMESTAMP");
- int[] accuracy = data.getIntArray("ACCURACY");
- float[] lux = data.getFloatArray("LUX");
- int numEvents = eventTimestamp.length;
- assertEquals(numEvents, accuracy.length);
- assertEquals(numEvents, lux.length);
- System.out.println("@" + data.getLong("TIMESTAMP") + " - " +
- "LUX Count:" + lux.length
- );
- }
-
-
-}
diff --git a/test/old/LocationProbeTest.java b/test/old/LocationProbeTest.java
deleted file mode 100644
index 074dc04..0000000
--- a/test/old/LocationProbeTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import android.location.Location;
-import android.os.Bundle;
-import edu.mit.media.funf.probe.ProbeTestCase;
-import edu.mit.media.funf.probe.Probe.Parameter;
-
-public class LocationProbeTest extends ProbeTestCase {
-
- private static final int FUDGE_FACTOR = 10;
-
-
- public LocationProbeTest() {
- super(LocationProbe.class);
- }
-
- public void testData() {
- Bundle params = new Bundle();
- params.putLong(Parameter.Builtin.DURATION.name, 30L);
- startProbe(params);
- Bundle data = getData(30 + FUDGE_FACTOR);
- Location location = (Location)data.get("LOCATION");
- assertNotNull(location);
- System.out.println("Accuracy: " + String.valueOf(location.getAccuracy()));
- }
-
- public void testReturningCachedLocation() {
- Bundle params = new Bundle();
- params.putLong(Parameter.Builtin.DURATION.name, 1L);
- startProbe(params);
- Bundle data = getData(1 + FUDGE_FACTOR);
- Location location = (Location)data.get("LOCATION");
- assertNotNull(location);
- System.out.println("Accuracy: " + String.valueOf(location.getAccuracy()));
- }
-
-
-}
diff --git a/test/old/ProbeUtilsTest.java b/test/old/ProbeUtilsTest.java
deleted file mode 100644
index 00614ce..0000000
--- a/test/old/ProbeUtilsTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import junit.framework.TestCase;
-import android.content.Intent;
-import android.location.Location;
-import android.os.Bundle;
-
-public class ProbeUtilsTest extends TestCase {
-
-
- public void testIntentUrls() {
- Intent i = new Intent("test.action");
- i.putExtra("TEST_PARAM1", true);
- i.putExtra("TEST_PARAM2", "(&U#ALAN");
- i.putExtra("TEST_PARAM6", new boolean[] {true, false, true});
- i.putExtra("TEST_PARAM7", new float[] {1, 0, 32.34f});
- i.putExtra("TEST_PARAM8", 2);
- i.putExtra("TEST_PARAM3", new Location("ASDF"));
- Bundle b = new Bundle();
- b.putFloat("TEST_PARAM4", 23423.34f);
- i.putExtra("TEST_PARAM5", b);
- System.out.println(i.toUri(Intent.URI_INTENT_SCHEME));
-
- // No arrays or parcelables show up
- }
-}
diff --git a/test/old/ProcessStatisticsProbeTest.java b/test/old/ProcessStatisticsProbeTest.java
deleted file mode 100644
index 8b19453..0000000
--- a/test/old/ProcessStatisticsProbeTest.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package edu.mit.media.funf.probe.builtin;
-
-import android.os.Bundle;
-import android.util.Log;
-
-import com.google.gson.Gson;
-
-import edu.mit.media.funf.probe.ProbeTestCase;
-import edu.mit.media.funf.probe.Probe.Parameter;
-import edu.mit.media.funf.tests.JsonUtils;
-
-public class ProcessStatisticsProbeTest extends ProbeTestCase {
-
- public ProcessStatisticsProbeTest() {
- super(ProcessStatisticsProbe.class);
- }
-
- public void testData() {
- Bundle params = new Bundle();
- params.putLong(Parameter.Builtin.PERIOD.name, 10L);
- startProbe(params);
-
- Bundle data = getData(10);
- Gson gson = JsonUtils.getGson();
- Log.i(TAG, "ProcessStatisticsProbe DATA: " + gson.toJson(data));
- }
-}
diff --git a/test/old/RunningApplicationsProbeTest.java b/test/old/RunningApplicationsProbeTest.java
deleted file mode 100644
index fe0f132..0000000
--- a/test/old/RunningApplicationsProbeTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import android.os.Bundle;
-import edu.mit.media.funf.opp.OppProbe;
-import edu.mit.media.funf.probe.ProbeTestCase;
-
-public class RunningApplicationsProbeTest extends ProbeTestCase {
-
- public RunningApplicationsProbeTest() {
- super(RunningApplicationsProbe.class);
- }
-
- public void testProbe() {
- Bundle params = new Bundle();
- params.putString(OppProbe.ReservedParamaters.PACKAGE.name, getTestRequester());
- startProbe(params);
- Bundle data = getData(20);
- assertNotNull(data.get("RUNNING_TASKS"));
- }
-}
diff --git a/test/old/SMSProbeTest.java b/test/old/SMSProbeTest.java
deleted file mode 100644
index 68a9121..0000000
--- a/test/old/SMSProbeTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import java.util.ArrayList;
-
-import android.os.Bundle;
-import android.os.Parcelable;
-import android.util.Log;
-import edu.mit.media.funf.probe.ProbeTestCase;
-import edu.mit.media.funf.probe.Probe.Parameter;
-
-public class SMSProbeTest extends ProbeTestCase {
-
- public SMSProbeTest() {
- super(SMSProbe.class);
- }
-
- public void testData() throws InterruptedException {
- Bundle params = new Bundle();
- params.putLong(Parameter.Builtin.PERIOD.name, 0L);
- startProbe(params);
- Bundle data = getData(10);
- ArrayList messages = data.getParcelableArrayList(SMSProbe.MESSAGES);
- assertNotNull(messages);
- assertTrue(messages.size() > 0);
-
- Thread.sleep(20000L);
- clearData();
-
- // Running again should return an empty result
- startProbe(params);
- data = getData(20);
- messages = data.getParcelableArrayList(SMSProbe.MESSAGES);
- assertNotNull(messages);
- Log.i(TAG, "SMS size: " + messages.size());
- assertTrue(messages.isEmpty());
- }
-
-}
diff --git a/test/old/ServicesProbeTest.java b/test/old/ServicesProbeTest.java
deleted file mode 100644
index 6513cf0..0000000
--- a/test/old/ServicesProbeTest.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package edu.mit.media.funf.probe.builtin;
-
-import android.os.Bundle;
-import android.util.Log;
-
-import com.google.gson.Gson;
-
-import edu.mit.media.funf.probe.ProbeTestCase;
-import edu.mit.media.funf.probe.Probe.Parameter;
-import edu.mit.media.funf.tests.JsonUtils;
-
-public class ServicesProbeTest extends ProbeTestCase {
-
- public ServicesProbeTest() {
- super(ServicesProbe.class);
- }
-
- public void testData() {
- Bundle params = new Bundle();
- params.putLong(Parameter.Builtin.PERIOD.name, 10L);
- startProbe(params);
-
- Bundle data = getData(10);
- Gson gson = JsonUtils.getGson();
- Log.i(TAG, "ServicesProbe DATA: " + gson.toJson(data));
- }
-}
diff --git a/test/old/TelephonyProbeTest.java b/test/old/TelephonyProbeTest.java
deleted file mode 100644
index e647ce1..0000000
--- a/test/old/TelephonyProbeTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import edu.mit.media.funf.probe.ProbeTestCase;
-import android.os.Bundle;
-
-public class TelephonyProbeTest extends ProbeTestCase {
-
- public TelephonyProbeTest() {
- super(TelephonyProbe.class);
- }
-
- public void testData() {
- Bundle params = new Bundle();
- startProbe(params);
- Bundle data = getData(5);
- String[] stringKeys = new String[] {
- "DEVICE_ID",
- "DEVICE_SOFTWARE_VERSION",
- "LINE_1_NUMBER",
- "NETWORK_COUNTRY_ISO",
- "NETWORK_OPERATOR",
- "NETWORK_OPERATOR_NAME",
- "SIM_COUNTRY_ISO",
- "SIM_OPERATOR",
- "SIM_OPERATOR_NAME",
- "SIM_SERIAL_NUMBER",
- "SUBSCRIBER_ID",
- "VOICEMAIL_ALPHA_TAG",
- "VOICEMAIL_NUMBER",
- };
- String[] otherKeys = new String[] {
- "CALL_STATE",
- "NETWORK_TYPE",
- "PHONE_TYPE",
- "SIM_STATE",
- "HAS_ICC_CARD"
- };
- for (String key : stringKeys) {
- assertNotNull(data.getString(key));
- }
- for (String key : otherKeys) {
- assertNotNull(data.get(key));
- }
- }
-
-}
diff --git a/test/old/TemperatureSensorProbeTest.java b/test/old/TemperatureSensorProbeTest.java
deleted file mode 100644
index 775ecfe..0000000
--- a/test/old/TemperatureSensorProbeTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import junit.framework.AssertionFailedError;
-import android.os.Bundle;
-import edu.mit.media.funf.probe.ProbeTestCase;
-import edu.mit.media.funf.probe.Probe.Parameter;
-
-public class TemperatureSensorProbeTest extends ProbeTestCase {
-
- public TemperatureSensorProbeTest() {
- super(TemperatureSensorProbe.class);
- }
-
-
- public void testData() throws InterruptedException {
- Bundle params = new Bundle();
- params.putLong(Parameter.Builtin.DURATION.name, 10L);
- params.putLong(Parameter.Builtin.PERIOD.name, 10L);
- startProbe(params);
- try {
- Bundle data = getData(10);
- fail("Should only fail if temperature probe is present on device.");
- } catch (AssertionFailedError e) {
- // Uncommon probe should not start
- }
- }
-
-
-}
diff --git a/test/old/TimeOffsetProbeTest.java b/test/old/TimeOffsetProbeTest.java
deleted file mode 100644
index 02731f0..0000000
--- a/test/old/TimeOffsetProbeTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import android.os.Bundle;
-import edu.mit.media.funf.probe.ProbeTestCase;
-import edu.mit.media.funf.probe.Probe.Parameter;
-
-public class TimeOffsetProbeTest extends ProbeTestCase {
-
- public TimeOffsetProbeTest() {
- super(TimeOffsetProbe.class);
- }
-
- public void testProbe() {
- Bundle params = new Bundle();
- params.putLong(Parameter.Builtin.PERIOD.name, 0L);
- startProbe(params);
- Bundle data = getData(20);
- assertNotNull(data.get(TimeOffsetProbe.TIME_OFFSET));
- //System.out.println("Time Offset:" + data.getDouble(NtpProbe.TIME_OFFSET));
- }
-}
diff --git a/test/old/VideosProbeTest.java b/test/old/VideosProbeTest.java
deleted file mode 100644
index fe23c34..0000000
--- a/test/old/VideosProbeTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import java.util.ArrayList;
-
-import android.os.Bundle;
-import android.os.Parcelable;
-import edu.mit.media.funf.probe.ProbeTestCase;
-import edu.mit.media.funf.probe.Probe.Parameter;
-
-public class VideosProbeTest extends ProbeTestCase {
-
- public VideosProbeTest() {
- super(VideosProbe.class);
- }
-
- public void testData() {
- Bundle params = new Bundle();
- params.putLong(Parameter.Builtin.PERIOD.name, 0L);
- startProbe(params);
- Bundle data = getData(10);
- ArrayList videos = data.getParcelableArrayList(VideosProbe.VIDEOS);
- assertNotNull(videos);
- assertTrue(videos.size() > 0);
-
- // Running again should return an empty result
- startProbe(params);
- data = getData(10);
- videos = data.getParcelableArrayList(VideosProbe.VIDEOS);
- assertNotNull(videos);
- assertTrue(videos.isEmpty());
- }
-
-}
diff --git a/test/old/WifiProbeTest.java b/test/old/WifiProbeTest.java
deleted file mode 100644
index e27a1ac..0000000
--- a/test/old/WifiProbeTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.probe.builtin;
-
-import java.util.ArrayList;
-
-import android.net.wifi.ScanResult;
-import android.os.Bundle;
-import android.os.Parcelable;
-import edu.mit.media.funf.opp.OppProbe;
-import edu.mit.media.funf.probe.ProbeTestCase;
-
-public class WifiProbeTest extends ProbeTestCase {
-
- private static final int FUDGE_FACTOR = 20;
-
- public WifiProbeTest() {
- super(WifiProbe.class);
- }
-
- public void testWifiProbe() throws InterruptedException {
- Bundle params = new Bundle();
- params.putString(OppProbe.ReservedParamaters.PACKAGE.name, getTestRequester());
- startProbe(params);
- Bundle data = getData(10 + FUDGE_FACTOR);
- ArrayList scanResults = data.getParcelableArrayList(WifiProbe.SCAN_RESULTS);
- assertNotNull(scanResults);
- assertFalse(scanResults.isEmpty());
- for (Parcelable result : scanResults) {
- System.out.println("SSID: " + ((ScanResult)result).SSID);
- }
- }
-
-}
diff --git a/test/proguard-project.txt b/test/proguard-project.txt
deleted file mode 100644
index f2fe155..0000000
--- a/test/proguard-project.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# To enable ProGuard in your project, edit project.properties
-# to define the proguard.config property as described in that file.
-#
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in ${sdk.dir}/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the ProGuard
-# include property in project.properties.
-#
-# 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/test/proguard.cfg b/test/proguard.cfg
deleted file mode 100644
index 49cc4ec..0000000
--- a/test/proguard.cfg
+++ /dev/null
@@ -1,40 +0,0 @@
--optimizationpasses 5
--dontusemixedcaseclassnames
--dontskipnonpubliclibraryclasses
--dontpreverify
--verbose
--optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-
--keep public class * extends android.app.Activity
--keep public class * extends android.app.Application
--keep public class * extends android.app.Service
--keep public class * extends android.content.BroadcastReceiver
--keep public class * extends android.content.ContentProvider
--keep public class * extends android.app.backup.BackupAgentHelper
--keep public class * extends android.preference.Preference
--keep public class com.android.vending.licensing.ILicensingService
-
--keepclasseswithmembers class * {
- native ;
-}
-
--keepclasseswithmembers class * {
- public (android.content.Context, android.util.AttributeSet);
-}
-
--keepclasseswithmembers class * {
- public (android.content.Context, android.util.AttributeSet, int);
-}
-
--keepclassmembers class * extends android.app.Activity {
- public void *(android.view.View);
-}
-
--keepclassmembers enum * {
- public static **[] values();
- public static ** valueOf(java.lang.String);
-}
-
--keep class * implements android.os.Parcelable {
- public static final android.os.Parcelable$Creator *;
-}
diff --git a/test/project.properties b/test/project.properties
deleted file mode 100644
index d08f89f..0000000
--- a/test/project.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-
-android.library.reference.1=..
-# Project target.
-target=android-17
diff --git a/test/res/.gitignore b/test/res/.gitignore
deleted file mode 100644
index d6b7ef3..0000000
--- a/test/res/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*
-!.gitignore
diff --git a/test/src/edu/mit/media/funf/AsyncSharedPrefsTest.java b/test/src/edu/mit/media/funf/AsyncSharedPrefsTest.java
deleted file mode 100644
index dad6c2e..0000000
--- a/test/src/edu/mit/media/funf/AsyncSharedPrefsTest.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf;
-
-import edu.mit.media.funf.util.StringUtil;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
-import android.test.AndroidTestCase;
-import static edu.mit.media.funf.util.AsyncSharedPrefs.async;
-
-public class AsyncSharedPrefsTest extends AndroidTestCase {
-
- public static final String TEST_PREFS = "TEST";
-
- private SharedPreferences innerPrefs;
- private SharedPreferences prefs;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- System.out.println("Clearing prefs");
- innerPrefs = getContext().getSharedPreferences(TEST_PREFS, Context.MODE_PRIVATE);
- prefs = async(getContext().getSharedPreferences(TEST_PREFS, Context.MODE_PRIVATE));
- prefs.edit().clear().commit();
- }
-
-
- public void testEdit() {
- prefs.edit().putBoolean("test1", true).commit();
- assertTrue(prefs.getBoolean("test1", false));
- assertTrue((Boolean)prefs.getAll().get("test1"));
-
- prefs.edit().putFloat("test2", 1.2f).commit();
- assertEquals(1.2f, prefs.getFloat("test2", 0.0f));
-
- prefs.edit().putInt("test3", 1).commit();
- assertEquals(1, prefs.getInt("test3", 0));
-
- prefs.edit().putLong("test4", 1L).commit();
- assertEquals(1L, prefs.getLong("test4", 0L));
-
- prefs.edit().putString("test5", "test").commit();
- assertEquals("test", prefs.getString("test5", ""));
-
- System.out.println("Entries: " + StringUtil.join(prefs.getAll().keySet(), ", "));
-
- assertEquals(5, prefs.getAll().size());
- }
-
- public void testEditMultiple() {
- prefs.edit().putBoolean("boolean", false).putString("string", "value").putInt("int", 3).commit();
- assertEquals(false, prefs.getBoolean("boolean", true));
- assertEquals("value", prefs.getString("string", ""));
- assertEquals(3, prefs.getInt("int", 0));
- }
-
- public void testNoCommit() {
- prefs.edit().putBoolean("boolean", true).commit();
- SharedPreferences.Editor editor = prefs.edit().putBoolean("boolean", false); // no commit
- assertEquals(true, prefs.getBoolean("boolean", false));
- editor.commit();
- }
-
- public void testDiskPersistenceDelay() throws InterruptedException {
- prefs.edit().putBoolean("boolean", true).commit();
- assertEquals(false, innerPrefs.getBoolean("boolean", false)); // not committed to disk yet
- assertEquals(true, prefs.getBoolean("boolean", false));
- Thread.sleep(1000);
- assertEquals(true, innerPrefs.getBoolean("boolean", false)); // committed later
- }
-
- private String keyUpdated, valueUpdated;
- public void testListeners() throws InterruptedException {
- keyUpdated = valueUpdated = null;
- OnSharedPreferenceChangeListener listener = new OnSharedPreferenceChangeListener() {
- @Override
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
- assertSame(prefs, sharedPreferences);
- keyUpdated = key;
- valueUpdated = sharedPreferences.getString(key, null);
- }
- };
- prefs.registerOnSharedPreferenceChangeListener(listener);
-
- prefs.edit().putString("listener_test", "text_value").commit();
- Thread.sleep(1000L);
- assertEquals("listener_test", keyUpdated);
- assertEquals("text_value", valueUpdated);
-
- prefs.unregisterOnSharedPreferenceChangeListener(listener);
- prefs.edit().putString("listener_test", "another_value").commit();
- keyUpdated = valueUpdated = null;
-
- Thread.sleep(1000L);
- assertNull(keyUpdated);
- }
-
- public void testMultipleConsecutiveCommits() throws InterruptedException {
- prefs.edit().putString("test", "1").commit();
- prefs.edit().putString("test", "2").commit();
- prefs.edit().putString("test", "3").commit();
- prefs.edit().putString("test", "4").commit();
- prefs.edit().putString("test", "5").commit();
- prefs.edit().putString("test", "6").commit();
- prefs.edit().putString("test", "7").commit();
- assertEquals("7", prefs.getString("test", ""));
- Thread.sleep(1000L);
- assertEquals("7", prefs.getString("test", ""));
- }
-}
diff --git a/test/src/edu/mit/media/funf/FunfManagerTest.java b/test/src/edu/mit/media/funf/FunfManagerTest.java
deleted file mode 100644
index 8ff6540..0000000
--- a/test/src/edu/mit/media/funf/FunfManagerTest.java
+++ /dev/null
@@ -1,136 +0,0 @@
-package edu.mit.media.funf;
-
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.os.IBinder;
-import android.test.AndroidTestCase;
-
-import com.google.gson.Gson;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParser;
-import com.google.gson.JsonPrimitive;
-import com.google.gson.internal.LazilyParsedNumber;
-
-import edu.mit.media.funf.json.IJsonArray;
-import edu.mit.media.funf.json.IJsonObject;
-import edu.mit.media.funf.json.JsonUtils;
-import edu.mit.media.funf.probe.Probe;
-import edu.mit.media.funf.probe.Probe.DataListener;
-import edu.mit.media.funf.probe.builtin.AccelerometerFeaturesProbe;
-
-public class FunfManagerTest extends AndroidTestCase {
-
- private JsonParser parser = new JsonParser();
- private FunfManager manager;
- private ServiceConnection conn = new ServiceConnection() {
-
- @Override
- public void onServiceDisconnected(ComponentName name) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onServiceConnected(ComponentName name, IBinder service) {
- manager = ((FunfManager.LocalBinder)service).getManager();
- }
- };
-
- public class SampleDataListener implements DataListener {
-
- public BlockingQueue dataEvents = new LinkedBlockingQueue();
- public BlockingQueue completeEvents = new LinkedBlockingQueue();
-
- @Override
- public void onDataReceived(IJsonObject probeConfig, IJsonObject data) {
- dataEvents.add(data);
- }
-
- @Override
- public void onDataCompleted(IJsonObject probeConfig, JsonElement checkpoint) {
- completeEvents.add(probeConfig);
- }
- };
-
-
-
- public SampleDataListener listener = new SampleDataListener();
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- listener = new SampleDataListener();
- getContext().bindService(new Intent(getContext(), FunfManager.class), conn, Context.BIND_AUTO_CREATE);
- waitForServiceConnection(3000);
- }
-
- public void waitForServiceConnection(long millisToWait) {
- long time = System.currentTimeMillis();
- while (System.currentTimeMillis() < time + millisToWait) {
- if (manager != null) {
- break;
- } else {
- try {
- Thread.sleep(100);
- }
- catch (InterruptedException e) {
- }
- }
- }
- }
-
- private final String probeConfig = "{\"@type\": \"" + AccelerometerFeaturesProbe.class.getName() + "\" " +
-
- "}";
-
- public void testDataRequest() {
- manager.requestData(listener, parser.parse(probeConfig));
- IJsonObject data = null;
- try {
- data = listener.dataEvents.poll(10, TimeUnit.SECONDS);
- } catch (InterruptedException e) {
- }
- if (data == null) {
- fail("Should have returned data within time alloted");
- }
-
- manager.unrequestData(listener, parser.parse(probeConfig));
- IJsonObject complete = null;
- try {
- complete = listener.completeEvents.poll(10, TimeUnit.SECONDS);
- } catch (InterruptedException e) {
- }
- if (complete == null) {
- fail("Should have completed within time alloted");
- }
- }
-
- public void testIJsonObjectEqualsAndHash() {
- JsonElement p1 = JsonUtils.immutable(new JsonPrimitive(new LazilyParsedNumber("1")));
- JsonElement p2 = JsonUtils.immutable(new JsonPrimitive(1));
- assertEquals(p1, p2);
- assertEquals(p1.hashCode(), p2.hashCode());
-
- Gson gson = manager.getGson();
- Probe probe = gson.fromJson(probeConfig, Probe.class);
- IJsonObject o1 = (IJsonObject)JsonUtils.immutable(gson.toJsonTree(probe));
- IJsonArray a1 = o1.getAsJsonArray("freqBandEdges");
- IJsonArray a2 = (IJsonArray)JsonUtils.immutable(new JsonParser().parse(gson.toJson(a1)));
-
- assertEquals(a1, a2);
- assertEquals(a1.hashCode(), a2.hashCode());
- IJsonObject o2 = (IJsonObject)JsonUtils.immutable(new JsonParser().parse(gson.toJson(o1)));
- assertEquals(o1, o2);
- assertEquals(o1.hashCode(), o2.hashCode());
- }
-
- public void testRegisterPipeline() {
-
- }
-}
diff --git a/test/src/edu/mit/media/funf/TestPipeline.java b/test/src/edu/mit/media/funf/TestPipeline.java
deleted file mode 100644
index 7fb8a8b..0000000
--- a/test/src/edu/mit/media/funf/TestPipeline.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package edu.mit.media.funf;
-
-import java.math.BigDecimal;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Queue;
-
-import android.test.AndroidTestCase;
-
-import com.google.gson.Gson;
-import com.google.gson.JsonElement;
-
-import edu.mit.media.funf.config.Configurable;
-import edu.mit.media.funf.pipeline.Pipeline;
-import edu.mit.media.funf.pipeline.PipelineFactory;
-
-public class TestPipeline extends AndroidTestCase {
-
- private Gson gson;
- private Queue actions;
-
- public static final String
- CREATED = "created",
- RAN = "ran",
- DESTROYED = "destroyed";
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- gson = FunfManager.getGsonBuilder(getContext()).create();
- actions = new LinkedList();
- }
-
- public static class SamplePipeline implements Pipeline {
-
- public SamplePipeline() {
-
- }
-
- @Configurable
- private Map schedules;
-
- @Configurable
- private Object testComponent;
-
- private Object nonConfigurable;
-
- @Override
- public void onCreate(FunfManager manager) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onRun(String action, JsonElement config) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onDestroy() {
- // TODO Auto-generated method stub
-
- }
-
- public Map getSchedules() {
- return schedules;
- }
-
- @Override
- public boolean isEnabled() {
- // TODO Auto-generated method stub
- return false;
- }
- }
-
- public String SAMPLE_PIPELINE_CONFIG = "{" +
- "\"@type\": \"" + SamplePipeline.class.getName() + "\"," +
- "\"" + PipelineFactory.SCHEDULES_FIELD_NAME + "\": {" +
- "\"archive\": {" +
- "\"interval\": 1," +
- "\"opportunistic\": false" +
- "}" +
- "}," +
- "\"testComponent\": {" +
- "\"@schedule\": {" +
- "\"duration\": 2" +
- "}" +
- "}," +
- "\"nonConfigurable\": {" +
- "\"@schedule\": {" +
- "\"duration\": 2" +
- "}" +
- "}" +
- "}";
-
-
- public void testPipelineLifecycle() {
-
- }
-
- public void testLoadPipeline() {
- Pipeline pipeline = gson.fromJson(SAMPLE_PIPELINE_CONFIG, Pipeline.class);
- assertTrue("Should respect runtime type.", pipeline instanceof SamplePipeline);
- SamplePipeline samplePipeline = (SamplePipeline)pipeline;
- Map schedules = samplePipeline.getSchedules();
- assertNotNull("Schedules should exists.", schedules);
- assertTrue("Schedule should contain explicit action", schedules.containsKey("archive"));
- Schedule archive = schedules.get("archive");
- assertEquals("Interval should have been set in schedule.", BigDecimal.ONE, archive.getInterval());
- assertEquals("Opportunistic should have been set in schedule.", false, archive.isOpportunistic());
- assertTrue("Schedule should contain annotation based action", schedules.containsKey("testComponent"));
- Schedule testComponent = schedules.get("testComponent");
- assertEquals("Interval should have been set in schedule.", new BigDecimal(2), testComponent.getDuration());
- assertFalse("Schedule should not contain schedule for non configurable item.", schedules.containsKey("nonConfigurable"));
- }
-}
diff --git a/test/src/edu/mit/media/funf/config/TestConfigurableParsing.java b/test/src/edu/mit/media/funf/config/TestConfigurableParsing.java
deleted file mode 100644
index f5b8eae..0000000
--- a/test/src/edu/mit/media/funf/config/TestConfigurableParsing.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package edu.mit.media.funf.config;
-
-import android.test.AndroidTestCase;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-
-import edu.mit.media.funf.probe.Probe;
-
-public class TestConfigurableParsing extends AndroidTestCase {
-
-
- public void testConfigurables() {
- Gson gson = new GsonBuilder().registerTypeAdapterFactory(
- new SingletonTypeAdapterFactory(
- new DefaultRuntimeTypeAdapterFactory(
- getContext(),
- TestConfigurable.class,
- Test1.class,
- new ConfigurableTypeAdapterFactory())
- )
- ).create();
- Test1 test1 = gson.fromJson(Probe.DEFAULT_CONFIG, Test1.class);
- assertEquals("Default was not set in configurable", 1, test1.overridden);
- assertEquals("Default private field was not set in configurable", 2, test1.getPrivateField());
- JsonObject expectedConfig = new JsonObject();
- expectedConfig.addProperty("@type", Test1.class.getName());
- expectedConfig.addProperty("overridden", 1);
- expectedConfig.addProperty("privateField", 2);
- assertEquals("Configurable not serialized correctly", expectedConfig, gson.toJsonTree(test1));
-
- test1 = gson.fromJson("{\"overridden\": 5, \"privateField\": 3}", Test1.class);
- assertEquals("Specified config was not set in configurable", 5, test1.overridden);
- assertEquals("Specified config on private field was not set in configurable", 3, test1.getPrivateField());
-
- // Test runtime config
- test1 = gson.fromJson("{\"@type\":\"" + Test2.class.getName() + "\", \"overridden\": 5, \"privateField\": 3}", Test1.class);
- assertTrue("Runtime type not created from config", test1 instanceof Test2);
- assertEquals("Specified config was not set in configurable", 5, test1.overridden);
- assertEquals("Specified config was not set in configurable", "5", ((Test2)test1).overridden);
- assertEquals("Specified config on private field was not set in configurable", 3, test1.getPrivateField());
-
-
- test1 = gson.fromJson("{\"notConfigurable\": \"yes\"}", Test1.class);
- assertEquals("Specified config was not set in configurable", "no", test1.notConfigurable);
-
- // Test default is used if not specified
- TestConfigurable test = gson.fromJson("{\"overridden\": 5, \"privateField\": 3}", TestConfigurable.class);
- assertTrue("Runtime type not created from config", test instanceof Test1);
-
- // Test nested types
- String nestedJson = "{\"@type\":\"" + Test2.class.getName() + "\", \"overridden\": 5, \"privateField\": 3, \"nested\": {\"@type\":\"" + Test2.class.getName() + "\", \"privateField\": 5}}";
- test = gson.fromJson(nestedJson, TestConfigurable.class);
- assertTrue("Runtime type not created from config", test instanceof Test2);
- Test2 test2 = (Test2)test;
- assertTrue("Runtime type not created from nested config", test2.nested instanceof Test2);
- assertEquals("Specified config was not set in nested configurable", 5, test2.nested.getPrivateField());
- String expectedSerialized = "{\"@type\":\"edu.mit.media.funf.config.TestConfigurableParsing$Test2\",\"nested\":{\"@type\":\"edu.mit.media.funf.config.TestConfigurableParsing$Test2\",\"nested\":{\"@type\":\"edu.mit.media.funf.config.TestConfigurableParsing$Test1\",\"overridden\":1,\"privateField\":2},\"overridden\":1,\"privateField\":5},\"overridden\":5,\"privateField\":3}";
- assertEquals("Configurable not serialized to json correctly", new JsonParser().parse(expectedSerialized), gson.toJsonTree(test));
-
- }
-
- public void testSingleton() {
- Gson gson = new GsonBuilder().registerTypeAdapterFactory(
- new SingletonTypeAdapterFactory(
- new DefaultRuntimeTypeAdapterFactory(
- getContext(),
- TestConfigurable.class,
- Test1.class,
- new ConfigurableTypeAdapterFactory())
- )
- ).create();
-
- TestConfigurable test1 = gson.fromJson(Probe.DEFAULT_CONFIG, Test1.class);
- TestConfigurable test2 = gson.fromJson(Probe.DEFAULT_CONFIG, Test1.class);
- TestConfigurable test3 = gson.fromJson(Probe.DEFAULT_CONFIG, TestConfigurable.class);
- assertSame("Singleton Type Adapter should return identical object for identical config and runtime configurations",
- test1, test2);
- assertSame("Singleton Type Adapter should return identical object for identical config and runtime configurations",
- test1, test3);
-
- test1 = gson.fromJson(Probe.DEFAULT_CONFIG, Test1.class);
- test2 = gson.fromJson("{\"privateField\": 5}", Test1.class);
- assertNotSame("Two different configurations should not be cached the same.", test1, test2);
-
- // Specifying default should not return different
- /* TODO: this is the way it should work, but need to come up with a method for doing this that does not involve creating an instance to figure out if you need to create a new instance
- test1 = gson.fromJson(Probe.DEFAULT_CONFIG, Test1.class);
- test2 = gson.fromJson("{\"privateField\": 2}", Test1.class);
- assertSame("Two configurations that produce the same runtime object should be the same.", test1, test2);
- */
- }
-
- public interface TestConfigurable {
-
- }
-
- public static class Test1 implements TestConfigurable {
- @Configurable
- public int overridden = 1;
- @Configurable
- private int privateField = 2;
-
- public String notConfigurable = "no";
-
- public int getPrivateField() {
- return privateField;
- }
- }
-
- public static class Test2 extends Test1 {
- @Configurable
- public String overridden = "test";
- @Configurable
- public Test1 nested = new Test1();
- }
-}
diff --git a/test/src/edu/mit/media/funf/pipeline/BasicPipelineTest.java b/test/src/edu/mit/media/funf/pipeline/BasicPipelineTest.java
deleted file mode 100644
index f39a9cb..0000000
--- a/test/src/edu/mit/media/funf/pipeline/BasicPipelineTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package edu.mit.media.funf.pipeline;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.os.IBinder;
-import android.test.AndroidTestCase;
-import android.util.Log;
-import edu.mit.media.funf.FunfManager;
-import edu.mit.media.funf.tests.R;
-
-public class BasicPipelineTest extends AndroidTestCase {
-
- private FunfManager mgr;
- private ServiceConnection conn = new ServiceConnection() {
-
- @Override
- public void onServiceConnected(ComponentName name, IBinder service) {
- mgr = ((FunfManager.LocalBinder)service).getManager();
- synchronized (s) {
- s.notify();
- }
- }
-
- @Override
- public void onServiceDisconnected(ComponentName name) {
- // TODO Auto-generated method stub
-
- }
-
- };
-
- private Object s = new Object();
-
- public void setUp() throws Exception {
- super.setUp();
- getContext().bindService(new Intent(getContext(), FunfManager.class), conn, Context.BIND_AUTO_CREATE);
- synchronized (s) {
- s.wait(5000L);
- }
- }
-
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- getContext().unbindService(conn);
- }
-
-
- public void testAsdf() {
- String testPipelineConfig = getContext().getResources().getString(R.string.default_pipeline);
- Pipeline pipeline = mgr.getGson().fromJson(testPipelineConfig, Pipeline.class);
- Log.d("FunfTest", "PIPELINE: " + mgr.getGson().toJson(pipeline));
- pipeline.onCreate(mgr);
- }
-}
diff --git a/test/src/edu/mit/media/funf/probe/AnnotationsTest.java b/test/src/edu/mit/media/funf/probe/AnnotationsTest.java
deleted file mode 100644
index 02718da..0000000
--- a/test/src/edu/mit/media/funf/probe/AnnotationsTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package edu.mit.media.funf.probe;
-
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import android.net.Uri;
-import android.test.AndroidTestCase;
-import android.text.Annotation;
-
-import com.google.gson.Gson;
-import com.google.gson.JsonObject;
-
-import edu.mit.media.funf.Schedule;
-
-public class AnnotationsTest extends AndroidTestCase {
-
- @Documented
- @Retention(RUNTIME)
- @Target(TYPE)
- @Inherited
- public @interface A {
- String value() default "a";
- }
-
- @Documented
- @Retention(RUNTIME)
- @Target(TYPE)
- @Inherited
- public @interface B {
- String value() default "b";
- }
-
- @A
- public class Parent {
-
- }
-
- @B
- public class Child1 extends Parent {
-
- }
-
- @A("test")
- @B
- public class Child2 extends Parent {
-
- }
-
- @A("interface")
- public interface TestInterface {
-
- }
-
- public class Child3 extends Parent implements TestInterface {
-
- }
-
- public class Child4 extends Child2 implements TestInterface {
-
- }
-
- public class Child5 implements TestInterface {
-
- }
-
- public void testAnnotationInheritance() {
- System.out.println(Parent.class.getAnnotations().length);
- System.out.println(Child1.class.getAnnotations().length);
- System.out.println(Child2.class.getAnnotations().length);
- System.out.println(Child2.class.getAnnotation(A.class).value());
- System.out.println(Child3.class.getAnnotation(A.class).value());
- System.out.println(Child4.class.getAnnotation(A.class).value());
- System.out.println(Child5.class.getAnnotation(A.class).value());
- }
-
- public void testReflectionAccessToDefaults() throws IllegalAccessException, InstantiationException {
-
- Annotation test = (Annotation) Schedule.DefaultSchedule.class.newInstance();
- }
-
- public void testGsonKeyOrderStability() {
- Gson gson = new Gson();
- JsonObject t1 = new JsonObject();
- t1.addProperty("test1", 1);
- t1.addProperty("test2", 2);
- t1.addProperty("test3", 3);
- System.out.println(gson.toJson(t1));
- JsonObject t2 = new JsonObject();
- t2.addProperty("test3", 3);
- t2.addProperty("test2", 2);
- t2.addProperty("test1", 1);
- System.out.println(gson.toJson(t2));
- }
-
- public void testUri() {
- Uri test = Uri.parse("http://www.test.com/test");
- Uri test2 = test.buildUpon().appendPath("/another?query=value").build();
- System.out.println(test2.toString());
- }
-}
diff --git a/test/src/edu/mit/media/funf/probe/ProbeTest.java b/test/src/edu/mit/media/funf/probe/ProbeTest.java
deleted file mode 100644
index 291d4aa..0000000
--- a/test/src/edu/mit/media/funf/probe/ProbeTest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-package edu.mit.media.funf.probe;
-
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-
-import android.test.AndroidTestCase;
-
-public class ProbeTest extends AndroidTestCase {
-
- private TestProbe testProbe;
-
- public class TestProbe extends Probe.Base implements Probe {
- public BlockingQueue messageQueue = new LinkedBlockingQueue();
-
- public static final String
- ENABLED = "ENABLED",
- DISABLED = "DISABLED",
- STARTED = "STARTED",
- STOPPED = "STOPPED";
-
-
-
-
- @Override
- protected void onEnable() {
- messageQueue.offer(ENABLED);
- }
-
- @Override
- protected void onStart() {
- messageQueue.offer(STARTED);
- }
-
- @Override
- protected void onStop() {
- messageQueue.offer(STOPPED);
- }
-
- @Override
- protected void onDisable() {
- messageQueue.offer(DISABLED);
- }
-
-
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- testProbe = new TestProbe();
- }
-
- @Override
- protected void tearDown() throws Exception {
- if (testProbe != null) {
- testProbe.disable();
- }
- super.tearDown();
- }
-
-
- public void testFullStateFlow() {
- assertEquals(Probe.State.DISABLED, testProbe.getState());
- testProbe.enable();
- assertStateChange(testProbe, Probe.State.ENABLED, TestProbe.ENABLED);
- testProbe.start();
- assertStateChange(testProbe, Probe.State.RUNNING, TestProbe.STARTED);
- testProbe.stop();
- assertStateChange(testProbe, Probe.State.ENABLED, TestProbe.STOPPED);
- testProbe.disable();
- assertStateChange(testProbe, Probe.State.DISABLED, TestProbe.DISABLED);
- }
-
- public void testIndempotence() {
- assertEquals(Probe.State.DISABLED, testProbe.getState());
- testProbe.disable();
- assertStateChange(testProbe, Probe.State.DISABLED);
-
- // Test multiple times to ensure it doesn't call onEnabled
- testProbe.enable();
- assertStateChange(testProbe, Probe.State.ENABLED, TestProbe.ENABLED);
- testProbe.enable();
- assertStateChange(testProbe, Probe.State.ENABLED);
- testProbe.enable();
- assertStateChange(testProbe, Probe.State.ENABLED);
-
- testProbe.disable();
- assertStateChange(testProbe, Probe.State.DISABLED, TestProbe.DISABLED);
- }
-
-
- /**
- * Asserts that the current state is as defined at the end of the list of state changes.
- * If no state changes are provided, it is assumed that there should NOT be a state change.
- * @param theTestProbe
- * @param correctState
- * @param correctMessages
- */
- private void assertStateChange(TestProbe theTestProbe, Probe.State correctState, String... correctMessages) {
- try {
- if (correctMessages == null) {
- correctMessages = new String[] { null };
- }
- for (String correctMessage : correctMessages) {
- String message = testProbe.messageQueue.poll(100, TimeUnit.MILLISECONDS);
- if (correctMessage == null) {
- assertNull(message);
- } else {
- assertNotNull(message);
- assertEquals(correctMessage, message);
- }
- }
- assertEquals(correctState, testProbe.getState());
- } catch (InterruptedException e) {
- fail();
- }
- }
-
-}
diff --git a/test/src/edu/mit/media/funf/probe/ProbeTestCase.java b/test/src/edu/mit/media/funf/probe/ProbeTestCase.java
deleted file mode 100644
index 0e52c2a..0000000
--- a/test/src/edu/mit/media/funf/probe/ProbeTestCase.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package edu.mit.media.funf.probe;
-
-import android.test.AndroidTestCase;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonObject;
-
-import edu.mit.media.funf.FunfManager;
-
-
-public class ProbeTestCase extends AndroidTestCase {
-
- private Gson factory;
- private Class probeClass;
-
- public ProbeTestCase(Class probeClass) {
- this.probeClass = probeClass;
- }
-
- public Gson getFactory() {
- if (factory == null) {
- factory = new GsonBuilder().registerTypeAdapterFactory(FunfManager.getProbeFactory(getContext())).create();
- }
- return factory;
- }
-
- public T getProbe(JsonObject config) {
- return getFactory().fromJson(config, probeClass);
- }
-}
diff --git a/test/src/edu/mit/media/funf/probe/builtin/ContactProbeTest.java b/test/src/edu/mit/media/funf/probe/builtin/ContactProbeTest.java
deleted file mode 100644
index 3b86ade..0000000
--- a/test/src/edu/mit/media/funf/probe/builtin/ContactProbeTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package edu.mit.media.funf.probe.builtin;
-
-import android.util.Log;
-
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
-import edu.mit.media.funf.json.IJsonObject;
-import edu.mit.media.funf.probe.Probe.DataListener;
-import edu.mit.media.funf.probe.ProbeTestCase;
-
-public class ContactProbeTest extends ProbeTestCase {
-
- public ContactProbeTest() {
- super(ContactProbe.class);
- }
-
- public static final String TAG = "Probes";
-
- private DataListener listener = new DataListener() {
- @Override
- public void onDataReceived(IJsonObject completeProbeUri, IJsonObject data) {
- Log.i(TAG, "DATA: " + completeProbeUri.toString() + " " + data.toString());
- }
-
- @Override
- public void onDataCompleted(IJsonObject completeProbeUri, JsonElement checkpoint) {
- Log.i(TAG, "COMPLETE: " + completeProbeUri.toString());
- }
-};
-
- public void testProbe() throws InterruptedException {
- ContactProbe probe = getProbe(new JsonObject());
- probe.registerListener(listener);
- Thread.sleep(100L);
- }
-}
diff --git a/test/src/edu/mit/media/funf/probe/builtin/RunningApplicationsProbeTest.java b/test/src/edu/mit/media/funf/probe/builtin/RunningApplicationsProbeTest.java
deleted file mode 100644
index 3441158..0000000
--- a/test/src/edu/mit/media/funf/probe/builtin/RunningApplicationsProbeTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package edu.mit.media.funf.probe.builtin;
-
-import android.util.Log;
-
-import com.google.gson.JsonElement;
-
-import edu.mit.media.funf.json.IJsonObject;
-import edu.mit.media.funf.probe.Probe.DataListener;
-import edu.mit.media.funf.probe.ProbeTestCase;
-
-public class RunningApplicationsProbeTest extends ProbeTestCase implements DataListener {
-
- public RunningApplicationsProbeTest() {
- super(RunningApplicationsProbe.class);
- }
-
- public void testApps() throws InterruptedException {
- RunningApplicationsProbe probe = getProbe(null);
- probe.registerListener(this);
- Thread.sleep(100000L);
- probe.unregisterListener(this);
-
- }
-
-
- @Override
- public void onDataReceived(IJsonObject completeProbeUri, IJsonObject data) {
- Log.i("MyData", data.toString());
- }
-
- @Override
- public void onDataCompleted(IJsonObject completeProbeUri, JsonElement checkpoint) {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/test/src/edu/mit/media/funf/probe/builtin/ServicesProbeTest.java b/test/src/edu/mit/media/funf/probe/builtin/ServicesProbeTest.java
deleted file mode 100644
index 35cb525..0000000
--- a/test/src/edu/mit/media/funf/probe/builtin/ServicesProbeTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package edu.mit.media.funf.probe.builtin;
-
-import android.util.Log;
-
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
-import edu.mit.media.funf.json.IJsonObject;
-import edu.mit.media.funf.probe.Probe.DataListener;
-import edu.mit.media.funf.probe.ProbeTestCase;
-
-public class ServicesProbeTest extends ProbeTestCase {
-
- public ServicesProbeTest() {
- super(ServicesProbe.class);
- }
-
- public static final String TAG = "Probes";
-
- private DataListener listener = new DataListener() {
- @Override
- public void onDataReceived(IJsonObject completeProbeUri, IJsonObject data) {
- Log.i(TAG, "DATA: " + completeProbeUri.toString() + " " + data.toString());
- }
-
- @Override
- public void onDataCompleted(IJsonObject completeProbeUri, JsonElement checkpoint) {
- Log.i(TAG, "COMPLETE: " + completeProbeUri.toString());
- }
-};
-
- public void testProbe() throws InterruptedException {
- ServicesProbe probe = getProbe(new JsonObject());
- probe.registerListener(listener);
- Thread.sleep(100L);
- }
-}
diff --git a/test/src/edu/mit/media/funf/probe/builtin/TelephonyProbeTest.java b/test/src/edu/mit/media/funf/probe/builtin/TelephonyProbeTest.java
deleted file mode 100644
index 1da0f69..0000000
--- a/test/src/edu/mit/media/funf/probe/builtin/TelephonyProbeTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package edu.mit.media.funf.probe.builtin;
-
-import android.util.Log;
-
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
-import edu.mit.media.funf.json.IJsonObject;
-import edu.mit.media.funf.probe.Probe.DataListener;
-import edu.mit.media.funf.probe.ProbeTestCase;
-
-public class TelephonyProbeTest extends ProbeTestCase {
-
- public TelephonyProbeTest() {
- super(TelephonyProbe.class);
- }
-
- public static final String TAG = "Probes";
-
- private DataListener listener = new DataListener() {
- @Override
- public void onDataReceived(IJsonObject completeProbeUri, IJsonObject data) {
- Log.i(TAG, "DATA: " + completeProbeUri.toString() + " " + data.toString());
- }
-
- @Override
- public void onDataCompleted(IJsonObject completeProbeUri, JsonElement checkpoint) {
- Log.i(TAG, "COMPLETE: " + completeProbeUri.toString());
- }
-};
-
- public void testProbe() throws InterruptedException {
- TelephonyProbe probe = getProbe(new JsonObject());
- probe.registerListener(listener);
- Thread.sleep(100L);
- }
-}
diff --git a/test/src/edu/mit/media/funf/probe/builtin/TestAllBuiltinProbes.java b/test/src/edu/mit/media/funf/probe/builtin/TestAllBuiltinProbes.java
deleted file mode 100644
index 9c21a00..0000000
--- a/test/src/edu/mit/media/funf/probe/builtin/TestAllBuiltinProbes.java
+++ /dev/null
@@ -1,151 +0,0 @@
-package edu.mit.media.funf.probe.builtin;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import android.os.Debug;
-import android.test.AndroidTestCase;
-import android.util.Log;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
-import edu.mit.media.funf.FunfManager;
-import edu.mit.media.funf.json.IJsonObject;
-import edu.mit.media.funf.probe.Probe;
-import edu.mit.media.funf.probe.Probe.ContinuousProbe;
-import edu.mit.media.funf.probe.Probe.DataListener;
-import edu.mit.media.funf.probe.Probe.State;
-import edu.mit.media.funf.probe.Probe.StateListener;
-
-
-/**
- * This class turns on and off all of the builtin probes.
- * While it doesn't test any of the output, it does ensure that basic use of the probes does not crash the process.
- * @author alangardner
- *
- */
-public class TestAllBuiltinProbes extends AndroidTestCase {
-
- public static final String TAG = "FunfTest";
-
- private DataListener listener = new DataListener() {
- @Override
- public void onDataReceived(IJsonObject completeProbeUri, IJsonObject data) {
- Log.i(TAG, "DATA: " + completeProbeUri.toString() + " " + data.toString());
- }
-
- @Override
- public void onDataCompleted(IJsonObject completeProbeUri, JsonElement checkpoint) {
- Log.i(TAG, "COMPLETE: " + completeProbeUri.toString());
- }
- };
-
-
-
- private StateListener stateListener = new StateListener() {
-
- @Override
- public void onStateChanged(Probe probe, State previousState) {
- Log.i(TAG, probe.getClass().getName() + ": " + probe.getState());
- Log.i(TAG, getGson().toJson(probe));
- }
-
- };
-
-
- private Gson gson;
- public Gson getGson() {
- if (gson == null) {
- gson = new GsonBuilder().registerTypeAdapterFactory(FunfManager.getProbeFactory(getContext())).create();
- }
- return gson;
- }
-
- @SuppressWarnings("rawtypes")
- public static final Class[] ALL_PROBES = {
- AccelerometerFeaturesProbe.class,
- AccelerometerSensorProbe.class,
- ApplicationsProbe.class,
- AudioFeaturesProbe.class,
- AudioMediaProbe.class,
- BatteryProbe.class,
- BluetoothProbe.class,
- BrowserBookmarksProbe.class,
- BrowserSearchesProbe.class,
- CallLogProbe.class,
- CellTowerProbe.class,
- ContactProbe.class,
- GravitySensorProbe.class,
- GyroscopeSensorProbe.class,
- HardwareInfoProbe.class,
- ImageMediaProbe.class,
- LightSensorProbe.class,
- LinearAccelerationSensorProbe.class,
- LocationProbe.class,
- MagneticFieldSensorProbe.class,
- OrientationSensorProbe.class,
- PressureSensorProbe.class,
- ProcessStatisticsProbe.class,
- ProximitySensorProbe.class,
- RotationVectorSensorProbe.class,
- RunningApplicationsProbe.class,
- ServicesProbe.class,
- SimpleLocationProbe.class,
- ScreenProbe.class,
- SmsProbe.class,
- TelephonyProbe.class,
- TemperatureSensorProbe.class,
- TimeOffsetProbe.class,
- VideoMediaProbe.class,
- WifiProbe.class
- };
-
-
-
- @SuppressWarnings("unchecked")
- public void testAll() throws ClassNotFoundException, IOException, InterruptedException {
- Log.i(TAG,"Running");
- Debug.startMethodTracing("calc");
- List> allProbeClasses = Arrays.asList((Class extends Probe>[])ALL_PROBES);
-
- // Run one at a time
- Gson gson = getGson();
- for (Class extends Probe> probeClass : allProbeClasses) {
- JsonObject config = new JsonObject();
- config.addProperty("sensorDelay", SensorProbe.SENSOR_DELAY_NORMAL);
- config.addProperty("asdf", 1);
- config.addProperty("zzzz", "__");
- Probe probe = gson.fromJson(config, probeClass);
- probe.addStateListener(stateListener);
- probe.registerListener(listener);
- Thread.sleep(100L);
- if (probe instanceof ContinuousProbe) {
- ((ContinuousProbe)probe).unregisterListener(listener);
- }
- }
- // Run simultaneously
- List probes = new ArrayList();
- for (Class extends Probe> probeClass : allProbeClasses) {
- probes.add(gson.fromJson(Probe.DEFAULT_CONFIG, probeClass));
- }
- for (Probe probe : probes) {
- probe.addStateListener(stateListener);
- probe.registerListener(listener);
- }
- Thread.sleep(10000L);
- for (Probe probe : probes) {
- if (probe instanceof ContinuousProbe) {
- ((ContinuousProbe)probe).unregisterListener(listener);
- }
- }
-
- Thread.sleep(1000L); // Give probes time stop
-
- Debug.stopMethodTracing();
- }
-}
diff --git a/test/src/edu/mit/media/funf/probe/builtin/TestLocationProbes.java b/test/src/edu/mit/media/funf/probe/builtin/TestLocationProbes.java
deleted file mode 100644
index 2413916..0000000
--- a/test/src/edu/mit/media/funf/probe/builtin/TestLocationProbes.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package edu.mit.media.funf.probe.builtin;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import android.test.AndroidTestCase;
-import android.util.Log;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
-import edu.mit.media.funf.FunfManager;
-import edu.mit.media.funf.json.IJsonObject;
-import edu.mit.media.funf.probe.Probe;
-import edu.mit.media.funf.probe.Probe.ContinuousProbe;
-import edu.mit.media.funf.probe.Probe.DataListener;
-import edu.mit.media.funf.probe.Probe.State;
-import edu.mit.media.funf.probe.Probe.StateListener;
-
-
-public class TestLocationProbes extends AndroidTestCase {
-
- public static final String TAG = "FunfTest";
-
- private DataListener listener = new DataListener() {
- @Override
- public void onDataReceived(IJsonObject completeProbeUri, IJsonObject data) {
- Log.i(TAG, "DATA: " + completeProbeUri.toString() + " " + data.toString());
- }
-
- @Override
- public void onDataCompleted(IJsonObject completeProbeUri, JsonElement checkpoint) {
- Log.i(TAG, "COMPLETE: " + completeProbeUri.toString());
- }
- };
-
- private StateListener stateListener = new StateListener() {
-
- @Override
- public void onStateChanged(Probe probe, State previousState) {
- Log.i(TAG, probe.getClass().getName() + ": " + probe.getState());
- Log.i(TAG, getGson().toJson(probe));
- }
-
- };
-
- private Gson gson;
- public Gson getGson() {
- if (gson == null) {
- gson = new GsonBuilder().registerTypeAdapterFactory(FunfManager.getProbeFactory(getContext())).create();
- }
- return gson;
- }
-
- @SuppressWarnings("rawtypes")
- public static final Class[] ALL_PROBES = {
- LocationProbe.class,
- SimpleLocationProbe.class
- };
-
-
- @SuppressWarnings("unchecked")
- public void testAll() throws ClassNotFoundException, IOException, InterruptedException {
- Log.i(TAG,"Running");
- List> allProbeClasses = Arrays.asList((Class extends Probe>[])ALL_PROBES);
-
- // Run one at a time
- Gson gson = getGson();
- for (Class extends Probe> probeClass : allProbeClasses) {
- JsonObject config = new JsonObject();
- config.addProperty("maxWaitTime", 1);
- config.addProperty("asdf", 1);
- config.addProperty("zzzz", "__");
- Probe probe = gson.fromJson(config, probeClass);
- probe.addStateListener(stateListener);
- probe.registerListener(listener);
- Thread.sleep(100L);
- if (probe instanceof ContinuousProbe) {
- ((ContinuousProbe)probe).unregisterListener(listener);
- }
- }
- // Run simultaneously
- List probes = new ArrayList();
- for (Class extends Probe> probeClass : allProbeClasses) {
- JsonObject config = new JsonObject();
- config.addProperty("maxWaitTime", 8);
- config.addProperty("asdf", 1);
- config.addProperty("zzzz", "__");
- Probe probe = gson.fromJson(config, probeClass);
- probes.add(probe);
- }
- for (Probe probe : probes) {
- probe.addStateListener(stateListener);
- probe.registerListener(listener);
- }
- Thread.sleep(10000L);
- for (Probe probe : probes) {
- if (probe instanceof ContinuousProbe) {
- ((ContinuousProbe)probe).unregisterListener(listener);
- }
- }
-
- Thread.sleep(1000L); // Give probes time stop
- }
-}
diff --git a/test/src/edu/mit/media/funf/storage/DefaultArchiveTest.java b/test/src/edu/mit/media/funf/storage/DefaultArchiveTest.java
deleted file mode 100644
index 4d2547e..0000000
--- a/test/src/edu/mit/media/funf/storage/DefaultArchiveTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.storage;
-
-import android.test.AndroidTestCase;
-
-public class DefaultArchiveTest extends AndroidTestCase {
-
-
- public void testEncryptionKeyGeneration() {
- DefaultArchive testDbArchive = new DefaultArchive(getContext(), "testDb");
- testDbArchive.setEncryptionPassword("changeme".toCharArray());
- testDbArchive.setEncryptionPassword("test1234".toCharArray());
- }
-}
diff --git a/test/src/edu/mit/media/funf/storage/PrefsWriteSpeedTest.java b/test/src/edu/mit/media/funf/storage/PrefsWriteSpeedTest.java
deleted file mode 100644
index 4a4007f..0000000
--- a/test/src/edu/mit/media/funf/storage/PrefsWriteSpeedTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Funf: Open Sensing Framework
- * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland.
- * Acknowledgments: Alan Gardner
- * Contact: nadav@media.mit.edu
- *
- * This file is part of Funf.
- *
- * Funf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Funf is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Funf. If not, see .
- */
-package edu.mit.media.funf.storage;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.os.StatFs;
-import android.test.AndroidTestCase;
-import android.util.Log;
-
-public class PrefsWriteSpeedTest extends AndroidTestCase {
-
- public static final String TAG = "FunfTest";
-
- public void testSpeed() {
- long now = System.currentTimeMillis();
- for (int i=0; i< 100; i++) {
- SharedPreferences prefs = getContext().getSharedPreferences("ASDF", Context.MODE_PRIVATE);
- prefs.edit().clear().putString("TEST_KEY", "TEST_VALUE").commit();
- }
- long total = System.currentTimeMillis() - now;
- Log.i(TAG, "Total time: " + total + "ms");
- }
-
- public void testBlockSize() {
- StatFs stats = new StatFs("/");
- Log.i(TAG, "Root block size:" + stats.getBlockSize());
- stats.restat("/sdcard");
- Log.i(TAG, "SDCard block size:" + stats.getBlockSize());
- }
-}
diff --git a/test/src/edu/mit/media/funf/tests/ExampleService.java b/test/src/edu/mit/media/funf/tests/ExampleService.java
deleted file mode 100644
index c34bafc..0000000
--- a/test/src/edu/mit/media/funf/tests/ExampleService.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package edu.mit.media.funf.tests;
-
-import java.util.Map;
-
-import android.app.IntentService;
-import android.content.Intent;
-import android.util.Log;
-import edu.mit.media.funf.util.BundleUtil;
-
-public class ExampleService extends IntentService {
-
- public ExampleService() {
- super("ExampleService");
- }
-
- @Override
- protected void onHandleIntent(Intent intent) {
- Map values = BundleUtil.getValues(intent.getExtras());
- String entryString = "{";
- for (Map.Entry entry : values.entrySet()) {
- entryString += "" + entry.getKey() + ": " + String.valueOf(entry.getValue());
- }
- entryString += "}";
- Log.i("ExampleService", "Intent: " + intent.getAction() + " -> " + entryString);
- }
-
-}
diff --git a/test/src/edu/mit/media/funf/tests/SensorTest.java b/test/src/edu/mit/media/funf/tests/SensorTest.java
deleted file mode 100644
index f2faf14..0000000
--- a/test/src/edu/mit/media/funf/tests/SensorTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package edu.mit.media.funf.tests;
-
-import android.content.Context;
-import android.hardware.Sensor;
-import android.hardware.SensorEvent;
-import android.hardware.SensorEventListener;
-import android.hardware.SensorManager;
-import android.test.AndroidTestCase;
-
-public class SensorTest extends AndroidTestCase {
-
- private long lastNanos = 0L;
- private long lastNanosSum = 0L;
- private long count = 0L;
-
- public void testSensorSpeed() throws InterruptedException {
- for (int i = 0; i< 1000; i++) {
- // calibrateNanosConversion();
- System.out.println(millisToSeconds(System.currentTimeMillis()) - uptimeNanosToTimestamp(System.nanoTime()));
- }
- System.out.println("---------------------------");
-
- double lastNano = 0;
- for (int i = 0; i< 20; i++) {
- long nano = System.nanoTime();
- double diff = millisToSeconds(System.currentTimeMillis()) - uptimeNanosToTimestamp(nano);
- System.out.println(diff);
- System.out.println(uptimeNanosToTimestamp(nano) - uptimeNanosToTimestamp(lastNanos));
- lastNanos = nano;
- System.out.println(millisToSeconds(System.currentTimeMillis()) + " " + uptimeNanosToTimestamp(System.nanoTime()));
- }
- SensorManager manager = (SensorManager) getContext().getSystemService(Context.SENSOR_SERVICE);
- Sensor sensor = manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
-
- calibrateNanosConversion();
- SensorEventListener sensorListener = new SensorEventListener() {
-
- @Override
- public void onSensorChanged(SensorEvent event) {
- System.out.println("--------------------");
- long mili = System.currentTimeMillis();
- long nano = System.nanoTime();
- if (lastNanos == 0L) {
- lastNanos = event.timestamp;
- }
- //calibrateNanosConversion();
- System.out.println("Event Seconds: " + uptimeNanosToTimestamp(event.timestamp));
- System.out.println("Nano Seconds: " + uptimeNanosToTimestamp(nano));
- System.out.println("Diff Seconds: " + (uptimeNanosToTimestamp(nano) - uptimeNanosToTimestamp(event.timestamp)));
- System.out.println("Acc Period: " + (uptimeNanosToTimestamp(nano) - uptimeNanosToTimestamp(lastNanos)));
- System.out.println("Mili Seconds: " + millisToSeconds(mili));
- lastNanosSum += nano - lastNanos;
- count++;
- System.out.println("Avg diff:" + (lastNanosSum / count));
- lastNanos = nano;
- }
-
- @Override
- public void onAccuracyChanged(Sensor sensor, int accuracy) {
- }
- };
- manager.registerListener(sensorListener, sensor, SensorManager.SENSOR_DELAY_FASTEST);
- Thread.sleep(30);
- }
-
- public static double millisToSeconds(long millis) {
- return ((double)millis)/1000;
- }
-
- public static long secondsToMillis(double seconds) {
- return (long)(seconds*1000);
- }
-
- public static final long NANOS_IN_SECOND = 1000000000; // 10^9
- private static long referenceNanos;
- private static long referenceMillis;
- private static double secondsOffset;
-
- /**
- * Aligns the nano seconds to the start of a new millisecond.
- * This should be called whenever device wakes up from sleep.
- */
- public static void calibrateNanosConversion() {
- long originalMillis = System.currentTimeMillis();
- long updatedMillis = originalMillis;
- while(originalMillis == updatedMillis) {
- updatedMillis = System.currentTimeMillis();
- }
- referenceNanos = System.nanoTime();
- referenceMillis = updatedMillis;
- secondsOffset = millisToSeconds(referenceMillis) - (double)referenceNanos / (double)NANOS_IN_SECOND;
- }
-
- public static double uptimeNanosToTimestamp(long nanos) {
- long currentMillisAccordingToNanos = secondsToMillis(_uptimeNanosToTimestamp(System.nanoTime()));
- if (Math.abs(currentMillisAccordingToNanos - System.currentTimeMillis()) > 1) {
- calibrateNanosConversion();
- }
- return _uptimeNanosToTimestamp(nanos);
- }
-
- private static double _uptimeNanosToTimestamp(long nanos) {
- return ((double)nanos / (double)NANOS_IN_SECOND) + secondsOffset;
- }
-
-}
-